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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 /* | 216 /* |
217 * decompose the layers | 217 * decompose the layers |
218 * | 218 * |
219 * storage is allocated on the stack for the first 3 layers. It is common in | 219 * storage is allocated on the stack for the first 3 layers. It is common in |
220 * some view systems (e.g. Android) that a few non-clipped layers are presen
t | 220 * some view systems (e.g. Android) that a few non-clipped layers are presen
t |
221 * and we will not need to malloc any additional memory in those cases. | 221 * and we will not need to malloc any additional memory in those cases. |
222 */ | 222 */ |
223 SkSWriter32<3*sizeof(SkCanvasLayerState)> layerWriter; | 223 SkSWriter32<3*sizeof(SkCanvasLayerState)> layerWriter; |
224 int layerCount = 0; | 224 int layerCount = 0; |
225 for (SkCanvas::LayerIter layer(canvas, true/*skipEmptyClips*/); !layer.done(
); layer.next()) { | 225 for (SkCanvas::LayerIter layer(canvas); !layer.done(); layer.next()) { |
226 | 226 |
227 // we currently only work for bitmap backed devices | 227 // we currently only work for bitmap backed devices |
228 SkPixmap pmap; | 228 SkPixmap pmap; |
229 if (!layer.device()->accessPixels(&pmap) || 0 == pmap.width() || 0 == pm
ap.height()) { | 229 if (!layer.device()->accessPixels(&pmap) || 0 == pmap.width() || 0 == pm
ap.height()) { |
230 return nullptr; | 230 return nullptr; |
231 } | 231 } |
232 | 232 |
233 SkCanvasLayerState* layerState = | 233 SkCanvasLayerState* layerState = |
234 (SkCanvasLayerState*) layerWriter.reserve(sizeof(SkCanvasLayerSt
ate)); | 234 (SkCanvasLayerState*) layerWriter.reserve(sizeof(SkCanvasLayerSt
ate)); |
235 layerState->type = kRaster_CanvasBackend; | 235 layerState->type = kRaster_CanvasBackend; |
(...skipping 110 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 |