Debian Codegraph @

src/core/SkPicturePriv.h

raw
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/SkFourByteTag.h"
12 #include "include/core/SkPicture.h"
13 #include "include/core/SkRefCnt.h"
14
15 #include <atomic>
16 #include <cstdint>
17
18 class SkBigPicture;
19 class SkReadBuffer;
20 class SkStream;
21 class SkWriteBuffer;
22 struct SkPictInfo;
23
24 class SkPicturePriv {
25 public:
26 /**
27 * Recreate a picture that was serialized into a buffer. If the creation requires bitmap
28 * decoding, the decoder must be set on the SkReadBuffer parameter by calling
29 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::MakeFromBuffer().
30 * @param buffer Serialized picture data.
31 * @return A new SkPicture representing the serialized data, or NULL if the buffer is
32 * invalid.
33 */
34 static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer& buffer);
35
36 /**
37 * Serialize to a buffer.
38 */
39 static void Flatten(const sk_sp<const SkPicture> , SkWriteBuffer& buffer);
40
41 // Returns NULL if this is not an SkBigPicture.
42 static const SkBigPicture* AsSkBigPicture(const sk_sp<const SkPicture>& picture) {
43 return picture->asSkBigPicture();
44 }
45
46 static uint64_t MakeSharedID(uint32_t pictureID) {
47 uint64_t sharedID = SkSetFourByteTag('p', 'i', 'c', 't');
48 return (sharedID << 32) | pictureID;
49 }
50
51 static void AddedToCache(const SkPicture* pic) {
52 pic->fAddedToCache.store(true);
53 }
54
55 // V35: Store SkRect (rather then width & height) in header
56 // V36: Remove (obsolete) alphatype from SkColorTable
57 // V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR)
58 // V38: Added PictureResolution option to SkPictureImageFilter
59 // V39: Added FilterLevel option to SkPictureImageFilter
60 // V40: Remove UniqueID serialization from SkImageFilter.
61 // V41: Added serialization of SkBitmapSource's filterQuality parameter
62 // V42: Added a bool to SkPictureShader serialization to indicate did-we-serialize-a-picture?
63 // V43: Added DRAW_IMAGE and DRAW_IMAGE_RECT opt codes to serialized data
64 // V44: Move annotations from paint to drawAnnotation
65 // V45: Add invNormRotation to SkLightingShader.
66 // V46: Add drawTextRSXform
67 // V47: Add occluder rect to SkBlurMaskFilter
68 // V48: Read and write extended SkTextBlobs.
69 // V49: Gradients serialized as SkColor4f + SkColorSpace
70 // V50: SkXfermode -> SkBlendMode
71 // V51: more SkXfermode -> SkBlendMode
72 // V52: Remove SkTextBlob::fRunCount
73 // V53: SaveLayerRec clip mask
74 // V54: ComposeShader can use a Mode or a Lerp
75 // V55: Drop blendmode[] from MergeImageFilter
76 // V56: Add TileMode in SkBlurImageFilter.
77 // V57: Sweep tiling info.
78 // V58: No more 2pt conical flipping.
79 // V59: No more LocalSpace option on PictureImageFilter
80 // V60: Remove flags in picture header
81 // V61: Change SkDrawPictureRec to take two colors rather than two alphas
82 // V62: Don't negate size of custom encoded images (don't write origin x,y either)
83 // V63: Store image bounds (including origin) instead of just width/height to support subsets
84 // V64: Remove occluder feature from blur maskFilter
85 // V65: Float4 paint color
86 // V66: Add saveBehind
87 // V67: Blobs serialize fonts instead of paints
88 // V68: Paint doesn't serialize font-related stuff
89 // V69: Clean up duplicated and redundant SkImageFilter related enums
90 // V70: Image filters definitions hidden, registered names updated to include "Impl"
91 // V71: Unify erode and dilate image filters
92 // V72: SkColorFilter_Matrix domain (rgba vs. hsla)
93 // V73: Use SkColor4f in per-edge AA quad API
94 // V74: MorphologyImageFilter internal radius is SkScaler
95 // V75: SkVertices switched from unsafe use of SkReader32 to SkReadBuffer (like everything else)
96 // V76: Add filtering enum to ImageShader
97 // V77: Explicit filtering options on imageshaders
98 // V78: Serialize skmipmap data for images that have it
99 // V79: Cubic Resampler option on imageshader
100 // V80: Smapling options on imageshader
101 // V81: sampling parameters on drawImage/drawImageRect/etc.
102 // V82: Add filter param to picture-shader
103 // V83: SkMatrixImageFilter now takes SkSamplingOptions instead of SkFilterQuality
104 // V84: SkImageFilters::Image now takes SkSamplingOptions instead of SkFilterQuality
105 // V85: Remove legacy support for inheriting sampling from the paint.
106 // V86: Remove support for custom data inside SkVertices
107 // V87: SkPaint now holds a user-defined blend function (SkBlender), no longer has DrawLooper
108 // V88: Add blender to ComposeShader and BlendImageFilter
109 // V89: Deprecated SkClipOps are no longer supported
110 // V90: Private API for backdrop scale factor in SaveLayerRec
111 // V91: Added raw image shaders
112 // V92: Added anisotropic filtering to SkSamplingOptions
113 // V94: Removed local matrices from SkShaderBase. Local matrices always use SkLocalMatrixShader.
114 // V95: SkImageFilters::Shader only saves SkShader, not a full SkPaint
115 // V96: SkImageFilters::Magnifier updated with more complete parameters
116 // V97: SkImageFilters::RuntimeShader takes a sample radius
117 // V98: Merged SkImageFilters::Blend and ::Arithmetic implementations
118 // V99: Remove legacy Magnifier filter
119 // V100: SkImageFilters::DropShadow does not have a dedicated implementation
120 // V101: Crop image filter supports all SkTileModes instead of just kDecal
121 // V102: Convolution image filter uses ::Crop to apply tile mode
122 // V103: Remove deprecated per-image filter crop rect
123 // v104: SaveLayer supports multiple image filters
124 // v105: Unclamped matrix color filter
125 // v106: SaveLayer supports custom backdrop tile modes
126 // v107: Combine SkColorShader and SkColorShader4
127 // v108: Serialize stable keys of runtime effects
128 // v109: Extend SkWorkingColorSpaceShader to have alpha type + output control
129
130 enum Version {
131 kPictureShaderFilterParam_Version = 82,
132 kMatrixImageFilterSampling_Version = 83,
133 kImageFilterImageSampling_Version = 84,
134 kNoFilterQualityShaders_Version = 85,
135 kVerticesRemoveCustomData_Version = 86,
136 kSkBlenderInSkPaint = 87,
137 kBlenderInEffects = 88,
138 kNoExpandingClipOps = 89,
139 kBackdropScaleFactor = 90,
140 kRawImageShaders = 91,
141 kAnisotropicFilter = 92,
142 kBlend4fColorFilter = 93,
143 kNoShaderLocalMatrix = 94,
144 kShaderImageFilterSerializeShader = 95,
145 kRevampMagnifierFilter = 96,
146 kRuntimeImageFilterSampleRadius = 97,
147 kCombineBlendArithmeticFilters = 98,
148 kRemoveLegacyMagnifierFilter = 99,
149 kDropShadowImageFilterComposition = 100,
150 kCropImageFilterSupportsTiling = 101,
151 kConvolutionImageFilterTilingUpdate = 102,
152 kRemoveDeprecatedCropRect = 103,
153 kMultipleFiltersOnSaveLayer = 104,
154 kUnclampedMatrixColorFilter = 105,
155 kSaveLayerBackdropTileMode = 106,
156 kCombineColorShaders = 107,
157 kSerializeStableKeys = 108,
158 kWorkingColorSpaceOutput = 109,
159
160 // Only SKPs within the min/current picture version range (inclusive) can be read.
161 //
162 // When updating kMin_Version also update oldestSupportedSkpVersion in
163 // infra/bots/gen_tasks_logic/gen_tasks_logic.go
164 //
165 // Steps on how to find which oldestSupportedSkpVersion to use:
166 // 1) Find the git hash when the desired kMin_Version was the kCurrent_Version from the
167 // git logs: https://skia.googlesource.com/skia/+log/main/src/core/SkPicturePriv.h
168 // Eg: https://skia.googlesource.com/skia/+/bfd330d081952424a93d51715653e4d1314d4822%5E%21/#F1
169 //
170 // 2) Use that git hash to find the SKP asset version number at that time here:
171 // https://skia.googlesource.com/skia/+/bfd330d081952424a93d51715653e4d1314d4822/infra/bots/assets/skp/VERSION
172 //
173 // 3) [Optional] Increment the SKP asset version number from step 3 and verify that it has
174 // the expected version number by downloading the asset and running skpinfo on it.
175 //
176 // 4) Use the incremented SKP asset version number as the oldestSupportedSkpVersion in
177 // infra/bots/gen_tasks_logic/gen_tasks_logic.go
178 //
179 // 5) Run `make -C infra/bots train`
180 //
181 // Contact the Infra Gardener if the above steps do not work for you.
182 kMin_Version = kPictureShaderFilterParam_Version,
183 kCurrent_Version = kWorkingColorSpaceOutput
184 };
185 };
186
187 bool SkPicture_StreamIsSKP(SkStream*, SkPictInfo*);
188
189 #endif