| 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 "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
| 11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
| 12 #include "SkNWayCanvas.h" | 12 #include "SkCanvasStack.h" |
| 13 #include "SkWriter32.h" | 13 #include "SkWriter32.h" |
| 14 | 14 |
| 15 #define CANVAS_STATE_VERSION 1 | 15 #define CANVAS_STATE_VERSION 1 |
| 16 /* | 16 /* |
| 17 * WARNING: The structs below are part of a stable ABI and as such we explicitly | 17 * 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). | 18 * use unambigious primitives (e.g. int32_t instead of an enum). |
| 19 * | 19 * |
| 20 * ANY CHANGES TO THE STRUCTS BELOW THAT IMPACT THE ABI SHOULD RESULT IN AN | 20 * ANY CHANGES TO THE STRUCTS BELOW THAT IMPACT THE ABI SHOULD RESULT IN AN |
| 21 * UPDATE OF THE CANVAS_STATE_VERSION. SUCH CHANGES SHOULD ONLY BE MADE IF | 21 * UPDATE OF THE CANVAS_STATE_VERSION. SUCH CHANGES SHOULD ONLY BE MADE IF |
| 22 * ABSOLUTELY NECESSARY! | 22 * ABSOLUTELY NECESSARY! |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // check that the versions match | 309 // check that the versions match |
| 310 if (CANVAS_STATE_VERSION != state->version) { | 310 if (CANVAS_STATE_VERSION != state->version) { |
| 311 SkDebugf("CreateFromCanvasState version does not match the one use to cr
eate the input"); | 311 SkDebugf("CreateFromCanvasState version does not match the one use to cr
eate the input"); |
| 312 return NULL; | 312 return NULL; |
| 313 } | 313 } |
| 314 | 314 |
| 315 if (state->layerCount < 1) { | 315 if (state->layerCount < 1) { |
| 316 return NULL; | 316 return NULL; |
| 317 } | 317 } |
| 318 | 318 |
| 319 SkAutoTUnref<SkNWayCanvas> canvas(SkNEW_ARGS(SkNWayCanvas, (state->width, st
ate->height))); | 319 SkAutoTUnref<SkCanvasStack> canvas(SkNEW_ARGS(SkCanvasStack, (state->width,
state->height))); |
| 320 | 320 |
| 321 // setup the matrix and clip on the n-way canvas | 321 // setup the matrix and clip on the n-way canvas |
| 322 setup_canvas_from_MC_state(state->mcState, canvas); | 322 setup_canvas_from_MC_state(state->mcState, canvas); |
| 323 | 323 |
| 324 // Iterate over the layers and add them to the n-way canvas | 324 // Iterate over the layers and add them to the n-way canvas |
| 325 for (int i = 0; i < state->layerCount; ++i) { | 325 for (int i = state->layerCount - 1; i >= 0; --i) { |
| 326 SkAutoTUnref<SkCanvas> canvasLayer(create_canvas_from_canvas_layer(state
->layers[i])); | 326 SkAutoTUnref<SkCanvas> canvasLayer(create_canvas_from_canvas_layer(state
->layers[i])); |
| 327 if (!canvasLayer.get()) { | 327 if (!canvasLayer.get()) { |
| 328 return NULL; | 328 return NULL; |
| 329 } | 329 } |
| 330 canvas->addCanvas(canvasLayer.get()); | 330 canvas->pushCanvas(canvasLayer.get(), SkIPoint::Make(state->layers[i].x, |
| 331 state->layers[i].y)
); |
| 331 } | 332 } |
| 332 | 333 |
| 333 return canvas.detach(); | 334 return canvas.detach(); |
| 334 } | 335 } |
| 335 | 336 |
| 336 //////////////////////////////////////////////////////////////////////////////// | 337 //////////////////////////////////////////////////////////////////////////////// |
| 337 | 338 |
| 338 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { | 339 void SkCanvasStateUtils::ReleaseCanvasState(SkCanvasState* state) { |
| 339 SkDELETE(state); | 340 SkDELETE(state); |
| 340 } | 341 } |
| OLD | NEW |