From 8b2f41b606d961992c19382bd01ac832f9859480 Mon Sep 17 00:00:00 2001 From: "junov@google.com" Date: Fri, 1 Feb 2013 16:41:47 +0000 Subject: [PATCH] Prevent SkPictureUtils::GatherPixelRefs from generating bitmaps from gradient 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/SkPictureUtils.cpp b/src/utils/SkPictureUtils.cpp index 4ddc566..d8041df 100644 --- a/src/utils/SkPictureUtils.cpp +++ b/src/utils/SkPictureUtils.cpp @@ -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()); } } -- 2.7.4