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

Side by Side Diff: samplecode/SampleLayers.cpp

Issue 2355483002: abstract name of clipping ops, to transtion to a more restricted set (Closed)
Patch Set: no need for ifdef for globals Created 4 years, 3 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/SampleIdentityScale.cpp ('k') | src/core/SkCanvas.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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 const SkScalar w = 250; 249 const SkScalar w = 250;
250 const SkScalar h = 150; 250 const SkScalar h = 150;
251 SkPath path; 251 SkPath path;
252 path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h)); 252 path.addOval(SkRect::MakeXYWH(-w/2, -h/2, w, h));
253 SkMatrix m; 253 SkMatrix m;
254 m.setRotate(fAngle); 254 m.setRotate(fAngle);
255 m.postTranslate(fCenter.x(), fCenter.y()); 255 m.postTranslate(fCenter.x(), fCenter.y());
256 path.transform(m); 256 path.transform(m);
257 257
258 canvas->clipPath(path, SkRegion::kIntersect_Op, true); 258 canvas->clipPath(path, SkCanvas::kIntersect_Op, true);
259 const SkRect bounds = path.getBounds(); 259 const SkRect bounds = path.getBounds();
260 260
261 SkPaint paint; 261 SkPaint paint;
262 paint.setAlpha(0xCC); 262 paint.setAlpha(0xCC);
263 canvas->saveLayer({ &bounds, &paint, fFilter.get(), 0 }); 263 canvas->saveLayer({ &bounds, &paint, fFilter.get(), 0 });
264 264
265 canvas->restore(); 265 canvas->restore();
266 } 266 }
267 267
268 bool onAnimate(const SkAnimTimer& timer) override { 268 bool onAnimate(const SkAnimTimer& timer) override {
269 fAngle = SkDoubleToScalar(fmod(timer.secs() * 360 / 5, 360)); 269 fAngle = SkDoubleToScalar(fmod(timer.secs() * 360 / 5, 360));
270 return true; 270 return true;
271 } 271 }
272 272
273 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride { 273 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove rride {
274 this->inval(nullptr); 274 this->inval(nullptr);
275 return new Click(this); 275 return new Click(this);
276 } 276 }
277 277
278 bool onClick(Click* click) override { 278 bool onClick(Click* click) override {
279 this->inval(nullptr); 279 this->inval(nullptr);
280 fCenter = click->fCurr; 280 fCenter = click->fCurr;
281 return this->INHERITED::onClick(click); 281 return this->INHERITED::onClick(click);
282 } 282 }
283 283
284 private: 284 private:
285 typedef SampleView INHERITED; 285 typedef SampleView INHERITED;
286 }; 286 };
287 DEF_SAMPLE( return new BackdropView; ) 287 DEF_SAMPLE( return new BackdropView; )
OLDNEW
« no previous file with comments | « samplecode/SampleIdentityScale.cpp ('k') | src/core/SkCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698