| 1 | /* |
| 2 | * Copyright 2018 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SkPicturePriv_DEFINED |
| 9 | #define SkPicturePriv_DEFINED |
| 10 | |
| 11 | #include "include/core/SkPicture.h" |
| 12 | |
| 13 | class SkReadBuffer; |
| 14 | class SkWriteBuffer; |
| 15 | |
| 16 | class SkPicturePriv { |
| 17 | public: |
| 18 | /** |
| 19 | * Recreate a picture that was serialized into a buffer. If the creation requires bitmap |
| 20 | * decoding, the decoder must be set on the SkReadBuffer parameter by calling |
| 21 | * SkReadBuffer::setBitmapDecoder() before calling SkPicture::MakeFromBuffer(). |
| 22 | * @param buffer Serialized picture data. |
| 23 | * @return A new SkPicture representing the serialized data, or NULL if the buffer is |
| 24 | * invalid. |
| 25 | */ |
| 26 | static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer& buffer); |
| 27 | |
| 28 | /** |
| 29 | * Serialize to a buffer. |
| 30 | */ |
| 31 | static void Flatten(const sk_sp<const SkPicture> , SkWriteBuffer& buffer); |
| 32 | |
| 33 | // Returns NULL if this is not an SkBigPicture. |
| 34 | static const SkBigPicture* AsSkBigPicture(const sk_sp<const SkPicture> picture) { |
| 35 | return picture->asSkBigPicture(); |
| 36 | } |
| 37 | |
| 38 | // V35: Store SkRect (rather then width & height) in header |
| 39 | // V36: Remove (obsolete) alphatype from SkColorTable |
| 40 | // V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR) |
| 41 | // V38: Added PictureResolution option to SkPictureImageFilter |
| 42 | // V39: Added FilterLevel option to SkPictureImageFilter |
| 43 | // V40: Remove UniqueID serialization from SkImageFilter. |
| 44 | // V41: Added serialization of SkBitmapSource's filterQuality parameter |
| 45 | // V42: Added a bool to SkPictureShader serialization to indicate did-we-serialize-a-picture? |
| 46 | // V43: Added DRAW_IMAGE and DRAW_IMAGE_RECT opt codes to serialized data |
| 47 | // V44: Move annotations from paint to drawAnnotation |
| 48 | // V45: Add invNormRotation to SkLightingShader. |
| 49 | // V46: Add drawTextRSXform |
| 50 | // V47: Add occluder rect to SkBlurMaskFilter |
| 51 | // V48: Read and write extended SkTextBlobs. |
| 52 | // V49: Gradients serialized as SkColor4f + SkColorSpace |
| 53 | // V50: SkXfermode -> SkBlendMode |
| 54 | // V51: more SkXfermode -> SkBlendMode |
| 55 | // V52: Remove SkTextBlob::fRunCount |
| 56 | // V53: SaveLayerRec clip mask |
| 57 | // V54: ComposeShader can use a Mode or a Lerp |
| 58 | // V55: Drop blendmode[] from MergeImageFilter |
| 59 | // V56: Add TileMode in SkBlurImageFilter. |
| 60 | // V57: Sweep tiling info. |
| 61 | // V58: No more 2pt conical flipping. |
| 62 | // V59: No more LocalSpace option on PictureImageFilter |
| 63 | // V60: Remove flags in picture header |
| 64 | // V61: Change SkDrawPictureRec to take two colors rather than two alphas |
| 65 | // V62: Don't negate size of custom encoded images (don't write origin x,y either) |
| 66 | // V63: Store image bounds (including origin) instead of just width/height to support subsets |
| 67 | // V64: Remove occluder feature from blur maskFilter |
| 68 | // V65: Float4 paint color |
| 69 | // V66: Add saveBehind |
| 70 | // V67: Blobs serialize fonts instead of paints |
| 71 | // V68: Paint doesn't serialize font-related stuff |
| 72 | // V69: Clean up duplicated and redundant SkImageFilter related enums |
| 73 | // V70: Image filters definitions hidden, registered names updated to include "Impl" |
| 74 | // V71: Unify erode and dilate image filters |
| 75 | // V72: SkColorFilter_Matrix domain (rgba vs. hsla) |
| 76 | // V73: Use SkColor4f in per-edge AA quad API |
| 77 | // V74: MorphologyImageFilter internal radius is SkScaler |
| 78 | // V75: SkVertices switched from unsafe use of SkReader32 to SkReadBuffer (like everything else) |
| 79 | // V76: Add filtering enum to ImageShader |
| 80 | // V77: Explicit filtering options on imageshaders |
| 81 | // V78: Serialize skmipmap data for images that have it |
| 82 | // V79: Cubic Resampler option on imageshader |
| 83 | |
| 84 | enum Version { |
| 85 | kMorphologyTakesScalar_Version = 74, |
| 86 | kVerticesUseReadBuffer_Version = 75, |
| 87 | kFilterEnumInImageShader_Version = 76, |
| 88 | kFilterOptionsInImageShader_Version = 77, |
| 89 | kSerializeMipmaps_Version = 78, |
| 90 | kCubicResamplerImageShader_Version = 79, |
| 91 | |
| 92 | // Only SKPs within the min/current picture version range (inclusive) can be read. |
| 93 | kMin_Version = kMorphologyTakesScalar_Version, |
| 94 | kCurrent_Version = kCubicResamplerImageShader_Version |
| 95 | }; |
| 96 | |
| 97 | static_assert(SkPicturePriv::kMin_Version <= SkPicturePriv::kCubicResamplerImageShader_Version, |
| 98 | "Remove SkFontDescriptor::maybeAsSkFontData, SkFontMgr::makeFromFontData, kFontAxes" ); |
| 99 | }; |
| 100 | |
| 101 | #endif |
| 102 | |