| 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 #include "gm.h" | 7 #include "gm.h" |
| 8 #include "SkTypeface.h" | 8 #include "SkTypeface.h" |
| 9 | 9 |
| 10 namespace skiagm { | 10 namespace skiagm { |
| 11 | 11 |
| 12 class FontScalerGM : public GM { | 12 class FontScalerGM : public GM { |
| 13 public: | 13 public: |
| 14 FontScalerGM() { | 14 FontScalerGM() { |
| 15 this->setBGColor(0xFFFFFFFF); | 15 this->setBGColor(0xFFFFFFFF); |
| 16 } | 16 } |
| 17 | 17 |
| 18 virtual ~FontScalerGM() { | 18 virtual ~FontScalerGM() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 protected: | 21 protected: |
| 22 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 22 uint32_t onGetFlags() const SK_OVERRIDE { |
| 23 return kSkipTiled_Flag; | 23 return kSkipTiled_Flag; |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual SkString onShortName() SK_OVERRIDE { | 26 SkString onShortName() SK_OVERRIDE { |
| 27 return SkString("fontscaler"); | 27 return SkString("fontscaler"); |
| 28 } | 28 } |
| 29 | 29 |
| 30 virtual SkISize onISize() SK_OVERRIDE { | 30 SkISize onISize() SK_OVERRIDE { |
| 31 return SkISize::Make(1450, 750); | 31 return SkISize::Make(1450, 750); |
| 32 } | 32 } |
| 33 | 33 |
| 34 static void rotate_about(SkCanvas* canvas, | 34 static void rotate_about(SkCanvas* canvas, |
| 35 SkScalar degrees, | 35 SkScalar degrees, |
| 36 SkScalar px, SkScalar py) { | 36 SkScalar px, SkScalar py) { |
| 37 canvas->translate(px, py); | 37 canvas->translate(px, py); |
| 38 canvas->rotate(degrees); | 38 canvas->rotate(degrees); |
| 39 canvas->translate(-px, -py); | 39 canvas->translate(-px, -py); |
| 40 } | 40 } |
| 41 | 41 |
| 42 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 42 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
| 43 SkPaint paint; | 43 SkPaint paint; |
| 44 | 44 |
| 45 paint.setAntiAlias(true); | 45 paint.setAntiAlias(true); |
| 46 paint.setLCDRenderText(true); | 46 paint.setLCDRenderText(true); |
| 47 //With freetype the default (normal hinting) can be really ugly. | 47 //With freetype the default (normal hinting) can be really ugly. |
| 48 //Most distros now set slight (vertical hinting only) in any event. | 48 //Most distros now set slight (vertical hinting only) in any event. |
| 49 paint.setHinting(SkPaint::kSlight_Hinting); | 49 paint.setHinting(SkPaint::kSlight_Hinting); |
| 50 sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::
kNormal); | 50 sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::
kNormal); |
| 51 | 51 |
| 52 const char* text = "Hamburgefons ooo mmm"; | 52 const char* text = "Hamburgefons ooo mmm"; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 private: | 86 private: |
| 87 typedef GM INHERITED; | 87 typedef GM INHERITED; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 ////////////////////////////////////////////////////////////////////////////// | 90 ////////////////////////////////////////////////////////////////////////////// |
| 91 | 91 |
| 92 static GM* MyFactory(void*) { return new FontScalerGM; } | 92 static GM* MyFactory(void*) { return new FontScalerGM; } |
| 93 static GMRegistry reg(MyFactory); | 93 static GMRegistry reg(MyFactory); |
| 94 | 94 |
| 95 } | 95 } |
| OLD | NEW |