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 "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 class GradTextGM : public GM { | 100 class GradTextGM : public GM { |
101 public: | 101 public: |
102 GradTextGM () {} | 102 GradTextGM () {} |
103 | 103 |
104 protected: | 104 protected: |
105 virtual SkString onShortName() { | 105 virtual SkString onShortName() { |
106 return SkString("gradtext"); | 106 return SkString("gradtext"); |
107 } | 107 } |
108 | 108 |
109 virtual SkISize onISize() { return SkISize::Make(500, 480); } | 109 uint32_t onGetFlags() const SK_OVERRIDE { |
| 110 return kSkipTiled_Flag; |
| 111 } |
| 112 |
| 113 SkISize onISize() SK_OVERRIDE { return SkISize::Make(500, 480); } |
110 | 114 |
111 static void draw_text(SkCanvas* canvas, const SkPaint& paint) { | 115 static void draw_text(SkCanvas* canvas, const SkPaint& paint) { |
112 const char* text = "When in the course of human events"; | 116 const char* text = "When in the course of human events"; |
113 size_t len = strlen(text); | 117 size_t len = strlen(text); |
114 canvas->drawText(text, len, 0, 0, paint); | 118 canvas->drawText(text, len, 0, 0, paint); |
115 } | 119 } |
116 | 120 |
117 static void draw_text3(SkCanvas* canvas, const SkPaint& paint) { | 121 static void draw_text3(SkCanvas* canvas, const SkPaint& paint) { |
118 SkPaint p(paint); | 122 SkPaint p(paint); |
119 | 123 |
120 p.setAntiAlias(false); | 124 p.setAntiAlias(false); |
121 draw_text(canvas, p); | 125 draw_text(canvas, p); |
122 p.setAntiAlias(true); | 126 p.setAntiAlias(true); |
123 canvas->translate(0, paint.getTextSize() * 4/3); | 127 canvas->translate(0, paint.getTextSize() * 4/3); |
124 draw_text(canvas, p); | 128 draw_text(canvas, p); |
125 p.setLCDRenderText(true); | 129 p.setLCDRenderText(true); |
126 canvas->translate(0, paint.getTextSize() * 4/3); | 130 canvas->translate(0, paint.getTextSize() * 4/3); |
127 draw_text(canvas, p); | 131 draw_text(canvas, p); |
128 } | 132 } |
129 | 133 |
130 virtual void onDraw(SkCanvas* canvas) { | 134 void onDraw(SkCanvas* canvas) SK_OVERRIDE { |
131 SkPaint paint; | 135 SkPaint paint; |
132 sk_tool_utils::set_portable_typeface(&paint); | 136 sk_tool_utils::set_portable_typeface(&paint); |
133 paint.setTextSize(SkIntToScalar(26)); | 137 paint.setTextSize(SkIntToScalar(26)); |
134 | 138 |
135 const SkISize& size = this->getISize(); | 139 const SkISize& size = this->getISize(); |
136 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), | 140 SkRect r = SkRect::MakeWH(SkIntToScalar(size.width()), |
137 SkIntToScalar(size.height()) / 2); | 141 SkIntToScalar(size.height()) / 2); |
138 canvas->drawRect(r, paint); | 142 canvas->drawRect(r, paint); |
139 | 143 |
140 canvas->translate(SkIntToScalar(20), paint.getTextSize()); | 144 canvas->translate(SkIntToScalar(20), paint.getTextSize()); |
(...skipping 18 matching lines...) Expand all Loading... |
159 ////////////////////////////////////////////////////////////////////////////// | 163 ////////////////////////////////////////////////////////////////////////////// |
160 | 164 |
161 static GM* MyFactory(void*) { return new GradTextGM; } | 165 static GM* MyFactory(void*) { return new GradTextGM; } |
162 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } | 166 static GM* CMyFactory(void*) { return new ChromeGradTextGM1; } |
163 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } | 167 static GM* CMyFactory2(void*) { return new ChromeGradTextGM2; } |
164 | 168 |
165 static GMRegistry reg(MyFactory); | 169 static GMRegistry reg(MyFactory); |
166 static GMRegistry Creg(CMyFactory); | 170 static GMRegistry Creg(CMyFactory); |
167 static GMRegistry Creg2(CMyFactory2); | 171 static GMRegistry Creg2(CMyFactory2); |
168 } | 172 } |
OLD | NEW |