| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 /* Tests text vertical text rendering with different fonts and centering. | 10 /* Tests text vertical text rendering with different fonts and centering. |
| 11 */ | 11 */ |
| 12 | 12 |
| 13 #include "gm.h" | 13 #include "gm.h" |
| 14 #include "SkCanvas.h" | 14 #include "SkCanvas.h" |
| 15 #include "SkTypeface.h" | 15 #include "SkTypeface.h" |
| 16 | 16 |
| 17 namespace skiagm { | 17 namespace skiagm { |
| 18 | 18 |
| 19 class VertText2GM : public GM { | 19 class VertText2GM : public GM { |
| 20 public: | 20 public: |
| 21 VertText2GM() { | 21 VertText2GM() |
| 22 const int pointSize = 24; | 22 : fProp(NULL) |
| 23 textHeight = SkIntToScalar(pointSize); | 23 , fMono(NULL) { |
| 24 fProp = sk_tool_utils::create_portable_typeface("Helvetica", SkTypeface:
:kNormal); | |
| 25 fMono = sk_tool_utils::create_portable_typeface("Courier New", SkTypefac
e::kNormal); | |
| 26 } | 24 } |
| 27 | 25 |
| 28 virtual ~VertText2GM() { | 26 virtual ~VertText2GM() { |
| 29 SkSafeUnref(fProp); | 27 SkSafeUnref(fProp); |
| 30 SkSafeUnref(fMono); | 28 SkSafeUnref(fMono); |
| 31 } | 29 } |
| 32 | 30 |
| 33 protected: | 31 protected: |
| 34 | 32 void onOnceBeforeDraw() override { |
| 33 const int pointSize = 24; |
| 34 textHeight = SkIntToScalar(pointSize); |
| 35 fProp = sk_tool_utils::create_portable_typeface("Helvetica", SkTypeface:
:kNormal); |
| 36 fMono = sk_tool_utils::create_portable_typeface("Courier New", SkTypefac
e::kNormal); |
| 37 } |
| 35 | 38 |
| 36 SkString onShortName() override { | 39 SkString onShortName() override { |
| 37 return SkString("verttext2"); | 40 return SkString("verttext2"); |
| 38 } | 41 } |
| 39 | 42 |
| 40 SkISize onISize() override { return SkISize::Make(640, 480); } | 43 SkISize onISize() override { return SkISize::Make(640, 480); } |
| 41 | 44 |
| 42 void onDraw(SkCanvas* canvas) override { | 45 void onDraw(SkCanvas* canvas) override { |
| 43 for (int i = 0; i < 3; ++i) { | 46 for (int i = 0; i < 3; ++i) { |
| 44 SkPaint paint; | 47 SkPaint paint; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 SkTypeface* fProp; | 92 SkTypeface* fProp; |
| 90 SkTypeface* fMono; | 93 SkTypeface* fMono; |
| 91 }; | 94 }; |
| 92 | 95 |
| 93 /////////////////////////////////////////////////////////////////////////////// | 96 /////////////////////////////////////////////////////////////////////////////// |
| 94 | 97 |
| 95 static GM* MyFactory(void*) { return new VertText2GM; } | 98 static GM* MyFactory(void*) { return new VertText2GM; } |
| 96 static GMRegistry reg(MyFactory); | 99 static GMRegistry reg(MyFactory); |
| 97 | 100 |
| 98 } | 101 } |
| OLD | NEW |