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