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

Side by Side Diff: gm/circularclips.cpp

Issue 21161003: Use Path Ops to generate PDF clips (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Make more things static, fix warnings when SK_PDF_USE_PATHOPS not enabled Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | src/pdf/SkPDFDevice.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2013 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkPath.h"
11
12 namespace skiagm {
13
14 class CircularClipsGM : public GM {
15 public:
16 CircularClipsGM() {
17
edisonn 2013/07/31 18:27:37 nit: {}
ducky 2013/08/01 00:45:08 Done.
18 }
19
20 protected:
21 virtual SkString onShortName() {
22 return SkString("circular-clips");
23 }
24
25 virtual SkISize onISize() {
26 return SkISize::Make(800, 600);
27 }
28
29 virtual void onDraw(SkCanvas* canvas) {
30 SkRegion::Op ops[] = {
31 SkRegion::kDifference_Op,
32 SkRegion::kIntersect_Op,
33 SkRegion::kUnion_Op,
34 SkRegion::kXOR_Op,
35 SkRegion::kReverseDifference_Op,
36 SkRegion::kReplace_Op,
37 };
38
39 SkScalar x1 = 80, x2 = 120;
40 SkScalar y = 50;
41 SkScalar r = 40;
42
43 SkPath circle1, circle2;
44 circle1.addCircle(x1, y, r, SkPath::kCW_Direction);
45 circle2.addCircle(x2, y, r, SkPath::kCW_Direction);
46 SkRect rect = SkRect::MakeLTRB(x1 - r, y - r, x2 + r, y + r);
47
48 SkPaint fillPaint;
49
50 for (size_t i = 0; i < 4; i++) {
51 circle1.toggleInverseFillType();
52 if (i % 2 == 0) {
53 circle2.toggleInverseFillType();
54 }
55
56 canvas->save();
57 for (size_t op = 0; op < SK_ARRAY_COUNT(ops); op++) {
58 canvas->save();
59
60 canvas->clipPath(circle1, SkRegion::kReplace_Op);
61 canvas->clipPath(circle2, ops[op]);
62
63 canvas->drawRect(rect, fillPaint);
64
65 canvas->restore();
66 canvas->translate(0, 2 * y);
67 }
68 canvas->restore();
69 canvas->translate(x1 + x2, 0);
70 }
71 }
72
73 private:
74 typedef GM INHERITED;
75 };
76
77 //////////////////////////////////////////////////////////////////////////////
78
79 DEF_GM( return new CircularClipsGM; )
80 }
OLDNEW
« no previous file with comments | « no previous file | gyp/gmslides.gypi » ('j') | src/pdf/SkPDFDevice.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698