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 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
11 #include "SkTypeface.h" | 11 #include "SkTypeface.h" |
12 | 12 |
13 namespace skiagm { | 13 namespace skiagm { |
14 | 14 |
15 class StrokeFillGM : public GM { | 15 class StrokeFillGM : public GM { |
16 public: | 16 public: |
17 StrokeFillGM() { | 17 StrokeFillGM() { |
18 | 18 |
19 } | 19 } |
20 | 20 |
21 protected: | 21 protected: |
22 virtual uint32_t onGetFlags() const SK_OVERRIDE { | 22 virtual uint32_t onGetFlags() const SK_OVERRIDE { |
23 return kSkipTiled_Flag; | 23 return kSkipTiled_Flag; |
24 } | 24 } |
25 | 25 |
26 virtual SkString onShortName() { | 26 virtual SkString onShortName() SK_OVERRIDE { |
27 return SkString("stroke-fill"); | 27 return SkString("stroke-fill"); |
28 } | 28 } |
29 | 29 |
30 virtual SkISize onISize() { | 30 virtual SkISize onISize() SK_OVERRIDE { |
31 return SkISize::Make(640, 480); | 31 return SkISize::Make(640, 480); |
32 } | 32 } |
33 | 33 |
34 static void show_bold(SkCanvas* canvas, const void* text, int len, | 34 static void show_bold(SkCanvas* canvas, const void* text, int len, |
35 SkScalar x, SkScalar y, const SkPaint& paint) { | 35 SkScalar x, SkScalar y, const SkPaint& paint) { |
36 SkPaint p(paint); | 36 SkPaint p(paint); |
37 canvas->drawText(text, len, x, y, p); | 37 canvas->drawText(text, len, x, y, p); |
38 p.setFakeBoldText(true); | 38 p.setFakeBoldText(true); |
39 canvas->drawText(text, len, x, y + SkIntToScalar(120), p); | 39 canvas->drawText(text, len, x, y + SkIntToScalar(120), p); |
40 } | 40 } |
41 | 41 |
42 virtual void onDraw(SkCanvas* canvas) { | 42 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
43 SkScalar x = SkIntToScalar(100); | 43 SkScalar x = SkIntToScalar(100); |
44 SkScalar y = SkIntToScalar(88); | 44 SkScalar y = SkIntToScalar(88); |
45 | 45 |
46 SkPaint paint; | 46 SkPaint paint; |
47 paint.setAntiAlias(true); | 47 paint.setAntiAlias(true); |
48 paint.setTextSize(SkIntToScalar(100)); | 48 paint.setTextSize(SkIntToScalar(100)); |
49 paint.setStrokeWidth(SkIntToScalar(5)); | 49 paint.setStrokeWidth(SkIntToScalar(5)); |
50 | 50 |
51 sk_tool_utils::set_portable_typeface(&paint, "Papyrus"); | 51 sk_tool_utils::set_portable_typeface(&paint, "Papyrus"); |
52 show_bold(canvas, "Hello", 5, x, y, paint); | 52 show_bold(canvas, "Hello", 5, x, y, paint); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 private: | 84 private: |
85 typedef GM INHERITED; | 85 typedef GM INHERITED; |
86 }; | 86 }; |
87 | 87 |
88 ////////////////////////////////////////////////////////////////////////////// | 88 ////////////////////////////////////////////////////////////////////////////// |
89 | 89 |
90 static GM* MyFactory(void*) { return new StrokeFillGM; } | 90 static GM* MyFactory(void*) { return new StrokeFillGM; } |
91 static GMRegistry reg(MyFactory); | 91 static GMRegistry reg(MyFactory); |
92 | 92 |
93 } | 93 } |
OLD | NEW |