Disable LCD text when rasterizing SkPictureShader tiles.
authorfmalita <fmalita@chromium.org>
Mon, 2 Feb 2015 13:25:04 +0000 (05:25 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 2 Feb 2015 13:25:04 +0000 (05:25 -0800)
BUG=chromium:453299
R=reed@google.com

Review URL: https://codereview.chromium.org/884163003

include/core/SkCanvas.h
src/core/SkPictureShader.cpp

index 3eecaf7..d929439 100644 (file)
@@ -100,6 +100,14 @@ public:
                         structure are copied to the canvas.
     */
     explicit SkCanvas(const SkBitmap& bitmap);
+
+    /** Construct a canvas with the specified bitmap to draw into.
+        @param bitmap   Specifies a bitmap for the canvas to draw into. Its
+                        structure are copied to the canvas.
+        @param props    New canvas surface properties.
+    */
+    SkCanvas(const SkBitmap& bitmap, const SkSurfaceProps& props);
+
     virtual ~SkCanvas();
 
     SkMetaData& getMetaData();
@@ -1278,7 +1286,6 @@ private:
     };
     SkCanvas(const SkIRect& bounds, InitFlags);
     SkCanvas(SkBaseDevice*, const SkSurfaceProps*, InitFlags);
-    SkCanvas(const SkBitmap&, const SkSurfaceProps&);
 
     // needs gettotalclip()
     friend class SkCanvasStateUtils;
index 36b55ca..adf2bb6 100644 (file)
@@ -194,7 +194,9 @@ SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
         }
         bm.eraseColor(SK_ColorTRANSPARENT);
 
-        SkCanvas canvas(bm);
+        // Always disable LCD text, since we can't assume our image will be opaque.
+        SkCanvas canvas(bm, SkSurfaceProps(0, kUnknown_SkPixelGeometry));
+
         canvas.scale(tileScale.width(), tileScale.height());
         canvas.translate(-fTile.x(), -fTile.y());
         canvas.drawPicture(fPicture);