OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #ifndef SkPicture_DEFINED | 9 #ifndef SkPicture_DEFINED |
10 #define SkPicture_DEFINED | 10 #define SkPicture_DEFINED |
11 | 11 |
12 #include "SkBitmap.h" | |
13 #include "SkDrawPictureCallback.h" | |
14 #include "SkImageDecoder.h" | 12 #include "SkImageDecoder.h" |
15 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
16 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
17 | 15 |
18 #if SK_SUPPORT_GPU | 16 #if SK_SUPPORT_GPU |
19 class GrContext; | 17 class GrContext; |
20 #endif | 18 #endif |
21 | 19 |
| 20 class SkBitmap; |
22 class SkBBoxHierarchy; | 21 class SkBBoxHierarchy; |
23 class SkCanvas; | 22 class SkCanvas; |
24 class SkData; | 23 class SkData; |
25 class SkPictureData; | 24 class SkPictureData; |
26 class SkPixelSerializer; | 25 class SkPixelSerializer; |
27 class SkStream; | 26 class SkStream; |
28 class SkWStream; | 27 class SkWStream; |
29 | 28 |
30 struct SkPictInfo; | 29 struct SkPictInfo; |
31 | 30 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 94 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
96 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). | 95 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). |
97 * @param SkReadBuffer Serialized picture data. | 96 * @param SkReadBuffer Serialized picture data. |
98 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is | 97 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is |
99 * invalid. | 98 * invalid. |
100 */ | 99 */ |
101 static SkPicture* CreateFromBuffer(SkReadBuffer&); | 100 static SkPicture* CreateFromBuffer(SkReadBuffer&); |
102 | 101 |
103 ~SkPicture(); | 102 ~SkPicture(); |
104 | 103 |
| 104 /** |
| 105 * Subclasses of this can be passed to playback(). During the playback |
| 106 * of the picture, this callback will periodically be invoked. If its |
| 107 * abort() returns true, then picture playback will be interrupted. |
| 108 * |
| 109 * The resulting drawing is undefined, as there is no guarantee how often th
e |
| 110 * callback will be invoked. If the abort happens inside some level of neste
d |
| 111 * calls to save(), restore will automatically be called to return the state |
| 112 * to the same level it was before the playback call was made. |
| 113 */ |
| 114 class SK_API AbortCallback { |
| 115 public: |
| 116 AbortCallback() {} |
| 117 virtual ~AbortCallback() {} |
| 118 |
| 119 virtual bool abort() = 0; |
| 120 }; |
| 121 |
105 /** Replays the drawing commands on the specified canvas. Note that | 122 /** Replays the drawing commands on the specified canvas. Note that |
106 this has the effect of unfurling this picture into the destination | 123 this has the effect of unfurling this picture into the destination |
107 canvas. Using the SkCanvas::drawPicture entry point gives the destinatio
n | 124 canvas. Using the SkCanvas::drawPicture entry point gives the destinatio
n |
108 canvas the option of just taking a ref. | 125 canvas the option of just taking a ref. |
109 @param canvas the canvas receiving the drawing commands. | 126 @param canvas the canvas receiving the drawing commands. |
110 @param callback a callback that allows interruption of playback | 127 @param callback a callback that allows interruption of playback |
111 */ | 128 */ |
112 void playback(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; | 129 void playback(SkCanvas* canvas, AbortCallback* = NULL) const; |
113 | 130 |
114 /** Return the cull rect used when creating this picture: { 0, 0, cullWidth,
cullHeight }. | 131 /** Return the cull rect used when creating this picture: { 0, 0, cullWidth,
cullHeight }. |
115 It does not necessarily reflect the bounds of what has been recorded int
o the picture. | 132 It does not necessarily reflect the bounds of what has been recorded int
o the picture. |
116 @return the cull rect used to create this picture | 133 @return the cull rect used to create this picture |
117 */ | 134 */ |
118 SkRect cullRect() const { return fCullRect; } | 135 SkRect cullRect() const { return fCullRect; } |
119 | 136 |
120 /** Return a non-zero, unique value representing the picture. | 137 /** Return a non-zero, unique value representing the picture. |
121 */ | 138 */ |
122 uint32_t uniqueID() const { return fUniqueID; } | 139 uint32_t uniqueID() const { return fUniqueID; } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 307 |
291 friend class SkPictureRecorder; // SkRecord-based constructor. | 308 friend class SkPictureRecorder; // SkRecord-based constructor. |
292 friend class GrLayerHoister; // access to fRecord | 309 friend class GrLayerHoister; // access to fRecord |
293 friend class ReplaceDraw; | 310 friend class ReplaceDraw; |
294 friend class SkPictureUtils; | 311 friend class SkPictureUtils; |
295 friend class SkRecordedDrawable; | 312 friend class SkRecordedDrawable; |
296 }; | 313 }; |
297 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); | 314 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
298 | 315 |
299 #endif | 316 #endif |
OLD | NEW |