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 13 matching lines...) Expand all Loading... |
24 if ((cx+cy)%2) { | 24 if ((cx+cy)%2) { |
25 *s = 0xFFFFFFFF; | 25 *s = 0xFFFFFFFF; |
26 } else { | 26 } else { |
27 *s = 0xFF000000; | 27 *s = 0xFF000000; |
28 } | 28 } |
29 } | 29 } |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty
le) { | 33 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty
le) { |
34 sk_tool_utils::set_portable_typeface_always(paint, name, style); | 34 sk_tool_utils::set_portable_typeface(paint, name, style); |
35 } | 35 } |
36 | 36 |
37 class DownsampleBitmapGM : public skiagm::GM { | 37 class DownsampleBitmapGM : public skiagm::GM { |
38 public: | 38 public: |
39 SkBitmap fBM; | 39 SkBitmap fBM; |
40 SkString fName; | 40 SkString fName; |
41 bool fBitmapMade; | 41 bool fBitmapMade; |
42 SkFilterQuality fFilterQuality; | 42 SkFilterQuality fFilterQuality; |
43 | 43 |
44 DownsampleBitmapGM(SkFilterQuality filterQuality) | 44 DownsampleBitmapGM(SkFilterQuality filterQuality) |
45 : fFilterQuality(filterQuality) | 45 : fFilterQuality(filterQuality) |
46 { | 46 { |
47 this->setBGColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); | 47 this->setBGColor(0xFFDDDDDD); |
48 fBitmapMade = false; | 48 fBitmapMade = false; |
49 } | 49 } |
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 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 void make_bitmap() 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, "serif", SkTypeface::kNormal); | 129 setTypeface(&paint, "Times", SkTypeface::kNormal); |
130 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint
); | 130 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint
); |
131 setTypeface(&paint, "serif", SkTypeface::kBold); | 131 setTypeface(&paint, "Times", SkTypeface::kBold); |
132 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint
); | 132 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint
); |
133 setTypeface(&paint, "serif", SkTypeface::kItalic); | 133 setTypeface(&paint, "Times", SkTypeface::kItalic); |
134 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint
); | 134 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint
); |
135 setTypeface(&paint, "serif", SkTypeface::kBoldItalic); | 135 setTypeface(&paint, "Times", SkTypeface::kBoldItalic); |
136 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint
); | 136 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint
); |
137 } | 137 } |
138 private: | 138 private: |
139 typedef DownsampleBitmapGM INHERITED; | 139 typedef DownsampleBitmapGM INHERITED; |
140 }; | 140 }; |
141 | 141 |
142 class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM { | 142 class DownsampleBitmapCheckerboardGM: public DownsampleBitmapGM { |
143 public: | 143 public: |
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) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 static void release_mipmap(void*, void* context) { | 196 static void release_mipmap(void*, void* context) { |
197 ((SkMipMap*)context)->unref(); | 197 ((SkMipMap*)context)->unref(); |
198 } | 198 } |
199 | 199 |
200 class ShowMipLevels : public skiagm::GM { | 200 class ShowMipLevels : public skiagm::GM { |
201 public: | 201 public: |
202 SkBitmap fBM; | 202 SkBitmap fBM; |
203 | 203 |
204 ShowMipLevels() { | 204 ShowMipLevels() { |
205 this->setBGColor(sk_tool_utils::color_to_565(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() override { | 211 SkString onShortName() override { |
212 return SkString("showmiplevels"); | 212 return SkString("showmiplevels"); |
213 } | 213 } |
214 | 214 |
215 SkISize onISize() override { | 215 SkISize onISize() override { |
(...skipping 48 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 |