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

Side by Side Diff: gm/downsamplebitmap.cpp

Issue 1574233003: expand gm to exercise miplevels and various scalers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | gm/showmiplevels.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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } else { 184 } else {
185 fBM.allocN32Pixels(1, 1); 185 fBM.allocN32Pixels(1, 1);
186 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad 186 *(fBM.getAddr32(0,0)) = 0xFF0000FF; // red == bad
187 } 187 }
188 fSize = fBM.height(); 188 fSize = fBM.height();
189 } 189 }
190 private: 190 private:
191 typedef DownsampleBitmapGM INHERITED; 191 typedef DownsampleBitmapGM INHERITED;
192 }; 192 };
193 193
194 #include "SkMipMap.h"
195
196 static void release_mipmap(void*, void* context) {
197 ((SkMipMap*)context)->unref();
198 }
199
200 class ShowMipLevels : public skiagm::GM {
201 public:
202 SkBitmap fBM;
203
204 ShowMipLevels() {
205 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD));
206 make_checker(&fBM, 512, 256);
207 }
208
209 protected:
210
211 SkString onShortName() override {
212 return SkString("showmiplevels");
213 }
214
215 SkISize onISize() override {
216 return SkISize::Make(fBM.width() + 8, 2 * fBM.height() + 80);
217 }
218
219 void onDraw(SkCanvas* canvas) override {
220 SkScalar x = 4;
221 SkScalar y = 4;
222 canvas->drawBitmap(fBM, x, y, nullptr);
223 y += fBM.height() + 4;
224
225 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, nullptr));
226
227 SkMipMap::Level level;
228 SkScalar scale = 0.5f;
229 while (mm->extractLevel(scale, &level)) {
230 SkImageInfo info = SkImageInfo::MakeN32Premul(level.fWidth, level.fH eight);
231 SkBitmap bm;
232 bm.installPixels(info, level.fPixels, level.fRowBytes, nullptr,
233 &release_mipmap, (void*)(SkRef(mm.get())));
234 bm.setImmutable();
235 canvas->drawBitmap(bm, x, y, nullptr);
236 y += bm.height() + 4;
237 scale /= 2;
238 if (info.width() == 1 || info.height() == 1) {
239 break;
240 }
241 }
242 }
243
244 private:
245 typedef skiagm::GM INHERITED;
246 };
247 DEF_GM( return new ShowMipLevels; )
248
249 //////////////////////////////////////////////////////////////////////////////
250
251 DEF_GM( return new DownsampleBitmapTextGM(72, kHigh_SkFilterQuality); ) 194 DEF_GM( return new DownsampleBitmapTextGM(72, kHigh_SkFilterQuality); )
252 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kHigh_SkFilterQuality ); ) 195 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kHigh_SkFilterQuality ); )
253 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kHigh_SkFilterQua lity); ) 196 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kHigh_SkFilterQua lity); )
254 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 197 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
255 kHigh_SkFilterQuality); ) 198 kHigh_SkFilterQuality); )
256 199
257 DEF_GM( return new DownsampleBitmapTextGM(72, kMedium_SkFilterQuality); ) 200 DEF_GM( return new DownsampleBitmapTextGM(72, kMedium_SkFilterQuality); )
258 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kMedium_SkFilterQuali ty); ) 201 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kMedium_SkFilterQuali ty); )
259 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kMedium_SkFilterQ uality); ) 202 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kMedium_SkFilterQ uality); )
260 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 203 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
261 kMedium_SkFilterQuality); ) 204 kMedium_SkFilterQuality); )
262 205
263 DEF_GM( return new DownsampleBitmapTextGM(72, kLow_SkFilterQuality); ) 206 DEF_GM( return new DownsampleBitmapTextGM(72, kLow_SkFilterQuality); )
264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality) ; ) 207 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality) ; )
265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual ity); ) 208 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual ity); )
266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 209 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
267 kLow_SkFilterQuality); ) 210 kLow_SkFilterQuality); )
268 211
269 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); ) 212 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); )
270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality ); ) 213 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality ); )
271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua lity); ) 214 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua lity); )
272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", 215 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc",
273 kNone_SkFilterQuality); ) 216 kNone_SkFilterQuality); )
OLDNEW
« no previous file with comments | « no previous file | gm/showmiplevels.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698