OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurDrawLooper.h" | 10 #include "SkBlurDrawLooper.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 matrix.setScale(-SK_Scalar1, -SK_Scalar1); | 86 matrix.setScale(-SK_Scalar1, -SK_Scalar1); |
87 matrix.postTranslate(pathLen, 0); | 87 matrix.postTranslate(pathLen, 0); |
88 canvas->drawTextOnPath(text, len, path, &matrix, paint); | 88 canvas->drawTextOnPath(text, len, path, &matrix, paint); |
89 } | 89 } |
90 | 90 |
91 class TextOnPathView : public SampleView { | 91 class TextOnPathView : public SampleView { |
92 public: | 92 public: |
93 SkPath fPath; | 93 SkPath fPath; |
94 SkScalar fHOffset; | 94 SkScalar fHOffset; |
95 | 95 |
96 TextOnPathView() { | 96 protected: |
| 97 void onOnceBeforeDraw() SK_OVERRIDE { |
97 SkRect r; | 98 SkRect r; |
98 r.set(SkIntToScalar(100), SkIntToScalar(100), | 99 r.set(SkIntToScalar(100), SkIntToScalar(100), |
99 SkIntToScalar(300), SkIntToScalar(300)); | 100 SkIntToScalar(300), SkIntToScalar(300)); |
100 fPath.addOval(r); | 101 fPath.addOval(r); |
101 fPath.offset(SkIntToScalar(-50), SkIntToScalar(-50)); | 102 fPath.offset(SkIntToScalar(-50), SkIntToScalar(-50)); |
102 | 103 |
103 fHOffset = SkIntToScalar(50); | 104 fHOffset = SkIntToScalar(50); |
104 } | 105 } |
105 | 106 |
106 protected: | |
107 // overrides from SkEventSink | 107 // overrides from SkEventSink |
108 bool onQuery(SkEvent* evt) SK_OVERRIDE { | 108 bool onQuery(SkEvent* evt) SK_OVERRIDE { |
109 if (SampleCode::TitleQ(*evt)) { | 109 if (SampleCode::TitleQ(*evt)) { |
110 SampleCode::TitleR(evt, "Text On Path"); | 110 SampleCode::TitleR(evt, "Text On Path"); |
111 return true; | 111 return true; |
112 } | 112 } |
113 return this->INHERITED::onQuery(evt); | 113 return this->INHERITED::onQuery(evt); |
114 } | 114 } |
115 | 115 |
116 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { | 116 void onDrawContent(SkCanvas* canvas) SK_OVERRIDE { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 typedef SampleView INHERITED; | 166 typedef SampleView INHERITED; |
167 }; | 167 }; |
168 | 168 |
169 ////////////////////////////////////////////////////////////////////////////// | 169 ////////////////////////////////////////////////////////////////////////////// |
170 | 170 |
171 static SkView* MyFactory() { | 171 static SkView* MyFactory() { |
172 return new TextOnPathView; | 172 return new TextOnPathView; |
173 } | 173 } |
174 | 174 |
175 static SkViewRegister reg(MyFactory); | 175 static SkViewRegister reg(MyFactory); |
OLD | NEW |