Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Macros
SkPictureRecord.h File Reference
#include "include/core/SkCanvas.h"
#include "include/core/SkCanvasVirtualEnforcer.h"
#include "include/core/SkColor.h"
#include "include/core/SkData.h"
#include "include/core/SkDrawable.h"
#include "include/core/SkImage.h"
#include "include/core/SkM44.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPicture.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSamplingOptions.h"
#include "include/core/SkScalar.h"
#include "include/core/SkTextBlob.h"
#include "include/core/SkVertices.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkTArray.h"
#include "include/private/base/SkTDArray.h"
#include "include/private/base/SkTo.h"
#include "include/private/chromium/Slug.h"
#include "src/core/SkPictureFlat.h"
#include "src/core/SkTHash.h"
#include "src/core/SkWriter32.h"
#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Classes

class  SkPictureRecord
 

Macros

#define MASK_24   0x00FFFFFF
 
#define UNPACK_8_24(combined, small, large)
 
#define PACK_8_24(small, large)   ((small << 24) | large)
 

Macro Definition Documentation

◆ MASK_24

#define MASK_24   0x00FFFFFF

Definition at line 59 of file SkPictureRecord.h.

◆ PACK_8_24

#define PACK_8_24 (   small,
  large 
)    ((small << 24) | large)

Definition at line 63 of file SkPictureRecord.h.

◆ UNPACK_8_24

#define UNPACK_8_24 (   combined,
  small,
  large 
)
Value:
small = (combined >> 24) & 0xFF; \
large = combined & MASK_24
#define MASK_24

Definition at line 60 of file SkPictureRecord.h.

