| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 namespace SkRecords { | 34 namespace SkRecords { |
| 35 class CollectLayers; | 35 class CollectLayers; |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /** \class SkPicture | 38 /** \class SkPicture |
| 39 | 39 |
| 40 The SkPicture class records the drawing commands made to a canvas, to | 40 The SkPicture class records the drawing commands made to a canvas, to |
| 41 be played back at a later time. | 41 be played back at a later time. |
| 42 */ | 42 */ |
| 43 class SK_API SkPicture : public SkRefCnt { | 43 class SK_API SkPicture : public SkNVRefCnt<SkPicture> { |
| 44 public: | 44 public: |
| 45 SK_DECLARE_INST_COUNT(SkPicture) | |
| 46 | |
| 47 // AccelData provides a base class for device-specific acceleration | 45 // AccelData provides a base class for device-specific acceleration |
| 48 // data. It is added to the picture via EXPERIMENTAL_addAccelData. | 46 // data. It is added to the picture via EXPERIMENTAL_addAccelData. |
| 49 class AccelData : public SkRefCnt { | 47 class AccelData : public SkRefCnt { |
| 50 public: | 48 public: |
| 51 typedef uint8_t Domain; | 49 typedef uint8_t Domain; |
| 52 typedef uint32_t Key; | 50 typedef uint32_t Key; |
| 53 | 51 |
| 54 AccelData(Key key) : fKey(key) { } | 52 AccelData(Key key) : fKey(key) { } |
| 55 | 53 |
| 56 const Key& getKey() const { return fKey; } | 54 const Key& getKey() const { return fKey; } |
| 57 | 55 |
| 58 // This entry point allows user's to get a unique domain prefix | 56 // This entry point allows user's to get a unique domain prefix |
| 59 // for their keys | 57 // for their keys |
| 60 static Domain GenerateDomain(); | 58 static Domain GenerateDomain(); |
| 61 private: | 59 private: |
| 62 Key fKey; | 60 Key fKey; |
| 63 | |
| 64 typedef SkRefCnt INHERITED; | |
| 65 }; | 61 }; |
| 66 | 62 |
| 67 /** PRIVATE / EXPERIMENTAL -- do not call */ | 63 /** PRIVATE / EXPERIMENTAL -- do not call */ |
| 68 void EXPERIMENTAL_addAccelData(const AccelData*) const; | 64 void EXPERIMENTAL_addAccelData(const AccelData*) const; |
| 69 | 65 |
| 70 /** PRIVATE / EXPERIMENTAL -- do not call */ | 66 /** PRIVATE / EXPERIMENTAL -- do not call */ |
| 71 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const; | 67 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const; |
| 72 | 68 |
| 73 /** | 69 /** |
| 74 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On | 70 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On |
| (...skipping 22 matching lines...) Expand all Loading... |
| 97 /** | 93 /** |
| 98 * Recreate a picture that was serialized into a buffer. If the creation re
quires bitmap | 94 * Recreate a picture that was serialized into a buffer. If the creation re
quires bitmap |
| 99 * 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 |
| 100 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). | 96 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). |
| 101 * @param SkReadBuffer Serialized picture data. | 97 * @param SkReadBuffer Serialized picture data. |
| 102 * @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 |
| 103 * invalid. | 99 * invalid. |
| 104 */ | 100 */ |
| 105 static SkPicture* CreateFromBuffer(SkReadBuffer&); | 101 static SkPicture* CreateFromBuffer(SkReadBuffer&); |
| 106 | 102 |
| 107 virtual ~SkPicture(); | 103 ~SkPicture(); |
| 108 | 104 |
| 109 /** Replays the drawing commands on the specified canvas. Note that | 105 /** Replays the drawing commands on the specified canvas. Note that |
| 110 this has the effect of unfurling this picture into the destination | 106 this has the effect of unfurling this picture into the destination |
| 111 canvas. Using the SkCanvas::drawPicture entry point gives the destinatio
n | 107 canvas. Using the SkCanvas::drawPicture entry point gives the destinatio
n |
| 112 canvas the option of just taking a ref. | 108 canvas the option of just taking a ref. |
| 113 @param canvas the canvas receiving the drawing commands. | 109 @param canvas the canvas receiving the drawing commands. |
| 114 @param callback a callback that allows interruption of playback | 110 @param callback a callback that allows interruption of playback |
| 115 */ | 111 */ |
| 116 void playback(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; | 112 void playback(SkCanvas* canvas, SkDrawPictureCallback* = NULL) const; |
| 117 | 113 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 static bool IsValidPictInfo(const SkPictInfo& info); | 256 static bool IsValidPictInfo(const SkPictInfo& info); |
| 261 | 257 |
| 262 // Takes ownership of the SkRecord, refs the (optional) drawablePicts and BB
H. | 258 // Takes ownership of the SkRecord, refs the (optional) drawablePicts and BB
H. |
| 263 SkPicture(const SkRect& cullRect, SkRecord*, SkData* drawablePicts, | 259 SkPicture(const SkRect& cullRect, SkRecord*, SkData* drawablePicts, |
| 264 SkBBoxHierarchy*); | 260 SkBBoxHierarchy*); |
| 265 | 261 |
| 266 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); | 262 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
| 267 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, | 263 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
| 268 SkPicture const* const drawablePics[], int dr
awableCount); | 264 SkPicture const* const drawablePics[], int dr
awableCount); |
| 269 | 265 |
| 266 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> |
| 267 mutable uint32_t fUniqueID; |
| 270 const SkRect fCullRect; | 268 const SkRect fCullRect; |
| 271 mutable SkAutoTUnref<const AccelData> fAccelData; | 269 mutable SkAutoTUnref<const AccelData> fAccelData; |
| 272 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re
fed | 270 mutable SkTDArray<DeletionListener*> fDeletionListeners; // pointers are re
fed |
| 273 SkAutoTDelete<SkRecord> fRecord; | 271 SkAutoTDelete<SkRecord> fRecord; |
| 274 SkAutoTUnref<SkBBoxHierarchy> fBBH; | 272 SkAutoTUnref<SkBBoxHierarchy> fBBH; |
| 275 SkAutoTUnref<SkData> fDrawablePicts; | 273 SkAutoTUnref<SkData> fDrawablePicts; |
| 276 | 274 |
| 277 // helpers for fDrawablePicts | 275 // helpers for fDrawablePicts |
| 278 int drawableCount() const; | 276 int drawableCount() const; |
| 279 // will return NULL if drawableCount() returns 0 | 277 // will return NULL if drawableCount() returns 0 |
| 280 SkPicture const* const* drawablePicts() const; | 278 SkPicture const* const* drawablePicts() const; |
| 281 | 279 |
| 282 struct PathCounter; | 280 struct PathCounter; |
| 283 | 281 |
| 284 struct Analysis { | 282 struct Analysis { |
| 285 Analysis() {} // Only used by SkPictureData codepath. | 283 Analysis() {} // Only used by SkPictureData codepath. |
| 286 explicit Analysis(const SkRecord&); | 284 explicit Analysis(const SkRecord&); |
| 287 | 285 |
| 288 bool suitableForGpuRasterization(const char** reason, int sampleCount) c
onst; | 286 bool suitableForGpuRasterization(const char** reason, int sampleCount) c
onst; |
| 289 | 287 |
| 290 bool fWillPlaybackBitmaps; | 288 bool fWillPlaybackBitmaps; |
| 291 bool fHasText; | 289 bool fHasText; |
| 292 int fNumPaintWithPathEffectUses; | 290 int fNumPaintWithPathEffectUses; |
| 293 int fNumFastPathDashEffects; | 291 int fNumFastPathDashEffects; |
| 294 int fNumAAConcavePaths; | 292 int fNumAAConcavePaths; |
| 295 int fNumAAHairlineConcavePaths; | 293 int fNumAAHairlineConcavePaths; |
| 296 int fNumAADFEligibleConcavePaths; | 294 int fNumAADFEligibleConcavePaths; |
| 297 } fAnalysis; | 295 } fAnalysis; |
| 298 mutable uint32_t fUniqueID; | |
| 299 | 296 |
| 300 friend class SkPictureRecorder; // SkRecord-based constructor. | 297 friend class SkPictureRecorder; // SkRecord-based constructor. |
| 301 friend class GrLayerHoister; // access to fRecord | 298 friend class GrLayerHoister; // access to fRecord |
| 302 friend class ReplaceDraw; | 299 friend class ReplaceDraw; |
| 303 friend class SkPictureUtils; | 300 friend class SkPictureUtils; |
| 304 | |
| 305 typedef SkRefCnt INHERITED; | |
| 306 }; | 301 }; |
| 302 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 96, SkPictureSize); |
| 307 | 303 |
| 308 #endif | 304 #endif |
| OLD | NEW |