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"
12 bool PaintHasBitmap(const SkPaint
&paint
) {
13 SkShader
* shader
= paint
.getShader();
17 if (shader
->asAGradient(NULL
) == SkShader::kNone_GradientType
)
20 return shader
->asABitmap(NULL
, NULL
, NULL
) != SkShader::kNone_BitmapType
;
25 PaintSimplifier::PaintSimplifier()
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
))
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));