Commit 3fd15f64 authored by reveman@chromium.org's avatar reveman@chromium.org

skia: Avoid drawing of images completely in PaintSimplifier.

Images are expensive to draw, especially when they need to be
scaled. This skips draw operations with images completely to
ensure that drawing using the PaintSimplifier has a predictable
cost.

BUG=

Review URL: https://codereview.chromium.org/310643004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274642 0039d316-1c4b-4281-b951-d872f2087c98
parent 025adfa4
...@@ -4,8 +4,23 @@ ...@@ -4,8 +4,23 @@
#include "skia/ext/paint_simplifier.h" #include "skia/ext/paint_simplifier.h"
#include "third_party/skia/include/core/SkPaint.h" #include "third_party/skia/include/core/SkPaint.h"
#include "third_party/skia/include/core/SkShader.h"
namespace skia { 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() PaintSimplifier::PaintSimplifier()
: INHERITED() { : INHERITED() {
...@@ -17,6 +32,9 @@ PaintSimplifier::~PaintSimplifier() { ...@@ -17,6 +32,9 @@ PaintSimplifier::~PaintSimplifier() {
} }
bool PaintSimplifier::filter(SkPaint* paint, Type type) { 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 // Preserve a modicum of text quality; black & white text is
// just too blocky, even during a fling. // just too blocky, even during a fling.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment