add compiler flags to control slugs

Change-Id: I581f78b829a810d93a065cbbda9a1f87c41f5c45
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/475541
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index 00e4d7d..4b7f602 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -29,6 +29,10 @@
 #include "src/gpu/ops/AtlasTextOp.h"
 #include "src/gpu/v1/SurfaceDrawContext_v1.h"
 
+// Defining SK_EXPERIMENTAL_ADD_ATLAS_PADDING will cause all glyphs in the atlas to have a one
+// pixel border to support bi-lerping on demand.
+// #define SK_EXPERIMENTAL_ADD_ATLAS_PADDING
+
 // Naming conventions
 //  * drawMatrix - the CTM from the canvas.
 //  * drawOrigin - the x, y location of the drawTextBlob call.
@@ -712,7 +716,11 @@
 
 std::tuple<bool, int>
 DirectMaskSubRun::regenerateAtlas(int begin, int end, GrMeshDrawTarget* target) const {
-    return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, 0, target);
+    #if defined(SK_EXPERIMENTAL_ADD_ATLAS_PADDING)
+        return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, 1, target, true);
+    #else
+        return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, 0, target, false);
+    #endif
 }
 
 // The 99% case. No clip. Non-color only.
@@ -1861,7 +1869,11 @@
 
 std::tuple<bool, int>
 DirectMaskSubRunNoCache::regenerateAtlas(int begin, int end, GrMeshDrawTarget* target) const {
-    return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, 0, target);
+    #if defined(SK_EXPERIMENTAL_ADD_ATLAS_PADDING)
+        return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, 1, target, true);
+    #else
+        return fGlyphs.regenerateAtlas(begin, end, fMaskFormat, 0, target, false);
+    #endif
 }
 
 // The 99% case. No clip. Non-color only.
diff --git a/src/gpu/v1/Device.cpp b/src/gpu/v1/Device.cpp
index 40d7f94..2bc8162 100644
--- a/src/gpu/v1/Device.cpp
+++ b/src/gpu/v1/Device.cpp
@@ -18,6 +18,7 @@
 #include "include/gpu/GrRecordingContext.h"
 #include "include/private/SkShadowFlags.h"
 #include "include/private/SkTo.h"
+#include "include/private/chromium/GrSlug.h"
 #include "src/core/SkCanvasPriv.h"
 #include "src/core/SkClipStack.h"
 #include "src/core/SkDraw.h"
@@ -47,6 +48,9 @@
 #include "src/image/SkSurface_Gpu.h"
 #include "src/utils/SkUTF.h"
 
+// Define this for testing text blob draw using a slug.
+// #define SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG
+
 #define ASSERT_SINGLE_OWNER GR_ASSERT_SINGLE_OWNER(fContext->priv().singleOwner())
 
 
@@ -900,6 +904,12 @@
     GR_CREATE_TRACE_MARKER_CONTEXT("skgpu::v1::Device", "drawGlyphRunList", fContext.get());
     SkASSERT(!glyphRunList.hasRSXForm());
 
+    #if defined(SK_EXPERIMENTAL_SIMULATE_DRAWGLYPHRUNLIST_WITH_SLUG)
+        auto slug = this->convertGlyphRunListToSlug(glyphRunList, paint);
+        this->drawSlug(slug.get());
+        return;
+    #endif
+
     fSurfaceDrawContext->drawGlyphRunList(
         this->clip(), this->asMatrixProvider(), glyphRunList, paint);
 }