OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits> | |
6 | |
7 #include "skia/ext/paint_simplifier.h" | 5 #include "skia/ext/paint_simplifier.h" |
8 #include "third_party/skia/include/core/SkPaint.h" | 6 #include "third_party/skia/include/core/SkPaint.h" |
9 | 7 |
10 namespace skia { | 8 namespace skia { |
11 | 9 |
12 PaintSimplifier::PaintSimplifier() | 10 PaintSimplifier::PaintSimplifier() |
13 : INHERITED() { | 11 : INHERITED() { |
14 | 12 |
15 } | 13 } |
16 | 14 |
17 PaintSimplifier::~PaintSimplifier() { | 15 PaintSimplifier::~PaintSimplifier() { |
18 | 16 |
19 } | 17 } |
20 | 18 |
21 bool PaintSimplifier::filter(SkPaint* paint, Type type) { | 19 bool PaintSimplifier::filter(SkPaint* paint, Type type) { |
22 | 20 |
23 // Preserve a modicum of text quality; black & white text is | 21 // Preserve a modicum of text quality; black & white text is |
24 // just too blocky, even during a fling. | 22 // just too blocky, even during a fling. |
25 if (type != kText_Type) { | 23 if (type != kText_Type) { |
26 paint->setAntiAlias(false); | 24 paint->setAntiAlias(false); |
27 } | 25 } |
28 paint->setSubpixelText(false); | 26 paint->setSubpixelText(false); |
29 paint->setLCDRenderText(false); | 27 paint->setLCDRenderText(false); |
30 | 28 |
31 // Reduce filter level to medium or less. Note that reducing the filter to | |
32 // less than medium can have a negative effect on performance as the filtered | |
33 // image is not cached in this case. | |
34 paint->setFilterLevel( | |
35 std::min(paint->getFilterLevel(), SkPaint::kMedium_FilterLevel)); | |
36 | |
37 paint->setMaskFilter(NULL); | 29 paint->setMaskFilter(NULL); |
38 | 30 |
39 // Uncomment this line to shade simplified tiles pink during debugging. | 31 // Uncomment this line to shade simplified tiles pink during debugging. |
40 //paint->setColor(SkColorSetRGB(255, 127, 127)); | 32 //paint->setColor(SkColorSetRGB(255, 127, 127)); |
41 | 33 |
42 return true; | 34 return true; |
43 } | 35 } |
44 | 36 |
45 | 37 |
46 } // namespace skia | 38 } // namespace skia |
47 | 39 |
48 | 40 |
OLD | NEW |