Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: samplecode/ClockFaceView.cpp

Issue 1974783002: Revert of Move SkTypeface to sk_sp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "SampleCode.h" 7 #include "SampleCode.h"
8 #include "SkView.h" 8 #include "SkView.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkReadBuffer.h" 10 #include "SkReadBuffer.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 SkLayerRasterizer::Builder rastBuilder; 163 SkLayerRasterizer::Builder rastBuilder;
164 164
165 p.setAntiAlias(true); 165 p.setAntiAlias(true);
166 r7(&rastBuilder, p, scale); 166 r7(&rastBuilder, p, scale);
167 paint->setRasterizer(rastBuilder.detach()); 167 paint->setRasterizer(rastBuilder.detach());
168 168
169 paint->setColor(SK_ColorBLUE); 169 paint->setColor(SK_ColorBLUE);
170 } 170 }
171 171
172 class ClockFaceView : public SkView { 172 class ClockFaceView : public SkView {
173 sk_sp<SkTypeface> fFace; 173 SkTypeface* fFace;
174 SkScalar fInterp; 174 SkScalar fInterp;
175 SkScalar fDx; 175 SkScalar fDx;
176 176
177 public: 177 public:
178 ClockFaceView() { 178 ClockFaceView() {
179 fFace = SkTypeface::MakeFromFile("/Users/reed/Downloads/p052024l.pfb"); 179 fFace = SkTypeface::CreateFromFile("/Users/reed/Downloads/p052024l.pfb") ;
180 fInterp = 0; 180 fInterp = 0;
181 fDx = SK_Scalar1/64; 181 fDx = SK_Scalar1/64;
182 } 182 }
183 183
184 virtual ~ClockFaceView() {
185 SkSafeUnref(fFace);
186 }
187
184 protected: 188 protected:
185 // overrides from SkEventSink 189 // overrides from SkEventSink
186 virtual bool onQuery(SkEvent* evt) { 190 virtual bool onQuery(SkEvent* evt) {
187 if (SampleCode::TitleQ(*evt)) { 191 if (SampleCode::TitleQ(*evt)) {
188 SampleCode::TitleR(evt, "Text Effects"); 192 SampleCode::TitleR(evt, "Text Effects");
189 return true; 193 return true;
190 } 194 }
191 return this->INHERITED::onQuery(evt); 195 return this->INHERITED::onQuery(evt);
192 } 196 }
193 197
(...skipping 20 matching lines...) Expand all
214 218
215 virtual void onDraw(SkCanvas* canvas) { 219 virtual void onDraw(SkCanvas* canvas) {
216 this->drawBG(canvas); 220 this->drawBG(canvas);
217 221
218 SkScalar x = SkIntToScalar(20); 222 SkScalar x = SkIntToScalar(20);
219 SkScalar y = SkIntToScalar(300); 223 SkScalar y = SkIntToScalar(300);
220 SkPaint paint; 224 SkPaint paint;
221 225
222 paint.setAntiAlias(true); 226 paint.setAntiAlias(true);
223 paint.setTextSize(SkIntToScalar(240)); 227 paint.setTextSize(SkIntToScalar(240));
224 paint.setTypeface(SkTypeface::MakeFromName("sans-serif", SkTypeface::kBo ld)); 228 paint.setTypeface(SkTypeface::CreateFromName("sans-serif",
229 SkTypeface::kBold));
225 230
226 SkString str("9"); 231 SkString str("9");
227 232
228 paint.setTypeface(fFace); 233 paint.setTypeface(fFace);
229 234
230 apply_shader(&paint, SkScalarToFloat(fInterp)); 235 apply_shader(&paint, SkScalarToFloat(fInterp));
231 canvas->drawText(str.c_str(), str.size(), x, y, paint); 236 canvas->drawText(str.c_str(), str.size(), x, y, paint);
232 237
233 // drawdots(canvas, paint); 238 // drawdots(canvas, paint);
234 239
(...skipping 11 matching lines...) Expand all
246 } 251 }
247 252
248 private: 253 private:
249 typedef SkView INHERITED; 254 typedef SkView INHERITED;
250 }; 255 };
251 256
252 ////////////////////////////////////////////////////////////////////////////// 257 //////////////////////////////////////////////////////////////////////////////
253 258
254 static SkView* MyFactory() { return new ClockFaceView; } 259 static SkView* MyFactory() { return new ClockFaceView; }
255 static SkViewRegister reg(MyFactory); 260 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « public.bzl ('k') | samplecode/SampleAll.cpp » ('j') | src/ports/SkFontMgr_android.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698