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 "Resources.h" | 8 #include "Resources.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
11 #include "SkSurface.h" | 11 #include "SkSurface.h" |
12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
13 | 13 |
14 class DFTextGM : public skiagm::GM { | 14 class DFTextGM : public skiagm::GM { |
15 public: | 15 public: |
16 DFTextGM() { | 16 DFTextGM() { |
17 this->setBGColor(0xFFFFFFFF); | 17 this->setBGColor(0xFFFFFFFF); |
18 fTypeface = NULL; | 18 fTypeface = NULL; |
19 } | 19 } |
20 | 20 |
21 virtual ~DFTextGM() { | 21 virtual ~DFTextGM() { |
22 SkSafeUnref(fTypeface); | 22 SkSafeUnref(fTypeface); |
23 } | 23 } |
24 | 24 |
25 protected: | 25 protected: |
26 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 26 void onOnceBeforeDraw() SK_OVERRIDE { |
27 SkString filename = GetResourcePath("/Funkster.ttf"); | 27 SkString filename = GetResourcePath("/Funkster.ttf"); |
28 SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str())); | 28 SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str())); |
29 if (!stream->isValid()) { | 29 if (!stream->isValid()) { |
30 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); | 30 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); |
31 return; | 31 return; |
32 } | 32 } |
33 | 33 |
34 fTypeface = SkTypeface::CreateFromStream(stream); | 34 fTypeface = SkTypeface::CreateFromStream(stream); |
35 } | 35 } |
36 | 36 |
37 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 37 uint32_t onGetFlags() const SK_OVERRIDE { |
38 return kGPUOnly_Flag; | 38 return kGPUOnly_Flag; |
39 } | 39 } |
40 | 40 |
41 virtual SkString onShortName() SK_OVERRIDE { | 41 SkString onShortName() SK_OVERRIDE { |
42 return SkString("dftext"); | 42 return SkString("dftext"); |
43 } | 43 } |
44 | 44 |
45 virtual SkISize onISize() SK_OVERRIDE { | 45 SkISize onISize() SK_OVERRIDE { |
46 return SkISize::Make(1024, 768); | 46 return SkISize::Make(1024, 768); |
47 } | 47 } |
48 | 48 |
49 static void rotate_about(SkCanvas* canvas, | 49 static void rotate_about(SkCanvas* canvas, |
50 SkScalar degrees, | 50 SkScalar degrees, |
51 SkScalar px, SkScalar py) { | 51 SkScalar px, SkScalar py) { |
52 canvas->translate(px, py); | 52 canvas->translate(px, py); |
53 canvas->rotate(degrees); | 53 canvas->rotate(degrees); |
54 canvas->translate(-px, -py); | 54 canvas->translate(-px, -py); |
55 } | 55 } |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 #endif | 216 #endif |
217 } | 217 } |
218 | 218 |
219 private: | 219 private: |
220 SkTypeface* fTypeface; | 220 SkTypeface* fTypeface; |
221 | 221 |
222 typedef skiagm::GM INHERITED; | 222 typedef skiagm::GM INHERITED; |
223 }; | 223 }; |
224 | 224 |
225 DEF_GM( return SkNEW(DFTextGM); ) | 225 DEF_GM( return SkNEW(DFTextGM); ) |
OLD | NEW |