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 uint32_t onGetFlags() const SK_OVERRIDE { |
23 return kSkipTiled_Flag; | 23 return kSkipTiled_Flag; |
24 } | 24 } |
25 | 25 |
26 virtual SkString onShortName() SK_OVERRIDE { | 26 SkString onShortName() SK_OVERRIDE { |
27 return SkString("stroke-fill"); | 27 return SkString("stroke-fill"); |
28 } | 28 } |
29 | 29 |
30 virtual SkISize onISize() SK_OVERRIDE { | 30 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) SK_OVERRIDE { | 42 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 private: | 120 private: |
121 typedef GM INHERITED; | 121 typedef GM INHERITED; |
122 }; | 122 }; |
123 | 123 |
124 ////////////////////////////////////////////////////////////////////////////// | 124 ////////////////////////////////////////////////////////////////////////////// |
125 | 125 |
126 DEF_GM(return SkNEW(StrokeFillGM);) | 126 DEF_GM(return SkNEW(StrokeFillGM);) |
127 | 127 |
128 } | 128 } |
OLD | NEW |