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 #ifndef SkPicture_DEFINED | 8 #ifndef SkPicture_DEFINED |
9 #define SkPicture_DEFINED | 9 #define SkPicture_DEFINED |
10 | 10 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 #include "SkRect.h" | 12 #include "SkRect.h" |
13 #include "SkTypes.h" | 13 #include "SkTypes.h" |
14 | 14 |
15 class GrContext; | 15 class GrContext; |
16 class SkBigPicture; | 16 class SkBigPicture; |
17 class SkBitmap; | 17 class SkBitmap; |
18 class SkCanvas; | 18 class SkCanvas; |
| 19 class SkData; |
| 20 class SkImage; |
19 class SkPath; | 21 class SkPath; |
20 class SkPictureData; | 22 class SkPictureData; |
21 class SkPixelSerializer; | 23 class SkPixelSerializer; |
22 class SkReadBuffer; | 24 class SkReadBuffer; |
23 class SkRefCntSet; | 25 class SkRefCntSet; |
24 class SkStream; | 26 class SkStream; |
25 class SkTypefacePlayback; | 27 class SkTypefacePlayback; |
26 class SkWStream; | 28 class SkWStream; |
27 class SkWriteBuffer; | 29 class SkWriteBuffer; |
28 struct SkPictInfo; | 30 struct SkPictInfo; |
29 | 31 |
| 32 class SkImageDeserializer { |
| 33 public: |
| 34 virtual ~SkImageDeserializer() {} |
| 35 |
| 36 virtual sk_sp<SkImage> deserialize(sk_sp<SkData>, const SkIRect* subset) = 0
; |
| 37 }; |
| 38 |
30 /** \class SkPicture | 39 /** \class SkPicture |
31 | 40 |
32 An SkPicture records drawing commands made to a canvas to be played back at
a later time. | 41 An SkPicture records drawing commands made to a canvas to be played back at
a later time. |
33 This base class handles serialization and a few other miscellany. | 42 This base class handles serialization and a few other miscellany. |
34 */ | 43 */ |
35 class SK_API SkPicture : public SkRefCnt { | 44 class SK_API SkPicture : public SkRefCnt { |
36 public: | 45 public: |
37 virtual ~SkPicture(); | 46 virtual ~SkPicture(); |
38 | 47 |
39 /** | 48 /** |
40 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On | 49 * Function signature defining a function that sets up an SkBitmap from enc
oded data. On |
41 * success, the SkBitmap should have its Config, width, height, rowBytes an
d pixelref set. | 50 * success, the SkBitmap should have its Config, width, height, rowBytes an
d pixelref set. |
42 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be | 51 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be |
43 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it | 52 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it |
44 * must make a copy of the src buffer. | 53 * must make a copy of the src buffer. |
45 * @param src Encoded data. | 54 * @param src Encoded data. |
46 * @param length Size of the encoded data, in bytes. | 55 * @param length Size of the encoded data, in bytes. |
47 * @param dst SkBitmap to install the pixel ref on. | 56 * @param dst SkBitmap to install the pixel ref on. |
48 * @param bool Whether or not a pixel ref was successfully installed. | 57 * @param bool Whether or not a pixel ref was successfully installed. |
49 */ | 58 */ |
50 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap
* dst); | 59 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap
* dst); |
51 | 60 |
| 61 #ifdef SK_SUPPORT_LEGACY_PICTUREINSTALLPIXELREF |
52 /** | 62 /** |
53 * Recreate a picture that was serialized into a stream. | 63 * Recreate a picture that was serialized into a stream. |
54 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. | 64 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. |
55 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the | 65 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the |
56 * encoded bitmap data from the stream. | 66 * encoded bitmap data from the stream. |
57 * @return A new SkPicture representing the serialized data, or NULL if the
stream is | 67 * @return A new SkPicture representing the serialized data, or NULL if the
stream is |
58 * invalid. | 68 * invalid. |
59 */ | 69 */ |
60 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc proc); | 70 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc proc); |
| 71 #endif |
| 72 |
| 73 static sk_sp<SkPicture> MakeFromStreamWithDeserializer(SkStream*, SkImageDes
erializer*); |
61 | 74 |
62 /** | 75 /** |
63 * Recreate a picture that was serialized into a stream. | 76 * Recreate a picture that was serialized into a stream. |
64 * | 77 * |
65 * Any serialized images in the stream will be passed to | 78 * Any serialized images in the stream will be passed to |
66 * SkImageGenerator::NewFromEncoded. | 79 * SkImageGenerator::NewFromEncoded. |
67 * | 80 * |
68 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. | 81 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. |
69 * @return A new SkPicture representing the serialized data, or NULL if the
stream is | 82 * @return A new SkPicture representing the serialized data, or NULL if the
stream is |
70 * invalid. | 83 * invalid. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 #endif | 194 #endif |
182 | 195 |
183 private: | 196 private: |
184 // Subclass whitelist. | 197 // Subclass whitelist. |
185 SkPicture(); | 198 SkPicture(); |
186 friend class SkBigPicture; | 199 friend class SkBigPicture; |
187 friend class SkEmptyPicture; | 200 friend class SkEmptyPicture; |
188 template <typename> friend class SkMiniPicture; | 201 template <typename> friend class SkMiniPicture; |
189 | 202 |
190 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const
; | 203 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const
; |
191 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkTyp
efacePlayback*); | 204 // static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkT
ypefacePlayback*); |
| 205 static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*, SkTy
pefacePlayback*); |
192 friend class SkPictureData; | 206 friend class SkPictureData; |
193 | 207 |
194 virtual int numSlowPaths() const = 0; | 208 virtual int numSlowPaths() const = 0; |
195 friend class SkPictureGpuAnalyzer; | 209 friend class SkPictureGpuAnalyzer; |
196 friend struct SkPathCounter; | 210 friend struct SkPathCounter; |
197 | 211 |
198 // V35: Store SkRect (rather then width & height) in header | 212 // V35: Store SkRect (rather then width & height) in header |
199 // V36: Remove (obsolete) alphatype from SkColorTable | 213 // V36: Remove (obsolete) alphatype from SkColorTable |
200 // V37: Added shadow only option to SkDropShadowImageFilter (last version to
record CLEAR) | 214 // V37: Added shadow only option to SkDropShadowImageFilter (last version to
record CLEAR) |
201 // V38: Added PictureResolution option to SkPictureImageFilter | 215 // V38: Added PictureResolution option to SkPictureImageFilter |
(...skipping 27 matching lines...) Expand all Loading... |
229 const SkPictureData*, | 243 const SkPictureData*, |
230 const SkReadBuffer* buffer); | 244 const SkReadBuffer* buffer); |
231 | 245 |
232 SkPictInfo createHeader() const; | 246 SkPictInfo createHeader() const; |
233 SkPictureData* backport() const; | 247 SkPictureData* backport() const; |
234 | 248 |
235 mutable uint32_t fUniqueID; | 249 mutable uint32_t fUniqueID; |
236 }; | 250 }; |
237 | 251 |
238 #endif | 252 #endif |
OLD | NEW |