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 #endif | |
66 | |
67 static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*); | |
61 | 68 |
62 /** | 69 /** |
63 * Recreate a picture that was serialized into a stream. | 70 * Recreate a picture that was serialized into a stream. |
64 * | 71 * |
65 * Any serialized images in the stream will be passed to | 72 * Any serialized images in the stream will be passed to |
66 * SkImageGenerator::NewFromEncoded. | 73 * SkImageGenerator::NewFromEncoded. |
67 * | 74 * |
68 * @param SkStream Serialized picture data. Ownership is unchanged by this call. | 75 * @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 | 76 * @return A new SkPicture representing the serialized data, or NULL if the stream is |
70 * invalid. | 77 * invalid. |
71 */ | 78 */ |
72 static sk_sp<SkPicture> MakeFromStream(SkStream*); | 79 static sk_sp<SkPicture> MakeFromStream(SkStream*); |
80 static sk_sp<SkPicture> MakeFromStream(SkStream* stream, std::nullptr_t) { | |
mtklein
2016/08/10 21:48:31
Confused. Are you sure we need two MakeFromStream
reed1
2016/08/10 23:43:19
This is needed as chrome has callers today that pa
| |
81 return MakeFromStream(stream); | |
82 } | |
73 | 83 |
74 /** | 84 /** |
75 * Recreate a picture that was serialized into a buffer. If the creation re quires bitmap | 85 * 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 | 86 * decoding, the decoder must be set on the SkReadBuffer parameter by calli ng |
77 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf fer(). | 87 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf fer(). |
78 * @param SkReadBuffer Serialized picture data. | 88 * @param SkReadBuffer Serialized picture data. |
79 * @return A new SkPicture representing the serialized data, or NULL if the buffer is | 89 * @return A new SkPicture representing the serialized data, or NULL if the buffer is |
80 * invalid. | 90 * invalid. |
81 */ | 91 */ |
82 static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer&); | 92 static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer&); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 #endif | 191 #endif |
182 | 192 |
183 private: | 193 private: |
184 // Subclass whitelist. | 194 // Subclass whitelist. |
185 SkPicture(); | 195 SkPicture(); |
186 friend class SkBigPicture; | 196 friend class SkBigPicture; |
187 friend class SkEmptyPicture; | 197 friend class SkEmptyPicture; |
188 template <typename> friend class SkMiniPicture; | 198 template <typename> friend class SkMiniPicture; |
189 | 199 |
190 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const ; | 200 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const ; |
191 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkTyp efacePlayback*); | 201 // static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkT ypefacePlayback*); |
202 static sk_sp<SkPicture> MakeFromStream(SkStream*, SkImageDeserializer*, SkTy pefacePlayback*); | |
192 friend class SkPictureData; | 203 friend class SkPictureData; |
193 | 204 |
194 virtual int numSlowPaths() const = 0; | 205 virtual int numSlowPaths() const = 0; |
195 friend class SkPictureGpuAnalyzer; | 206 friend class SkPictureGpuAnalyzer; |
196 friend struct SkPathCounter; | 207 friend struct SkPathCounter; |
197 | 208 |
198 // V35: Store SkRect (rather then width & height) in header | 209 // V35: Store SkRect (rather then width & height) in header |
199 // V36: Remove (obsolete) alphatype from SkColorTable | 210 // V36: Remove (obsolete) alphatype from SkColorTable |
200 // V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR) | 211 // V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR) |
201 // V38: Added PictureResolution option to SkPictureImageFilter | 212 // V38: Added PictureResolution option to SkPictureImageFilter |
(...skipping 27 matching lines...) Expand all Loading... | |
229 const SkPictureData*, | 240 const SkPictureData*, |
230 const SkReadBuffer* buffer); | 241 const SkReadBuffer* buffer); |
231 | 242 |
232 SkPictInfo createHeader() const; | 243 SkPictInfo createHeader() const; |
233 SkPictureData* backport() const; | 244 SkPictureData* backport() const; |
234 | 245 |
235 mutable uint32_t fUniqueID; | 246 mutable uint32_t fUniqueID; |
236 }; | 247 }; |
237 | 248 |
238 #endif | 249 #endif |
OLD | NEW |