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

Side by Side Diff: gm/showmiplevels.cpp

Issue 1686563002: Relocate anisotropic mipmap logic to SkMipMap::extractLevel() (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | src/core/SkBitmapController.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 2016 Google Inc. 2 * Copyright 2016 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 SkPixmap prevPM; 144 SkPixmap prevPM;
145 baseBM.lockPixels(); 145 baseBM.lockPixels();
146 baseBM.peekPixels(&prevPM); 146 baseBM.peekPixels(&prevPM);
147 147
148 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr)); 148 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr));
149 149
150 int index = 0; 150 int index = 0;
151 SkMipMap::Level level; 151 SkMipMap::Level level;
152 SkScalar scale = 0.5f; 152 SkScalar scale = 0.5f;
153 while (mm->extractLevel(scale, &level)) { 153 while (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
154 SkBitmap bm = func(prevPM, level.fPixmap); 154 SkBitmap bm = func(prevPM, level.fPixmap);
155 DrawAndFrame(canvas, bm, x, y); 155 DrawAndFrame(canvas, bm, x, y);
156 156
157 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) { 157 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) {
158 break; 158 break;
159 } 159 }
160 if (index & 1) { 160 if (index & 1) {
161 x += level.fPixmap.width() + 4; 161 x += level.fPixmap.width() + 4;
162 } else { 162 } else {
163 y += level.fPixmap.height() + 4; 163 y += level.fPixmap.height() + 4;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 void drawLevels(SkCanvas* canvas, const SkBitmap& baseBM) { 252 void drawLevels(SkCanvas* canvas, const SkBitmap& baseBM) {
253 SkScalar x = 4; 253 SkScalar x = 4;
254 SkScalar y = 4; 254 SkScalar y = 4;
255 255
256 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr)); 256 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr));
257 257
258 int index = 0; 258 int index = 0;
259 SkMipMap::Level level; 259 SkMipMap::Level level;
260 SkScalar scale = 0.5f; 260 SkScalar scale = 0.5f;
261 while (mm->extractLevel(scale, &level)) { 261 while (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
262 SkBitmap bm; 262 SkBitmap bm;
263 bm.installPixels(level.fPixmap); 263 bm.installPixels(level.fPixmap);
264 DrawAndFrame(canvas, bm, x, y); 264 DrawAndFrame(canvas, bm, x, y);
265 265
266 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) { 266 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) {
267 break; 267 break;
268 } 268 }
269 if (index & 1) { 269 if (index & 1) {
270 x += level.fPixmap.width() + 4; 270 x += level.fPixmap.width() + 4;
271 } else { 271 } else {
(...skipping 30 matching lines...) Expand all
302 } 302 }
303 } 303 }
304 304
305 private: 305 private:
306 typedef skiagm::GM INHERITED; 306 typedef skiagm::GM INHERITED;
307 }; 307 };
308 DEF_GM( return new ShowMipLevels2(255, 255); ) 308 DEF_GM( return new ShowMipLevels2(255, 255); )
309 DEF_GM( return new ShowMipLevels2(256, 255); ) 309 DEF_GM( return new ShowMipLevels2(256, 255); )
310 DEF_GM( return new ShowMipLevels2(255, 256); ) 310 DEF_GM( return new ShowMipLevels2(255, 256); )
311 DEF_GM( return new ShowMipLevels2(256, 256); ) 311 DEF_GM( return new ShowMipLevels2(256, 256); )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkBitmapController.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698