/src/skia/src/core/SkPicturePriv.h
Line | Count | Source (jump to first uncovered line) |
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 | 0 | static const SkBigPicture* AsSkBigPicture(const sk_sp<const SkPicture>& picture) { |
43 | 0 | return picture->asSkBigPicture(); |
44 | 0 | } |
45 | | |
46 | 3.19k | static uint64_t MakeSharedID(uint32_t pictureID) { |
47 | 3.19k | uint64_t sharedID = SkSetFourByteTag('p', 'i', 'c', 't'); |
48 | 3.19k | return (sharedID << 32) | pictureID; |
49 | 3.19k | } |
50 | | |
51 | 1.13k | static void AddedToCache(const SkPicture* pic) { |
52 | 1.13k | pic->fAddedToCache.store(true); |
53 | 1.13k | } |
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 | | |
125 | | enum Version { |
126 | | kPictureShaderFilterParam_Version = 82, |
127 | | kMatrixImageFilterSampling_Version = 83, |
128 | | kImageFilterImageSampling_Version = 84, |
129 | | kNoFilterQualityShaders_Version = 85, |
130 | | kVerticesRemoveCustomData_Version = 86, |
131 | | kSkBlenderInSkPaint = 87, |
132 | | kBlenderInEffects = 88, |
133 | | kNoExpandingClipOps = 89, |
134 | | kBackdropScaleFactor = 90, |
135 | | kRawImageShaders = 91, |
136 | | kAnisotropicFilter = 92, |
137 | | kBlend4fColorFilter = 93, |
138 | | kNoShaderLocalMatrix = 94, |
139 | | kShaderImageFilterSerializeShader = 95, |
140 | | kRevampMagnifierFilter = 96, |
141 | | kRuntimeImageFilterSampleRadius = 97, |
142 | | kCombineBlendArithmeticFilters = 98, |
143 | | kRemoveLegacyMagnifierFilter = 99, |
144 | | kDropShadowImageFilterComposition = 100, |
145 | | kCropImageFilterSupportsTiling = 101, |
146 | | kConvolutionImageFilterTilingUpdate = 102, |
147 | | kRemoveDeprecatedCropRect = 103, |
148 | | kMultipleFiltersOnSaveLayer = 104, |
149 | | kUnclampedMatrixColorFilter = 105, |
150 | | |
151 | | // Only SKPs within the min/current picture version range (inclusive) can be read. |
152 | | // |
153 | | // When updating kMin_Version also update oldestSupportedSkpVersion in |
154 | | // infra/bots/gen_tasks_logic/gen_tasks_logic.go |
155 | | // |
156 | | // Steps on how to find which oldestSupportedSkpVersion to use: |
157 | | // 1) Find the git hash when the desired kMin_Version was the kCurrent_Version from the |
158 | | // git logs: https://skia.googlesource.com/skia/+log/main/src/core/SkPicturePriv.h |
159 | | // Eg: https://skia.googlesource.com/skia/+/bfd330d081952424a93d51715653e4d1314d4822%5E%21/#F1 |
160 | | // |
161 | | // 2) Use that git hash to find the SKP asset version number at that time here: |
162 | | // https://skia.googlesource.com/skia/+/bfd330d081952424a93d51715653e4d1314d4822/infra/bots/assets/skp/VERSION |
163 | | // |
164 | | // 3) [Optional] Increment the SKP asset version number from step 3 and verify that it has |
165 | | // the expected version number by downloading the asset and running skpinfo on it. |
166 | | // |
167 | | // 4) Use the incremented SKP asset version number as the oldestSupportedSkpVersion in |
168 | | // infra/bots/gen_tasks_logic/gen_tasks_logic.go |
169 | | // |
170 | | // 5) Run `make -C infra/bots train` |
171 | | // |
172 | | // Contact the Infra Gardener if the above steps do not work for you. |
173 | | kMin_Version = kPictureShaderFilterParam_Version, |
174 | | kCurrent_Version = kUnclampedMatrixColorFilter |
175 | | }; |
176 | | }; |
177 | | |
178 | | bool SkPicture_StreamIsSKP(SkStream*, SkPictInfo*); |
179 | | |
180 | | #endif |