| 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 | 22 |
| 23 SkString onShortName() override { | 23 SkString onShortName() override { |
| 24 return SkString("fontscaler"); | 24 SkString name("fontscaler"); |
| 25 name.append(sk_tool_utils::major_platform_os_name()); |
| 26 return name; |
| 25 } | 27 } |
| 26 | 28 |
| 27 SkISize onISize() override { | 29 SkISize onISize() override { |
| 28 return SkISize::Make(1450, 750); | 30 return SkISize::Make(1450, 750); |
| 29 } | 31 } |
| 30 | 32 |
| 31 static void rotate_about(SkCanvas* canvas, | 33 static void rotate_about(SkCanvas* canvas, |
| 32 SkScalar degrees, | 34 SkScalar degrees, |
| 33 SkScalar px, SkScalar py) { | 35 SkScalar px, SkScalar py) { |
| 34 canvas->translate(px, py); | 36 canvas->translate(px, py); |
| 35 canvas->rotate(degrees); | 37 canvas->rotate(degrees); |
| 36 canvas->translate(-px, -py); | 38 canvas->translate(-px, -py); |
| 37 } | 39 } |
| 38 | 40 |
| 39 void onDraw(SkCanvas* canvas) override { | 41 void onDraw(SkCanvas* canvas) override { |
| 40 SkPaint paint; | 42 SkPaint paint; |
| 41 | 43 |
| 42 paint.setAntiAlias(true); | 44 paint.setAntiAlias(true); |
| 43 paint.setLCDRenderText(true); | 45 paint.setLCDRenderText(true); |
| 44 //With freetype the default (normal hinting) can be really ugly. | 46 //With freetype the default (normal hinting) can be really ugly. |
| 45 //Most distros now set slight (vertical hinting only) in any event. | 47 //Most distros now set slight (vertical hinting only) in any event. |
| 46 paint.setHinting(SkPaint::kSlight_Hinting); | 48 paint.setHinting(SkPaint::kSlight_Hinting); |
| 47 sk_tool_utils::set_portable_typeface(&paint, "Times Roman", SkTypeface::
kNormal); | |
| 48 | 49 |
| 49 const char* text = "Hamburgefons ooo mmm"; | 50 const char* text = "Hamburgefons ooo mmm"; |
| 50 const size_t textLen = strlen(text); | 51 const size_t textLen = strlen(text); |
| 51 | 52 |
| 52 for (int j = 0; j < 2; ++j) { | 53 for (int j = 0; j < 2; ++j) { |
| 53 // This used to do 6 iterations but it causes the N4 to crash in the
MSAA4 config. | 54 // This used to do 6 iterations but it causes the N4 to crash in the
MSAA4 config. |
| 54 for (int i = 0; i < 5; ++i) { | 55 for (int i = 0; i < 5; ++i) { |
| 55 SkScalar x = SkIntToScalar(10); | 56 SkScalar x = SkIntToScalar(10); |
| 56 SkScalar y = SkIntToScalar(20); | 57 SkScalar y = SkIntToScalar(20); |
| 57 | 58 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 83 private: | 84 private: |
| 84 typedef GM INHERITED; | 85 typedef GM INHERITED; |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 ////////////////////////////////////////////////////////////////////////////// | 88 ////////////////////////////////////////////////////////////////////////////// |
| 88 | 89 |
| 89 static GM* MyFactory(void*) { return new FontScalerGM; } | 90 static GM* MyFactory(void*) { return new FontScalerGM; } |
| 90 static GMRegistry reg(MyFactory); | 91 static GMRegistry reg(MyFactory); |
| 91 | 92 |
| 92 } | 93 } |
| OLD | NEW |