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

Side by Side Diff: gm/showmiplevels.cpp

Issue 2029373004: respect srgb gamma when building mips (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix warning Created 4 years, 6 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/mipmap.cpp ('k') | include/private/SkTemplates.h » ('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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 137 }
138 138
139 template <typename F> void drawLevels(SkCanvas* canvas, const SkBitmap& base BM, F func) { 139 template <typename F> void drawLevels(SkCanvas* canvas, const SkBitmap& base BM, F func) {
140 SkScalar x = 4; 140 SkScalar x = 4;
141 SkScalar y = 4; 141 SkScalar y = 4;
142 142
143 SkPixmap prevPM; 143 SkPixmap prevPM;
144 baseBM.lockPixels(); 144 baseBM.lockPixels();
145 baseBM.peekPixels(&prevPM); 145 baseBM.peekPixels(&prevPM);
146 146
147 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr)); 147 SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore;
148 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, treatment, nullptr));
148 149
149 int index = 0; 150 int index = 0;
150 SkMipMap::Level level; 151 SkMipMap::Level level;
151 SkScalar scale = 0.5f; 152 SkScalar scale = 0.5f;
152 while (mm->extractLevel(SkSize::Make(scale, scale), &level)) { 153 while (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
153 SkBitmap bm = func(prevPM, level.fPixmap); 154 SkBitmap bm = func(prevPM, level.fPixmap);
154 DrawAndFrame(canvas, bm, x, y); 155 DrawAndFrame(canvas, bm, x, y);
155 156
156 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) { 157 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) {
157 break; 158 break;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 SkPaint paint; 246 SkPaint paint;
246 paint.setStyle(SkPaint::kStroke_Style); 247 paint.setStyle(SkPaint::kStroke_Style);
247 paint.setColor(0xFFFFCCCC); 248 paint.setColor(0xFFFFCCCC);
248 canvas->drawRect(SkRect::MakeIWH(bm.width(), bm.height()).makeOffset(x, y).makeOutset(0.5f, 0.5f), paint); 249 canvas->drawRect(SkRect::MakeIWH(bm.width(), bm.height()).makeOffset(x, y).makeOutset(0.5f, 0.5f), paint);
249 } 250 }
250 251
251 void drawLevels(SkCanvas* canvas, const SkBitmap& baseBM) { 252 void drawLevels(SkCanvas* canvas, const SkBitmap& baseBM) {
252 SkScalar x = 4; 253 SkScalar x = 4;
253 SkScalar y = 4; 254 SkScalar y = 4;
254 255
255 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, nullptr)); 256 SkSourceGammaTreatment treatment = SkSourceGammaTreatment::kIgnore;
257 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(baseBM, treatment, nullptr));
256 258
257 int index = 0; 259 int index = 0;
258 SkMipMap::Level level; 260 SkMipMap::Level level;
259 SkScalar scale = 0.5f; 261 SkScalar scale = 0.5f;
260 while (mm->extractLevel(SkSize::Make(scale, scale), &level)) { 262 while (mm->extractLevel(SkSize::Make(scale, scale), &level)) {
261 SkBitmap bm; 263 SkBitmap bm;
262 bm.installPixels(level.fPixmap); 264 bm.installPixels(level.fPixmap);
263 DrawAndFrame(canvas, bm, x, y); 265 DrawAndFrame(canvas, bm, x, y);
264 266
265 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) { 267 if (level.fPixmap.width() <= 2 || level.fPixmap.height() <= 2) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 303 }
302 } 304 }
303 305
304 private: 306 private:
305 typedef skiagm::GM INHERITED; 307 typedef skiagm::GM INHERITED;
306 }; 308 };
307 DEF_GM( return new ShowMipLevels2(255, 255); ) 309 DEF_GM( return new ShowMipLevels2(255, 255); )
308 DEF_GM( return new ShowMipLevels2(256, 255); ) 310 DEF_GM( return new ShowMipLevels2(256, 255); )
309 DEF_GM( return new ShowMipLevels2(255, 256); ) 311 DEF_GM( return new ShowMipLevels2(255, 256); )
310 DEF_GM( return new ShowMipLevels2(256, 256); ) 312 DEF_GM( return new ShowMipLevels2(256, 256); )
OLDNEW
« no previous file with comments | « gm/mipmap.cpp ('k') | include/private/SkTemplates.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698