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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 class CollectLayers; | 34 class CollectLayers; |
35 }; | 35 }; |
36 | 36 |
37 /** \class SkPicture | 37 /** \class SkPicture |
38 | 38 |
39 The SkPicture class records the drawing commands made to a canvas, to | 39 The SkPicture class records the drawing commands made to a canvas, to |
40 be played back at a later time. | 40 be played back at a later time. |
41 */ | 41 */ |
42 class SK_API SkPicture : public SkNVRefCnt<SkPicture> { | 42 class SK_API SkPicture : public SkNVRefCnt<SkPicture> { |
43 public: | 43 public: |
44 // AccelData provides a base class for device-specific acceleration | 44 // AccelData provides a base class for device-specific acceleration data. |
45 // data. It is added to the picture via EXPERIMENTAL_addAccelData. | |
46 class AccelData : public SkRefCnt { | 45 class AccelData : public SkRefCnt { |
47 public: | 46 public: |
48 typedef uint8_t Domain; | 47 typedef uint8_t Domain; |
49 typedef uint32_t Key; | 48 typedef uint32_t Key; |
50 | 49 |
51 AccelData(Key key) : fKey(key) { } | 50 AccelData(Key key) : fKey(key) { } |
52 | 51 |
53 const Key& getKey() const { return fKey; } | 52 const Key& getKey() const { return fKey; } |
54 | 53 |
55 // This entry point allows user's to get a unique domain prefix | 54 // This entry point allows user's to get a unique domain prefix |
56 // for their keys | 55 // for their keys |
57 static Domain GenerateDomain(); | 56 static Domain GenerateDomain(); |
58 private: | 57 private: |
59 Key fKey; | 58 Key fKey; |
60 }; | 59 }; |
61 | 60 |
62 /** PRIVATE / EXPERIMENTAL -- do not call */ | 61 /** PRIVATE / EXPERIMENTAL -- do not call */ |
63 void EXPERIMENTAL_addAccelData(const AccelData*) const; | |
64 | |
65 /** PRIVATE / EXPERIMENTAL -- do not call */ | |
66 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const; | 62 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key) const; |
67 | 63 |
68 /** | 64 /** |
69 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On | 65 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On |
70 * success, the SkBitmap should have its Config, width, height, rowBytes an
d pixelref set. | 66 * success, the SkBitmap should have its Config, width, height, rowBytes an
d pixelref set. |
71 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be | 67 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be |
72 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it | 68 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it |
73 * must make a copy of the src buffer. | 69 * must make a copy of the src buffer. |
74 * @param src Encoded data. | 70 * @param src Encoded data. |
75 * @param length Size of the encoded data, in bytes. | 71 * @param length Size of the encoded data, in bytes. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M3
9. | 249 static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M3
9. |
254 static const uint32_t CURRENT_PICTURE_VERSION = 41; | 250 static const uint32_t CURRENT_PICTURE_VERSION = 41; |
255 | 251 |
256 static_assert(MIN_PICTURE_VERSION <= 41, | 252 static_assert(MIN_PICTURE_VERSION <= 41, |
257 "Remove kFontFileName and related code from SkFontDescriptor.c
pp."); | 253 "Remove kFontFileName and related code from SkFontDescriptor.c
pp."); |
258 | 254 |
259 void createHeader(SkPictInfo* info) const; | 255 void createHeader(SkPictInfo* info) const; |
260 static bool IsValidPictInfo(const SkPictInfo& info); | 256 static bool IsValidPictInfo(const SkPictInfo& info); |
261 | 257 |
262 // Takes ownership of the (optional) SnapshotArray. | 258 // Takes ownership of the (optional) SnapshotArray. |
263 // For performance, we take ownership of the caller's refs on the SkRecord a
nd BBH. | 259 // For performance, we take ownership of the caller's refs on the SkRecord,
BBH, and AccelData. |
264 SkPicture(const SkRect& cullRect, | 260 SkPicture(const SkRect& cullRect, |
265 SkRecord*, | 261 SkRecord*, |
266 SnapshotArray*, | 262 SnapshotArray*, |
267 SkBBoxHierarchy*, | 263 SkBBoxHierarchy*, |
| 264 AccelData*, |
268 size_t approxBytesUsedBySubPictures); | 265 size_t approxBytesUsedBySubPictures); |
269 | 266 |
270 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); | 267 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); |
271 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, | 268 static SkPictureData* Backport(const SkRecord&, const SkPictInfo&, |
272 SkPicture const* const drawablePics[], int dr
awableCount); | 269 SkPicture const* const drawablePics[], int dr
awableCount); |
273 | 270 |
274 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> | 271 // uint32_t fRefCnt; from SkNVRefCnt<SkPicture> |
275 mutable uint32_t fUniqueID; | 272 mutable uint32_t fUniqueID; |
276 const SkRect fCullRect; | 273 const SkRect fCullRect; |
277 mutable SkAutoTUnref<const AccelData> fAccelData; | |
278 SkAutoTUnref<const SkRecord> fRecord; | 274 SkAutoTUnref<const SkRecord> fRecord; |
| 275 SkAutoTDelete<const SnapshotArray> fDrawablePicts; |
279 SkAutoTUnref<const SkBBoxHierarchy> fBBH; | 276 SkAutoTUnref<const SkBBoxHierarchy> fBBH; |
280 SkAutoTDelete<const SnapshotArray> fDrawablePicts; | 277 SkAutoTUnref<const AccelData> fAccelData; |
281 const size_t fApproxBytesUsedBySubPictures; | 278 const size_t fApproxBytesUsedBySubPictures; |
282 | 279 |
283 // helpers for fDrawablePicts | 280 // helpers for fDrawablePicts |
284 int drawableCount() const; | 281 int drawableCount() const; |
285 // will return NULL if drawableCount() returns 0 | 282 // will return NULL if drawableCount() returns 0 |
286 SkPicture const* const* drawablePicts() const; | 283 SkPicture const* const* drawablePicts() const; |
287 | 284 |
288 struct PathCounter; | 285 struct PathCounter; |
289 | 286 |
290 struct Analysis { | 287 struct Analysis { |
291 Analysis() {} // Only used by SkPictureData codepath. | 288 Analysis() {} // Only used by SkPictureData codepath. |
292 explicit Analysis(const SkRecord&); | 289 explicit Analysis(const SkRecord&); |
293 | 290 |
294 bool suitableForGpuRasterization(const char** reason, int sampleCount) c
onst; | 291 bool suitableForGpuRasterization(const char** reason, int sampleCount) c
onst; |
295 | 292 |
296 uint8_t fNumSlowPathsAndDashEffects; | 293 uint8_t fNumSlowPathsAndDashEffects; |
297 bool fWillPlaybackBitmaps : 1; | 294 bool fWillPlaybackBitmaps : 1; |
298 bool fHasText : 1; | 295 bool fHasText : 1; |
299 } fAnalysis; | 296 } fAnalysis; |
300 | 297 |
301 friend class SkPictureRecorder; // SkRecord-based constructor. | 298 friend class SkPictureRecorder; // SkRecord-based constructor. |
302 friend class GrLayerHoister; // access to fRecord | 299 friend class GrLayerHoister; // access to fRecord |
303 friend class ReplaceDraw; | 300 friend class ReplaceDraw; |
304 friend class SkPictureUtils; | 301 friend class SkPictureUtils; |
305 friend class SkRecordedDrawable; | 302 friend class SkRecordedDrawable; |
306 }; | 303 }; |
307 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 88, SkPictureSize); | 304 SK_COMPILE_ASSERT(sizeof(SkPicture) <= 88, SkPictureSize); |
308 | 305 |
309 #endif | 306 #endif |
OLD | NEW |