2 * Copyright 2014 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "SkPictureData.h"
10 #include "SkPictureRangePlayback.h"
12 void SkPictureRangePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) {
13 AutoResetOpID aroi(this);
14 SkASSERT(0 == fCurOffset);
16 SkReader32 reader(fPictureData->opData()->bytes(), fPictureData->opData()->size());
18 if (0 != fStart || 0 != fStop) {
19 reader.setOffset(fStart);
21 SkDEBUGCODE(DrawType op = ) ReadOpAndSize(&reader, &size);
22 SkASSERT(SAVE_LAYER == op);
23 reader.setOffset(fStart + size);
26 // Record this, so we can concat w/ it if we encounter a setMatrix()
27 SkMatrix initialMatrix = canvas->getTotalMatrix();
29 SkAutoCanvasRestore acr(canvas, false);
31 while (!reader.eof()) {
32 if (NULL != callback && callback->abortDrawing()) {
36 if (0 != fStart || 0 != fStop) {
37 size_t offset = reader.offset();
38 if (offset >= fStop) {
39 SkDEBUGCODE(uint32_t size;)
40 SkDEBUGCODE(DrawType op = ReadOpAndSize(&reader, &size);)
41 SkASSERT(RESTORE == op);
46 fCurOffset = reader.offset();
48 DrawType op = ReadOpAndSize(&reader, &size);
50 // NOOPs are to be ignored - do not propagate them any further
51 reader.setOffset(fCurOffset + size);
55 this->handleOp(&reader, op, size, canvas, initialMatrix);