| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 for (int x = 0; x < bm.width(); ++x) { | 98 for (int x = 0; x < bm.width(); ++x) { |
| 99 SkPMColor c = *bm.getAddr32(x, y); | 99 SkPMColor c = *bm.getAddr32(x, y); |
| 100 unsigned r = gamma(SkGetPackedR32(c)); | 100 unsigned r = gamma(SkGetPackedR32(c)); |
| 101 unsigned g = gamma(SkGetPackedG32(c)); | 101 unsigned g = gamma(SkGetPackedG32(c)); |
| 102 unsigned b = gamma(SkGetPackedB32(c)); | 102 unsigned b = gamma(SkGetPackedB32(c)); |
| 103 *bm.getAddr32(x, y) = SkPackARGB32(0xFF, r, g, b); | 103 *bm.getAddr32(x, y) = SkPackARGB32(0xFF, r, g, b); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 ShowMipLevels(int N) : fN(N) { | 108 ShowMipLevels(int N) : fN(N) { } |
| 109 fBM[0] = sk_tool_utils::create_checkerboard_bitmap(N, N, SK_ColorBLACK,
SK_ColorWHITE, 2); | |
| 110 fBM[1] = make_bitmap(N, N); | |
| 111 fBM[2] = make_bitmap2(N, N); | |
| 112 fBM[3] = make_bitmap3(N, N); | |
| 113 } | |
| 114 | 109 |
| 115 protected: | 110 protected: |
| 116 | 111 |
| 117 SkString onShortName() override { | 112 SkString onShortName() override { |
| 118 SkString str; | 113 SkString str; |
| 119 str.printf("showmiplevels_%d", fN); | 114 str.printf("showmiplevels_%d", fN); |
| 120 return str; | 115 return str; |
| 121 } | 116 } |
| 122 | 117 |
| 123 SkISize onISize() override { | 118 SkISize onISize() override { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 for (auto method : methods) { | 186 for (auto method : methods) { |
| 192 canvas->translate(orig.width()/2 + 8.0f, 0); | 187 canvas->translate(orig.width()/2 + 8.0f, 0); |
| 193 drawLevels(canvas, orig, [basePM, method](const SkPixmap& prev, cons
t SkPixmap& curr) { | 188 drawLevels(canvas, orig, [basePM, method](const SkPixmap& prev, cons
t SkPixmap& curr) { |
| 194 SkBitmap bm; | 189 SkBitmap bm; |
| 195 SkBitmapScaler::Resize(&bm, prev, method, curr.width(), curr.hei
ght()); | 190 SkBitmapScaler::Resize(&bm, prev, method, curr.width(), curr.hei
ght()); |
| 196 return bm; | 191 return bm; |
| 197 }); | 192 }); |
| 198 } | 193 } |
| 199 } | 194 } |
| 200 | 195 |
| 196 void onOnceBeforeDraw() override { |
| 197 fBM[0] = sk_tool_utils::create_checkerboard_bitmap(fN, fN, SK_ColorBLACK
, SK_ColorWHITE, 2); |
| 198 fBM[1] = make_bitmap(fN, fN); |
| 199 fBM[2] = make_bitmap2(fN, fN); |
| 200 fBM[3] = make_bitmap3(fN, fN); |
| 201 } |
| 202 |
| 201 void onDraw(SkCanvas* canvas) override { | 203 void onDraw(SkCanvas* canvas) override { |
| 202 canvas->translate(4, 4); | 204 canvas->translate(4, 4); |
| 203 for (const auto& bm : fBM) { | 205 for (const auto& bm : fBM) { |
| 204 this->drawSet(canvas, bm); | 206 this->drawSet(canvas, bm); |
| 205 canvas->translate(0, bm.height() * 0.85f); | 207 canvas->translate(0, bm.height() * 0.85f); |
| 206 } | 208 } |
| 207 } | 209 } |
| 208 | 210 |
| 209 private: | 211 private: |
| 210 typedef skiagm::GM INHERITED; | 212 typedef skiagm::GM INHERITED; |
| 211 }; | 213 }; |
| 212 DEF_GM( return new ShowMipLevels(255); ) | 214 DEF_GM( return new ShowMipLevels(255); ) |
| 213 DEF_GM( return new ShowMipLevels(256); ) | 215 DEF_GM( return new ShowMipLevels(256); ) |
| 214 | 216 |
| 215 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | 217 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 216 | 218 |
| 217 /** | 219 /** |
| 218 * Show mip levels that were built, for all supported colortypes | 220 * Show mip levels that were built, for all supported colortypes |
| 219 */ | 221 */ |
| 220 class ShowMipLevels2 : public skiagm::GM { | 222 class ShowMipLevels2 : public skiagm::GM { |
| 221 const int fW, fH; | 223 const int fW, fH; |
| 222 SkBitmap fBM[4]; | 224 SkBitmap fBM[4]; |
| 223 | 225 |
| 224 public: | 226 public: |
| 225 ShowMipLevels2(int w, int h) : fW(w), fH(h) { | 227 ShowMipLevels2(int w, int h) : fW(w), fH(h) { } |
| 226 fBM[0] = sk_tool_utils::create_checkerboard_bitmap(w, h, SHOW_MIP_COLOR,
SK_ColorWHITE, 2); | |
| 227 fBM[1] = make_bitmap(w, h); | |
| 228 fBM[2] = make_bitmap2(w, h); | |
| 229 fBM[3] = make_bitmap3(w, h); | |
| 230 } | |
| 231 | 228 |
| 232 protected: | 229 protected: |
| 233 | 230 |
| 234 SkString onShortName() override { | 231 SkString onShortName() override { |
| 235 SkString str; | 232 SkString str; |
| 236 str.printf("showmiplevels2_%dx%d", fW, fH); | 233 str.printf("showmiplevels2_%dx%d", fW, fH); |
| 237 return str; | 234 return str; |
| 238 } | 235 } |
| 239 | 236 |
| 240 SkISize onISize() override { | 237 SkISize onISize() override { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 SkAutoCanvasRestore acr(canvas, true); | 282 SkAutoCanvasRestore acr(canvas, true); |
| 286 | 283 |
| 287 for (auto ctype : ctypes) { | 284 for (auto ctype : ctypes) { |
| 288 SkBitmap bm; | 285 SkBitmap bm; |
| 289 orig.copyTo(&bm, ctype); | 286 orig.copyTo(&bm, ctype); |
| 290 drawLevels(canvas, bm); | 287 drawLevels(canvas, bm); |
| 291 canvas->translate(orig.width()/2 + 8.0f, 0); | 288 canvas->translate(orig.width()/2 + 8.0f, 0); |
| 292 } | 289 } |
| 293 } | 290 } |
| 294 | 291 |
| 292 void onOnceBeforeDraw() override { |
| 293 fBM[0] = sk_tool_utils::create_checkerboard_bitmap(fW, fH, |
| 294 SHOW_MIP_COLOR, SK_Co
lorWHITE, 2); |
| 295 fBM[1] = make_bitmap(fW, fH); |
| 296 fBM[2] = make_bitmap2(fW, fH); |
| 297 fBM[3] = make_bitmap3(fW, fH); |
| 298 } |
| 299 |
| 295 void onDraw(SkCanvas* canvas) override { | 300 void onDraw(SkCanvas* canvas) override { |
| 296 canvas->translate(4, 4); | 301 canvas->translate(4, 4); |
| 297 for (const auto& bm : fBM) { | 302 for (const auto& bm : fBM) { |
| 298 this->drawSet(canvas, bm); | 303 this->drawSet(canvas, bm); |
| 299 // round so we always produce an integral translate, so the GOLD too
l won't show | 304 // round so we always produce an integral translate, so the GOLD too
l won't show |
| 300 // unimportant diffs if this is drawn on a GPU with different roundi
ng rules | 305 // unimportant diffs if this is drawn on a GPU with different roundi
ng rules |
| 301 // since we draw the bitmaps using nearest-neighbor | 306 // since we draw the bitmaps using nearest-neighbor |
| 302 canvas->translate(0, SkScalarRoundToScalar(bm.height() * 0.85f)); | 307 canvas->translate(0, SkScalarRoundToScalar(bm.height() * 0.85f)); |
| 303 } | 308 } |
| 304 } | 309 } |
| 305 | 310 |
| 306 private: | 311 private: |
| 307 typedef skiagm::GM INHERITED; | 312 typedef skiagm::GM INHERITED; |
| 308 }; | 313 }; |
| 309 DEF_GM( return new ShowMipLevels2(255, 255); ) | 314 DEF_GM( return new ShowMipLevels2(255, 255); ) |
| 310 DEF_GM( return new ShowMipLevels2(256, 255); ) | 315 DEF_GM( return new ShowMipLevels2(256, 255); ) |
| 311 DEF_GM( return new ShowMipLevels2(255, 256); ) | 316 DEF_GM( return new ShowMipLevels2(255, 256); ) |
| 312 DEF_GM( return new ShowMipLevels2(256, 256); ) | 317 DEF_GM( return new ShowMipLevels2(256, 256); ) |
| OLD | NEW |