| 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" |
| 12 #include "SkImageDecoder.h" | 14 #include "SkImageDecoder.h" |
| 13 #include "SkRefCnt.h" | 15 #include "SkRefCnt.h" |
| 14 #include "SkTDArray.h" | 16 #include "SkTDArray.h" |
| 15 | 17 |
| 16 #if SK_SUPPORT_GPU | 18 #if SK_SUPPORT_GPU |
| 17 class GrContext; | 19 class GrContext; |
| 18 #endif | 20 #endif |
| 19 | 21 |
| 20 class SkBitmap; | |
| 21 class SkBBoxHierarchy; | 22 class SkBBoxHierarchy; |
| 22 class SkCanvas; | 23 class SkCanvas; |
| 23 class SkData; | 24 class SkData; |
| 24 class SkPictureData; | 25 class SkPictureData; |
| 25 class SkPixelSerializer; | 26 class SkPixelSerializer; |
| 26 class SkStream; | 27 class SkStream; |
| 27 class SkWStream; | 28 class SkWStream; |
| 28 | 29 |
| 29 struct SkPictInfo; | 30 struct SkPictInfo; |
| 30 | 31 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 95 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
| 95 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). | 96 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). |
| 96 * @param SkReadBuffer Serialized picture data. | 97 * @param SkReadBuffer Serialized picture data. |
| 97 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is | 98 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is |
| 98 * invalid. | 99 * invalid. |
| 99 */ | 100 */ |
| 100 static SkPicture* CreateFromBuffer(SkReadBuffer&); | 101 static SkPicture* CreateFromBuffer(SkReadBuffer&); |
| 101 | 102 |
| 102 ~SkPicture(); | 103 ~SkPicture(); |
| 103 | 104 |
| 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 AbortCallback { | |
| 115 public: | |
| 116 AbortCallback() {} | |
| 117 virtual ~AbortCallback() {} | |
| 118 | |
| 119 virtual bool abort() = 0; | |
| 120 }; | |
| 121 | |
| 122 /** Replays the drawing commands on the specified canvas. Note that | 105 /** Replays the drawing commands on the specified canvas. Note that |
| 123 this has the effect of unfurling this picture into the destination | 106 this has the effect of unfurling this picture into the destination |
| 124 canvas. Using the SkCanvas::drawPicture entry point gives the destinatio
n | 107 canvas. Using the SkCanvas::drawPicture entry point gives the destinatio
n |
| 125 canvas the option of just taking a ref. | 108 canvas the option of just taking a ref. |
| 126 @param canvas the canvas receiving the drawing commands. | 109 @param canvas the canvas receiving the drawing commands. |
| 127 @param callback a callback that allows interruption of playback | 110 @param callback a callback that allows interruption of playback |
| 128 */ | 111 */ |
| 129 void playback(SkCanvas* canvas, AbortCallback* = NULL) const; | 112 void playback(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; |
| 130 | 113 |
| 131 /** Return the cull rect used when creating this picture: { 0, 0, cullWidth,
cullHeight }. | 114 /** Return the cull rect used when creating this picture: { 0, 0, cullWidth,
cullHeight }. |
| 132 It does not necessarily reflect the bounds of what has been recorded int
o the picture. | 115 It does not necessarily reflect the bounds of what has been recorded int
o the picture. |
| 133 @return the cull rect used to create this picture | 116 @return the cull rect used to create this picture |
| 134 */ | 117 */ |
| 135 SkRect cullRect() const { return fCullRect; } | 118 SkRect cullRect() const { return fCullRect; } |
| 136 | 119 |
| 137 /** Return a non-zero, unique value representing the picture. | 120 /** Return a non-zero, unique value representing the picture. |
| 138 */ | 121 */ |
| 139 uint32_t uniqueID() const { return fUniqueID; } | 122 uint32_t uniqueID() const { return fUniqueID; } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 | 290 |
| 308 friend class SkPictureRecorder; // SkRecord-based constructor. | 291 friend class SkPictureRecorder; // SkRecord-based constructor. |
| 309 friend class GrLayerHoister; // access to fRecord | 292 friend class GrLayerHoister; // access to fRecord |
| 310 friend class ReplaceDraw; | 293 friend class ReplaceDraw; |
| 311 friend class SkPictureUtils; | 294 friend class SkPictureUtils; |
| 312 friend class SkRecordedDrawable; | 295 friend class SkRecordedDrawable; |
| 313 }; | 296 }; |
| 314 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); | 297 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
| 315 | 298 |
| 316 #endif | 299 #endif |
| OLD | NEW |