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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 setup_MC_state(&layerState->mcState, layer.matrix(), layer.clip()); | 253 setup_MC_state(&layerState->mcState, layer.matrix(), layer.clip()); |
254 layerCount++; | 254 layerCount++; |
255 } | 255 } |
256 | 256 |
257 // allocate memory for the layers and then and copy them to the struct | 257 // allocate memory for the layers and then and copy them to the struct |
258 SkASSERT(layerWriter.bytesWritten() == layerCount * sizeof(SkCanvasLayerStat
e)); | 258 SkASSERT(layerWriter.bytesWritten() == layerCount * sizeof(SkCanvasLayerStat
e)); |
259 canvasState->layerCount = layerCount; | 259 canvasState->layerCount = layerCount; |
260 canvasState->layers = (SkCanvasLayerState*) sk_malloc_throw(layerWriter.byte
sWritten()); | 260 canvasState->layers = (SkCanvasLayerState*) sk_malloc_throw(layerWriter.byte
sWritten()); |
261 layerWriter.flatten(canvasState->layers); | 261 layerWriter.flatten(canvasState->layers); |
262 | 262 |
263 // for now, just ignore any client supplied DrawFilter. | |
264 if (canvas->getDrawFilter()) { | |
265 // SkDEBUGF(("CaptureCanvasState will ignore the canvas's draw filter.\n"
)); | |
266 } | |
267 | |
268 return canvasState.detach(); | 263 return canvasState.detach(); |
269 } | 264 } |
270 | 265 |
271 //////////////////////////////////////////////////////////////////////////////// | 266 //////////////////////////////////////////////////////////////////////////////// |
272 | 267 |
273 static void setup_canvas_from_MC_state(const SkMCState& state, SkCanvas* canvas)
{ | 268 static void setup_canvas_from_MC_state(const SkMCState& state, SkCanvas* canvas)
{ |
274 // reconstruct the matrix | 269 // reconstruct the matrix |
275 SkMatrix matrix; | 270 SkMatrix matrix; |
276 for (int i = 0; i < 9; i++) { | 271 for (int i = 0; i < 9; i++) { |
277 matrix.set(i, state.matrix[i]); | 272 matrix.set(i, state.matrix[i]); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 | 345 |
351 //////////////////////////////////////////////////////////////////////////////// | 346 //////////////////////////////////////////////////////////////////////////////// |
352 | 347 |
353 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { | 348 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { |
354 SkASSERT(!state || SkCanvasState_v1::kVersion == state->version); | 349 SkASSERT(!state || SkCanvasState_v1::kVersion == state->version); |
355 // Upcast to the correct version of SkCanvasState. This avoids having a virt
ual destructor on | 350 // Upcast to the correct version of SkCanvasState. This avoids having a virt
ual destructor on |
356 // SkCanvasState. That would be strange since SkCanvasState has no other vir
tual functions, and | 351 // SkCanvasState. That would be strange since SkCanvasState has no other vir
tual functions, and |
357 // instead uses the field "version" to determine how to behave. | 352 // instead uses the field "version" to determine how to behave. |
358 delete static_cast<SkCanvasState_v1*>(state); | 353 delete static_cast<SkCanvasState_v1*>(state); |
359 } | 354 } |
OLD | NEW |