| 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 |
#ifndef SkPicturePlayback_DEFINED |
| 9 |
#define SkPicturePlayback_DEFINED |
| 10 |
|
| 11 |
#include "include/core/SkM44.h" |
| 12 |
#include "include/core/SkPicture.h" |
| 13 |
#include "include/private/base/SkNoncopyable.h" |
| 14 |
#include "src/core/SkPictureFlat.h" |
| 15 |
|
| 16 |
#include <cstddef> |
| 17 |
#include <cstdint> |
| 18 |
|
| 19 |
class SkCanvas; |
| 20 |
class SkPictureData; |
| 21 |
class SkReadBuffer; |
| 22 |
|
| 23 |
// The basic picture playback class replays the provided picture into a canvas. |
| 24 |
class SkPicturePlayback final : SkNoncopyable { |
| 25 |
public: |
| 26 |
explicit SkPicturePlayback(const SkPictureData* data) : fPictureData(data), fCurOffset(0) {} |
| 27 |
|
| 28 |
void draw(SkCanvas* canvas, SkPicture::AbortCallback*, SkReadBuffer* buffer); |
| 29 |
|
| 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; } |
| 35 |
|
| 36 |
private: |
| 37 |
const SkPictureData* fPictureData; |
| 38 |
|
| 39 |
// The offset of the current operation when within the draw method |
| 40 |
size_t fCurOffset; |
| 41 |
|
| 42 |
void handleOp(SkReadBuffer* reader, |
| 43 |
DrawType op, |
| 44 |
uint32_t size, |
| 45 |
SkCanvas* canvas, |
| 46 |
const SkM44& initialMatrix); |
| 47 |
|
| 48 |
class AutoResetOpID { |
| 49 |
public: |
| 50 |
AutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { } |
| 51 |
~AutoResetOpID() { |
| 52 |
if (fPlayback) { |
| 53 |
fPlayback->resetOpID(); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
private: |
| 58 |
SkPicturePlayback* fPlayback; |
| 59 |
}; |
| 60 |
|
| 61 |
using INHERITED = SkNoncopyable; |
| 62 |
}; |
| 63 |
|
| 64 |
#endif |