Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: include/core/SkPicture.h

Issue 143163005: Revert of Revert "Serialization of SkPictureImageFilter" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkImage.h ('k') | include/effects/SkColorMatrix.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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. If the creation re quires bitmap
73 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng
74 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf fer().
75 * @param SkReadBuffer Serialized picture data.
76 * @return A new SkPicture representing the serialized data, or NULL if the buffer is
77 * invalid.
78 */
79 static SkPicture* CreateFromBuffer(SkReadBuffer&);
80
71 virtual ~SkPicture(); 81 virtual ~SkPicture();
72 82
73 /** 83 /**
74 * Swap the contents of the two pictures. Guaranteed to succeed. 84 * Swap the contents of the two pictures. Guaranteed to succeed.
75 */ 85 */
76 void swap(SkPicture& other); 86 void swap(SkPicture& other);
77 87
78 /** 88 /**
79 * Creates a thread-safe clone of the picture that is ready for playback. 89 * Creates a thread-safe clone of the picture that is ready for playback.
80 */ 90 */
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm); 190 typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm);
181 191
182 /** 192 /**
183 * Serialize to a stream. If non NULL, encoder will be used to encode 193 * Serialize to a stream. If non NULL, encoder will be used to encode
184 * any bitmaps in the picture. 194 * any bitmaps in the picture.
185 * encoder will never be called with a NULL pixelRefOffset. 195 * encoder will never be called with a NULL pixelRefOffset.
186 */ 196 */
187 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const; 197 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const;
188 198
189 /** 199 /**
200 * Serialize to a buffer.
201 */
202 void flatten(SkWriteBuffer&) const;
203
204 /**
190 * Returns true if any bitmaps may be produced when this SkPicture 205 * Returns true if any bitmaps may be produced when this SkPicture
191 * is replayed. 206 * is replayed.
192 * Returns false if called while still recording. 207 * Returns false if called while still recording.
193 */ 208 */
194 bool willPlayBackBitmaps() const; 209 bool willPlayBackBitmaps() const;
195 210
196 #ifdef SK_BUILD_FOR_ANDROID 211 #ifdef SK_BUILD_FOR_ANDROID
197 /** Signals that the caller is prematurely done replaying the drawing 212 /** Signals that the caller is prematurely done replaying the drawing
198 commands. This can be called from a canvas virtual while the picture 213 commands. This can be called from a canvas virtual while the picture
199 is drawing. Has no effect if the picture is not drawing. 214 is drawing. Has no effect if the picture is not drawing.
(...skipping 16 matching lines...) Expand all
216 // V11: modify how readBitmap and writeBitmap store their info. 231 // V11: modify how readBitmap and writeBitmap store their info.
217 // V12: add conics to SkPath, use new SkPathRef flattening 232 // V12: add conics to SkPath, use new SkPathRef flattening
218 // V13: add flag to drawBitmapRectToRect 233 // V13: add flag to drawBitmapRectToRect
219 // parameterize blurs by sigma rather than radius 234 // parameterize blurs by sigma rather than radius
220 // V14: Add flags word to PathRef serialization 235 // V14: Add flags word to PathRef serialization
221 // V15: Remove A1 bitmpa config (and renumber remaining configs) 236 // V15: Remove A1 bitmpa config (and renumber remaining configs)
222 // V16: Move SkPath's isOval flag to SkPathRef 237 // V16: Move SkPath's isOval flag to SkPathRef
223 // V17: SkPixelRef now writes SkImageInfo 238 // V17: SkPixelRef now writes SkImageInfo
224 // V18: SkBitmap now records x,y for its pixelref origin, instead of offset. 239 // V18: SkBitmap now records x,y for its pixelref origin, instead of offset.
225 // V19: encode matrices and regions into the ops stream 240 // V19: encode matrices and regions into the ops stream
226 static const uint32_t PICTURE_VERSION = 19; 241 // V20: added bool to SkPictureImageFilter's serialization (to allow SkPictu re serialization)
242 static const uint32_t PICTURE_VERSION = 20;
227 243
228 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class es to 244 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class es to
229 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv ed 245 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv ed
230 // recorders and set the picture size 246 // recorders and set the picture size
231 SkPicturePlayback* fPlayback; 247 SkPicturePlayback* fPlayback;
232 SkPictureRecord* fRecord; 248 SkPictureRecord* fRecord;
233 int fWidth, fHeight; 249 int fWidth, fHeight;
234 250
235 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of 251 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of
236 // playback is unchanged. 252 // playback is unchanged.
237 SkPicture(SkPicturePlayback*, int width, int height); 253 SkPicture(SkPicturePlayback*, int width, int height);
238 254
239 // For testing. Derived classes may instantiate an alternate 255 // For testing. Derived classes may instantiate an alternate
240 // SkBBoxHierarchy implementation 256 // SkBBoxHierarchy implementation
241 virtual SkBBoxHierarchy* createBBoxHierarchy() const; 257 virtual SkBBoxHierarchy* createBBoxHierarchy() const;
242 258
243 // Return true if the SkStream represents a serialized picture, and fills ou t 259 // Return true if the SkStream represents a serialized picture, and fills ou t
244 // SkPictInfo. After this function returns, the SkStream is not rewound; it 260 // SkPictInfo. After this function returns, the SkStream is not rewound; it
245 // will be ready to be parsed to create an SkPicturePlayback. 261 // will be ready to be parsed to create an SkPicturePlayback.
246 // If false is returned, SkPictInfo is unmodified. 262 // If false is returned, SkPictInfo is unmodified.
247 static bool StreamIsSKP(SkStream*, SkPictInfo*); 263 static bool StreamIsSKP(SkStream*, SkPictInfo*);
264 static bool BufferIsSKP(SkReadBuffer&, SkPictInfo*);
248 private: 265 private:
266 void createHeader(void* header) const;
267
249 friend class SkFlatPicture; 268 friend class SkFlatPicture;
250 friend class SkPicturePlayback; 269 friend class SkPicturePlayback;
251 270
252 typedef SkRefCnt INHERITED; 271 typedef SkRefCnt INHERITED;
253 }; 272 };
254 273
255 /** 274 /**
256 * Subclasses of this can be passed to canvas.drawPicture. During the drawing 275 * Subclasses of this can be passed to canvas.drawPicture. During the drawing
257 * of the picture, this callback will periodically be invoked. If its 276 * of the picture, this callback will periodically be invoked. If its
258 * abortDrawing() returns true, then picture playback will be interrupted. 277 * abortDrawing() returns true, then picture playback will be interrupted.
259 * 278 *
260 * The resulting drawing is undefined, as there is no guarantee how often the 279 * The resulting drawing is undefined, as there is no guarantee how often the
261 * callback will be invoked. If the abort happens inside some level of nested 280 * callback will be invoked. If the abort happens inside some level of nested
262 * calls to save(), restore will automatically be called to return the state 281 * calls to save(), restore will automatically be called to return the state
263 * to the same level it was before the drawPicture call was made. 282 * to the same level it was before the drawPicture call was made.
264 */ 283 */
265 class SK_API SkDrawPictureCallback { 284 class SK_API SkDrawPictureCallback {
266 public: 285 public:
267 SkDrawPictureCallback() {} 286 SkDrawPictureCallback() {}
268 virtual ~SkDrawPictureCallback() {} 287 virtual ~SkDrawPictureCallback() {}
269 288
270 virtual bool abortDrawing() = 0; 289 virtual bool abortDrawing() = 0;
271 }; 290 };
272 291
273 #endif 292 #endif
OLDNEW
« no previous file with comments | « include/core/SkImage.h ('k') | include/effects/SkColorMatrix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698