blob: cfa8c95f0b11897d8b3b5780cb7fb3df8ee1c8fe [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@android.com8a1c16f2008-12-17 15:59:43 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2007 The Android Open Source Project
reed@android.com8a1c16f2008-12-17 15:59:43 +00004 *
epoger@google.comec3ed6a2011-07-28 14:26:00 +00005 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@android.com8a1c16f2008-12-17 15:59:43 +00007 */
8
epoger@google.comec3ed6a2011-07-28 14:26:00 +00009
reed@android.com8a1c16f2008-12-17 15:59:43 +000010#ifndef SkPicture_DEFINED
11#define SkPicture_DEFINED
12
scroggo@google.comf8d7d272013-02-22 21:38:35 +000013#include "SkBitmap.h"
scroggo@google.comf1754ec2013-06-28 21:32:00 +000014#include "SkImageDecoder.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000015#include "SkRefCnt.h"
16
commit-bot@chromium.orgeb9547c2014-03-19 21:24:25 +000017#if SK_SUPPORT_GPU
18class GrContext;
19#endif
20
junov@chromium.org35ac0482012-11-01 17:10:32 +000021class SkBBoxHierarchy;
reed@android.com8a1c16f2008-12-17 15:59:43 +000022class SkCanvas;
reed@google.com74babdf2013-05-20 17:02:41 +000023class SkDrawPictureCallback;
scroggo@google.com1b1bcc32013-05-21 20:31:23 +000024class SkData;
reed@android.com8a1c16f2008-12-17 15:59:43 +000025class SkPicturePlayback;
26class SkPictureRecord;
27class SkStream;
28class SkWStream;
29
scroggo@google.comf1754ec2013-06-28 21:32:00 +000030struct SkPictInfo;
31
reed@android.com8a1c16f2008-12-17 15:59:43 +000032/** \class SkPicture
33
34 The SkPicture class records the drawing commands made to a canvas, to
35 be played back at a later time.
36*/
reed@google.com1a32d4a2011-04-25 20:02:38 +000037class SK_API SkPicture : public SkRefCnt {
reed@android.com8a1c16f2008-12-17 15:59:43 +000038public:
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +000039 SK_DECLARE_INST_COUNT(SkPicture)
40
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +000041 // AccelData provides a base class for device-specific acceleration
skia.committer@gmail.comeb849e52014-03-17 03:02:17 +000042 // data. It is added to the picture via a call to a device's optimize
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +000043 // method.
44 class AccelData : public SkRefCnt {
45 public:
46 typedef uint8_t Domain;
47 typedef uint32_t Key;
48
49 AccelData(Key key) : fKey(key) { }
50
51 const Key& getKey() const { return fKey; }
52
53 // This entry point allows user's to get a unique domain prefix
54 // for their keys
55 static Domain GenerateDomain();
56 private:
57 Key fKey;
58
59 typedef SkRefCnt INHERITED;
60 };
61
reed@android.com8a1c16f2008-12-17 15:59:43 +000062 SkPicture();
63 /** Make a copy of the contents of src. If src records more drawing after
64 this call, those elements will not appear in this picture.
65 */
66 SkPicture(const SkPicture& src);
scroggo@google.comf8d7d272013-02-22 21:38:35 +000067
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +000068 /** PRIVATE / EXPERIMENTAL -- do not call */
skia.committer@gmail.comeb849e52014-03-17 03:02:17 +000069 void EXPERIMENTAL_addAccelData(const AccelData* data) {
70 SkRefCnt_SafeAssign(fAccelData, data);
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +000071 }
72 /** PRIVATE / EXPERIMENTAL -- do not call */
skia.committer@gmail.comeb849e52014-03-17 03:02:17 +000073 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key key) const {
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +000074 if (NULL != fAccelData && fAccelData->getKey() == key) {
skia.committer@gmail.comeb849e52014-03-17 03:02:17 +000075 return fAccelData;
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +000076 }
77 return NULL;
78 }
79
reed@google.com34342f62012-06-25 14:36:28 +000080 /**
scroggo@google.comf8d7d272013-02-22 21:38:35 +000081 * Function signature defining a function that sets up an SkBitmap from encoded data. On
82 * success, the SkBitmap should have its Config, width, height, rowBytes and pixelref set.
83 * If the installed pixelref has decoded the data into pixels, then the src buffer need not be
84 * copied. If the pixelref defers the actual decode until its lockPixels() is called, then it
85 * must make a copy of the src buffer.
86 * @param src Encoded data.
87 * @param length Size of the encoded data, in bytes.
88 * @param dst SkBitmap to install the pixel ref on.
89 * @param bool Whether or not a pixel ref was successfully installed.
90 */
91 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap* dst);
92
93 /**
94 * Recreate a picture that was serialized into a stream.
95 * @param SkStream Serialized picture data.
scroggo@google.comf8d7d272013-02-22 21:38:35 +000096 * @param proc Function pointer for installing pixelrefs on SkBitmaps representing the
97 * encoded bitmap data from the stream.
scroggo@google.comf1754ec2013-06-28 21:32:00 +000098 * @return A new SkPicture representing the serialized data, or NULL if the stream is
99 * invalid.
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000100 */
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000101 static SkPicture* CreateFromStream(SkStream*,
102 InstallPixelRefProc proc = &SkImageDecoder::DecodeMemory);
scroggo@google.comf8d7d272013-02-22 21:38:35 +0000103
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000104 /**
105 * Recreate a picture that was serialized into a buffer. If the creation requires bitmap
106 * decoding, the decoder must be set on the SkReadBuffer parameter by calling
107 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuffer().
108 * @param SkReadBuffer Serialized picture data.
109 * @return A new SkPicture representing the serialized data, or NULL if the buffer is
110 * invalid.
111 */
112 static SkPicture* CreateFromBuffer(SkReadBuffer&);
113
reed@android.com8a1c16f2008-12-17 15:59:43 +0000114 virtual ~SkPicture();
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000115
reed@android.com8a1c16f2008-12-17 15:59:43 +0000116 /**
117 * Swap the contents of the two pictures. Guaranteed to succeed.
118 */
119 void swap(SkPicture& other);
skia.committer@gmail.coma27096b2012-08-30 14:38:00 +0000120
djsollen@google.comc9ab9872012-08-29 18:52:07 +0000121 /**
122 * Creates a thread-safe clone of the picture that is ready for playback.
123 */
124 SkPicture* clone() const;
125
126 /**
127 * Creates multiple thread-safe clones of this picture that are ready for
128 * playback. The resulting clones are stored in the provided array of
129 * SkPictures.
130 */
131 void clone(SkPicture* pictures, int count) const;
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000132
reed@android.comae814c82009-02-13 14:56:09 +0000133 enum RecordingFlags {
134 /* This flag specifies that when clipPath() is called, the path will
135 be faithfully recorded, but the recording canvas' current clip will
136 only see the path's bounds. This speeds up the recording process
137 without compromising the fidelity of the playback. The only side-
138 effect for recording is that calling getTotalClip() or related
139 clip-query calls will reflect the path's bounds, not the actual
140 path.
141 */
rileya@google.com8515e792012-09-13 21:41:51 +0000142 kUsePathBoundsForClip_RecordingFlag = 0x01,
143 /* This flag causes the picture to compute bounding boxes and build
144 up a spatial hierarchy (currently an R-Tree), plus a tree of Canvas'
145 usually stack-based clip/etc state. This requires an increase in
146 recording time (often ~2x; likely more for very complex pictures),
147 but allows us to perform much faster culling at playback time, and
148 completely avoid some unnecessary clips and other operations. This
149 is ideal for tiled rendering, or any other situation where you're
skia.committer@gmail.com1d225f22012-09-14 02:01:10 +0000150 drawing a fraction of a large scene into a smaller viewport.
rileya@google.com8515e792012-09-13 21:41:51 +0000151
152 In most cases the record cost is offset by the playback improvement
153 after a frame or two of tiled rendering (and complex pictures that
154 induce the worst record times will generally get the largest
155 speedups at playback time).
156
157 Note: Currently this is not serializable, the bounding data will be
158 discarded if you serialize into a stream and then deserialize.
159 */
robertphillips@google.comad7d4812013-04-12 15:13:35 +0000160 kOptimizeForClippedPlayback_RecordingFlag = 0x02,
reed@android.comae814c82009-02-13 14:56:09 +0000161 };
162
reed@android.com8a1c16f2008-12-17 15:59:43 +0000163 /** Returns the canvas that records the drawing commands.
reed@android.comae814c82009-02-13 14:56:09 +0000164 @param width the base width for the picture, as if the recording
165 canvas' bitmap had this width.
166 @param height the base width for the picture, as if the recording
167 canvas' bitmap had this height.
168 @param recordFlags optional flags that control recording.
reed@android.com8a1c16f2008-12-17 15:59:43 +0000169 @return the picture canvas.
170 */
reed@android.comae814c82009-02-13 14:56:09 +0000171 SkCanvas* beginRecording(int width, int height, uint32_t recordFlags = 0);
172
reed@android.com8a1c16f2008-12-17 15:59:43 +0000173 /** Returns the recording canvas if one is active, or NULL if recording is
174 not active. This does not alter the refcnt on the canvas (if present).
175 */
176 SkCanvas* getRecordingCanvas() const;
177 /** Signal that the caller is done recording. This invalidates the canvas
178 returned by beginRecording/getRecordingCanvas, and prepares the picture
179 for drawing. Note: this happens implicitly the first time the picture
180 is drawn.
181 */
182 void endRecording();
junov@chromium.org4866cc02012-06-01 21:23:07 +0000183
reed@android.com8a1c16f2008-12-17 15:59:43 +0000184 /** Replays the drawing commands on the specified canvas. This internally
185 calls endRecording() if that has not already been called.
reed@google.com74babdf2013-05-20 17:02:41 +0000186 @param canvas the canvas receiving the drawing commands.
reed@android.com8a1c16f2008-12-17 15:59:43 +0000187 */
reed@google.com74babdf2013-05-20 17:02:41 +0000188 void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL);
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000189
reed@android.com8a1c16f2008-12-17 15:59:43 +0000190 /** Return the width of the picture's recording canvas. This
191 value reflects what was passed to setSize(), and does not necessarily
192 reflect the bounds of what has been recorded into the picture.
193 @return the width of the picture's recording canvas
194 */
195 int width() const { return fWidth; }
196
197 /** Return the height of the picture's recording canvas. This
198 value reflects what was passed to setSize(), and does not necessarily
199 reflect the bounds of what has been recorded into the picture.
200 @return the height of the picture's recording canvas
201 */
202 int height() const { return fHeight; }
203
robertphillips@google.comd5500882014-04-02 23:51:13 +0000204 static const uint32_t kInvalidGenID = 0;
205
skia.committer@gmail.coma9157722014-04-03 03:04:26 +0000206 /** Return a non-zero, unique value representing the picture. This call is
207 only valid when not recording. Between a beginRecording/endRecording
robertphillips@google.comd5500882014-04-02 23:51:13 +0000208 pair it will just return 0 (the invalid gen ID). Each beginRecording/
209 endRecording pair will cause a different generation ID to be returned.
210 */
211 uint32_t getGenerationID() const;
212
scroggo@google.com5a7c6be2012-10-04 21:46:08 +0000213 /**
scroggo@google.com1b1bcc32013-05-21 20:31:23 +0000214 * Function to encode an SkBitmap to an SkData. A function with this
commit-bot@chromium.org8b0e8ac2014-01-30 18:58:24 +0000215 * signature can be passed to serialize() and SkWriteBuffer.
216 * Returning NULL will tell the SkWriteBuffer to use
scroggo@google.com1b1bcc32013-05-21 20:31:23 +0000217 * SkBitmap::flatten() to store the bitmap.
reed@google.com672588b2014-01-08 15:42:01 +0000218 *
219 * @param pixelRefOffset DEPRECATED -- caller assumes it will return 0.
scroggo@google.com1b1bcc32013-05-21 20:31:23 +0000220 * @return SkData If non-NULL, holds encoded data representing the passed
221 * in bitmap. The caller is responsible for calling unref().
scroggo@google.com32ef1312013-02-22 22:04:19 +0000222 */
scroggo@google.com1b1bcc32013-05-21 20:31:23 +0000223 typedef SkData* (*EncodeBitmap)(size_t* pixelRefOffset, const SkBitmap& bm);
scroggo@google.com32ef1312013-02-22 22:04:19 +0000224
225 /**
scroggo@google.com5a7c6be2012-10-04 21:46:08 +0000226 * Serialize to a stream. If non NULL, encoder will be used to encode
227 * any bitmaps in the picture.
scroggo@google.com1b1bcc32013-05-21 20:31:23 +0000228 * encoder will never be called with a NULL pixelRefOffset.
scroggo@google.com5a7c6be2012-10-04 21:46:08 +0000229 */
scroggo@google.com32ef1312013-02-22 22:04:19 +0000230 void serialize(SkWStream*, EncodeBitmap encoder = NULL) const;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000231
tomhudson@google.com381010e2013-10-24 11:12:47 +0000232 /**
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000233 * Serialize to a buffer.
234 */
235 void flatten(SkWriteBuffer&) const;
236
237 /**
tomhudson@google.com381010e2013-10-24 11:12:47 +0000238 * Returns true if any bitmaps may be produced when this SkPicture
239 * is replayed.
240 * Returns false if called while still recording.
241 */
242 bool willPlayBackBitmaps() const;
243
djsollen@google.comd9b0f482013-02-01 16:18:09 +0000244#ifdef SK_BUILD_FOR_ANDROID
reed@android.com8a1c16f2008-12-17 15:59:43 +0000245 /** Signals that the caller is prematurely done replaying the drawing
246 commands. This can be called from a canvas virtual while the picture
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000247 is drawing. Has no effect if the picture is not drawing.
djsollen@google.comd9b0f482013-02-01 16:18:09 +0000248 @deprecated preserving for legacy purposes
reed@android.com8a1c16f2008-12-17 15:59:43 +0000249 */
250 void abortPlayback();
djsollen@google.comd9b0f482013-02-01 16:18:09 +0000251#endif
rmistry@google.comfbfcd562012-08-23 18:09:54 +0000252
commit-bot@chromium.org6f4fb0f2014-03-03 19:18:39 +0000253 /** Return true if the SkStream/Buffer represents a serialized picture, and
254 fills out SkPictInfo. After this function returns, the data source is not
skia.committer@gmail.comade9a342014-03-04 03:02:32 +0000255 rewound so it will have to be manually reset before passing to
commit-bot@chromium.org6f4fb0f2014-03-03 19:18:39 +0000256 CreateFromStream or CreateFromBuffer. Note, CreateFromStream and
257 CreateFromBuffer perform this check internally so these entry points are
258 intended for stand alone tools.
259 If false is returned, SkPictInfo is unmodified.
260 */
261 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*);
262 static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*);
263
commit-bot@chromium.orge494dbd2014-03-04 19:08:57 +0000264 /** Enable/disable all the picture recording optimizations (i.e.,
265 those in SkPictureRecord). It is mainly intended for testing the
266 existing optimizations (i.e., to actually have the pattern
267 appear in an .skp we have to disable the optimization). Call right
268 after 'beginRecording'.
269 */
270 void internalOnly_EnableOpts(bool enableOpts);
271
commit-bot@chromium.orgeb9547c2014-03-19 21:24:25 +0000272 /** Return true if the picture is suitable for rendering on the GPU.
273 */
274
275#if SK_SUPPORT_GPU
276 bool suitableForGpuRasterization(GrContext*) const;
277#endif
278
scroggo@google.com2983ddd2013-05-07 14:45:40 +0000279protected:
robertphillips@google.com9a5b5702012-11-13 20:41:18 +0000280 // V2 : adds SkPixelRef's generation ID.
281 // V3 : PictInfo tag at beginning, and EOF tag at the end
282 // V4 : move SkPictInfo to be the header
283 // V5 : don't read/write FunctionPtr on cross-process (we can detect that)
284 // V6 : added serialization of SkPath's bounds (and packed its flags tighter)
285 // V7 : changed drawBitmapRect(IRect) to drawBitmapRectToRect(Rect)
286 // V8 : Add an option for encoding bitmaps
287 // V9 : Allow the reader and writer of an SKP disagree on whether to support
288 // SK_SUPPORT_HINTING_SCALE_FACTOR
reed@google.com4ed0fb72012-12-12 20:48:18 +0000289 // V10: add drawRRect, drawOval, clipRRect
scroggo@google.com74b7ffd2013-04-30 02:32:41 +0000290 // V11: modify how readBitmap and writeBitmap store their info.
reed@google.com277c3f82013-05-31 15:17:50 +0000291 // V12: add conics to SkPath, use new SkPathRef flattening
commit-bot@chromium.orgeed779d2013-08-16 10:24:37 +0000292 // V13: add flag to drawBitmapRectToRect
robertphillips@google.com7ce661d2013-08-27 16:14:03 +0000293 // parameterize blurs by sigma rather than radius
robertphillips@google.comca0c8382013-09-26 12:18:23 +0000294 // V14: Add flags word to PathRef serialization
robertphillips@google.comd5500882014-04-02 23:51:13 +0000295 // V15: Remove A1 bitmap config (and renumber remaining configs)
robertphillips@google.com466310d2013-12-03 16:43:54 +0000296 // V16: Move SkPath's isOval flag to SkPathRef
reed@google.come132f502013-12-13 19:58:46 +0000297 // V17: SkPixelRef now writes SkImageInfo
reed@google.com672588b2014-01-08 15:42:01 +0000298 // V18: SkBitmap now records x,y for its pixelref origin, instead of offset.
commit-bot@chromium.orgfed2ab62014-01-23 15:16:05 +0000299 // V19: encode matrices and regions into the ops stream
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000300 // V20: added bool to SkPictureImageFilter's serialization (to allow SkPicture serialization)
commit-bot@chromium.org210ae2a2014-02-27 17:40:13 +0000301 // V21: add pushCull, popCull
commit-bot@chromium.orgdcb8e542014-03-05 18:25:20 +0000302 // V22: SK_PICT_FACTORY_TAG's size is now the chunk size in bytes
commit-bot@chromium.orgd281c922014-02-18 22:08:16 +0000303
304 // Note: If the picture version needs to be increased then please follow the
305 // steps to generate new SKPs in (only accessible to Googlers): http://goo.gl/qATVcw
commit-bot@chromium.orge8d96142014-02-25 02:16:10 +0000306
307 // Only SKPs within the min/current picture version range (inclusive) can be read.
308 static const uint32_t MIN_PICTURE_VERSION = 19;
commit-bot@chromium.orgdcb8e542014-03-05 18:25:20 +0000309 static const uint32_t CURRENT_PICTURE_VERSION = 22;
robertphillips@google.com9a5b5702012-11-13 20:41:18 +0000310
robertphillips@google.comd5500882014-04-02 23:51:13 +0000311 mutable uint32_t fGenerationID;
312
robertphillips@google.com9a5b5702012-11-13 20:41:18 +0000313 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived classes to
skia.committer@gmail.comfbb0ed92012-11-13 21:46:06 +0000314 // install their own SkPicturePlayback-derived players,SkPictureRecord-derived
robertphillips@google.com9a5b5702012-11-13 20:41:18 +0000315 // recorders and set the picture size
commit-bot@chromium.org145d1c02014-03-16 19:46:36 +0000316 SkPicturePlayback* fPlayback;
317 SkPictureRecord* fRecord;
318 int fWidth, fHeight;
319 const AccelData* fAccelData;
robertphillips@google.com63f11272012-10-24 19:30:41 +0000320
robertphillips@google.comd5500882014-04-02 23:51:13 +0000321 void needsNewGenID() { fGenerationID = kInvalidGenID; }
322
scroggo@google.comf1754ec2013-06-28 21:32:00 +0000323 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of
324 // playback is unchanged.
325 SkPicture(SkPicturePlayback*, int width, int height);
326
junov@chromium.org35ac0482012-11-01 17:10:32 +0000327 // For testing. Derived classes may instantiate an alternate
328 // SkBBoxHierarchy implementation
329 virtual SkBBoxHierarchy* createBBoxHierarchy() const;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000330private:
commit-bot@chromium.org70512af2014-03-18 17:45:32 +0000331 // An OperationList encapsulates a set of operation offsets into the picture byte
332 // stream along with the CTMs needed for those operation.
333 class OperationList : public SkNoncopyable {
334 public:
335 virtual ~OperationList() {}
336
337 // If valid returns false then there is no optimization data
338 // present. All the draw operations need to be issued.
339 virtual bool valid() const { return false; }
340
341 // The following three entry points should only be accessed if
342 // 'valid' returns true.
343 virtual int numOps() const { SkASSERT(false); return 0; };
344 // The offset in the picture of the operation to execute.
345 virtual uint32_t offset(int index) const { SkASSERT(false); return 0; };
346 // The CTM that must be installed for the operation to behave correctly
347 virtual const SkMatrix& matrix(int index) const { SkASSERT(false); return SkMatrix::I(); }
348
349 static const OperationList& InvalidList();
350
351 private:
352 typedef SkNoncopyable INHERITED;
353 };
354
355 /** PRIVATE / EXPERIMENTAL -- do not call
356 Return the operations required to render the content inside 'queryRect'.
357 */
358 const OperationList& EXPERIMENTAL_getActiveOps(const SkIRect& queryRect);
359
commit-bot@chromium.org75cf29b2014-03-24 19:40:49 +0000360 /** PRIVATE / EXPERIMENTAL -- do not call
361 Return the ID of the operation currently being executed when playing
362 back. 0 indicates no call is active.
363 */
364 size_t EXPERIMENTAL_curOpID() const;
365
commit-bot@chromium.org9e5f85e2014-03-12 14:46:41 +0000366 void createHeader(SkPictInfo* info) const;
367 static bool IsValidPictInfo(const SkPictInfo& info);
commit-bot@chromium.org5e0995e2014-02-07 12:20:04 +0000368
reed@android.com8a1c16f2008-12-17 15:59:43 +0000369 friend class SkFlatPicture;
370 friend class SkPicturePlayback;
commit-bot@chromium.org70512af2014-03-18 17:45:32 +0000371 friend class SkGpuDevice;
commit-bot@chromium.org75cf29b2014-03-24 19:40:49 +0000372 friend class GrGatherDevice;
373 friend class SkDebugCanvas;
robertphillips@google.com15e9d3e2012-06-21 20:25:03 +0000374
375 typedef SkRefCnt INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +0000376};
377
reed@google.com74babdf2013-05-20 17:02:41 +0000378/**
379 * Subclasses of this can be passed to canvas.drawPicture. During the drawing
380 * of the picture, this callback will periodically be invoked. If its
381 * abortDrawing() returns true, then picture playback will be interrupted.
382 *
383 * The resulting drawing is undefined, as there is no guarantee how often the
384 * callback will be invoked. If the abort happens inside some level of nested
385 * calls to save(), restore will automatically be called to return the state
386 * to the same level it was before the drawPicture call was made.
387 */
commit-bot@chromium.orgbe879bc2013-05-22 21:11:42 +0000388class SK_API SkDrawPictureCallback {
reed@google.com74babdf2013-05-20 17:02:41 +0000389public:
390 SkDrawPictureCallback() {}
391 virtual ~SkDrawPictureCallback() {}
skia.committer@gmail.com3e50e992013-05-21 07:01:40 +0000392
reed@google.com74babdf2013-05-20 17:02:41 +0000393 virtual bool abortDrawing() = 0;
394};
reed@android.com8a1c16f2008-12-17 15:59:43 +0000395
396#endif