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

Side by Side Diff: samplecode/SampleLayers.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage Created 4 years, 9 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
« no previous file with comments | « samplecode/SampleFilterQuality.cpp ('k') | samplecode/SampleShip.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7
8 #include "SampleCode.h" 8 #include "SampleCode.h"
9 #include "SkView.h" 9 #include "SkView.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 #include "SkBlurImageFilter.h" 237 #include "SkBlurImageFilter.h"
238 #include "SkMatrixConvolutionImageFilter.h" 238 #include "SkMatrixConvolutionImageFilter.h"
239 #include "SkMorphologyImageFilter.h" 239 #include "SkMorphologyImageFilter.h"
240 240
241 #include "Resources.h" 241 #include "Resources.h"
242 #include "SkAnimTimer.h" 242 #include "SkAnimTimer.h"
243 243
244 class BackdropView : public SampleView { 244 class BackdropView : public SampleView {
245 SkPoint fCenter; 245 SkPoint fCenter;
246 SkScalar fAngle; 246 SkScalar fAngle;
247 SkAutoTUnref<SkImage> fImage; 247 sk_sp<SkImage> fImage;
248 SkAutoTUnref<SkImageFilter> fFilter; 248 SkAutoTUnref<SkImageFilter> fFilter;
249 public: 249 public:
250 BackdropView() { 250 BackdropView() {
251 fCenter.set(200, 150); 251 fCenter.set(200, 150);
252 fAngle = 0; 252 fAngle = 0;
253 fImage.reset(GetResourceAsImage("mandrill_512.png")); 253 fImage = GetResourceAsImage("mandrill_512.png");
254 fFilter.reset(SkDilateImageFilter::Create(8, 8)); 254 fFilter.reset(SkDilateImageFilter::Create(8, 8));
255 } 255 }
256 256
257 protected: 257 protected:
258 // overrides from SkEventSink 258 // overrides from SkEventSink
259 bool onQuery(SkEvent* evt) override { 259 bool onQuery(SkEvent* evt) override {
260 if (SampleCode::TitleQ(*evt)) { 260 if (SampleCode::TitleQ(*evt)) {
261 SampleCode::TitleR(evt, "Backdrop"); 261 SampleCode::TitleR(evt, "Backdrop");
262 return true; 262 return true;
263 } 263 }
264 return this->INHERITED::onQuery(evt); 264 return this->INHERITED::onQuery(evt);
265 } 265 }
266 266
267 void onDrawContent(SkCanvas* canvas) override { 267 void onDrawContent(SkCanvas* canvas) override {
268 canvas->drawImage(fImage, 0, 0, nullptr); 268 canvas->drawImage(fImage.get(), 0, 0, nullptr);
269 269
270 const SkScalar w = 250; 270 const SkScalar w = 250;
271 const SkScalar h = 150; 271 const SkScalar h = 150;
272 SkPath path; 272 SkPath path;
273 path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h)); 273 path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h));
274 SkMatrix m; 274 SkMatrix m;
275 m.setRotate(fAngle); 275 m.setRotate(fAngle);
276 m.postTranslate(fCenter.x(), fCenter.y()); 276 m.postTranslate(fCenter.x(), fCenter.y());
277 path.transform(m); 277 path.transform(m);
278 278
(...skipping 21 matching lines...) Expand all
300 this->inval(nullptr); 300 this->inval(nullptr);
301 fCenter = click->fCurr; 301 fCenter = click->fCurr;
302 return this->INHERITED::onClick(click); 302 return this->INHERITED::onClick(click);
303 } 303 }
304 304
305 private: 305 private:
306 typedef SampleView INHERITED; 306 typedef SampleView INHERITED;
307 }; 307 };
308 DEF_SAMPLE( return new BackdropView; ) 308 DEF_SAMPLE( return new BackdropView; )
309 309
OLDNEW
« no previous file with comments | « samplecode/SampleFilterQuality.cpp ('k') | samplecode/SampleShip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698