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

Side by Side Diff: src/utils/SkCanvasStateUtils.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 | « src/utils/SkCanvasStack.cpp ('k') | src/utils/SkDeferredCanvas.h » ('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 "SkCanvasStateUtils.h" 8 #include "SkCanvasStateUtils.h"
9 9
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 }; 135 };
136 136
137 //////////////////////////////////////////////////////////////////////////////// 137 ////////////////////////////////////////////////////////////////////////////////
138 138
139 class ClipValidator : public SkCanvas::ClipVisitor { 139 class ClipValidator : public SkCanvas::ClipVisitor {
140 public: 140 public:
141 ClipValidator() : fFailed(false) {} 141 ClipValidator() : fFailed(false) {}
142 bool failed() { return fFailed; } 142 bool failed() { return fFailed; }
143 143
144 // ClipVisitor 144 // ClipVisitor
145 void clipRect(const SkRect& rect, SkRegion::Op op, bool antialias) override { 145 void clipRect(const SkRect& rect, SkCanvas::ClipOp op, bool antialias) overr ide {
146 fFailed |= antialias; 146 fFailed |= antialias;
147 } 147 }
148 148
149 void clipRRect(const SkRRect& rrect, SkRegion::Op op, bool antialias) overri de { 149 void clipRRect(const SkRRect& rrect, SkCanvas::ClipOp op, bool antialias) ov erride {
150 fFailed |= antialias; 150 fFailed |= antialias;
151 } 151 }
152 152
153 void clipPath(const SkPath&, SkRegion::Op, bool antialias) override { 153 void clipPath(const SkPath&, SkCanvas::ClipOp, bool antialias) override {
154 fFailed |= antialias; 154 fFailed |= antialias;
155 } 155 }
156 156
157 private: 157 private:
158 bool fFailed; 158 bool fFailed;
159 }; 159 };
160 160
161 static void setup_MC_state(SkMCState* state, const SkMatrix& matrix, const SkReg ion& clip) { 161 static void setup_MC_state(SkMCState* state, const SkMatrix& matrix, const SkReg ion& clip) {
162 // initialize the struct 162 // initialize the struct
163 state->clipRectCount = 0; 163 state->clipRectCount = 0;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 SkRegion clip; 277 SkRegion clip;
278 for (int i = 0; i < state.clipRectCount; ++i) { 278 for (int i = 0; i < state.clipRectCount; ++i) {
279 clip.op(SkIRect::MakeLTRB(state.clipRects[i].left, 279 clip.op(SkIRect::MakeLTRB(state.clipRects[i].left,
280 state.clipRects[i].top, 280 state.clipRects[i].top,
281 state.clipRects[i].right, 281 state.clipRects[i].right,
282 state.clipRects[i].bottom), 282 state.clipRects[i].bottom),
283 SkRegion::kUnion_Op); 283 SkRegion::kUnion_Op);
284 } 284 }
285 285
286 canvas->setMatrix(matrix); 286 canvas->setMatrix(matrix);
287 canvas->setClipRegion(clip); 287 canvas->clipRegion(clip, SkCanvas::kReplace_Op);
288 } 288 }
289 289
290 static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer State) { 290 static SkCanvas* create_canvas_from_canvas_layer(const SkCanvasLayerState& layer State) {
291 SkASSERT(kRaster_CanvasBackend == layerState.type); 291 SkASSERT(kRaster_CanvasBackend == layerState.type);
292 292
293 SkBitmap bitmap; 293 SkBitmap bitmap;
294 SkColorType colorType = 294 SkColorType colorType =
295 layerState.raster.config == kARGB_8888_RasterConfig ? kN32_SkColorType : 295 layerState.raster.config == kARGB_8888_RasterConfig ? kN32_SkColorType :
296 layerState.raster.config == kRGB_565_RasterConfig ? kRGB_565_SkColorType : 296 layerState.raster.config == kRGB_565_RasterConfig ? kRGB_565_SkColorType :
297 kUnknown_SkColorType; 297 kUnknown_SkColorType;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 //////////////////////////////////////////////////////////////////////////////// 347 ////////////////////////////////////////////////////////////////////////////////
348 348
349 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { 349 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) {
350 SkASSERT(!state || SkCanvasState_v1::kVersion == state->version); 350 SkASSERT(!state || SkCanvasState_v1::kVersion == state->version);
351 // Upcast to the correct version of SkCanvasState. This avoids having a virt ual destructor on 351 // Upcast to the correct version of SkCanvasState. This avoids having a virt ual destructor on
352 // SkCanvasState. That would be strange since SkCanvasState has no other vir tual functions, and 352 // SkCanvasState. That would be strange since SkCanvasState has no other vir tual functions, and
353 // instead uses the field "version" to determine how to behave. 353 // instead uses the field "version" to determine how to behave.
354 delete static_cast<SkCanvasState_v1*>(state); 354 delete static_cast<SkCanvasState_v1*>(state);
355 } 355 }
OLDNEW
« no previous file with comments | « src/utils/SkCanvasStack.cpp ('k') | src/utils/SkDeferredCanvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698