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 |
5 #include "skia/ext/paint_simplifier.h" | 7 #include "skia/ext/paint_simplifier.h" |
6 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
7 | 9 |
8 namespace skia { | 10 namespace skia { |
9 | 11 |
10 PaintSimplifier::PaintSimplifier() | 12 PaintSimplifier::PaintSimplifier() |
11 : INHERITED() { | 13 : INHERITED() { |
12 | 14 |
13 } | 15 } |
14 | 16 |
15 PaintSimplifier::~PaintSimplifier() { | 17 PaintSimplifier::~PaintSimplifier() { |
16 | 18 |
17 } | 19 } |
18 | 20 |
19 bool PaintSimplifier::filter(SkPaint* paint, Type type) { | 21 bool PaintSimplifier::filter(SkPaint* paint, Type type) { |
20 | 22 |
21 // Preserve a modicum of text quality; black & white text is | 23 // Preserve a modicum of text quality; black & white text is |
22 // just too blocky, even during a fling. | 24 // just too blocky, even during a fling. |
23 if (type != kText_Type) { | 25 if (type != kText_Type) { |
24 paint->setAntiAlias(false); | 26 paint->setAntiAlias(false); |
25 } | 27 } |
26 paint->setSubpixelText(false); | 28 paint->setSubpixelText(false); |
27 paint->setLCDRenderText(false); | 29 paint->setLCDRenderText(false); |
28 | 30 |
| 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 |
29 paint->setMaskFilter(NULL); | 37 paint->setMaskFilter(NULL); |
30 | 38 |
31 // Uncomment this line to shade simplified tiles pink during debugging. | 39 // Uncomment this line to shade simplified tiles pink during debugging. |
32 //paint->setColor(SkColorSetRGB(255, 127, 127)); | 40 //paint->setColor(SkColorSetRGB(255, 127, 127)); |
33 | 41 |
34 return true; | 42 return true; |
35 } | 43 } |
36 | 44 |
37 | 45 |
38 } // namespace skia | 46 } // namespace skia |
39 | 47 |
40 | 48 |
OLD | NEW |