Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: gm/downsamplebitmap.cpp

Issue 1014533004: SkPaint::FilterLevel -> SkFilterQuality (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/clippedbitmapshaders.cpp ('k') | gm/drawbitmaprect.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 9
10 #include "Resources.h" 10 #include "Resources.h"
(...skipping 21 matching lines...) Expand all
32 32
33 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) { 33 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty le) {
34 sk_tool_utils::set_portable_typeface(paint, name, style); 34 sk_tool_utils::set_portable_typeface(paint, name, style);
35 } 35 }
36 36
37 class DownsampleBitmapGM : public skiagm::GM { 37 class DownsampleBitmapGM : public skiagm::GM {
38 public: 38 public:
39 SkBitmap fBM; 39 SkBitmap fBM;
40 SkString fName; 40 SkString fName;
41 bool fBitmapMade; 41 bool fBitmapMade;
42 SkPaint::FilterLevel fFilterLevel; 42 SkFilterQuality fFilterQuality;
43 43
44 DownsampleBitmapGM(SkPaint::FilterLevel filterLevel) 44 DownsampleBitmapGM(SkFilterQuality filterQuality)
45 : fFilterLevel(filterLevel) 45 : fFilterQuality(filterQuality)
46 { 46 {
47 this->setBGColor(0xFFDDDDDD); 47 this->setBGColor(0xFFDDDDDD);
48 fBitmapMade = false; 48 fBitmapMade = false;
49 } 49 }
50 50
51 const char* filterLevelToString() { 51 const char* filterQualityToString() {
52 static const char *filterLevelNames[] = { 52 static const char *filterQualityNames[] = {
53 "none", "low", "medium", "high" 53 "none", "low", "medium", "high"
54 }; 54 };
55 return filterLevelNames[fFilterLevel]; 55 return filterQualityNames[fFilterQuality];
56 } 56 }
57 57
58 protected: 58 protected:
59 59
60 SkString onShortName() SK_OVERRIDE { 60 SkString onShortName() SK_OVERRIDE {
61 return fName; 61 return fName;
62 } 62 }
63 63
64 SkISize onISize() SK_OVERRIDE { 64 SkISize onISize() SK_OVERRIDE {
65 make_bitmap_wrapper(); 65 make_bitmap_wrapper();
(...skipping 14 matching lines...) Expand all
80 80
81 int curY = 0; 81 int curY = 0;
82 int curHeight; 82 int curHeight;
83 float curScale = 1; 83 float curScale = 1;
84 do { 84 do {
85 85
86 SkMatrix matrix; 86 SkMatrix matrix;
87 matrix.setScale( curScale, curScale ); 87 matrix.setScale( curScale, curScale );
88 88
89 SkPaint paint; 89 SkPaint paint;
90 paint.setFilterLevel(fFilterLevel); 90 paint.setFilterQuality(fFilterQuality);
91 91
92 canvas->save(); 92 canvas->save();
93 canvas->translate(0, (SkScalar)curY); 93 canvas->translate(0, (SkScalar)curY);
94 canvas->concat(matrix); 94 canvas->concat(matrix);
95 canvas->drawBitmap(fBM, 0, 0, &paint); 95 canvas->drawBitmap(fBM, 0, 0, &paint);
96 canvas->restore(); 96 canvas->restore();
97 97
98 curHeight = (int) (fBM.height() * curScale + 2); 98 curHeight = (int) (fBM.height() * curScale + 2);
99 curY += curHeight; 99 curY += curHeight;
100 curScale *= 0.75f; 100 curScale *= 0.75f;
101 } while (curHeight >= 2 && curY < 4*fBM.height()); 101 } while (curHeight >= 2 && curY < 4*fBM.height());
102 } 102 }
103 103
104 private: 104 private:
105 typedef skiagm::GM INHERITED; 105 typedef skiagm::GM INHERITED;
106 }; 106 };
107 107
108 class DownsampleBitmapTextGM: public DownsampleBitmapGM { 108 class DownsampleBitmapTextGM: public DownsampleBitmapGM {
109 public: 109 public:
110 DownsampleBitmapTextGM(float textSize, SkPaint::FilterLevel filterLevel) 110 DownsampleBitmapTextGM(float textSize, SkFilterQuality filterQuality)
111 : INHERITED(filterLevel), fTextSize(textSize) 111 : INHERITED(filterQuality), fTextSize(textSize)
112 { 112 {
113 fName.printf("downsamplebitmap_text_%s_%.2fpt", this->filterLevelToS tring(), fTextSize); 113 fName.printf("downsamplebitmap_text_%s_%.2fpt", this->filterQualityT oString(), fTextSize);
114 } 114 }
115 115
116 protected: 116 protected:
117 float fTextSize; 117 float fTextSize;
118 118
119 void make_bitmap() SK_OVERRIDE { 119 void make_bitmap() SK_OVERRIDE {
120 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); 120 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6));
121 SkCanvas canvas(fBM); 121 SkCanvas canvas(fBM);
122 canvas.drawColor(SK_ColorWHITE); 122 canvas.drawColor(SK_ColorWHITE);
123 123
(...skipping 10 matching lines...) Expand all
134 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint ); 134 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint );
135 setTypeface(&paint, "Times", SkTypeface::kBoldItalic); 135 setTypeface(&paint, "Times", SkTypeface::kBoldItalic);
136 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint ); 136 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint );
137 } 137 }
138 private: 138 private:
139 typedef DownsampleBitmapGM INHERITED; 139 typedef DownsampleBitmapGM INHERITED;
140 }; 140 };
141 141
142 class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM { 142 class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM {
143 public: 143 public:
144 DownsampleBitmapCheckerboardGM(int size, int numChecks, SkPaint::FilterLev el filterLevel) 144 DownsampleBitmapCheckerboardGM(int size, int numChecks, SkFilterQuality fi lterQuality)
145 : INHERITED(filterLevel), fSize(size), fNumChecks(numChecks) 145 : INHERITED(filterQuality), fSize(size), fNumChecks(numChecks)
146 { 146 {
147 fName.printf("downsamplebitmap_checkerboard_%s_%d_%d", this->filterL evelToString(), fSize, fNumChecks); 147 fName.printf("downsamplebitmap_checkerboard_%s_%d_%d", this->filterQ ualityToString(), fSize, fNumChecks);
148 } 148 }
149 149
150 protected: 150 protected:
151 int fSize; 151 int fSize;
152 int fNumChecks; 152 int fNumChecks;
153 153
154 void make_bitmap() SK_OVERRIDE { 154 void make_bitmap() SK_OVERRIDE {
155 make_checker(&fBM, fSize, fNumChecks); 155 make_checker(&fBM, fSize, fNumChecks);
156 } 156 }
157 private: 157 private:
158 typedef DownsampleBitmapGM INHERITED; 158 typedef DownsampleBitmapGM INHERITED;
159 }; 159 };
160 160
161 class DownsampleBitmapImageGM: public DownsampleBitmapGM { 161 class DownsampleBitmapImageGM: public DownsampleBitmapGM {
162 public: 162 public:
163 DownsampleBitmapImageGM(const char filename[], SkPaint::FilterLevel filter Level) 163 DownsampleBitmapImageGM(const char filename[], SkFilterQuality filterQuali ty)
164 : INHERITED(filterLevel), fFilename(filename) 164 : INHERITED(filterQuality), fFilename(filename)
165 { 165 {
166 fName.printf("downsamplebitmap_image_%s_%s", this->filterLevelToStri ng(), filename); 166 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt ring(), filename);
167 } 167 }
168 168
169 protected: 169 protected:
170 SkString fFilename; 170 SkString fFilename;
171 int fSize; 171 int fSize;
172 172
173 void make_bitmap() SK_OVERRIDE { 173 void make_bitmap() SK_OVERRIDE {
174 SkImageDecoder* codec = NULL; 174 SkImageDecoder* codec = NULL;
175 SkString resourcePath = GetResourcePath(fFilename.c_str()); 175 SkString resourcePath = GetResourcePath(fFilename.c_str());
176 SkFILEStream stream(resourcePath.c_str()); 176 SkFILEStream stream(resourcePath.c_str());
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 } 242 }
243 243
244 private: 244 private:
245 typedef skiagm::GM INHERITED; 245 typedef skiagm::GM INHERITED;
246 }; 246 };
247 DEF_GM( return new ShowMipLevels; ) 247 DEF_GM( return new ShowMipLevels; )
248 248
249 ////////////////////////////////////////////////////////////////////////////// 249 //////////////////////////////////////////////////////////////////////////////
250 250
251 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kHigh_FilterLevel); ) 251 DEF_GM( return new DownsampleBitmapTextGM(72, kHigh_SkFilterQuality); )
252 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kHigh_Filter Level); ) 252 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kHigh_SkFilterQuality ); )
253 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kHigh_Fi lterLevel); ) 253 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kHigh_SkFilterQua lity); )
254 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 254 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
255 SkPaint::kHigh_FilterLevel); ) 255 kHigh_SkFilterQuality); )
256 256
257 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kMedium_FilterLevel); ) 257 DEF_GM( return new DownsampleBitmapTextGM(72, kMedium_SkFilterQuality); )
258 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kMedium_Filt erLevel); ) 258 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kMedium_SkFilterQuali ty); )
259 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kMedium_ FilterLevel); ) 259 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kMedium_SkFilterQ uality); )
260 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 260 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
261 SkPaint::kMedium_FilterLevel); ) 261 kMedium_SkFilterQuality); )
262 262
263 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kLow_FilterLevel); ) 263 DEF_GM( return new DownsampleBitmapTextGM(72, kLow_SkFilterQuality); )
264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL evel); ) 264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality) ; )
265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil terLevel); ) 265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual ity); )
266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
267 SkPaint::kLow_FilterLevel); ) 267 kLow_SkFilterQuality); )
268 268
269 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); ) 269 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); )
270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter Level); ) 270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality ); )
271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi lterLevel); ) 271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua lity); )
272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
273 SkPaint::kNone_FilterLevel); ) 273 kNone_SkFilterQuality); )
OLDNEW
« no previous file with comments | « gm/clippedbitmapshaders.cpp ('k') | gm/drawbitmaprect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698