Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Unified Diff: skia/ext/paint_simplifier.cc

Issue 310643004: skia: Avoid drawing of images completely in PaintSimplifier. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/paint_simplifier.cc
diff --git a/skia/ext/paint_simplifier.cc b/skia/ext/paint_simplifier.cc
index 8df91a888a42cd07eb8c650caa94c570c52b66a7..683f92ec00a1a7828ed1c28a325f282508689a11 100644
--- a/skia/ext/paint_simplifier.cc
+++ b/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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698