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

Side by Side Diff: gm/pathopsinverse.cpp

Issue 777643003: use ClipOp instead of SkRegion for clipping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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 | « gm/megalooper.cpp ('k') | gm/pathopsskpclip.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 2013 Google Inc. 2 * Copyright 2013 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 "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkPath.h" 10 #include "SkPath.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SkPath::FillType twoF = twoFill ? SkPath::kInverseEvenOdd_FillTy pe 68 SkPath::FillType twoF = twoFill ? SkPath::kInverseEvenOdd_FillTy pe
69 : SkPath::kEvenOdd_FillType; 69 : SkPath::kEvenOdd_FillType;
70 one.reset(); 70 one.reset();
71 one.setFillType(oneF); 71 one.setFillType(oneF);
72 one.addRect(10, 10, 70, 70); 72 one.addRect(10, 10, 70, 70);
73 two.reset(); 73 two.reset();
74 two.setFillType(twoF); 74 two.setFillType(twoF);
75 two.addRect(40, 40, 100, 100); 75 two.addRect(40, 40, 100, 100);
76 canvas->save(); 76 canvas->save();
77 canvas->translate(0, SkIntToScalar(yPos)); 77 canvas->translate(0, SkIntToScalar(yPos));
78 canvas->clipRect(SkRect::MakeWH(110, 110), SkRegion::kIntersect_ Op, true); 78 canvas->clipRect(SkRect::MakeWH(110, 110), kIntersect_SkClipOp, true);
79 canvas->drawPath(one, fOnePaint); 79 canvas->drawPath(one, fOnePaint);
80 canvas->drawPath(one, fOutlinePaint); 80 canvas->drawPath(one, fOutlinePaint);
81 canvas->drawPath(two, fTwoPaint); 81 canvas->drawPath(two, fTwoPaint);
82 canvas->drawPath(two, fOutlinePaint); 82 canvas->drawPath(two, fOutlinePaint);
83 canvas->restore(); 83 canvas->restore();
84 int xPos = 150; 84 int xPos = 150;
85 for (int op = kDifference_PathOp; op <= kReverseDifference_PathO p; ++op) { 85 for (int op = kDifference_PathOp; op <= kReverseDifference_PathO p; ++op) {
86 SkPath result; 86 SkPath result;
87 Op(one, two, (SkPathOp) op, &result); 87 Op(one, two, (SkPathOp) op, &result);
88 canvas->save(); 88 canvas->save();
89 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos)); 89 canvas->translate(SkIntToScalar(xPos), SkIntToScalar(yPos));
90 canvas->clipRect(SkRect::MakeWH(110, 110), SkRegion::kInters ect_Op, true); 90 canvas->clipRect(SkRect::MakeWH(110, 110), kIntersect_SkClip Op, true);
91 canvas->drawPath(result, fOpPaint[op]); 91 canvas->drawPath(result, fOpPaint[op]);
92 canvas->drawPath(result, fOutlinePaint); 92 canvas->drawPath(result, fOutlinePaint);
93 canvas->restore(); 93 canvas->restore();
94 xPos += 150; 94 xPos += 150;
95 } 95 }
96 yPos += 150; 96 yPos += 150;
97 } 97 }
98 } 98 }
99 } 99 }
100 100
101 private: 101 private:
102 SkPaint fOnePaint; 102 SkPaint fOnePaint;
103 SkPaint fTwoPaint; 103 SkPaint fTwoPaint;
104 SkPaint fOutlinePaint; 104 SkPaint fOutlinePaint;
105 SkPaint fOpPaint[kReverseDifference_PathOp - kDifference_PathOp + 1]; 105 SkPaint fOpPaint[kReverseDifference_PathOp - kDifference_PathOp + 1];
106 typedef GM INHERITED; 106 typedef GM INHERITED;
107 }; 107 };
108 108
109 ////////////////////////////////////////////////////////////////////////////// 109 //////////////////////////////////////////////////////////////////////////////
110 110
111 static GM* MyFactory(void*) { return new PathOpsInverseGM; } 111 static GM* MyFactory(void*) { return new PathOpsInverseGM; }
112 static GMRegistry reg(MyFactory); 112 static GMRegistry reg(MyFactory);
113 113
114 } 114 }
OLDNEW
« no previous file with comments | « gm/megalooper.cpp ('k') | gm/pathopsskpclip.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698