| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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" |
| 11 #include "SkGradientShader.h" | 11 #include "SkGradientShader.h" |
| 12 #include "SkStream.h" | 12 #include "SkStream.h" |
| 13 #include "SkTypeface.h" | 13 #include "SkTypeface.h" |
| 14 | 14 |
| 15 static void setTypeface(SkPaint* paint, const char name[], SkTypeface::Style sty
le) { | 15 static void setTypeface(SkPaint* paint, const char name[], SkFontStyle style) { |
| 16 sk_tool_utils::set_portable_typeface(paint, name, style); | 16 sk_tool_utils::set_portable_typeface(paint, name, style); |
| 17 } | 17 } |
| 18 | 18 |
| 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { | 19 static SkSize computeSize(const SkBitmap& bm, const SkMatrix& mat) { |
| 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), | 20 SkRect bounds = SkRect::MakeWH(SkIntToScalar(bm.width()), |
| 21 SkIntToScalar(bm.height())); | 21 SkIntToScalar(bm.height())); |
| 22 mat.mapRect(&bounds); | 22 mat.mapRect(&bounds); |
| 23 return SkSize::Make(bounds.width(), bounds.height()); | 23 return SkSize::Make(bounds.width(), bounds.height()); |
| 24 } | 24 } |
| 25 | 25 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 void makeBitmap() override { | 116 void makeBitmap() override { |
| 117 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); | 117 fBM.allocN32Pixels(int(fTextSize * 8), int(fTextSize * 6)); |
| 118 SkCanvas canvas(fBM); | 118 SkCanvas canvas(fBM); |
| 119 canvas.drawColor(SK_ColorWHITE); | 119 canvas.drawColor(SK_ColorWHITE); |
| 120 | 120 |
| 121 SkPaint paint; | 121 SkPaint paint; |
| 122 paint.setAntiAlias(true); | 122 paint.setAntiAlias(true); |
| 123 paint.setSubpixelText(true); | 123 paint.setSubpixelText(true); |
| 124 paint.setTextSize(fTextSize); | 124 paint.setTextSize(fTextSize); |
| 125 | 125 |
| 126 setTypeface(&paint, "serif", SkTypeface::kNormal); | 126 setTypeface(&paint, "serif", SkFontStyle()); |
| 127 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint
); | 127 canvas.drawText("Hamburgefons", 12, fTextSize/2, 1.2f*fTextSize, paint
); |
| 128 setTypeface(&paint, "serif", SkTypeface::kBold); | 128 setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBo
ld)); |
| 129 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint
); | 129 canvas.drawText("Hamburgefons", 12, fTextSize/2, 2.4f*fTextSize, paint
); |
| 130 setTypeface(&paint, "serif", SkTypeface::kItalic); | 130 setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kIt
alic)); |
| 131 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint
); | 131 canvas.drawText("Hamburgefons", 12, fTextSize/2, 3.6f*fTextSize, paint
); |
| 132 setTypeface(&paint, "serif", SkTypeface::kBoldItalic); | 132 setTypeface(&paint, "serif", SkFontStyle::FromOldStyle(SkTypeface::kBo
ldItalic)); |
| 133 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint
); | 133 canvas.drawText("Hamburgefons", 12, fTextSize/2, 4.8f*fTextSize, paint
); |
| 134 } | 134 } |
| 135 private: | 135 private: |
| 136 typedef FilterBitmapGM INHERITED; | 136 typedef FilterBitmapGM INHERITED; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 class FilterBitmapCheckerboardGM: public FilterBitmapGM { | 139 class FilterBitmapCheckerboardGM: public FilterBitmapGM { |
| 140 public: | 140 public: |
| 141 FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = fals
e) | 141 FilterBitmapCheckerboardGM(int size, int num_checks, bool convertToG8 = fals
e) |
| 142 : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8) | 142 : fSize(size), fNumChecks(num_checks), fConvertToG8(convertToG8) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 DEF_GM( return new FilterBitmapCheckerboardGM(32,2); ) | 224 DEF_GM( return new FilterBitmapCheckerboardGM(32,2); ) |
| 225 DEF_GM( return new FilterBitmapCheckerboardGM(192,192); ) | 225 DEF_GM( return new FilterBitmapCheckerboardGM(192,192); ) |
| 226 DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); ) | 226 DEF_GM( return new FilterBitmapImageGM("mandrill_16.png"); ) |
| 227 DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); ) | 227 DEF_GM( return new FilterBitmapImageGM("mandrill_32.png"); ) |
| 228 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); ) | 228 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png"); ) |
| 229 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); ) | 229 DEF_GM( return new FilterBitmapImageGM("mandrill_64.png", true); ) |
| 230 DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); ) | 230 DEF_GM( return new FilterBitmapImageGM("mandrill_128.png"); ) |
| 231 DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); ) | 231 DEF_GM( return new FilterBitmapImageGM("mandrill_256.png"); ) |
| 232 DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); ) | 232 DEF_GM( return new FilterBitmapImageGM("mandrill_512.png"); ) |
| 233 DEF_GM( return new FilterBitmapImageGM("color_wheel.png"); ) | 233 DEF_GM( return new FilterBitmapImageGM("color_wheel.png"); ) |
| OLD | NEW |