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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 be faithfully recorded, but the recording canvas' current clip will | 140 be faithfully recorded, but the recording canvas' current clip will |
141 only see the path's bounds. This speeds up the recording process | 141 only see the path's bounds. This speeds up the recording process |
142 without compromising the fidelity of the playback. The only side- | 142 without compromising the fidelity of the playback. The only side- |
143 effect for recording is that calling getTotalClip() or related | 143 effect for recording is that calling getTotalClip() or related |
144 clip-query calls will reflect the path's bounds, not the actual | 144 clip-query calls will reflect the path's bounds, not the actual |
145 path. | 145 path. |
146 */ | 146 */ |
147 kUsePathBoundsForClip_RecordingFlag = 0x01 | 147 kUsePathBoundsForClip_RecordingFlag = 0x01 |
148 }; | 148 }; |
149 | 149 |
150 /** Replays the drawing commands on the specified canvas. This internally | 150 /** Replays the drawing commands on the specified canvas. |
151 calls endRecording() if that has not already been called. | |
152 @param canvas the canvas receiving the drawing commands. | 151 @param canvas the canvas receiving the drawing commands. |
153 */ | 152 */ |
154 void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; | 153 void draw(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; |
155 | 154 |
156 /** Return the width of the picture's recording canvas. This | 155 /** Return the width of the picture's recording canvas. This |
157 value reflects what was passed to setSize(), and does not necessarily | 156 value reflects what was passed to setSize(), and does not necessarily |
158 reflect the bounds of what has been recorded into the picture. | 157 reflect the bounds of what has been recorded into the picture. |
159 @return the width of the picture's recording canvas | 158 @return the width of the picture's recording canvas |
160 */ | 159 */ |
161 int width() const { return fWidth; } | 160 int width() const { return fWidth; } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 fills out SkPictInfo. After this function returns, the data source is no
t | 217 fills out SkPictInfo. After this function returns, the data source is no
t |
219 rewound so it will have to be manually reset before passing to | 218 rewound so it will have to be manually reset before passing to |
220 CreateFromStream or CreateFromBuffer. Note, CreateFromStream and | 219 CreateFromStream or CreateFromBuffer. Note, CreateFromStream and |
221 CreateFromBuffer perform this check internally so these entry points are | 220 CreateFromBuffer perform this check internally so these entry points are |
222 intended for stand alone tools. | 221 intended for stand alone tools. |
223 If false is returned, SkPictInfo is unmodified. | 222 If false is returned, SkPictInfo is unmodified. |
224 */ | 223 */ |
225 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); | 224 static bool InternalOnly_StreamIsSKP(SkStream*, SkPictInfo*); |
226 static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*); | 225 static bool InternalOnly_BufferIsSKP(SkReadBuffer&, SkPictInfo*); |
227 | 226 |
228 /** Enable/disable all the picture recording optimizations (i.e., | |
229 those in SkPictureRecord). It is mainly intended for testing the | |
230 existing optimizations (i.e., to actually have the pattern | |
231 appear in an .skp we have to disable the optimization). Call right | |
232 after 'beginRecording'. | |
233 */ | |
234 void internalOnly_EnableOpts(bool enableOpts); | |
235 | |
236 /** Return true if the picture is suitable for rendering on the GPU. | 227 /** Return true if the picture is suitable for rendering on the GPU. |
237 */ | 228 */ |
238 | 229 |
239 #if SK_SUPPORT_GPU | 230 #if SK_SUPPORT_GPU |
240 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; | 231 bool suitableForGpuRasterization(GrContext*, const char ** = NULL) const; |
241 #endif | 232 #endif |
242 | 233 |
243 protected: | 234 protected: |
244 // V2 : adds SkPixelRef's generation ID. | 235 // V2 : adds SkPixelRef's generation ID. |
245 // V3 : PictInfo tag at beginning, and EOF tag at the end | 236 // V3 : PictInfo tag at beginning, and EOF tag at the end |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Only SKPs within the min/current picture version range (inclusive) can be
read. | 268 // Only SKPs within the min/current picture version range (inclusive) can be
read. |
278 static const uint32_t MIN_PICTURE_VERSION = 19; | 269 static const uint32_t MIN_PICTURE_VERSION = 19; |
279 static const uint32_t CURRENT_PICTURE_VERSION = 28; | 270 static const uint32_t CURRENT_PICTURE_VERSION = 28; |
280 | 271 |
281 mutable uint32_t fUniqueID; | 272 mutable uint32_t fUniqueID; |
282 | 273 |
283 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class
es to | 274 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class
es to |
284 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv
ed | 275 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv
ed |
285 // recorders and set the picture size | 276 // recorders and set the picture size |
286 SkPicturePlayback* fPlayback; | 277 SkPicturePlayback* fPlayback; |
287 SkPictureRecord* fRecord; | |
288 int fWidth, fHeight; | 278 int fWidth, fHeight; |
289 mutable const AccelData* fAccelData; | 279 mutable const AccelData* fAccelData; |
290 | 280 |
291 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } | 281 void needsNewGenID() { fUniqueID = SK_InvalidGenID; } |
292 | 282 |
293 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of | 283 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of |
294 // playback is unchanged. | 284 // playback is unchanged. |
295 SkPicture(SkPicturePlayback*, int width, int height); | 285 SkPicture(SkPicturePlayback*, int width, int height); |
296 | 286 |
297 private: | 287 private: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 bool deepCopy); | 402 bool deepCopy); |
413 | 403 |
414 friend class SkFlatPicture; | 404 friend class SkFlatPicture; |
415 friend class SkPicturePlayback; | 405 friend class SkPicturePlayback; |
416 friend class SkPictureRecorder; | 406 friend class SkPictureRecorder; |
417 friend class SkGpuDevice; | 407 friend class SkGpuDevice; |
418 friend class GrGatherCanvas; | 408 friend class GrGatherCanvas; |
419 friend class GrGatherDevice; | 409 friend class GrGatherDevice; |
420 friend class SkDebugCanvas; | 410 friend class SkDebugCanvas; |
421 | 411 |
422 // TODO: beginRecording, getRecordingCanvas & endRecording can now be | |
423 // be moved out of SkPicture (and, presumably, be directly implemented | |
424 // in SkPictureRecorder) | |
425 | |
426 /** Returns the canvas that records the drawing commands. | |
427 @param width the base width for the picture, as if the recording | |
428 canvas' bitmap had this width. | |
429 @param height the base width for the picture, as if the recording | |
430 canvas' bitmap had this height. | |
431 @param factory if non-NULL, the factory used to the BBH for the recorded
picture | |
432 @param recordFlags optional flags that control recording. | |
433 @return the picture canvas. | |
434 */ | |
435 SkCanvas* beginRecording(int width, int height, SkBBHFactory* factory, uint3
2_t recordFlags); | |
436 /** Returns the recording canvas if one is active, or NULL if recording is | |
437 not active. This does not alter the refcnt on the canvas (if present). | |
438 */ | |
439 SkCanvas* getRecordingCanvas() const; | |
440 /** Signal that the caller is done recording. This invalidates the canvas | |
441 returned by beginRecording/getRecordingCanvas, and prepares the picture | |
442 for drawing. Note: this happens implicitly the first time the picture | |
443 is drawn. | |
444 */ | |
445 void endRecording(); | |
446 | |
447 typedef SkRefCnt INHERITED; | 412 typedef SkRefCnt INHERITED; |
448 }; | 413 }; |
449 | 414 |
450 /** | 415 /** |
451 * Subclasses of this can be passed to canvas.drawPicture. During the drawing | 416 * Subclasses of this can be passed to canvas.drawPicture. During the drawing |
452 * of the picture, this callback will periodically be invoked. If its | 417 * of the picture, this callback will periodically be invoked. If its |
453 * abortDrawing() returns true, then picture playback will be interrupted. | 418 * abortDrawing() returns true, then picture playback will be interrupted. |
454 * | 419 * |
455 * The resulting drawing is undefined, as there is no guarantee how often the | 420 * The resulting drawing is undefined, as there is no guarantee how often the |
456 * callback will be invoked. If the abort happens inside some level of nested | 421 * callback will be invoked. If the abort happens inside some level of nested |
457 * calls to save(), restore will automatically be called to return the state | 422 * calls to save(), restore will automatically be called to return the state |
458 * to the same level it was before the drawPicture call was made. | 423 * to the same level it was before the drawPicture call was made. |
459 */ | 424 */ |
460 class SK_API SkDrawPictureCallback { | 425 class SK_API SkDrawPictureCallback { |
461 public: | 426 public: |
462 SkDrawPictureCallback() {} | 427 SkDrawPictureCallback() {} |
463 virtual ~SkDrawPictureCallback() {} | 428 virtual ~SkDrawPictureCallback() {} |
464 | 429 |
465 virtual bool abortDrawing() = 0; | 430 virtual bool abortDrawing() = 0; |
466 }; | 431 }; |
467 | 432 |
468 #endif | 433 #endif |
OLD | NEW |