Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkRecorder.h
Go to the documentation of this file.
1/*
2 * Copyright 2014 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 SkRecorder_DEFINED
9#define SkRecorder_DEFINED
10
13#include "include/core/SkM44.h"
22
23#include <cstddef>
24#include <memory>
25#include <utility>
26
27class SkBlender;
28class SkData;
29class SkDrawable;
30class SkImage;
31class SkMatrix;
32class SkMesh;
33class SkPaint;
34class SkPath;
35class SkPicture;
36class SkRRect;
37class SkRecord;
38class SkRegion;
39class SkShader;
40class SkSurface;
41class SkSurfaceProps;
42class SkTextBlob;
43class SkVertices;
44enum class SkBlendMode;
45enum class SkClipOp;
46struct SkDrawShadowRec;
47struct SkImageInfo;
48struct SkPoint;
49struct SkRSXform;
50struct SkRect;
51
52namespace sktext {
53 class GlyphRunList;
54 namespace gpu { class Slug; }
55}
56
58public:
61
62 int count() const { return fArray.size(); }
63 SkDrawable* const* begin() const { return fArray.begin(); }
64 SkDrawable* const* end() const { return fArray.end(); }
65
66 void append(SkDrawable* drawable);
67
68 // Return a new or ref'd array of pictures that were snapped from our drawables.
70
71private:
73};
74
75// SkRecorder provides an SkCanvas interface for recording into an SkRecord.
76
77class SkRecorder final : public SkCanvasVirtualEnforcer<SkNoDrawCanvas> {
78public:
79 // Does not take ownership of the SkRecord.
80 SkRecorder(SkRecord*, int width, int height); // TODO: remove
81 SkRecorder(SkRecord*, const SkRect& bounds);
82
83 void reset(SkRecord*, const SkRect& bounds);
84
85 size_t approxBytesUsedBySubPictures() const { return fApproxBytesUsedBySubPictures; }
86
87 SkDrawableList* getDrawableList() const { return fDrawableList.get(); }
88 std::unique_ptr<SkDrawableList> detachDrawableList() { return std::move(fDrawableList); }
89
90 // Make SkRecorder forget entirely about its SkRecord*; all calls to SkRecorder will fail.
91 void forgetRecord();
92
93 void willSave() override;
94 SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec&) override;
95 bool onDoSaveBehind(const SkRect*) override;
96 void willRestore() override {}
97 void didRestore() override;
98
99 void didConcat44(const SkM44&) override;
100 void didSetM44(const SkM44&) override;
101 void didScale(SkScalar, SkScalar) override;
102 void didTranslate(SkScalar, SkScalar) override;
103
104 void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) override;
105 void onDrawDrawable(SkDrawable*, const SkMatrix*) override;
106 void onDrawTextBlob(const SkTextBlob* blob,
107 SkScalar x,
108 SkScalar y,
109 const SkPaint& paint) override;
110 void onDrawSlug(const sktext::gpu::Slug* slug, const SkPaint& paint) override;
112 const sktext::GlyphRunList& glyphRunList, const SkPaint& paint) override;
113 void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4],
114 const SkPoint texCoords[4], SkBlendMode,
115 const SkPaint& paint) override;
116
117 void onDrawPaint(const SkPaint&) override;
118 void onDrawBehind(const SkPaint&) override;
119 void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) override;
120 void onDrawRect(const SkRect&, const SkPaint&) override;
121 void onDrawRegion(const SkRegion&, const SkPaint&) override;
122 void onDrawOval(const SkRect&, const SkPaint&) override;
123 void onDrawArc(const SkRect&, SkScalar, SkScalar, bool, const SkPaint&) override;
124 void onDrawRRect(const SkRRect&, const SkPaint&) override;
125 void onDrawPath(const SkPath&, const SkPaint&) override;
126
128 const SkPaint*) override;
129 void onDrawImageRect2(const SkImage*, const SkRect&, const SkRect&, const SkSamplingOptions&,
130 const SkPaint*, SrcRectConstraint) override;
131 void onDrawImageLattice2(const SkImage*, const Lattice&, const SkRect&, SkFilterMode,
132 const SkPaint*) override;
133 void onDrawAtlas2(const SkImage*, const SkRSXform[], const SkRect[], const SkColor[], int,
134 SkBlendMode, const SkSamplingOptions&, const SkRect*, const SkPaint*) override;
135
136 void onDrawVerticesObject(const SkVertices*, SkBlendMode, const SkPaint&) override;
137
138 void onDrawMesh(const SkMesh&, sk_sp<SkBlender>, const SkPaint&) override;
139
140 void onDrawShadowRec(const SkPath&, const SkDrawShadowRec&) override;
141
142 void onClipRect(const SkRect& rect, SkClipOp, ClipEdgeStyle) override;
143 void onClipRRect(const SkRRect& rrect, SkClipOp, ClipEdgeStyle) override;
144 void onClipPath(const SkPath& path, SkClipOp, ClipEdgeStyle) override;
145 void onClipShader(sk_sp<SkShader>, SkClipOp) override;
146 void onClipRegion(const SkRegion& deviceRgn, SkClipOp) override;
147 void onResetClip() override;
148
149 void onDrawPicture(const SkPicture*, const SkMatrix*, const SkPaint*) override;
150
151 void onDrawAnnotation(const SkRect&, const char[], SkData*) override;
152
153 void onDrawEdgeAAQuad(const SkRect&, const SkPoint[4], QuadAAFlags, const SkColor4f&,
154 SkBlendMode) override;
155 void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[],
156 const SkSamplingOptions&, const SkPaint*,
157 SrcRectConstraint) override;
158
160
161private:
162 template <typename T>
163 T* copy(const T*);
164
165 template <typename T>
166 T* copy(const T[], size_t count);
167
168 template<typename T, typename... Args>
169 void append(Args&&...);
170
171 size_t fApproxBytesUsedBySubPictures;
172 SkRecord* fRecord;
173 std::unique_ptr<SkDrawableList> fDrawableList;
174};
175
176#endif//SkRecorder_DEFINED
m reset()
int count
SkBlendMode
Definition SkBlendMode.h:38
SkClipOp
Definition SkClipOp.h:13
uint32_t SkColor
Definition SkColor.h:37
SkFilterMode
SrcRectConstraint
Definition SkCanvas.h:1541
SaveLayerStrategy
Definition SkCanvas.h:2263
SkDrawable *const * end() const
Definition SkRecorder.h:64
SkBigPicture::SnapshotArray * newDrawableSnapshot()
int count() const
Definition SkRecorder.h:62
SkDrawable *const * begin() const
Definition SkRecorder.h:63
void append(SkDrawable *drawable)
Definition SkM44.h:150
void didScale(SkScalar, SkScalar) override
void onDrawShadowRec(const SkPath &, const SkDrawShadowRec &) override
void didTranslate(SkScalar, SkScalar) override
void didConcat44(const SkM44 &) override
void onDrawDRRect(const SkRRect &, const SkRRect &, const SkPaint &) override
void onDrawPicture(const SkPicture *, const SkMatrix *, const SkPaint *) override
void onClipShader(sk_sp< SkShader >, SkClipOp) override
void onDrawDrawable(SkDrawable *, const SkMatrix *) override
void onDrawPatch(const SkPoint cubics[12], const SkColor colors[4], const SkPoint texCoords[4], SkBlendMode, const SkPaint &paint) override
std::unique_ptr< SkDrawableList > detachDrawableList()
Definition SkRecorder.h:88
void onDrawPaint(const SkPaint &) override
void onClipRRect(const SkRRect &rrect, SkClipOp, ClipEdgeStyle) override
void onClipRegion(const SkRegion &deviceRgn, SkClipOp) override
void onDrawSlug(const sktext::gpu::Slug *slug, const SkPaint &paint) override
void onDrawPath(const SkPath &, const SkPaint &) override
void onDrawMesh(const SkMesh &, sk_sp< SkBlender >, const SkPaint &) override
void onDrawBehind(const SkPaint &) override
void onDrawImage2(const SkImage *, SkScalar, SkScalar, const SkSamplingOptions &, const SkPaint *) override
SkDrawableList * getDrawableList() const
Definition SkRecorder.h:87
void onDrawEdgeAAQuad(const SkRect &, const SkPoint[4], QuadAAFlags, const SkColor4f &, SkBlendMode) override
void didSetM44(const SkM44 &) override
void onDrawRegion(const SkRegion &, const SkPaint &) override
void onDrawVerticesObject(const SkVertices *, SkBlendMode, const SkPaint &) override
void onDrawRect(const SkRect &, const SkPaint &) override
void onResetClip() override
size_t approxBytesUsedBySubPictures() const
Definition SkRecorder.h:85
void onDrawImageLattice2(const SkImage *, const Lattice &, const SkRect &, SkFilterMode, const SkPaint *) override
void onClipRect(const SkRect &rect, SkClipOp, ClipEdgeStyle) override
sk_sp< SkSurface > onNewSurface(const SkImageInfo &, const SkSurfaceProps &) override
bool onDoSaveBehind(const SkRect *) override
void onDrawGlyphRunList(const sktext::GlyphRunList &glyphRunList, const SkPaint &paint) override
void onDrawArc(const SkRect &, SkScalar, SkScalar, bool, const SkPaint &) override
void onDrawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint &) override
void onDrawAtlas2(const SkImage *, const SkRSXform[], const SkRect[], const SkColor[], int, SkBlendMode, const SkSamplingOptions &, const SkRect *, const SkPaint *) override
void didRestore() override
void onDrawTextBlob(const SkTextBlob *blob, SkScalar x, SkScalar y, const SkPaint &paint) override
void onDrawImageRect2(const SkImage *, const SkRect &, const SkRect &, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) override
void onDrawEdgeAAImageSet2(const ImageSetEntry[], int count, const SkPoint[], const SkMatrix[], const SkSamplingOptions &, const SkPaint *, SrcRectConstraint) override
void onDrawAnnotation(const SkRect &, const char[], SkData *) override
void willRestore() override
Definition SkRecorder.h:96
void forgetRecord()
void onClipPath(const SkPath &path, SkClipOp, ClipEdgeStyle) override
void onDrawOval(const SkRect &, const SkPaint &) override
void willSave() override
SaveLayerStrategy getSaveLayerStrategy(const SaveLayerRec &) override
void onDrawRRect(const SkRRect &, const SkPaint &) override
T * end()
Definition SkTDArray.h:152
int size() const
Definition SkTDArray.h:138
T * begin()
Definition SkTDArray.h:150
const Paint & paint
float SkScalar
Definition extension.cpp:12
double y
double x
Definition copy.py:1
#define T
int32_t height
int32_t width