OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 class ColorEmojiGM : public GM { | 47 class ColorEmojiGM : public GM { |
48 public: | 48 public: |
49 ColorEmojiGM() { | 49 ColorEmojiGM() { |
50 fTypeface = NULL; | 50 fTypeface = NULL; |
51 } | 51 } |
52 | 52 |
53 ~ColorEmojiGM() { | 53 ~ColorEmojiGM() { |
54 SkSafeUnref(fTypeface); | 54 SkSafeUnref(fTypeface); |
55 } | 55 } |
56 protected: | 56 protected: |
57 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 57 void onOnceBeforeDraw() SK_OVERRIDE { |
58 SkString filename = GetResourcePath("/Funkster.ttf"); | 58 SkString filename = GetResourcePath("/Funkster.ttf"); |
59 SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str())); | 59 SkAutoTUnref<SkFILEStream> stream(new SkFILEStream(filename.c_str())); |
60 if (!stream->isValid()) { | 60 if (!stream->isValid()) { |
61 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); | 61 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); |
62 return; | 62 return; |
63 } | 63 } |
64 | 64 |
65 fTypeface = SkTypeface::CreateFromStream(stream); | 65 fTypeface = SkTypeface::CreateFromStream(stream); |
66 } | 66 } |
67 | 67 |
68 virtual SkString onShortName() SK_OVERRIDE { | 68 SkString onShortName() SK_OVERRIDE { |
69 return SkString("coloremoji"); | 69 return SkString("coloremoji"); |
70 } | 70 } |
71 | 71 |
72 virtual SkISize onISize() SK_OVERRIDE { | 72 SkISize onISize() SK_OVERRIDE { |
73 return SkISize::Make(650, 480); | 73 return SkISize::Make(650, 480); |
74 } | 74 } |
75 | 75 |
76 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 76 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
77 | 77 |
78 canvas->drawColor(SK_ColorGRAY); | 78 canvas->drawColor(SK_ColorGRAY); |
79 | 79 |
80 SkPaint paint; | 80 SkPaint paint; |
81 paint.setTypeface(fTypeface); | 81 paint.setTypeface(fTypeface); |
82 | 82 |
83 const char* text = "hamburgerfons"; | 83 const char* text = "hamburgerfons"; |
84 | 84 |
85 // draw text at different point sizes | 85 // draw text at different point sizes |
86 const int textSize[] = { 10, 30, 50, }; | 86 const int textSize[] = { 10, 30, 50, }; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 typedef GM INHERITED; | 166 typedef GM INHERITED; |
167 }; | 167 }; |
168 | 168 |
169 ////////////////////////////////////////////////////////////////////////////// | 169 ////////////////////////////////////////////////////////////////////////////// |
170 | 170 |
171 static GM* MyFactory(void*) { return new ColorEmojiGM; } | 171 static GM* MyFactory(void*) { return new ColorEmojiGM; } |
172 static GMRegistry reg(MyFactory); | 172 static GMRegistry reg(MyFactory); |
173 | 173 |
174 } | 174 } |
OLD | NEW |