OLD | NEW |
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 } |
OLD | NEW |