67public:
68 SkPictureRecord(const SkISize& dimensions, uint32_t recordFlags);
69
70 SkPictureRecord(const SkIRect& dimensions, uint32_t recordFlags);
71
72 const skia_private::TArray<sk_sp<const SkPicture>>& getPictures() const {
73 return fPictures;
74 }
75
76 const skia_private::TArray<sk_sp<SkDrawable>>& getDrawables() const {
77 return fDrawables;
78 }
79
80 const skia_private::TArray<sk_sp<const SkTextBlob>>& getTextBlobs() const {
81 return fTextBlobs;
82 }
83
85 return fSlugs;
86 }
87
88 const skia_private::TArray<sk_sp<const SkVertices>>& getVertices() const {
89 return fVertices;
90 }
91
92 const skia_private::TArray<sk_sp<const SkImage>>& getImages() const {
93 return fImages;
94 }
95
96 sk_sp<SkData> opData() const {
97 this->validate(fWriter.bytesWritten(), 0);
98
99 if (fWriter.bytesWritten() == 0) {
100 return SkData::MakeEmpty();
101 }
102 return fWriter.snapshotAsData();
103 }
104
105 void setFlags(uint32_t recordFlags) {
106 fRecordFlags = recordFlags;
107 }
108
109 const SkWriter32& writeStream() const {
110 return fWriter;
111 }
112
113 void beginRecording();
114 void endRecording();
115
116protected:
117 void addNoOp();
118
119private:
120 void handleOptimization(int opt);
121 size_t recordRestoreOffsetPlaceholder();
122 void fillRestoreOffsetPlaceholdersForCurrentStackLevel(uint32_t restoreOffset);
123
124 SkTDArray<int32_t> fRestoreOffsetStack;
125
126 SkTDArray<uint32_t> fCullOffsetStack;
127
128 /*
129 * Write the 'drawType' operation and chunk size to the skp. 'size'
130 * can potentially be increased if the chunk size needs its own storage
131 * location (i.e., it overflows 24 bits).
132 * Returns the start offset of the chunk. This is the location at which
133 * the opcode & size are stored.
134 * TODO: since we are handing the size into here we could call reserve
135 * and then return a pointer to the memory storage. This could decrease
136 * allocation overhead but could lead to more wasted space (the tail
137 * end of blocks could go unused). Possibly add a second addDraw that
138 * operates in this manner.
139 */
140 size_t addDraw(DrawType drawType, size_t* size) {
141 size_t offset = fWriter.bytesWritten();
142
143 SkASSERT_RELEASE(this->predrawNotify());
144
145 SkASSERT(0 != *size);
146 SkASSERT(((uint8_t) drawType) == drawType);
147
148 if (0 != (*size & ~MASK_24) || *size == MASK_24) {
149 fWriter.writeInt(PACK_8_24(drawType, MASK_24));
150 *size += 1;
151 fWriter.writeInt(SkToU32(*size));
152 } else {
153 fWriter.writeInt(PACK_8_24(drawType, SkToU32(*size)));
154 }
155
156 return offset;
157 }
158
159 void addInt(int value) {
160 fWriter.writeInt(value);
161 }
162 void addScalar(SkScalar scalar) {
163 fWriter.writeScalar(scalar);
164 }
165
166 void addImage(const SkImage*);
167 void addMatrix(const SkMatrix& matrix);
168 void addPaint(const SkPaint& paint) { this->addPaintPtr(&paint); }
169 void addPaintPtr(const SkPaint* paint);
170 void addPatch(const SkPoint cubics[12]);
171 void addPath(const SkPath& path);
172 void addPicture(const SkPicture* picture);
173 void addDrawable(SkDrawable* picture);
174 void addPoint(const SkPoint& point);
175 void addPoints(const SkPoint pts[], int count);
176 void addRect(const SkRect& rect);
177 void addRectPtr(const SkRect* rect);
178 void addIRect(const SkIRect& rect);
179 void addIRectPtr(const SkIRect* rect);
180 void addRRect(const SkRRect&);
181 void addRegion(const SkRegion& region);
182 void addSampling(const SkSamplingOptions&);
183 void addText(const void* text, size_t byteLength);
184 void addTextBlob(const SkTextBlob* blob);
185 void addSlug(const sktext::gpu::Slug* slug);
186 void addVertices(const SkVertices*);
187
188 int find(const SkBitmap& bitmap);
189
190protected:
191 void validate(size_t initialOffset, size_t size) const {
192 SkASSERT(fWriter.bytesWritten() == initialOffset + size);
193 }
194
195 sk_sp<SkSurface> onNewSurface(const SkImageInfo&, const SkSurfaceProps&) override;
196 bool onPeekPixels(SkPixmap*) override { return false; }
197
198 void willSave() override;
199 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
200 bool onDoSaveBehind(const SkRect*) override;
201 void willRestore() override;
202
203 void didConcat44(const SkM44&) override;
204 void didSetM44(const SkM44&) override;
205 void didScale(SkScalar, SkScalar) override;
206 void didTranslate(SkScalar, SkScalar) override;
207
208 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
209
210 void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
211 const SkPaint& paint) override;
212 void onDrawSlug(const sktext::gpu::Slug* slug, const SkPaint& paint) override;
213 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
214 const SkPoint texCoords[4], SkBlendMode, const SkPaint& paint) override;
215
216 void onDrawPaint(const SkPaint&) override;
217 void onDrawBehind(const SkPaint&) override;
218 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
219 void onDrawRect(const SkRect&, const SkPaint&) override;
220 void onDrawRegion(const SkRegion&, const SkPaint&) override;
221 void onDrawOval(const SkRect&, const SkPaint&) override;
222 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
223 void onDrawRRect(const SkRRect&, const SkPaint&) override;
224 void onDrawPath(const SkPath&, const SkPaint&) override;
225
226 void onDrawImage2(const SkImage*, SkScalar, SkScalar, const SkSamplingOptions&,
227 const SkPaint*) override;
228 void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
229 const SkPaint*, SrcRectConstraint) override;
230 void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
231 const SkPaint*) override;
232 void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
233 SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
234
235 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
236 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
237
238 void onClipRect(const SkRect&, SkClipOp, ClipEdgeStyle) override;
239 void onClipRRect(const SkRRect&, SkClipOp, ClipEdgeStyle) override;
240 void onClipPath(const SkPath&, SkClipOp, ClipEdgeStyle) override;
241 void onClipShader(sk_sp<SkShader>, SkClipOp) override;
242 void onClipRegion(const SkRegion&, SkClipOp) override;
243 void onResetClip() override;
244
245 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
246
247 void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
248 void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
249
250 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&,
251 SkBlendMode) override;
252 void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
253 const SkSamplingOptions&,const SkPaint*, SrcRectConstraint) override;
254
255 int addPathToHeap(const SkPath& path); // does not write to ops stream
256
257 // These entry points allow the writing of matrices, clips, saves &
258 // restores to be deferred (e.g., if the MC state is being collapsed and
259 // only written out as needed).
260 void recordConcat(const SkMatrix& matrix);
261 void recordTranslate(const SkMatrix& matrix);
262 void recordScale(const SkMatrix& matrix);
263 size_t recordClipRect(const SkRect& rect, SkClipOp op, bool doAA);
264 size_t recordClipRRect(const SkRRect& rrect, SkClipOp op, bool doAA);
265 size_t recordClipPath(int pathID, SkClipOp op, bool doAA);
266 size_t recordClipRegion(const SkRegion& region, SkClipOp op);
267 void recordSave();
268 void recordSaveLayer(const SaveLayerRec&);
269 void recordRestore(bool fillInSkips = true);
270
271private:
273
274 struct PathHash {
275 uint32_t operator()(const SkPath& p) { return p.getGenerationID(); }
276 };
278
279 SkWriter32 fWriter;
280
287
288 uint32_t fRecordFlags;
289 int fInitialSaveCount;
290
291 friend class SkPictureData; // for SkPictureData's SkPictureRecord-based constructor
292};
293
294#endif
int count
#define SkASSERT_RELEASE(cond)
Definition SkAssert.h:100
#define SkASSERT(cond)
Definition SkAssert.h:116
SkBlendMode
Definition SkBlendMode.h:38
SkClipOp
Definition SkClipOp.h:13
uint32_t SkColor
Definition SkColor.h:37
#define PACK_8_24(small, large)
SkFilterMode
constexpr uint32_t SkToU32(S x)
Definition SkTo.h:26
int find(T *array, int N, T item)
static sk_sp< SkData > MakeEmpty()
Definition SkData.cpp:94
Definition SkM44.h:150
const Paint & paint
float SkScalar
Definition extension.cpp:12
std::u16string text
double y
double x
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
Point offset