| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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); ) |
| OLD | NEW |