| 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 "SkImageDecoder.h" | 11 #include "SkImageDecoder.h" |
| 12 #include "SkRefCnt.h" | 12 #include "SkRefCnt.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 SkPictureData; | 19 class SkPictureData; |
| 20 class SkPixelSerializer; | 20 class SkPixelSerializer; |
| 21 class SkRefCntSet; | 21 class SkRefCntSet; |
| 22 class SkStream; | 22 class SkStream; |
| 23 class SkTypefacePlayback; | 23 class SkTypefacePlayback; |
| 24 class SkWStream; | 24 class SkWStream; |
| 25 struct SkPictInfo; | 25 struct SkPictInfo; |
| 26 | 26 |
| 27 #define SK_SUPPORT_LEGACY_PICTURE_PTR |
| 28 |
| 27 /** \class SkPicture | 29 /** \class SkPicture |
| 28 | 30 |
| 29 An SkPicture records drawing commands made to a canvas to be played back at
a later time. | 31 An SkPicture records drawing commands made to a canvas to be played back at
a later time. |
| 30 This base class handles serialization and a few other miscellany. | 32 This base class handles serialization and a few other miscellany. |
| 31 */ | 33 */ |
| 32 class SK_API SkPicture : public SkRefCnt { | 34 class SK_API SkPicture : public SkRefCnt { |
| 33 public: | 35 public: |
| 34 virtual ~SkPicture(); | 36 virtual ~SkPicture(); |
| 35 | 37 |
| 36 /** | 38 /** |
| (...skipping 10 matching lines...) Expand all Loading... |
| 47 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap
* dst); | 49 typedef bool (*InstallPixelRefProc)(const void* src, size_t length, SkBitmap
* dst); |
| 48 | 50 |
| 49 /** | 51 /** |
| 50 * Recreate a picture that was serialized into a stream. | 52 * Recreate a picture that was serialized into a stream. |
| 51 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. | 53 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. |
| 52 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the | 54 * @param proc Function pointer for installing pixelrefs on SkBitmaps repre
senting the |
| 53 * encoded bitmap data from the stream. | 55 * encoded bitmap data from the stream. |
| 54 * @return A new SkPicture representing the serialized data, or NULL if the
stream is | 56 * @return A new SkPicture representing the serialized data, or NULL if the
stream is |
| 55 * invalid. | 57 * invalid. |
| 56 */ | 58 */ |
| 57 static SkPicture* CreateFromStream(SkStream*, InstallPixelRefProc proc); | 59 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc proc); |
| 58 | 60 |
| 59 /** | 61 /** |
| 60 * Recreate a picture that was serialized into a stream. | 62 * Recreate a picture that was serialized into a stream. |
| 61 * | 63 * |
| 62 * Any serialized images in the stream will be passed to | 64 * Any serialized images in the stream will be passed to |
| 63 * SkImageGenerator::NewFromEncoded. | 65 * SkImageGenerator::NewFromEncoded. |
| 64 * | 66 * |
| 65 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. | 67 * @param SkStream Serialized picture data. Ownership is unchanged by this
call. |
| 66 * @return A new SkPicture representing the serialized data, or NULL if the
stream is | 68 * @return A new SkPicture representing the serialized data, or NULL if the
stream is |
| 67 * invalid. | 69 * invalid. |
| 68 */ | 70 */ |
| 69 static SkPicture* CreateFromStream(SkStream*); | 71 static sk_sp<SkPicture> MakeFromStream(SkStream*); |
| 70 | 72 |
| 71 /** | 73 /** |
| 72 * Recreate a picture that was serialized into a buffer. If the creation re
quires bitmap | 74 * Recreate a picture that was serialized into a buffer. If the creation re
quires bitmap |
| 73 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng | 75 * decoding, the decoder must be set on the SkReadBuffer parameter by calli
ng |
| 74 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). | 76 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::CreateFromBuf
fer(). |
| 75 * @param SkReadBuffer Serialized picture data. | 77 * @param SkReadBuffer Serialized picture data. |
| 76 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is | 78 * @return A new SkPicture representing the serialized data, or NULL if the
buffer is |
| 77 * invalid. | 79 * invalid. |
| 78 */ | 80 */ |
| 79 static SkPicture* CreateFromBuffer(SkReadBuffer&); | 81 static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer&); |
| 80 | 82 |
| 81 /** | 83 /** |
| 82 * Subclasses of this can be passed to playback(). During the playback | 84 * Subclasses of this can be passed to playback(). During the playback |
| 83 * of the picture, this callback will periodically be invoked. If its | 85 * of the picture, this callback will periodically be invoked. If its |
| 84 * abort() returns true, then picture playback will be interrupted. | 86 * abort() returns true, then picture playback will be interrupted. |
| 85 * | 87 * |
| 86 * The resulting drawing is undefined, as there is no guarantee how often th
e | 88 * The resulting drawing is undefined, as there is no guarantee how often th
e |
| 87 * callback will be invoked. If the abort happens inside some level of neste
d | 89 * callback will be invoked. If the abort happens inside some level of neste
d |
| 88 * calls to save(), restore will automatically be called to return the state | 90 * calls to save(), restore will automatically be called to return the state |
| 89 * to the same level it was before the playback call was made. | 91 * to the same level it was before the playback call was made. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Sent via SkMessageBus from destructor. | 162 // Sent via SkMessageBus from destructor. |
| 161 struct DeletionMessage { int32_t fUniqueID; }; // TODO: -> uint32_t? | 163 struct DeletionMessage { int32_t fUniqueID; }; // TODO: -> uint32_t? |
| 162 | 164 |
| 163 // Returns NULL if this is not an SkBigPicture. | 165 // Returns NULL if this is not an SkBigPicture. |
| 164 virtual const SkBigPicture* asSkBigPicture() const { return NULL; } | 166 virtual const SkBigPicture* asSkBigPicture() const { return NULL; } |
| 165 | 167 |
| 166 // Global setting to enable or disable security precautions for serializatio
n. | 168 // Global setting to enable or disable security precautions for serializatio
n. |
| 167 static void SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set); | 169 static void SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set); |
| 168 static bool PictureIOSecurityPrecautionsEnabled(); | 170 static bool PictureIOSecurityPrecautionsEnabled(); |
| 169 | 171 |
| 172 #ifdef SK_SUPPORT_LEGACY_PICTURE_PTR |
| 173 static SkPicture* CreateFromStream(SkStream* stream, InstallPixelRefProc pro
c) { |
| 174 return MakeFromStream(stream, proc).release(); |
| 175 } |
| 176 static SkPicture* CreateFromStream(SkStream* stream) { |
| 177 return MakeFromStream(stream).release(); |
| 178 } |
| 179 static SkPicture* CreateFromBuffer(SkReadBuffer& rbuf) { |
| 180 return MakeFromBuffer(rbuf).release(); |
| 181 } |
| 182 #endif |
| 183 |
| 170 private: | 184 private: |
| 171 // Subclass whitelist. | 185 // Subclass whitelist. |
| 172 SkPicture(); | 186 SkPicture(); |
| 173 friend class SkBigPicture; | 187 friend class SkBigPicture; |
| 174 friend class SkEmptyPicture; | 188 friend class SkEmptyPicture; |
| 175 template <typename> friend class SkMiniPicture; | 189 template <typename> friend class SkMiniPicture; |
| 176 | 190 |
| 177 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const
; | 191 void serialize(SkWStream*, SkPixelSerializer*, SkRefCntSet* typefaces) const
; |
| 178 static SkPicture* CreateFromStream(SkStream*, | 192 static sk_sp<SkPicture> MakeFromStream(SkStream*, InstallPixelRefProc, SkTyp
efacePlayback*); |
| 179 InstallPixelRefProc proc, | |
| 180 SkTypefacePlayback*); | |
| 181 friend class SkPictureData; | 193 friend class SkPictureData; |
| 182 | 194 |
| 183 virtual int numSlowPaths() const = 0; | 195 virtual int numSlowPaths() const = 0; |
| 184 friend struct SkPathCounter; | 196 friend struct SkPathCounter; |
| 185 | 197 |
| 186 // V35: Store SkRect (rather then width & height) in header | 198 // V35: Store SkRect (rather then width & height) in header |
| 187 // V36: Remove (obsolete) alphatype from SkColorTable | 199 // V36: Remove (obsolete) alphatype from SkColorTable |
| 188 // V37: Added shadow only option to SkDropShadowImageFilter (last version to
record CLEAR) | 200 // V37: Added shadow only option to SkDropShadowImageFilter (last version to
record CLEAR) |
| 189 // V38: Added PictureResolution option to SkPictureImageFilter | 201 // V38: Added PictureResolution option to SkPictureImageFilter |
| 190 // V39: Added FilterLevel option to SkPictureImageFilter | 202 // V39: Added FilterLevel option to SkPictureImageFilter |
| (...skipping 10 matching lines...) Expand all Loading... |
| 201 static_assert(MIN_PICTURE_VERSION <= 41, | 213 static_assert(MIN_PICTURE_VERSION <= 41, |
| 202 "Remove kFontFileName and related code from SkFontDescriptor.c
pp."); | 214 "Remove kFontFileName and related code from SkFontDescriptor.c
pp."); |
| 203 | 215 |
| 204 static_assert(MIN_PICTURE_VERSION <= 42, | 216 static_assert(MIN_PICTURE_VERSION <= 42, |
| 205 "Remove COMMENT API handlers from SkPicturePlayback.cpp"); | 217 "Remove COMMENT API handlers from SkPicturePlayback.cpp"); |
| 206 | 218 |
| 207 static_assert(MIN_PICTURE_VERSION <= 43, | 219 static_assert(MIN_PICTURE_VERSION <= 43, |
| 208 "Remove SkBitmapSourceDeserializer."); | 220 "Remove SkBitmapSourceDeserializer."); |
| 209 | 221 |
| 210 static bool IsValidPictInfo(const SkPictInfo& info); | 222 static bool IsValidPictInfo(const SkPictInfo& info); |
| 211 static SkPicture* Forwardport(const SkPictInfo&, const SkPictureData*); | 223 static sk_sp<SkPicture> Forwardport(const SkPictInfo&, const SkPictureData*)
; |
| 212 | 224 |
| 213 SkPictInfo createHeader() const; | 225 SkPictInfo createHeader() const; |
| 214 SkPictureData* backport() const; | 226 SkPictureData* backport() const; |
| 215 | 227 |
| 216 mutable uint32_t fUniqueID; | 228 mutable uint32_t fUniqueID; |
| 217 }; | 229 }; |
| 218 | 230 |
| 219 #endif | 231 #endif |
| OLD | NEW |