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.
8 #ifndef SkPicturePlayback_DEFINED
9 #define SkPicturePlayback_DEFINED
11 #include "SkPictureFlat.h" // for DrawType
15 class SkDrawPictureCallback;
19 // The basic picture playback class replays the provided picture into a canvas.
20 class SkPicturePlayback : SkNoncopyable {
22 SkPicturePlayback(const SkPicture* picture)
23 : fPictureData(picture->fData.get())
26 virtual ~SkPicturePlayback() { }
28 virtual void draw(SkCanvas* canvas, SkDrawPictureCallback*);
30 // TODO: remove the curOp calls after cleaning up GrGatherDevice
31 // Return the ID of the operation currently being executed when playing
32 // back. 0 indicates no call is active.
33 size_t curOpID() const { return fCurOffset; }
34 void resetOpID() { fCurOffset = 0; }
37 const SkPictureData* fPictureData;
39 // The offset of the current operation when within the draw method
42 void handleOp(SkReader32* reader,
46 const SkMatrix& initialMatrix);
48 static DrawType ReadOpAndSize(SkReader32* reader, uint32_t* size);
52 AutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { }
55 fPlayback->resetOpID();
60 SkPicturePlayback* fPlayback;
64 typedef SkNoncopyable INHERITED;