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