OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2007 The Android Open Source Project | 3 * Copyright 2007 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkPicture_DEFINED | 10 #ifndef SkPicture_DEFINED |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 * Recreate a picture that was serialized into a stream. | 61 * Recreate a picture that was serialized into a stream. |
62 * @param SkStream Serialized picture data. | 62 * @param SkStream Serialized picture data. |
63 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the | 63 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the |
64 * encoded bitmap data from the stream. | 64 * encoded bitmap data from the stream. |
65 * @return A new SkPicture representing the serialized data, or NULL if the
stream is | 65 * @return A new SkPicture representing the serialized data, or NULL if the
stream is |
66 * invalid. | 66 * invalid. |
67 */ | 67 */ |
68 static SkPicture* CreateFromStream(SkStream*, | 68 static SkPicture* CreateFromStream(SkStream*, |
69 InstallPixelRefProc proc = &SkImageDecode
r::DecodeMemory); | 69 InstallPixelRefProc proc = &SkImageDecode
r::DecodeMemory); |
70 | 70 |
| 71 /** |
| 72 * Recreate a picture that was serialized into a buffer. |
| 73 * @param SkFlattenableReadBuffer Serialized picture data. |
| 74 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is |
| 75 * invalid. |
| 76 */ |
| 77 static SkPicture* CreateFromBuffer(SkFlattenableReadBuffer&); |
| 78 |
71 virtual ~SkPicture(); | 79 virtual ~SkPicture(); |
72 | 80 |
73 /** | 81 /** |
74 * Swap the contents of the two pictures. Guaranteed to succeed. | 82 * Swap the contents of the two pictures. Guaranteed to succeed. |
75 */ | 83 */ |
76 void swap(SkPicture& other); | 84 void swap(SkPicture& other); |
77 | 85 |
78 /** | 86 /** |
79 * Creates a thread-safe clone of the picture that is ready for playback. | 87 * Creates a thread-safe clone of the picture that is ready for playback. |
80 */ | 88 */ |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm); | 188 typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm); |
181 | 189 |
182 /** | 190 /** |
183 * Serialize to a stream. If non NULL, encoder will be used to encode | 191 * Serialize to a stream. If non NULL, encoder will be used to encode |
184 * any bitmaps in the picture. | 192 * any bitmaps in the picture. |
185 * encoder will never be called with a NULL pixelRefOffset. | 193 * encoder will never be called with a NULL pixelRefOffset. |
186 */ | 194 */ |
187 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; | 195 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; |
188 | 196 |
189 /** | 197 /** |
| 198 * Serialize to a buffer. |
| 199 */ |
| 200 void flatten(SkFlattenableWriteBuffer&) const; |
| 201 |
| 202 /** |
190 * Returns true if any bitmaps may be produced when this SkPicture | 203 * Returns true if any bitmaps may be produced when this SkPicture |
191 * is replayed. | 204 * is replayed. |
192 * Returns false if called while still recording. | 205 * Returns false if called while still recording. |
193 */ | 206 */ |
194 bool willPlayBackBitmaps() const; | 207 bool willPlayBackBitmaps() const; |
195 | 208 |
196 #ifdef SK_BUILD_FOR_ANDROID | 209 #ifdef SK_BUILD_FOR_ANDROID |
197 /** Signals that the caller is prematurely done replaying the drawing | 210 /** Signals that the caller is prematurely done replaying the drawing |
198 commands. This can be called from a canvas virtual while the picture | 211 commands. This can be called from a canvas virtual while the picture |
199 is drawing. Has no effect if the picture is not drawing. | 212 is drawing. Has no effect if the picture is not drawing. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 253 |
241 // For testing. Derived classes may instantiate an alternate | 254 // For testing. Derived classes may instantiate an alternate |
242 // SkBBoxHierarchy implementation | 255 // SkBBoxHierarchy implementation |
243 virtual SkBBoxHierarchy* createBBoxHierarchy() const; | 256 virtual SkBBoxHierarchy* createBBoxHierarchy() const; |
244 | 257 |
245 // Return true if the SkStream represents a serialized picture, and fills ou
t | 258 // Return true if the SkStream represents a serialized picture, and fills ou
t |
246 // SkPictInfo. After this function returns, the SkStream is not rewound; it | 259 // SkPictInfo. After this function returns, the SkStream is not rewound; it |
247 // will be ready to be parsed to create an SkPicturePlayback. | 260 // will be ready to be parsed to create an SkPicturePlayback. |
248 // If false is returned, SkPictInfo is unmodified. | 261 // If false is returned, SkPictInfo is unmodified. |
249 static bool StreamIsSKP(SkStream*, SkPictInfo*); | 262 static bool StreamIsSKP(SkStream*, SkPictInfo*); |
| 263 static bool BufferIsSKP(SkFlattenableReadBuffer&, SkPictInfo*); |
250 private: | 264 private: |
251 friend class SkFlatPicture; | 265 friend class SkFlatPicture; |
252 friend class SkPicturePlayback; | 266 friend class SkPicturePlayback; |
253 | 267 |
254 typedef SkRefCnt INHERITED; | 268 typedef SkRefCnt INHERITED; |
255 }; | 269 }; |
256 | 270 |
257 /** | 271 /** |
258 * Subclasses of this can be passed to canvas.drawPicture. During the drawing | 272 * Subclasses of this can be passed to canvas.drawPicture. During the drawing |
259 * of the picture, this callback will periodically be invoked. If its | 273 * of the picture, this callback will periodically be invoked. If its |
260 * abortDrawing() returns true, then picture playback will be interrupted. | 274 * abortDrawing() returns true, then picture playback will be interrupted. |
261 * | 275 * |
262 * The resulting drawing is undefined, as there is no guarantee how often the | 276 * The resulting drawing is undefined, as there is no guarantee how often the |
263 * callback will be invoked. If the abort happens inside some level of nested | 277 * callback will be invoked. If the abort happens inside some level of nested |
264 * calls to save(), restore will automatically be called to return the state | 278 * calls to save(), restore will automatically be called to return the state |
265 * to the same level it was before the drawPicture call was made. | 279 * to the same level it was before the drawPicture call was made. |
266 */ | 280 */ |
267 class SK_API SkDrawPictureCallback { | 281 class SK_API SkDrawPictureCallback { |
268 public: | 282 public: |
269 SkDrawPictureCallback() {} | 283 SkDrawPictureCallback() {} |
270 virtual ~SkDrawPictureCallback() {} | 284 virtual ~SkDrawPictureCallback() {} |
271 | 285 |
272 virtual bool abortDrawing() = 0; | 286 virtual bool abortDrawing() = 0; |
273 }; | 287 }; |
274 | 288 |
275 #endif | 289 #endif |
OLD | NEW |