RESTRICT AUTOMERGE Add 1/16th pixel offset when drawing non-AA points/lines

This nudge ensures that pixel-aligned non-AA'd draws fill the desired
fragment.

Coupled with http://review.skia.org/665816, we're moving this logic from
Skia to Android so that the prerotation matrix can be properly accounted
for. Offseting only in Skia without accounting for prerotation  meant
the device-space Y offset could be applied in the wrong direction when
using Vulkan.

Equivalent change in T: Idfb5027fe3230f2c2b0cad224f2c7640e147ce4a

Bug: 254771190
Test: android.uirendering.cts.testclasses.ExactCanvasTests#testDrawLine
Change-Id: I975b62510a36312a395d1e254474bca726a9445d
(cherry picked from commit 7f785ebd57cf129bb39e89237fba541912ce3649)
diff --git a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
index 940d6bf..f0461be 100644
--- a/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaOpenGLPipeline.h
@@ -53,6 +53,14 @@
     bool isSurfaceReady() override;
     bool isContextReady() override;
 
+    const SkM44& getPixelSnapMatrix() const override {
+        // Small (~1/16th) nudge to ensure that pixel-aligned non-AA'd draws fill the
+        // desired fragment
+        static const SkScalar kOffset = 0.063f;
+        static const SkM44 sSnapMatrix = SkM44::Translate(kOffset, kOffset);
+        return sSnapMatrix;
+    }
+
     static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
 
 protected:
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
index c8f2e69..86096d5 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.cpp
@@ -210,6 +210,10 @@
     }
 }
 
+const SkM44& SkiaVulkanPipeline::getPixelSnapMatrix() const {
+    return mVkSurface->getPixelSnapMatrix();
+}
+
 } /* namespace skiapipeline */
 } /* namespace uirenderer */
 } /* namespace android */
diff --git a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
index d921ddb..c089739 100644
--- a/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
+++ b/libs/hwui/pipeline/skia/SkiaVulkanPipeline.h
@@ -55,6 +55,7 @@
     bool isContextReady() override;
     bool supportsExtendedRangeHdr() const override { return true; }
     void setTargetSdrHdrRatio(float ratio) override;
+    const SkM44& getPixelSnapMatrix() const override;
 
     static void invokeFunctor(const renderthread::RenderThread& thread, Functor* functor);
     static sk_sp<Bitmap> allocateHardwareBitmap(renderthread::RenderThread& thread,