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
13class SkReadBuffer;
14class SkWriteBuffer;
15
16class SkPicturePriv {
17public:
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
79 enum Version {
80 kTileModeInBlurImageFilter_Version = 56,
81 kTileInfoInSweepGradient_Version = 57,
82 k2PtConicalNoFlip_Version = 58,
83 kRemovePictureImageFilterLocalSpace = 59,
84 kRemoveHeaderFlags_Version = 60,
85 kTwoColorDrawShadow_Version = 61,
86 kDontNegateImageSize_Version = 62,
87 kStoreImageBounds_Version = 63,
88 kRemoveOccluderFromBlurMaskFilter = 64,
89 kFloat4PaintColor_Version = 65,
90 kSaveBehind_Version = 66,
91 kSerializeFonts_Version = 67,
92 kPaintDoesntSerializeFonts_Version = 68,
93 kCleanupImageFilterEnums_Version = 69,
94 kHideImageFilterImpls_Version = 70,
95 kUnifyErodeDilateImpls_Version = 71,
96 kMatrixColorFilterDomain_Version = 72,
97 kEdgeAAQuadColor4f_Version = 73,
98 kMorphologyTakesScalar_Version = 74,
99
100 // Only SKPs within the min/current picture version range (inclusive) can be read.
101 kMin_Version = kTileModeInBlurImageFilter_Version,
102 kCurrent_Version = kMorphologyTakesScalar_Version
103 };
104
105 static_assert(kMin_Version <= 62, "Remove kFontAxes_bad from SkFontDescriptor.cpp");
106};
107
108#endif
109