Prevent SkPictureUtils::GatherPixelRefs from generating bitmaps from gradient
authorjunov@google.com <junov@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 1 Feb 2013 16:41:47 +0000 (16:41 +0000)
committerjunov@google.com <junov@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 1 Feb 2013 16:41:47 +0000 (16:41 +0000)
shaders.

BUG=https://code.google.com/p/chromium/issues/detail?id=173657
Review URL: https://codereview.appspot.com/7220074

git-svn-id: http://skia.googlecode.com/svn/trunk@7517 2bbb7eff-a529-9590-31e7-b0007b416f81

src/utils/SkPictureUtils.cpp

index 4ddc566..d8041df 100644 (file)
@@ -58,7 +58,11 @@ private:
         SkShader* shader = paint.getShader();
         if (shader) {
             SkBitmap bm;
-            if (shader->asABitmap(&bm, NULL, NULL)) {
+            // Check whether the shader is a gradient in order to short-circuit
+            // call to asABitmap to prevent generation of bitmaps from
+            // gradient shaders, which implement asABitmap.
+            if (SkShader::kNone_GradientType == shader->asAGradient(NULL) &&
+                shader->asABitmap(&bm, NULL, NULL)) {
                 fPRSet->add(bm.pixelRef());
             }
         }