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

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

Issue 138063005: Serialization of SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Follow up on comments 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
« no previous file with comments | « no previous file | samplecode/SampleFilterFuzz.cpp » ('j') | src/effects/SkPictureImageFilter.cpp » ('J')
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.
73 * @param SkReadBuffer 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(SkReadBuffer&);
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
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(SkWriteBuffer&) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 251
239 // For testing. Derived classes may instantiate an alternate 252 // For testing. Derived classes may instantiate an alternate
240 // SkBBoxHierarchy implementation 253 // SkBBoxHierarchy implementation
241 virtual SkBBoxHierarchy* createBBoxHierarchy() const; 254 virtual SkBBoxHierarchy* createBBoxHierarchy() const;
242 255
243 // Return true if the SkStream represents a serialized picture, and fills ou t 256 // 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 257 // SkPictInfo. After this function returns, the SkStream is not rewound; it
245 // will be ready to be parsed to create an SkPicturePlayback. 258 // will be ready to be parsed to create an SkPicturePlayback.
246 // If false is returned, SkPictInfo is unmodified. 259 // If false is returned, SkPictInfo is unmodified.
247 static bool StreamIsSKP(SkStream*, SkPictInfo*); 260 static bool StreamIsSKP(SkStream*, SkPictInfo*);
261 static bool BufferIsSKP(SkReadBuffer&, SkPictInfo*);
248 private: 262 private:
263 void createHeader(void* header) const;
264
249 friend class SkFlatPicture; 265 friend class SkFlatPicture;
250 friend class SkPicturePlayback; 266 friend class SkPicturePlayback;
251 267
252 typedef SkRefCnt INHERITED; 268 typedef SkRefCnt INHERITED;
253 }; 269 };
254 270
255 /** 271 /**
256 * 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
257 * of the picture, this callback will periodically be invoked. If its 273 * of the picture, this callback will periodically be invoked. If its
258 * abortDrawing() returns true, then picture playback will be interrupted. 274 * abortDrawing() returns true, then picture playback will be interrupted.
259 * 275 *
260 * 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
261 * 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
262 * 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
263 * 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.
264 */ 280 */
265 class SK_API SkDrawPictureCallback { 281 class SK_API SkDrawPictureCallback {
266 public: 282 public:
267 SkDrawPictureCallback() {} 283 SkDrawPictureCallback() {}
268 virtual ~SkDrawPictureCallback() {} 284 virtual ~SkDrawPictureCallback() {}
269 285
270 virtual bool abortDrawing() = 0; 286 virtual bool abortDrawing() = 0;
271 }; 287 };
272 288
273 #endif 289 #endif
OLDNEW
« no previous file with comments | « no previous file | samplecode/SampleFilterFuzz.cpp » ('j') | src/effects/SkPictureImageFilter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698