OLD | NEW |
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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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" | 194 #include "SkMipMap.h" |
| 195 |
| 196 static void release_mipmap(void*, void* context) { |
| 197 ((SkMipMap*)context)->unref(); |
| 198 } |
| 199 |
195 class ShowMipLevels : public skiagm::GM { | 200 class ShowMipLevels : public skiagm::GM { |
196 public: | 201 public: |
197 SkBitmap fBM; | 202 SkBitmap fBM; |
198 | 203 |
199 ShowMipLevels() { | 204 ShowMipLevels() { |
200 this->setBGColor(0xFFDDDDDD); | 205 this->setBGColor(0xFFDDDDDD); |
201 make_checker(&fBM, 512, 256); | 206 make_checker(&fBM, 512, 256); |
202 } | 207 } |
203 | 208 |
204 protected: | 209 protected: |
(...skipping 12 matching lines...) Expand all Loading... |
217 canvas->drawBitmap(fBM, x, y, NULL); | 222 canvas->drawBitmap(fBM, x, y, NULL); |
218 y += fBM.height() + 4; | 223 y += fBM.height() + 4; |
219 | 224 |
220 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, NULL)); | 225 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, NULL)); |
221 | 226 |
222 SkMipMap::Level level; | 227 SkMipMap::Level level; |
223 SkScalar scale = 0.5f; | 228 SkScalar scale = 0.5f; |
224 while (mm->extractLevel(scale, &level)) { | 229 while (mm->extractLevel(scale, &level)) { |
225 SkImageInfo info = SkImageInfo::MakeN32Premul(level.fWidth, level.fH
eight); | 230 SkImageInfo info = SkImageInfo::MakeN32Premul(level.fWidth, level.fH
eight); |
226 SkBitmap bm; | 231 SkBitmap bm; |
227 bm.installPixels(info, level.fPixels, level.fRowBytes); | 232 bm.installPixels(info, level.fPixels, level.fRowBytes, NULL, |
| 233 &release_mipmap, (void*)(SkRef(mm.get()))); |
| 234 bm.setImmutable(); |
228 canvas->drawBitmap(bm, x, y, NULL); | 235 canvas->drawBitmap(bm, x, y, NULL); |
229 y += bm.height() + 4; | 236 y += bm.height() + 4; |
230 scale /= 2; | 237 scale /= 2; |
231 if (info.width() == 1 || info.height() == 1) { | 238 if (info.width() == 1 || info.height() == 1) { |
232 break; | 239 break; |
233 } | 240 } |
234 } | 241 } |
235 } | 242 } |
236 | 243 |
237 private: | 244 private: |
(...skipping 19 matching lines...) Expand all Loading... |
257 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL
evel); ) | 264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kLow_FilterL
evel); ) |
258 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil
terLevel); ) | 265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kLow_Fil
terLevel); ) |
259 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", | 266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", |
260 SkPaint::kLow_FilterLevel); ) | 267 SkPaint::kLow_FilterLevel); ) |
261 | 268 |
262 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); ) | 269 DEF_GM( return new DownsampleBitmapTextGM(72, SkPaint::kNone_FilterLevel); ) |
263 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter
Level); ) | 270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, SkPaint::kNone_Filter
Level); ) |
264 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi
lterLevel); ) | 271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", SkPaint::kNone_Fi
lterLevel); ) |
265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", | 272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", |
266 SkPaint::kNone_FilterLevel); ) | 273 SkPaint::kNone_FilterLevel); ) |
OLD | NEW |