From 3d91aad293b0f68886ed48ecfa6aa75826a27da8 Mon Sep 17 00:00:00 2001 From: fmalita Date: Mon, 2 Feb 2015 05:25:04 -0800 Subject: [PATCH] Disable LCD text when rasterizing SkPictureShader tiles. BUG=chromium:453299 R=reed@google.com Review URL: https://codereview.chromium.org/884163003 --- include/core/SkCanvas.h | 9 ++++++++- src/core/SkPictureShader.cpp | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 3eecaf7..d929439 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -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; diff --git a/src/core/SkPictureShader.cpp b/src/core/SkPictureShader.cpp index 36b55ca..adf2bb6 100644 --- a/src/core/SkPictureShader.cpp +++ b/src/core/SkPictureShader.cpp @@ -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); -- 2.7.4