/src/skia/src/core/SkPicturePlayback.h
Line | Count | Source (jump to first uncovered line) |
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 "src/core/SkPictureFlat.h" |
12 | | |
13 | | class SkBitmap; |
14 | | class SkCanvas; |
15 | | class SkPaint; |
16 | | class SkPictureData; |
17 | | |
18 | | // The basic picture playback class replays the provided picture into a canvas. |
19 | | class SkPicturePlayback final : SkNoncopyable { |
20 | | public: |
21 | | SkPicturePlayback(const SkPictureData* data) |
22 | | : fPictureData(data) |
23 | 85 | , fCurOffset(0) { |
24 | 85 | } |
25 | | |
26 | | void draw(SkCanvas* canvas, SkPicture::AbortCallback*, SkReadBuffer* buffer); |
27 | | |
28 | | // TODO: remove the curOp calls after cleaning up GrGatherDevice |
29 | | // Return the ID of the operation currently being executed when playing |
30 | | // back. 0 indicates no call is active. |
31 | 0 | size_t curOpID() const { return fCurOffset; } |
32 | 85 | void resetOpID() { fCurOffset = 0; } |
33 | | |
34 | | protected: |
35 | | const SkPictureData* fPictureData; |
36 | | |
37 | | // The offset of the current operation when within the draw method |
38 | | size_t fCurOffset; |
39 | | |
40 | | void handleOp(SkReadBuffer* reader, |
41 | | DrawType op, |
42 | | uint32_t size, |
43 | | SkCanvas* canvas, |
44 | | const SkM44& initialMatrix); |
45 | | |
46 | | class AutoResetOpID { |
47 | | public: |
48 | 85 | AutoResetOpID(SkPicturePlayback* playback) : fPlayback(playback) { } |
49 | 85 | ~AutoResetOpID() { |
50 | 85 | if (fPlayback) { |
51 | 85 | fPlayback->resetOpID(); |
52 | 85 | } |
53 | 85 | } |
54 | | |
55 | | private: |
56 | | SkPicturePlayback* fPlayback; |
57 | | }; |
58 | | |
59 | | private: |
60 | | using INHERITED = SkNoncopyable; |
61 | | }; |
62 | | |
63 | | #endif |