diff options
Diffstat (limited to 'chromium/skia/ext/paint_simplifier.cc')
-rw-r--r-- | chromium/skia/ext/paint_simplifier.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/chromium/skia/ext/paint_simplifier.cc b/chromium/skia/ext/paint_simplifier.cc index 6b697662458..683f92ec00a 100644 --- a/chromium/skia/ext/paint_simplifier.cc +++ b/chromium/skia/ext/paint_simplifier.cc @@ -4,8 +4,23 @@ #include "skia/ext/paint_simplifier.h" #include "third_party/skia/include/core/SkPaint.h" +#include "third_party/skia/include/core/SkShader.h" namespace skia { +namespace { + +bool PaintHasBitmap(const SkPaint &paint) { + SkShader* shader = paint.getShader(); + if (!shader) + return false; + + if (shader->asAGradient(NULL) == SkShader::kNone_GradientType) + return false; + + return shader->asABitmap(NULL, NULL, NULL) != SkShader::kNone_BitmapType; +} + +} // namespace PaintSimplifier::PaintSimplifier() : INHERITED() { @@ -17,6 +32,9 @@ PaintSimplifier::~PaintSimplifier() { } bool PaintSimplifier::filter(SkPaint* paint, Type type) { + // Bitmaps are expensive. Skip draw if type has a bitmap. + if (type == kBitmap_Type || PaintHasBitmap(*paint)) + return false; // Preserve a modicum of text quality; black & white text is // just too blocky, even during a fling. @@ -26,7 +44,6 @@ bool PaintSimplifier::filter(SkPaint* paint, Type type) { paint->setSubpixelText(false); paint->setLCDRenderText(false); - paint->setFilterBitmap(false); paint->setMaskFilter(NULL); // Uncomment this line to shade simplified tiles pink during debugging. |