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

Side by Side Diff: samplecode/SampleClipDrawMatch.cpp

Issue 2357333002: allow clip calls w/o op param, remove unnecessary kReplace ops (Closed)
Patch Set: 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 | « include/core/SkCanvas.h ('k') | no next file » | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkInterpolator.h" 10 #include "SkInterpolator.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 157 }
158 return this->INHERITED::onQuery(evt); 158 return this->INHERITED::onQuery(evt);
159 } 159 }
160 160
161 void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) { 161 void drawClippedGeom(SkCanvas* canvas, const SkPoint& offset, bool useAA) {
162 162
163 int count = canvas->save(); 163 int count = canvas->save();
164 164
165 switch (fGeom) { 165 switch (fGeom) {
166 case kRect_Geometry: 166 case kRect_Geometry:
167 canvas->clipRect(create_rect(offset), SkCanvas::kReplace_Op, useAA); 167 canvas->clipRect(create_rect(offset), useAA);
168 break; 168 break;
169 case kRRect_Geometry: 169 case kRRect_Geometry:
170 canvas->clipRRect(create_rrect(offset), SkCanvas::kReplace_Op, useAA ); 170 canvas->clipRRect(create_rrect(offset), useAA);
171 break; 171 break;
172 case kCircle_Geometry: 172 case kCircle_Geometry:
173 canvas->clipRRect(create_circle(offset), SkCanvas::kReplace_Op, useA A); 173 canvas->clipRRect(create_circle(offset), useAA);
174 break; 174 break;
175 case kConvexPath_Geometry: 175 case kConvexPath_Geometry:
176 canvas->clipPath(create_convex_path(offset), SkCanvas::kReplace_Op, useAA); 176 canvas->clipPath(create_convex_path(offset), useAA);
177 break; 177 break;
178 case kConcavePath_Geometry: 178 case kConcavePath_Geometry:
179 canvas->clipPath(create_concave_path(offset), SkCanvas::kReplace_Op, useAA); 179 canvas->clipPath(create_concave_path(offset), useAA);
180 break; 180 break;
181 case kRectAndRect_Geometry: { 181 case kRectAndRect_Geometry: {
182 SkRect r = create_rect(offset); 182 SkRect r = create_rect(offset);
183 r.offset(fSign * kXlate, fSign * kXlate); 183 r.offset(fSign * kXlate, fSign * kXlate);
184 canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips 184 canvas->clipRect(r, true); // AA here forces shader clips
185 canvas->clipRect(create_rect(offset), SkCanvas::kIntersect_Op, useAA ); 185 canvas->clipRect(create_rect(offset), useAA);
186 } break; 186 } break;
187 case kRectAndRRect_Geometry: { 187 case kRectAndRRect_Geometry: {
188 SkRect r = create_rect(offset); 188 SkRect r = create_rect(offset);
189 r.offset(fSign * kXlate, fSign * kXlate); 189 r.offset(fSign * kXlate, fSign * kXlate);
190 canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips 190 canvas->clipRect(r, true); // AA here forces shader clips
191 canvas->clipRRect(create_rrect(offset), SkCanvas::kIntersect_Op, use AA); 191 canvas->clipRRect(create_rrect(offset), useAA);
192 } break; 192 } break;
193 case kRectAndConvex_Geometry: { 193 case kRectAndConvex_Geometry: {
194 SkRect r = create_rect(offset); 194 SkRect r = create_rect(offset);
195 r.offset(fSign * kXlate, fSign * kXlate); 195 r.offset(fSign * kXlate, fSign * kXlate);
196 canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips 196 canvas->clipRect(r, true); // AA here forces shader clips
197 canvas->clipPath(create_convex_path(offset), SkCanvas::kIntersect_Op , useAA); 197 canvas->clipPath(create_convex_path(offset), useAA);
198 } break; 198 } break;
199 case kRectAndConcave_Geometry: { 199 case kRectAndConcave_Geometry: {
200 SkRect r = create_rect(offset); 200 SkRect r = create_rect(offset);
201 r.offset(fSign * kXlate, fSign * kXlate); 201 r.offset(fSign * kXlate, fSign * kXlate);
202 canvas->clipRect(r, SkCanvas::kReplace_Op, true); // AA here forces shader clips 202 canvas->clipRect(r, true); // AA here forces shader clips
203 canvas->clipPath(create_concave_path(offset), SkCanvas::kIntersect_O p, useAA); 203 canvas->clipPath(create_concave_path(offset), useAA);
204 } break; 204 } break;
205 } 205 }
206 206
207 SkISize size = canvas->getDeviceSize(); 207 SkISize size = canvas->getDeviceSize();
208 SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar( size.height())); 208 SkRect bigR = SkRect::MakeWH(SkIntToScalar(size.width()), SkIntToScalar( size.height()));
209 209
210 SkPaint p; 210 SkPaint p;
211 p.setColor(SK_ColorRED); 211 p.setColor(SK_ColorRED);
212 212
213 canvas->drawRect(bigR, p); 213 canvas->drawRect(bigR, p);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 int fSign; 254 int fSign;
255 const double fStart = SkTime::GetMSecs(); 255 const double fStart = SkTime::GetMSecs();
256 256
257 typedef SampleView INHERITED; 257 typedef SampleView INHERITED;
258 }; 258 };
259 259
260 ////////////////////////////////////////////////////////////////////////////// 260 //////////////////////////////////////////////////////////////////////////////
261 261
262 static SkView* MyFactory() { return new ClipDrawMatchView; } 262 static SkView* MyFactory() { return new ClipDrawMatchView; }
263 static SkViewRegister reg(MyFactory); 263 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « include/core/SkCanvas.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698