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" |
11 #include "SkCanvasStack.h" | 11 #include "SkCanvasStack.h" |
12 #include "SkDevice.h" | 12 #include "SkDevice.h" |
13 #include "SkErrorInternals.h" | 13 #include "SkErrorInternals.h" |
| 14 #include "SkRasterClip.h" |
14 #include "SkWriter32.h" | 15 #include "SkWriter32.h" |
15 | 16 |
16 /* | 17 /* |
17 * WARNING: The structs below are part of a stable ABI and as such we explicitly | 18 * WARNING: The structs below are part of a stable ABI and as such we explicitly |
18 * use unambigious primitives (e.g. int32_t instead of an enum). | 19 * use unambigious primitives (e.g. int32_t instead of an enum). |
19 * | 20 * |
20 * ANY CHANGES TO THE STRUCTS BELOW THAT IMPACT THE ABI SHOULD RESULT IN A NEW | 21 * ANY CHANGES TO THE STRUCTS BELOW THAT IMPACT THE ABI SHOULD RESULT IN A NEW |
21 * NEW SUBCLASS OF SkCanvasState. SUCH CHANGES SHOULD ONLY BE MADE IF ABSOLUTELY | 22 * NEW SUBCLASS OF SkCanvasState. SUCH CHANGES SHOULD ONLY BE MADE IF ABSOLUTELY |
22 * NECESSARY! | 23 * NECESSARY! |
23 * | 24 * |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 break; | 244 break; |
244 case kRGB_565_SkColorType: | 245 case kRGB_565_SkColorType: |
245 layerState->raster.config = kRGB_565_RasterConfig; | 246 layerState->raster.config = kRGB_565_RasterConfig; |
246 break; | 247 break; |
247 default: | 248 default: |
248 return nullptr; | 249 return nullptr; |
249 } | 250 } |
250 layerState->raster.rowBytes = pmap.rowBytes(); | 251 layerState->raster.rowBytes = pmap.rowBytes(); |
251 layerState->raster.pixels = pmap.writable_addr(); | 252 layerState->raster.pixels = pmap.writable_addr(); |
252 | 253 |
253 setup_MC_state(&layerState->mcState, layer.matrix(), layer.clip()); | 254 setup_MC_state(&layerState->mcState, layer.matrix(), layer.clip().bwRgn(
)); |
254 layerCount++; | 255 layerCount++; |
255 } | 256 } |
256 | 257 |
257 // allocate memory for the layers and then and copy them to the struct | 258 // allocate memory for the layers and then and copy them to the struct |
258 SkASSERT(layerWriter.bytesWritten() == layerCount * sizeof(SkCanvasLayerStat
e)); | 259 SkASSERT(layerWriter.bytesWritten() == layerCount * sizeof(SkCanvasLayerStat
e)); |
259 canvasState->layerCount = layerCount; | 260 canvasState->layerCount = layerCount; |
260 canvasState->layers = (SkCanvasLayerState*) sk_malloc_throw(layerWriter.byte
sWritten()); | 261 canvasState->layers = (SkCanvasLayerState*) sk_malloc_throw(layerWriter.byte
sWritten()); |
261 layerWriter.flatten(canvasState->layers); | 262 layerWriter.flatten(canvasState->layers); |
262 | 263 |
263 return canvasState.release(); | 264 return canvasState.release(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 346 |
346 //////////////////////////////////////////////////////////////////////////////// | 347 //////////////////////////////////////////////////////////////////////////////// |
347 | 348 |
348 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { | 349 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { |
349 SkASSERT(!state || SkCanvasState_v1::kVersion == state->version); | 350 SkASSERT(!state || SkCanvasState_v1::kVersion == state->version); |
350 // 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 |
351 // 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 |
352 // instead uses the field "version" to determine how to behave. | 353 // instead uses the field "version" to determine how to behave. |
353 delete static_cast<SkCanvasState_v1*>(state); | 354 delete static_cast<SkCanvasState_v1*>(state); |
354 } | 355 } |
OLD | NEW |