| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2014 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 #include "SkCanvas.h" | |
| 9 #include "SkPictureData.h" | |
| 10 #include "SkPictureRangePlayback.h" | |
| 11 | |
| 12 void SkPictureRangePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callb
ack) { | |
| 13 AutoResetOpID aroi(this); | |
| 14 SkASSERT(0 == fCurOffset); | |
| 15 | |
| 16 SkReader32 reader(fPictureData->opData()->bytes(), fPictureData->opData()->s
ize()); | |
| 17 | |
| 18 if (0 != fStart || 0 != fStop) { | |
| 19 reader.setOffset(fStart); | |
| 20 uint32_t size; | |
| 21 SkDEBUGCODE(DrawType op = ) ReadOpAndSize(&reader, &size); | |
| 22 SkASSERT(SAVE_LAYER == op); | |
| 23 reader.setOffset(fStart + size); | |
| 24 } | |
| 25 | |
| 26 // Record this, so we can concat w/ it if we encounter a setMatrix() | |
| 27 SkMatrix initialMatrix = canvas->getTotalMatrix(); | |
| 28 | |
| 29 SkAutoCanvasRestore acr(canvas, false); | |
| 30 | |
| 31 while (!reader.eof()) { | |
| 32 if (NULL != callback && callback->abortDrawing()) { | |
| 33 return; | |
| 34 } | |
| 35 | |
| 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); | |
| 42 return; | |
| 43 } | |
| 44 } | |
| 45 | |
| 46 fCurOffset = reader.offset(); | |
| 47 uint32_t size; | |
| 48 DrawType op = ReadOpAndSize(&reader, &size); | |
| 49 if (NOOP == op) { | |
| 50 // NOOPs are to be ignored - do not propagate them any further | |
| 51 reader.setOffset(fCurOffset + size); | |
| 52 continue; | |
| 53 } | |
| 54 | |
| 55 this->handleOp(&reader, op, size, canvas, initialMatrix); | |
| 56 } | |
| 57 } | |
| OLD | NEW |