| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 const char* filterQualityToString() { | 51 const char* filterQualityToString() { |
| 52 static const char *filterQualityNames[] = { | 52 static const char *filterQualityNames[] = { |
| 53 "none", "low", "medium", "high" | 53 "none", "low", "medium", "high" |
| 54 }; | 54 }; |
| 55 return filterQualityNames[fFilterQuality]; | 55 return filterQualityNames[fFilterQuality]; |
| 56 } | 56 } |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 | 59 |
| 60 SkString onShortName() SK_OVERRIDE { | 60 SkString onShortName() override { |
| 61 return fName; | 61 return fName; |
| 62 } | 62 } |
| 63 | 63 |
| 64 SkISize onISize() SK_OVERRIDE { | 64 SkISize onISize() override { |
| 65 make_bitmap_wrapper(); | 65 make_bitmap_wrapper(); |
| 66 return SkISize::Make(fBM.width(), 4 * fBM.height()); | 66 return SkISize::Make(fBM.width(), 4 * fBM.height()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void make_bitmap_wrapper() { | 69 void make_bitmap_wrapper() { |
| 70 if (!fBitmapMade) { | 70 if (!fBitmapMade) { |
| 71 fBitmapMade = true; | 71 fBitmapMade = true; |
| 72 make_bitmap(); | 72 make_bitmap(); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void make_bitmap() = 0; | 76 virtual void make_bitmap() = 0; |
| 77 | 77 |
| 78 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 78 void onDraw(SkCanvas* canvas) override { |
| 79 make_bitmap_wrapper(); | 79 make_bitmap_wrapper(); |
| 80 | 80 |
| 81 int curY = 0; | 81 int curY = 0; |
| 82 int curHeight; | 82 int curHeight; |
| 83 float curScale = 1; | 83 float curScale = 1; |
| 84 do { | 84 do { |
| 85 | 85 |
| 86 SkMatrix matrix; | 86 SkMatrix matrix; |
| 87 matrix.setScale( curScale, curScale ); | 87 matrix.setScale( curScale, curScale ); |
| 88 | 88 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 109 public: | 109 public: |
| 110 DownsampleBitmapTextGM(float textSize, SkFilterQuality filterQuality) | 110 DownsampleBitmapTextGM(float textSize, SkFilterQuality filterQuality) |
| 111 : INHERITED(filterQuality), fTextSize(textSize) | 111 : INHERITED(filterQuality), fTextSize(textSize) |
| 112 { | 112 { |
| 113 fName.printf("downsamplebitmap_text_%s_%.2fpt", this->filterQualityT
oString(), fTextSize); | 113 fName.printf("downsamplebitmap_text_%s_%.2fpt", this->filterQualityT
oString(), fTextSize); |
| 114 } | 114 } |
| 115 | 115 |
| 116 protected: | 116 protected: |
| 117 float fTextSize; | 117 float fTextSize; |
| 118 | 118 |
| 119 void make_bitmap() SK_OVERRIDE { | 119 void make_bitmap() override { |
| 120 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); | 120 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); |
| 121 SkCanvas canvas(fBM); | 121 SkCanvas canvas(fBM); |
| 122 canvas.drawColor(SK_ColorWHITE); | 122 canvas.drawColor(SK_ColorWHITE); |
| 123 | 123 |
| 124 SkPaint paint; | 124 SkPaint paint; |
| 125 paint.setAntiAlias(true); | 125 paint.setAntiAlias(true); |
| 126 paint.setSubpixelText(true); | 126 paint.setSubpixelText(true); |
| 127 paint.setTextSize(fTextSize); | 127 paint.setTextSize(fTextSize); |
| 128 | 128 |
| 129 setTypeface(&paint, "Times", SkTypeface::kNormal); | 129 setTypeface(&paint, "Times", SkTypeface::kNormal); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 144 DownsampleBitmapCheckerboardGM(int size, int numChecks, SkFilterQuality fi
lterQuality) | 144 DownsampleBitmapCheckerboardGM(int size, int numChecks, SkFilterQuality fi
lterQuality) |
| 145 : INHERITED(filterQuality), fSize(size), fNumChecks(numChecks) | 145 : INHERITED(filterQuality), fSize(size), fNumChecks(numChecks) |
| 146 { | 146 { |
| 147 fName.printf("downsamplebitmap_checkerboard_%s_%d_%d", this->filterQ
ualityToString(), fSize, fNumChecks); | 147 fName.printf("downsamplebitmap_checkerboard_%s_%d_%d", this->filterQ
ualityToString(), fSize, fNumChecks); |
| 148 } | 148 } |
| 149 | 149 |
| 150 protected: | 150 protected: |
| 151 int fSize; | 151 int fSize; |
| 152 int fNumChecks; | 152 int fNumChecks; |
| 153 | 153 |
| 154 void make_bitmap() SK_OVERRIDE { | 154 void make_bitmap() override { |
| 155 make_checker(&fBM, fSize, fNumChecks); | 155 make_checker(&fBM, fSize, fNumChecks); |
| 156 } | 156 } |
| 157 private: | 157 private: |
| 158 typedef DownsampleBitmapGM INHERITED; | 158 typedef DownsampleBitmapGM INHERITED; |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 class DownsampleBitmapImageGM: public DownsampleBitmapGM { | 161 class DownsampleBitmapImageGM: public DownsampleBitmapGM { |
| 162 public: | 162 public: |
| 163 DownsampleBitmapImageGM(const char filename[], SkFilterQuality filterQuali
ty) | 163 DownsampleBitmapImageGM(const char filename[], SkFilterQuality filterQuali
ty) |
| 164 : INHERITED(filterQuality), fFilename(filename) | 164 : INHERITED(filterQuality), fFilename(filename) |
| 165 { | 165 { |
| 166 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt
ring(), filename); | 166 fName.printf("downsamplebitmap_image_%s_%s", this->filterQualityToSt
ring(), filename); |
| 167 } | 167 } |
| 168 | 168 |
| 169 protected: | 169 protected: |
| 170 SkString fFilename; | 170 SkString fFilename; |
| 171 int fSize; | 171 int fSize; |
| 172 | 172 |
| 173 void make_bitmap() SK_OVERRIDE { | 173 void make_bitmap() override { |
| 174 SkImageDecoder* codec = NULL; | 174 SkImageDecoder* codec = NULL; |
| 175 SkString resourcePath = GetResourcePath(fFilename.c_str()); | 175 SkString resourcePath = GetResourcePath(fFilename.c_str()); |
| 176 SkFILEStream stream(resourcePath.c_str()); | 176 SkFILEStream stream(resourcePath.c_str()); |
| 177 if (stream.isValid()) { | 177 if (stream.isValid()) { |
| 178 codec = SkImageDecoder::Factory(&stream); | 178 codec = SkImageDecoder::Factory(&stream); |
| 179 } | 179 } |
| 180 if (codec) { | 180 if (codec) { |
| 181 stream.rewind(); | 181 stream.rewind(); |
| 182 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); | 182 codec->decode(&stream, &fBM, kN32_SkColorType, SkImageDecoder::kDe
codePixels_Mode); |
| 183 SkDELETE(codec); | 183 SkDELETE(codec); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 201 public: | 201 public: |
| 202 SkBitmap fBM; | 202 SkBitmap fBM; |
| 203 | 203 |
| 204 ShowMipLevels() { | 204 ShowMipLevels() { |
| 205 this->setBGColor(0xFFDDDDDD); | 205 this->setBGColor(0xFFDDDDDD); |
| 206 make_checker(&fBM, 512, 256); | 206 make_checker(&fBM, 512, 256); |
| 207 } | 207 } |
| 208 | 208 |
| 209 protected: | 209 protected: |
| 210 | 210 |
| 211 SkString onShortName() SK_OVERRIDE { | 211 SkString onShortName() override { |
| 212 return SkString("showmiplevels"); | 212 return SkString("showmiplevels"); |
| 213 } | 213 } |
| 214 | 214 |
| 215 SkISize onISize() SK_OVERRIDE { | 215 SkISize onISize() override { |
| 216 return SkISize::Make(fBM.width() + 8, 2 * fBM.height() + 80); | 216 return SkISize::Make(fBM.width() + 8, 2 * fBM.height() + 80); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 219 void onDraw(SkCanvas* canvas) override { |
| 220 SkScalar x = 4; | 220 SkScalar x = 4; |
| 221 SkScalar y = 4; | 221 SkScalar y = 4; |
| 222 canvas->drawBitmap(fBM, x, y, NULL); | 222 canvas->drawBitmap(fBM, x, y, NULL); |
| 223 y += fBM.height() + 4; | 223 y += fBM.height() + 4; |
| 224 | 224 |
| 225 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, NULL)); | 225 SkAutoTUnref<SkMipMap> mm(SkMipMap::Build(fBM, NULL)); |
| 226 | 226 |
| 227 SkMipMap::Level level; | 227 SkMipMap::Level level; |
| 228 SkScalar scale = 0.5f; | 228 SkScalar scale = 0.5f; |
| 229 while (mm->extractLevel(scale, &level)) { | 229 while (mm->extractLevel(scale, &level)) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality)
; ) | 264 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kLow_SkFilterQuality)
; ) |
| 265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual
ity); ) | 265 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kLow_SkFilterQual
ity); ) |
| 266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", | 266 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", |
| 267 kLow_SkFilterQuality); ) | 267 kLow_SkFilterQuality); ) |
| 268 | 268 |
| 269 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); ) | 269 DEF_GM( return new DownsampleBitmapTextGM(72, kNone_SkFilterQuality); ) |
| 270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality
); ) | 270 DEF_GM( return new DownsampleBitmapCheckerboardGM(512,256, kNone_SkFilterQuality
); ) |
| 271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua
lity); ) | 271 DEF_GM( return new DownsampleBitmapImageGM("mandrill_512.png", kNone_SkFilterQua
lity); ) |
| 272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", | 272 DEF_GM( return new DownsampleBitmapImageGM("mandrill_132x132_12x12.astc", |
| 273 kNone_SkFilterQuality); ) | 273 kNone_SkFilterQuality); ) |
| OLD | NEW |