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

Side by Side Diff: gm/xfermodes.cpp

Issue 241453003: Reduce internal explicit SaveFlags usage. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Re-added needed save flag in SkPictureStateTree::Iterator::draw() Created 6 years, 8 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 | « bench/DeferredCanvasBench.cpp ('k') | gm/xfermodes2.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkShader.h" 10 #include "SkShader.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 p.setColor(0xFF66AAFF); 105 p.setColor(0xFF66AAFF);
106 SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW, 106 SkRect r = SkRect::MakeXYWH(x + halfW, y, halfW,
107 SkIntToScalar(H)); 107 SkIntToScalar(H));
108 canvas->drawRect(r, p); 108 canvas->drawRect(r, p);
109 p.setColor(0xFFAA66FF); 109 p.setColor(0xFFAA66FF);
110 r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH); 110 r = SkRect::MakeXYWH(x, y + halfH, SkIntToScalar(W), halfH);
111 canvas->drawRect(r, p); 111 canvas->drawRect(r, p);
112 break; 112 break;
113 } 113 }
114 case kRectangleWithMask_SrcType: { 114 case kRectangleWithMask_SrcType: {
115 canvas->save(SkCanvas::kClip_SaveFlag); 115 canvas->save();
116 restoreNeeded = true; 116 restoreNeeded = true;
117 SkScalar w = SkIntToScalar(W); 117 SkScalar w = SkIntToScalar(W);
118 SkScalar h = SkIntToScalar(H); 118 SkScalar h = SkIntToScalar(H);
119 SkRect r = SkRect::MakeXYWH(x, y + h / 4, w, h * 23 / 60); 119 SkRect r = SkRect::MakeXYWH(x, y + h / 4, w, h * 23 / 60);
120 canvas->clipRect(r); 120 canvas->clipRect(r);
121 // Fall through. 121 // Fall through.
122 } 122 }
123 case kRectangle_SrcType: { 123 case kRectangle_SrcType: {
124 SkScalar w = SkIntToScalar(W); 124 SkScalar w = SkIntToScalar(W);
125 SkScalar h = SkIntToScalar(H); 125 SkScalar h = SkIntToScalar(H);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 SkXfermode* mode = SkXfermode::Create(gModes[i].fMode); 240 SkXfermode* mode = SkXfermode::Create(gModes[i].fMode);
241 SkAutoUnref aur(mode); 241 SkAutoUnref aur(mode);
242 SkRect r; 242 SkRect r;
243 r.set(x, y, x+w, y+h); 243 r.set(x, y, x+w, y+h);
244 244
245 SkPaint p; 245 SkPaint p;
246 p.setStyle(SkPaint::kFill_Style); 246 p.setStyle(SkPaint::kFill_Style);
247 p.setShader(s); 247 p.setShader(s);
248 canvas->drawRect(r, p); 248 canvas->drawRect(r, p);
249 249
250 canvas->saveLayer(&r, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag); 250 canvas->saveLayer(&r, NULL);
251 draw_mode(canvas, mode, static_cast<SrcType>(sourceType), 251 draw_mode(canvas, mode, static_cast<SrcType>(sourceType),
252 r.fLeft, r.fTop); 252 r.fLeft, r.fTop);
253 canvas->restore(); 253 canvas->restore();
254 254
255 r.inset(-SK_ScalarHalf, -SK_ScalarHalf); 255 r.inset(-SK_ScalarHalf, -SK_ScalarHalf);
256 p.setStyle(SkPaint::kStroke_Style); 256 p.setStyle(SkPaint::kStroke_Style);
257 p.setShader(NULL); 257 p.setShader(NULL);
258 canvas->drawRect(r, p); 258 canvas->drawRect(r, p);
259 259
260 #if 1 260 #if 1
(...skipping 22 matching lines...) Expand all
283 private: 283 private:
284 typedef GM INHERITED; 284 typedef GM INHERITED;
285 }; 285 };
286 286
287 ////////////////////////////////////////////////////////////////////////////// 287 //////////////////////////////////////////////////////////////////////////////
288 288
289 static GM* MyFactory(void*) { return new XfermodesGM; } 289 static GM* MyFactory(void*) { return new XfermodesGM; }
290 static GMRegistry reg(MyFactory); 290 static GMRegistry reg(MyFactory);
291 291
292 } 292 }
OLDNEW
« no previous file with comments | « bench/DeferredCanvasBench.cpp ('k') | gm/xfermodes2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698