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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 /** \class SkPicture | 28 /** \class SkPicture |
29 | 29 |
30 The SkPicture class records the drawing commands made to a canvas, to | 30 The SkPicture class records the drawing commands made to a canvas, to |
31 be played back at a later time. | 31 be played back at a later time. |
32 */ | 32 */ |
33 class SK_API SkPicture : public SkRefCnt { | 33 class SK_API SkPicture : public SkRefCnt { |
34 public: | 34 public: |
35 SK_DECLARE_INST_COUNT(SkPicture) | 35 SK_DECLARE_INST_COUNT(SkPicture) |
36 | 36 |
| 37 // AccelData provides a base class for device-specific acceleration |
| 38 // data. It is added to the picture via a call to a device's optimize |
| 39 // method. |
| 40 class AccelData : public SkRefCnt { |
| 41 public: |
| 42 typedef uint8_t Domain; |
| 43 typedef uint32_t Key; |
| 44 |
| 45 AccelData(Key key) : fKey(key) { } |
| 46 |
| 47 const Key& getKey() const { return fKey; } |
| 48 |
| 49 // This entry point allows user's to get a unique domain prefix |
| 50 // for their keys |
| 51 static Domain GenerateDomain(); |
| 52 private: |
| 53 Key fKey; |
| 54 |
| 55 typedef SkRefCnt INHERITED; |
| 56 }; |
| 57 |
37 /** The constructor prepares the picture to record. | 58 /** The constructor prepares the picture to record. |
38 @param width the width of the virtual device the picture records. | 59 @param width the width of the virtual device the picture records. |
39 @param height the height of the virtual device the picture records. | 60 @param height the height of the virtual device the picture records. |
40 */ | 61 */ |
41 SkPicture(); | 62 SkPicture(); |
42 /** Make a copy of the contents of src. If src records more drawing after | 63 /** Make a copy of the contents of src. If src records more drawing after |
43 this call, those elements will not appear in this picture. | 64 this call, those elements will not appear in this picture. |
44 */ | 65 */ |
45 SkPicture(const SkPicture& src); | 66 SkPicture(const SkPicture& src); |
46 | 67 |
| 68 /** PRIVATE / EXPERIMENTAL -- do not call */ |
| 69 void EXPERIMENTAL_addAccelData(const AccelData* data) { |
| 70 SkRefCnt_SafeAssign(fAccelData, data); |
| 71 } |
| 72 /** PRIVATE / EXPERIMENTAL -- do not call */ |
| 73 const AccelData* EXPERIMENTAL_getAccelData(AccelData::Key key) const { |
| 74 if (NULL != fAccelData && fAccelData->getKey() == key) { |
| 75 return fAccelData; |
| 76 } |
| 77 return NULL; |
| 78 } |
| 79 |
47 /** | 80 /** |
48 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On | 81 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On |
49 * success, the SkBitmap should have its Config, width, height, rowBytes an
d pixelref set. | 82 * success, the SkBitmap should have its Config, width, height, rowBytes an
d pixelref set. |
50 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be | 83 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be |
51 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it | 84 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it |
52 * must make a copy of the src buffer. | 85 * must make a copy of the src buffer. |
53 * @param src Encoded data. | 86 * @param src Encoded data. |
54 * @param length Size of the encoded data, in bytes. | 87 * @param length Size of the encoded data, in bytes. |
55 * @param dst SkBitmap to install the pixel ref on. | 88 * @param dst SkBitmap to install the pixel ref on. |
56 * @param bool Whether or not a pixel ref was successfully installed. | 89 * @param bool Whether or not a pixel ref was successfully installed. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Note: If the picture version needs to be increased then please follow the | 288 // Note: If the picture version needs to be increased then please follow the |
256 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g
l/qATVcw | 289 // steps to generate new SKPs in (only accessible to Googlers): http://goo.g
l/qATVcw |
257 | 290 |
258 // Only SKPs within the min/current picture version range (inclusive) can be
read. | 291 // Only SKPs within the min/current picture version range (inclusive) can be
read. |
259 static const uint32_t MIN_PICTURE_VERSION = 19; | 292 static const uint32_t MIN_PICTURE_VERSION = 19; |
260 static const uint32_t CURRENT_PICTURE_VERSION = 22; | 293 static const uint32_t CURRENT_PICTURE_VERSION = 22; |
261 | 294 |
262 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class
es to | 295 // fPlayback, fRecord, fWidth & fHeight are protected to allow derived class
es to |
263 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv
ed | 296 // install their own SkPicturePlayback-derived players,SkPictureRecord-deriv
ed |
264 // recorders and set the picture size | 297 // recorders and set the picture size |
265 SkPicturePlayback* fPlayback; | 298 SkPicturePlayback* fPlayback; |
266 SkPictureRecord* fRecord; | 299 SkPictureRecord* fRecord; |
267 int fWidth, fHeight; | 300 int fWidth, fHeight; |
| 301 const AccelData* fAccelData; |
268 | 302 |
269 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of | 303 // Create a new SkPicture from an existing SkPicturePlayback. Ref count of |
270 // playback is unchanged. | 304 // playback is unchanged. |
271 SkPicture(SkPicturePlayback*, int width, int height); | 305 SkPicture(SkPicturePlayback*, int width, int height); |
272 | 306 |
273 // For testing. Derived classes may instantiate an alternate | 307 // For testing. Derived classes may instantiate an alternate |
274 // SkBBoxHierarchy implementation | 308 // SkBBoxHierarchy implementation |
275 virtual SkBBoxHierarchy* createBBoxHierarchy() const; | 309 virtual SkBBoxHierarchy* createBBoxHierarchy() const; |
276 private: | 310 private: |
277 void createHeader(SkPictInfo* info) const; | 311 void createHeader(SkPictInfo* info) const; |
(...skipping 17 matching lines...) Expand all Loading... |
295 */ | 329 */ |
296 class SK_API SkDrawPictureCallback { | 330 class SK_API SkDrawPictureCallback { |
297 public: | 331 public: |
298 SkDrawPictureCallback() {} | 332 SkDrawPictureCallback() {} |
299 virtual ~SkDrawPictureCallback() {} | 333 virtual ~SkDrawPictureCallback() {} |
300 | 334 |
301 virtual bool abortDrawing() = 0; | 335 virtual bool abortDrawing() = 0; |
302 }; | 336 }; |
303 | 337 |
304 #endif | 338 #endif |
OLD | NEW |