aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkPictureRangePlayback.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-07-08 08:28:08 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-08 08:28:08 -0700
commit1ad00e4b245d464c16ba78bdaa377281f29972cd (patch)
tree06a227ada11ef57eb124a79c9484d36c09aa1775 /src/core/SkPictureRangePlayback.cpp
parent55fad7af61c21d502acb9891d631e8aa29e3628c (diff)
Split SkPictureRangePlayback out of SkPicturePlayback
This CL starts cleaning up SkPicturePlayback. Future CLs will: split out the SkPictureReplacementPlayback remove the preDraw/postDraw entry points & fix up SkPictureTimedPlayback R=mtklein@google.com, reed@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/374833006
Diffstat (limited to 'src/core/SkPictureRangePlayback.cpp')
-rw-r--r--src/core/SkPictureRangePlayback.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/core/SkPictureRangePlayback.cpp b/src/core/SkPictureRangePlayback.cpp
new file mode 100644
index 0000000000..16473dbfcc
--- /dev/null
+++ b/src/core/SkPictureRangePlayback.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkCanvas.h"
+#include "SkPictureData.h"
+#include "SkPictureRangePlayback.h"
+
+void SkPictureRangePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) {
+ AutoResetOpID aroi(this);
+ SkASSERT(0 == fCurOffset);
+
+ SkReader32 reader(fPictureData->opData()->bytes(), fPictureData->opData()->size());
+
+ if (0 != fStart || 0 != fStop) {
+ reader.setOffset(fStart);
+ uint32_t size;
+ SkDEBUGCODE(DrawType op = ) ReadOpAndSize(&reader, &size);
+ SkASSERT(SAVE_LAYER == op);
+ reader.setOffset(fStart + size);
+ }
+
+ // Record this, so we can concat w/ it if we encounter a setMatrix()
+ SkMatrix initialMatrix = canvas->getTotalMatrix();
+
+ SkAutoCanvasRestore acr(canvas, false);
+
+ while (!reader.eof()) {
+ if (callback && callback->abortDrawing()) {
+ return;
+ }
+
+ if (0 != fStart || 0 != fStop) {
+ size_t offset = reader.offset();
+ if (offset >= fStop) {
+ SkDEBUGCODE(uint32_t size;)
+ SkDEBUGCODE(DrawType op = ReadOpAndSize(&reader, &size);)
+ SkASSERT(RESTORE == op);
+ return;
+ }
+ }
+
+ fCurOffset = reader.offset();
+ uint32_t size;
+ DrawType op = ReadOpAndSize(&reader, &size);
+ if (NOOP == op) {
+ // NOOPs are to be ignored - do not propagate them any further
+ reader.setOffset(fCurOffset + size);
+ continue;
+ }
+
+ this->handleOp(&reader, op, size, canvas, initialMatrix);
+ }
+}