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; |
| 21 class SkImageDeserializer; |
19 class SkPath; | 22 class SkPath; |
20 class SkPictureData; | 23 class SkPictureData; |
21 class SkPixelSerializer; | 24 class SkPixelSerializer; |
22 class SkReadBuffer; | 25 class SkReadBuffer; |
23 class SkRefCntSet; | 26 class SkRefCntSet; |
24 class SkStream; | 27 class SkStream; |
25 class SkTypefacePlayback; | 28 class SkTypefacePlayback; |
26 class SkWStream; | 29 class SkWStream; |
27 class SkWriteBuffer; | 30 class SkWriteBuffer; |
28 struct SkPictInfo; | 31 struct SkPictInfo; |
(...skipping 13 matching lines...) Expand all Loading... |
42 * If the installed pixelref has decoded the data into pixels, then the src
buffer need not be | 45 * 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 | 46 * copied. If the pixelref defers the actual decode until its lockPixels()
is called, then it |
44 * must make a copy of the src buffer. | 47 * must make a copy of the src buffer. |
45 * @param src Encoded data. | 48 * @param src Encoded data. |
46 * @param length Size of the encoded data, in bytes. | 49 * @param length Size of the encoded data, in bytes. |
47 * @param dst SkBitmap to install the pixel ref on. | 50 * @param dst SkBitmap to install the pixel ref on. |
48 * @param bool Whether or not a pixel ref was successfully installed. | 51 * @param bool Whether or not a pixel ref was successfully installed. |
49 */ | 52 */ |
50 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap
* dst); | 53 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap
* dst); |
51 | 54 |
| 55 #ifdef SK_SUPPORT_LEGACY_PICTUREINSTALLPIXELREF |
52 /** | 56 /** |
53 * Recreate a picture that was serialized into a stream. | 57 * Recreate a picture that was serialized into a stream. |
54 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. | 58 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. |
55 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the | 59 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the |
56 * encoded bitmap data from the stream. | 60 * encoded bitmap data from the stream. |
57 * @return A new SkPicture representing the serialized data, or NULL if the
stream is | 61 * @return A new SkPicture representing the serialized data, or NULL if the
stream is |
58 * invalid. | 62 * invalid. |
59 */ | 63 */ |
60 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc proc); | 64 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc proc); |
| 65 static sk_sp<SkPicture> MakeFromStream(SkStream* stream, std::nullptr_t) { |
| 66 return MakeFromStream(stream); |
| 67 } |
| 68 #endif |
61 | 69 |
62 /** | 70 /** |
63 * Recreate a picture that was serialized into a stream. | 71 * Recreate a picture that was serialized into a stream. |
64 * | 72 * |
65 * Any serialized images in the stream will be passed to | 73 * Any serialized images in the stream will be passed the image-deserialize
r, or if that is |
66 * SkImageGenerator::NewFromEncoded. | 74 * null, to the default deserializer that will call SkImage::MakeFromEncode
d(). |
67 * | |
68 * @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 | |
70 * invalid. | |
71 */ | 75 */ |
| 76 static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*); |
72 static sk_sp<SkPicture> MakeFromStream(SkStream*); | 77 static sk_sp<SkPicture> MakeFromStream(SkStream*); |
73 | 78 |
74 /** | 79 /** |
75 * Recreate a picture that was serialized into a buffer. If the creation re
quires bitmap | 80 * Recreate a picture that was serialized into a buffer. If the creation re
quires bitmap |
76 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 81 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
77 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). | 82 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). |
78 * @param SkReadBuffer Serialized picture data. | 83 * @param SkReadBuffer Serialized picture data. |
79 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is | 84 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is |
80 * invalid. | 85 * invalid. |
81 */ | 86 */ |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 #endif | 186 #endif |
182 | 187 |
183 private: | 188 private: |
184 // Subclass whitelist. | 189 // Subclass whitelist. |
185 SkPicture(); | 190 SkPicture(); |
186 friend class SkBigPicture; | 191 friend class SkBigPicture; |
187 friend class SkEmptyPicture; | 192 friend class SkEmptyPicture; |
188 template <typename> friend class SkMiniPicture; | 193 template <typename> friend class SkMiniPicture; |
189 | 194 |
190 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const
; | 195 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const
; |
191 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkTyp
efacePlayback*); | 196 static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*, SkTy
pefacePlayback*); |
192 friend class SkPictureData; | 197 friend class SkPictureData; |
193 | 198 |
194 virtual int numSlowPaths() const = 0; | 199 virtual int numSlowPaths() const = 0; |
195 friend class SkPictureGpuAnalyzer; | 200 friend class SkPictureGpuAnalyzer; |
196 friend struct SkPathCounter; | 201 friend struct SkPathCounter; |
197 | 202 |
198 // V35: Store SkRect (rather then width & height) in header | 203 // V35: Store SkRect (rather then width & height) in header |
199 // V36: Remove (obsolete) alphatype from SkColorTable | 204 // V36: Remove (obsolete) alphatype from SkColorTable |
200 // V37: Added shadow only option to SkDropShadowImageFilter (last version to
record CLEAR) | 205 // V37: Added shadow only option to SkDropShadowImageFilter (last version to
record CLEAR) |
201 // V38: Added PictureResolution option to SkPictureImageFilter | 206 // V38: Added PictureResolution option to SkPictureImageFilter |
(...skipping 28 matching lines...) Expand all Loading... |
230 const SkPictureData*, | 235 const SkPictureData*, |
231 const SkReadBuffer* buffer); | 236 const SkReadBuffer* buffer); |
232 | 237 |
233 SkPictInfo createHeader() const; | 238 SkPictInfo createHeader() const; |
234 SkPictureData* backport() const; | 239 SkPictureData* backport() const; |
235 | 240 |
236 mutable uint32_t fUniqueID; | 241 mutable uint32_t fUniqueID; |
237 }; | 242 }; |
238 | 243 |
239 #endif | 244 #endif |
OLD | NEW |