Flutter Engine
The Flutter Engine
SkPictureFlat.h
Go to the documentation of this file.
1/*
2 * Copyright 2011 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#ifndef SkPictureFlat_DEFINED
8#define SkPictureFlat_DEFINED
9
18
19#include <cstddef>
20#include <cstdint>
21#include <memory>
22
23enum class SkClipOp;
24
25/*
26 * Note: While adding new DrawTypes, it is necessary to add to the end of this list
27 * and update LAST_DRAWTYPE_ENUM to avoid having the code read older skps wrong.
28 * (which can cause segfaults)
29 *
30 * Reordering can be done during version updates.
31 */
73
74 // new ops -- feel free to re-alphabetize on next version bump
76 PUSH_CULL, // deprecated, M41 was last Chromium version to write this to an .skp
77 POP_CULL, // deprecated, M41 was last Chromium version to write this to an .skp
78
79 DRAW_PATCH, // could not add in aphabetical order
87
90
95
96 TRANSLATE_Z, // deprecated (M60)
97
103
104 FLUSH, // no-op
105
107
109
111
115 MARK_CTM, // deprecated
117
122
124
126
128};
129
135};
136
141};
142
145};
146
156};
157
160};
161
162///////////////////////////////////////////////////////////////////////////////
163// clipparams are packed in 5 bits
164// doAA:1 | clipOp:4
165
166// Newly serialized pictures will only write kIntersect or kDifference.
167static inline uint32_t ClipParams_pack(SkClipOp op, bool doAA) {
168 unsigned doAABit = doAA ? 1 : 0;
169 return (doAABit << 4) | static_cast<int>(op);
170}
171
172// But old SKPs may have been serialized with the SK_SUPPORT_DEPRECATED_CLIPOP flag, so might
173// encounter expanding clip ops. Thus, this returns the clip op as the more general Region::Op.
175 uint32_t unpacked = packed & 0xF;
176 if (buffer->validate(unpacked <= SkRegion::kIntersect_Op ||
177 (unpacked <= SkRegion::kReplace_Op &&
179 return static_cast<SkRegion::Op>(unpacked);
180 }
182}
183
184static inline bool ClipParams_unpackDoAA(uint32_t packed) {
185 return SkToBool((packed >> 4) & 1);
186}
187
188///////////////////////////////////////////////////////////////////////////////
189
191public:
192 SkTypefacePlayback() : fCount(0), fArray(nullptr) {}
194
195 void setCount(size_t count);
196
197 size_t count() const { return fCount; }
198
200 SkASSERT(index < fCount);
201 return fArray[index];
202 }
203
205 buffer.setTypefaceArray(fArray.get(), fCount);
206 }
207
208protected:
209 size_t fCount;
210 std::unique_ptr<sk_sp<SkTypeface>[]> fArray;
211};
212
214public:
215 SkFactoryPlayback(int count) : fCount(count) { fArray = new SkFlattenable::Factory[count]; }
216
217 ~SkFactoryPlayback() { delete[] fArray; }
218
219 SkFlattenable::Factory* base() const { return fArray; }
220
222 buffer.setFactoryPlayback(fArray, fCount);
223 }
224
225private:
226 int fCount;
228};
229
230#endif
int count
Definition: FontMgrTest.cpp:50
#define SkASSERT(cond)
Definition: SkAssert.h:116
SkClipOp
Definition: SkClipOp.h:13
SaveBehindFlatFlags
@ SAVEBEHIND_HAS_SUBSET
static SkRegion::Op ClipParams_unpackRegionOp(SkReadBuffer *buffer, uint32_t packed)
@ DRAW_EDGEAA_QUAD
@ BEGIN_COMMENT_GROUP_obsolete
Definition: SkPictureFlat.h:70
@ DRAW_PATH
Definition: SkPictureFlat.h:47
@ TRANSLATE_Z
Definition: SkPictureFlat.h:96
@ DRAW_BITMAP_MATRIX_RETIRED_2016_REMOVED_2018
Definition: SkPictureFlat.h:40
@ RESTORE
Definition: SkPictureFlat.h:61
@ SET_M44
@ CLIP_PATH
Definition: SkPictureFlat.h:34
@ SAVE_LAYER_SAVELAYERFLAGS_DEPRECATED_JAN_2016_REMOVED_01_2018
Definition: SkPictureFlat.h:88
@ DRAW_POS_TEXT_REMOVED_1_2019
Definition: SkPictureFlat.h:50
@ DRAW_PAINT
Definition: SkPictureFlat.h:46
@ DRAW_SLUG
@ DRAW_PICTURE_MATRIX_PAINT
Definition: SkPictureFlat.h:80
@ DRAW_EDGEAA_IMAGE_SET
@ DRAW_REGION
@ SET_MATRIX
Definition: SkPictureFlat.h:66
@ FLUSH
@ DRAW_DATA
Definition: SkPictureFlat.h:44
@ ROTATE
Definition: SkPictureFlat.h:62
@ DRAW_DRAWABLE
Definition: SkPictureFlat.h:92
@ DRAW_IMAGE_RECT2
@ DRAW_IMAGE2
@ DRAW_RRECT
Definition: SkPictureFlat.h:55
@ DRAW_DRRECT
Definition: SkPictureFlat.h:75
@ SCALE
Definition: SkPictureFlat.h:65
@ LAST_DRAWTYPE_ENUM
@ DRAW_TEXT_REMOVED_1_2019
Definition: SkPictureFlat.h:57
@ DRAW_IMAGE_RECT
Definition: SkPictureFlat.h:86
@ DRAW_BITMAP_RETIRED_2016_REMOVED_2018
Definition: SkPictureFlat.h:39
@ DRAW_PATCH
Definition: SkPictureFlat.h:79
@ DRAW_BEHIND_PAINT
@ DRAW_EDGEAA_IMAGE_SET2
@ DRAW_TEXT_BLOB
Definition: SkPictureFlat.h:81
@ DRAW_PICTURE
Definition: SkPictureFlat.h:48
@ PUSH_CULL
Definition: SkPictureFlat.h:76
@ SKEW
Definition: SkPictureFlat.h:67
@ CONCAT44
@ NOOP
Definition: SkPictureFlat.h:69
@ SAVE
Definition: SkPictureFlat.h:63
@ DRAW_BITMAP_RECT_RETIRED_2016_REMOVED_2018
Definition: SkPictureFlat.h:42
@ DRAW_IMAGE
Definition: SkPictureFlat.h:82
@ RESET_CLIP
@ DRAW_DRAWABLE_MATRIX
Definition: SkPictureFlat.h:93
@ DRAW_ARC
@ DRAW_RECT
Definition: SkPictureFlat.h:54
@ DRAW_POS_TEXT_H_REMOVED_1_2019
Definition: SkPictureFlat.h:52
@ DRAW_VERTICES_OBJECT
@ DRAW_VERTICES_RETIRED_03_2017_REMOVED_01_2018
Definition: SkPictureFlat.h:60
@ MARK_CTM
@ DRAW_ANNOTATION
Definition: SkPictureFlat.h:91
@ CONCAT
Definition: SkPictureFlat.h:38
@ DRAW_TEXT_TOP_BOTTOM_REMOVED_1_2019
Definition: SkPictureFlat.h:59
@ DRAW_TEXT_ON_PATH_RETIRED_08_2018_REMOVED_10_2018
Definition: SkPictureFlat.h:58
@ SAVE_LAYER_SAVEFLAGS_DEPRECATED_2015_REMOVED_12_2020
Definition: SkPictureFlat.h:64
@ DRAW_IMAGE_NINE
Definition: SkPictureFlat.h:85
@ UNUSED
Definition: SkPictureFlat.h:33
@ SAVE_BEHIND
@ DRAW_IMAGE_LATTICE
Definition: SkPictureFlat.h:99
@ DRAW_POINTS
Definition: SkPictureFlat.h:49
@ DRAW_SHADOW_REC
Definition: SkPictureFlat.h:98
@ SAVE_LAYER_SAVELAYERREC
Definition: SkPictureFlat.h:89
@ END_COMMENT_GROUP_obsolete
Definition: SkPictureFlat.h:72
@ DRAW_ATLAS
Definition: SkPictureFlat.h:84
@ DRAW_TEXT_RSXFORM_DEPRECATED_DEC_2018
Definition: SkPictureFlat.h:94
@ CLIP_RRECT
Definition: SkPictureFlat.h:37
@ TRANSLATE
Definition: SkPictureFlat.h:68
@ COMMENT_obsolete
Definition: SkPictureFlat.h:71
@ DRAW_OVAL
Definition: SkPictureFlat.h:45
@ CLIP_REGION
Definition: SkPictureFlat.h:35
@ DRAW_CLEAR
Definition: SkPictureFlat.h:43
@ CLIP_SHADER_IN_PAINT
@ DRAW_IMAGE_RECT_STRICT_obsolete
Definition: SkPictureFlat.h:83
@ DRAW_POS_TEXT_H_TOP_BOTTOM_REMOVED_1_2019
Definition: SkPictureFlat.h:53
@ DRAW_BITMAP_NINE_RETIRED_2016_REMOVED_2018
Definition: SkPictureFlat.h:41
@ CLIP_RECT
Definition: SkPictureFlat.h:36
@ DRAW_SPRITE_RETIRED_2015_REMOVED_2018
Definition: SkPictureFlat.h:56
@ DRAW_POS_TEXT_TOP_BOTTOM_REMOVED_1_2019
Definition: SkPictureFlat.h:51
@ POP_CULL
Definition: SkPictureFlat.h:77
@ DRAW_IMAGE_LATTICE2
static uint32_t ClipParams_pack(SkClipOp op, bool doAA)
static bool ClipParams_unpackDoAA(uint32_t packed)
SaveLayerRecFlatFlags
@ SAVELAYERREC_HAS_FLAGS
@ SAVELAYERREC_HAS_BACKDROP_SCALE
@ SAVELAYERREC_HAS_MULTIPLE_FILTERS
@ SAVELAYERREC_HAS_PAINT
@ SAVELAYERREC_HAS_CLIPMASK_OBSOLETE
@ SAVELAYERREC_HAS_CLIPMATRIX_OBSOLETE
@ SAVELAYERREC_HAS_BACKDROP
@ SAVELAYERREC_HAS_BOUNDS
DrawVertexFlags
@ DRAW_VERTICES_HAS_TEXS
@ DRAW_VERTICES_HAS_XFER
@ DRAW_VERTICES_HAS_INDICES
@ DRAW_VERTICES_HAS_COLORS
DrawTextRSXformFlags
@ DRAW_TEXT_RSXFORM_HAS_CULL
DrawAtlasFlags
@ DRAW_ATLAS_HAS_SAMPLING
@ DRAW_ATLAS_HAS_COLORS
@ DRAW_ATLAS_HAS_CULL
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
SkFlattenable::Factory * base() const
void setupBuffer(SkReadBuffer &buffer) const
SkFactoryPlayback(int count)
sk_sp< SkFlattenable >(* Factory)(SkReadBuffer &)
Definition: SkFlattenable.h:41
@ kReplace_Op
replace target with operand
Definition: SkRegion.h:372
@ kIntersect_Op
target intersected with operand
Definition: SkRegion.h:368
void setupBuffer(SkReadBuffer &buffer) const
size_t count() const
~SkTypefacePlayback()=default
void setCount(size_t count)
sk_sp< SkTypeface > & operator[](size_t index)
std::unique_ptr< sk_sp< SkTypeface >[]> fArray
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126