Service Worker: Remove legacy code for resolving register() to a version
[chromium-blink-merge.git] / skia / ext / paint_simplifier.cc
blob683f92ec00a1a7828ed1c28a325f282508689a11
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "skia/ext/paint_simplifier.h"
6 #include "third_party/skia/include/core/SkPaint.h"
7 #include "third_party/skia/include/core/SkShader.h"
9 namespace skia {
10 namespace {
12 bool PaintHasBitmap(const SkPaint &paint) {
13 SkShader* shader = paint.getShader();
14 if (!shader)
15 return false;
17 if (shader->asAGradient(NULL) == SkShader::kNone_GradientType)
18 return false;
20 return shader->asABitmap(NULL, NULL, NULL) != SkShader::kNone_BitmapType;
23 } // namespace
25 PaintSimplifier::PaintSimplifier()
26 : INHERITED() {
30 PaintSimplifier::~PaintSimplifier() {
34 bool PaintSimplifier::filter(SkPaint* paint, Type type) {
35 // Bitmaps are expensive. Skip draw if type has a bitmap.
36 if (type == kBitmap_Type || PaintHasBitmap(*paint))
37 return false;
39 // Preserve a modicum of text quality; black & white text is
40 // just too blocky, even during a fling.
41 if (type != kText_Type) {
42 paint->setAntiAlias(false);
44 paint->setSubpixelText(false);
45 paint->setLCDRenderText(false);
47 paint->setMaskFilter(NULL);
49 // Uncomment this line to shade simplified tiles pink during debugging.
50 //paint->setColor(SkColorSetRGB(255, 127, 127));
52 return true;
56 } // namespace skia