5#ifndef FLUTTER_DISPLAY_LIST_DL_OP_RECORDS_H_
6#define FLUTTER_DISPLAY_LIST_DL_OP_RECORDS_H_
8#include "flutter/display_list/display_list.h"
9#include "flutter/display_list/dl_blend_mode.h"
10#include "flutter/display_list/dl_op_receiver.h"
11#include "flutter/display_list/dl_sampling_options.h"
12#include "flutter/display_list/effects/dl_color_source.h"
13#include "flutter/fml/macros.h"
15#include "flutter/impeller/geometry/path.h"
16#include "flutter/impeller/typographer/text_frame.h"
86#pragma pack(push, DLOpPackLabel, 8)
111#define DEFINE_SET_BOOL_OP(name) \
112 struct Set##name##Op final : DLOp { \
113 static constexpr auto kType = DisplayListOpType::kSet##name; \
115 explicit Set##name##Op(bool value) : value(value) {} \
119 void dispatch(DispatchContext& ctx) const { \
120 ctx.receiver.set##name(value); \
125#undef DEFINE_SET_BOOL_OP
128#define DEFINE_SET_ENUM_OP(name) \
129 struct SetStroke##name##Op final : DLOp { \
130 static constexpr auto kType = DisplayListOpType::kSetStroke##name; \
132 explicit SetStroke##name##Op(DlStroke##name value) : value(value) {} \
134 const DlStroke##name value; \
136 void dispatch(DispatchContext& ctx) const { \
137 ctx.receiver.setStroke##name(value); \
142#undef DEFINE_SET_ENUM_OP
146 static constexpr auto kType = DisplayListOpType::kSetStyle;
158 static constexpr auto kType = DisplayListOpType::kSetStrokeWidth;
170 static constexpr auto kType = DisplayListOpType::kSetStrokeMiter;
183 static constexpr auto kType = DisplayListOpType::kSetColor;
193 static constexpr auto kType = DisplayListOpType::kSetBlendMode;
210#define DEFINE_SET_CLEAR_DLATTR_OP(name, sk_name, field) \
211 struct Clear##name##Op final : DLOp { \
212 static constexpr auto kType = DisplayListOpType::kClear##name; \
214 Clear##name##Op() {} \
216 void dispatch(DispatchContext& ctx) const { \
217 ctx.receiver.set##name(nullptr); \
220 struct SetPod##name##Op final : DLOp { \
221 static constexpr auto kType = DisplayListOpType::kSetPod##name; \
223 SetPod##name##Op() {} \
225 void dispatch(DispatchContext& ctx) const { \
226 const Dl##name* filter = reinterpret_cast<const Dl##name*>(this + 1); \
227 ctx.receiver.set##name(filter); \
234#undef DEFINE_SET_CLEAR_DLATTR_OP
239 static constexpr auto kType = DisplayListOpType::kSetImageColorSource;
243 source->horizontal_tile_mode(),
244 source->vertical_tile_mode(),
258 static constexpr auto kType = DisplayListOpType::kSetRuntimeEffectColorSource;
264 source->uniform_data()) {}
278#ifdef IMPELLER_ENABLE_3D
279struct SetSceneColorSourceOp : DLOp {
280 static constexpr auto kType = DisplayListOpType::kSetSceneColorSource;
282 explicit SetSceneColorSourceOp(
const DlSceneColorSource*
source)
285 const DlSceneColorSource
source;
287 void dispatch(DispatchContext& ctx)
const {
288 ctx.receiver.setColorSource(&
source);
300 static constexpr auto kType = DisplayListOpType::kSetSharedImageFilter;
305 const std::shared_ptr<DlImageFilter>
filter;
345 static constexpr auto kType = DisplayListOpType::kSave;
367 static constexpr auto kType = DisplayListOpType::kSaveLayer;
382 static constexpr auto kType = DisplayListOpType::kSaveLayerBackdrop;
407 static constexpr auto kType = DisplayListOpType::kRestore;
415 if (
info.save_was_needed) {
434 static constexpr auto kType = DisplayListOpType::kTranslate;
450 static constexpr auto kType = DisplayListOpType::kScale;
465 static constexpr auto kType = DisplayListOpType::kRotate;
480 static constexpr auto kType = DisplayListOpType::kSkew;
496 static constexpr auto kType = DisplayListOpType::kTransform2DAffine;
517 static constexpr auto kType = DisplayListOpType::kTransformFullPerspective;
548 static constexpr auto kType = DisplayListOpType::kTransformReset;
569#define DEFINE_CLIP_SHAPE_OP(shapetype, clipop) \
570 struct Clip##clipop##shapetype##Op final : TransformClipOpBase { \
571 static constexpr auto kType = DisplayListOpType::kClip##clipop##shapetype; \
573 Clip##clipop##shapetype##Op(Sk##shapetype shape, bool is_aa) \
574 : is_aa(is_aa), shape(shape) {} \
577 const Sk##shapetype shape; \
579 void dispatch(DispatchContext& ctx) const { \
580 if (op_needed(ctx)) { \
581 ctx.receiver.clip##shapetype(shape, DlCanvas::ClipOp::k##clipop, \
590#undef DEFINE_CLIP_SHAPE_OP
592#define DEFINE_CLIP_PATH_OP(clipop) \
593 struct Clip##clipop##PathOp final : TransformClipOpBase { \
594 static constexpr auto kType = DisplayListOpType::kClip##clipop##Path; \
596 Clip##clipop##PathOp(const SkPath& path, bool is_aa) \
597 : is_aa(is_aa), cached_path(path) {} \
600 const DlOpReceiver::CacheablePath cached_path; \
602 void dispatch(DispatchContext& ctx) const { \
603 if (op_needed(ctx)) { \
604 if (ctx.receiver.PrefersImpellerPaths()) { \
605 ctx.receiver.clipPath(cached_path, DlCanvas::ClipOp::k##clipop, \
608 ctx.receiver.clipPath(cached_path.sk_path, \
609 DlCanvas::ClipOp::k##clipop, is_aa); \
614 DisplayListCompare equals(const Clip##clipop##PathOp* other) const { \
615 return is_aa == other->is_aa && cached_path == other->cached_path \
616 ? DisplayListCompare::kEqual \
617 : DisplayListCompare::kNotEqual; \
622#undef DEFINE_CLIP_PATH_OP
635 static constexpr auto kType = DisplayListOpType::kDrawPaint;
648 static constexpr auto kType = DisplayListOpType::kDrawColor;
667#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name) \
668 struct Draw##op_name##Op final : DrawOpBase { \
669 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
671 explicit Draw##op_name##Op(arg_type arg_name) : arg_name(arg_name) {} \
673 const arg_type arg_name; \
675 void dispatch(DispatchContext& ctx) const { \
676 if (op_needed(ctx)) { \
677 ctx.receiver.draw##op_name(arg_name); \
684#undef DEFINE_DRAW_1ARG_OP
689 static constexpr auto kType = DisplayListOpType::kDrawPath;
717#define DEFINE_DRAW_2ARG_OP(op_name, type1, name1, type2, name2) \
718 struct Draw##op_name##Op final : DrawOpBase { \
719 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
721 Draw##op_name##Op(type1 name1, type2 name2) \
722 : name1(name1), name2(name2) {} \
727 void dispatch(DispatchContext& ctx) const { \
728 if (op_needed(ctx)) { \
729 ctx.receiver.draw##op_name(name1, name2); \
736#undef DEFINE_DRAW_2ARG_OP
740 static constexpr auto kType = DisplayListOpType::kDrawDashedLine;
762 static constexpr auto kType = DisplayListOpType::kDrawArc;
785#define DEFINE_DRAW_POINTS_OP(name, mode) \
786 struct Draw##name##Op final : DrawOpBase { \
787 static constexpr auto kType = DisplayListOpType::kDraw##name; \
789 explicit Draw##name##Op(uint32_t count) : count(count) {} \
791 const uint32_t count; \
793 void dispatch(DispatchContext& ctx) const { \
794 if (op_needed(ctx)) { \
795 const SkPoint* pts = reinterpret_cast<const SkPoint*>(this + 1); \
796 ctx.receiver.drawPoints(DlCanvas::PointMode::mode, count, pts); \
803#undef DEFINE_DRAW_POINTS_OP
822 reinterpret_cast<const DlVertices*
>(
this + 1);
830#define DEFINE_DRAW_IMAGE_OP(name, with_attributes) \
831 struct name##Op final : DrawOpBase { \
832 static constexpr auto kType = DisplayListOpType::k##name; \
834 name##Op(const sk_sp<DlImage>& image, \
835 const SkPoint& point, \
836 DlImageSampling sampling) \
837 : point(point), sampling(sampling), image(std::move(image)) {} \
839 const SkPoint point; \
840 const DlImageSampling sampling; \
841 const sk_sp<DlImage> image; \
843 void dispatch(DispatchContext& ctx) const { \
844 if (op_needed(ctx)) { \
845 ctx.receiver.drawImage(image, point, sampling, with_attributes); \
849 DisplayListCompare equals(const name##Op* other) const { \
850 return (point == other->point && sampling == other->sampling && \
851 image->Equals(other->image)) \
852 ? DisplayListCompare::kEqual \
853 : DisplayListCompare::kNotEqual; \
858#undef DEFINE_DRAW_IMAGE_OP
863 static constexpr auto kType = DisplayListOpType::kDrawImageRect;
903#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes) \
904 struct name##Op final : DrawOpBase { \
905 static constexpr auto kType = DisplayListOpType::k##name; \
907 name##Op(const sk_sp<DlImage>& image, \
908 const SkIRect& center, \
911 : center(center), dst(dst), mode(mode), image(std::move(image)) {} \
913 const SkIRect center; \
915 const DlFilterMode mode; \
916 const sk_sp<DlImage> image; \
918 void dispatch(DispatchContext& ctx) const { \
919 if (op_needed(ctx)) { \
920 ctx.receiver.drawImageNine(image, center, dst, mode, \
921 render_with_attributes); \
925 DisplayListCompare equals(const name##Op* other) const { \
926 return (center == other->center && dst == other->dst && \
927 mode == other->mode && image->Equals(other->image)) \
928 ? DisplayListCompare::kEqual \
929 : DisplayListCompare::kNotEqual; \
934#undef DEFINE_DRAW_IMAGE_NINE_OP
965 const void* pod_this,
966 const void* pod_other)
const {
976 ret = (memcmp(pod_this, pod_other, bytes) == 0);
985 static constexpr auto kType = DisplayListOpType::kDrawAtlas;
1013 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
1014 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
1026 static constexpr auto kType = DisplayListOpType::kDrawAtlasCulled;
1058 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
1059 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
1070 static constexpr auto kType = DisplayListOpType::kDrawDisplayList;
1096 static constexpr auto kType = DisplayListOpType::kDrawTextBlob;
1113 static constexpr auto kType = DisplayListOpType::kDrawTextFrame;
1132#define DEFINE_DRAW_SHADOW_OP(name, transparent_occluder) \
1133 struct Draw##name##Op final : DrawOpBase { \
1134 static constexpr auto kType = DisplayListOpType::kDraw##name; \
1136 Draw##name##Op(const SkPath& path, \
1138 SkScalar elevation, \
1140 : color(color), elevation(elevation), dpr(dpr), cached_path(path) {} \
1142 const DlColor color; \
1143 const SkScalar elevation; \
1144 const SkScalar dpr; \
1145 const DlOpReceiver::CacheablePath cached_path; \
1147 void dispatch(DispatchContext& ctx) const { \
1148 if (op_needed(ctx)) { \
1149 if (ctx.receiver.PrefersImpellerPaths()) { \
1150 ctx.receiver.drawShadow(cached_path, color, elevation, \
1151 transparent_occluder, dpr); \
1153 ctx.receiver.drawShadow(cached_path.sk_path, color, elevation, \
1154 transparent_occluder, dpr); \
1159 DisplayListCompare equals(const Draw##name##Op* other) const { \
1160 return color == other->color && elevation == other->elevation && \
1161 dpr == other->dpr && cached_path == other->cached_path \
1162 ? DisplayListCompare::kEqual \
1163 : DisplayListCompare::kNotEqual; \
1168#undef DEFINE_DRAW_SHADOW_OP
1170#pragma pack(pop, DLOpPackLabel)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
bool equals(SkDrawable *a, SkDrawable *b)
Internal API for rendering recorded display lists to backends.
virtual void drawImageRect(const sk_sp< DlImage > image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, bool render_with_attributes, SrcRectConstraint constraint=SrcRectConstraint::kFast)=0
virtual void drawArc(const SkRect &oval_bounds, SkScalar start_degrees, SkScalar sweep_degrees, bool use_center)=0
virtual void saveLayer(const SkRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr)=0
virtual void setStrokeMiter(float limit)=0
virtual void transformReset()=0
virtual void drawVertices(const DlVertices *vertices, DlBlendMode mode)=0
virtual void drawPath(const CacheablePath &cache)
virtual void skew(SkScalar sx, SkScalar sy)=0
virtual void drawDisplayList(const sk_sp< DisplayList > display_list, SkScalar opacity=SK_Scalar1)=0
virtual void setStrokeWidth(float width)=0
virtual void drawTextFrame(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y)=0
virtual void drawColor(DlColor color, DlBlendMode mode)=0
virtual void drawAtlas(const sk_sp< DlImage > atlas, const SkRSXform xform[], const SkRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const SkRect *cull_rect, bool render_with_attributes)=0
virtual void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt)=0
virtual void drawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length)=0
virtual void translate(SkScalar tx, SkScalar ty)=0
virtual void scale(SkScalar sx, SkScalar sy)=0
virtual void setImageFilter(const DlImageFilter *filter)=0
virtual void setColorSource(const DlColorSource *source)=0
virtual void rotate(SkScalar degrees)=0
virtual void drawPaint()=0
virtual bool PrefersImpellerPaths() const
virtual void setDrawStyle(DlDrawStyle style)=0
virtual void drawTextBlob(const sk_sp< SkTextBlob > blob, SkScalar x, SkScalar y)=0
virtual void setBlendMode(DlBlendMode mode)=0
virtual void transformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt)=0
virtual void setColor(DlColor color)=0
Holds all of the data (both required and optional) for a DisplayList drawVertices call.
#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes)
#define DEFINE_SET_BOOL_OP(name)
#define DEFINE_DRAW_IMAGE_OP(name, with_attributes)
#define DEFINE_DRAW_SHADOW_OP(name, transparent_occluder)
#define DEFINE_DRAW_2ARG_OP(op_name, type1, name1, type2, name2)
#define DEFINE_CLIP_SHAPE_OP(shapetype, clipop)
#define DEFINE_CLIP_PATH_OP(clipop)
#define DEFINE_SET_CLEAR_DLATTR_OP(name, sk_name, field)
#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name)
#define DEFINE_SET_ENUM_OP(name)
sk_sp< const SkImage > image
sk_sp< SkBlender > blender SkRect rect
PODArray< SkColor > colors
SkSamplingOptions sampling
void DrawImage(SkCanvas *canvas, const SkImage *image, SkScalar x, SkScalar y, const SkSamplingOptions &sampling={}, const SkPaint *paint=nullptr, SkCanvas::SrcRectConstraint constraint=SkCanvas::kFast_SrcRectConstraint)
impeller::Scalar DlScalar
bool Equals(const T *a, const T *b)
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
DEFINE_DRAW_POINTS_OP(Points, kPoints)
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 mode
SK_API sk_sp< PrecompileShader > ColorFilter(SkSpan< const sk_sp< PrecompileShader > > shaders, SkSpan< const sk_sp< PrecompileColorFilter > > colorFilters)
static constexpr uint32_t kRenderOpInc
DisplayListCompare equals(const DLOp *other) const
static constexpr uint32_t kDepthInc
SaveInfo(int previous_restore_index, bool save_was_needed)
int previous_restore_index
std::vector< SaveInfo > save_infos
DrawArcOp(SkRect bounds, SkScalar start, SkScalar sweep, bool center)
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
const sk_sp< DlImage > atlas
const uint16_t mode_index
DrawAtlasBaseOp(const sk_sp< DlImage > &atlas, int count, DlBlendMode mode, DlImageSampling sampling, bool has_colors, bool render_with_attributes)
bool equals(const DrawAtlasBaseOp *other, const void *pod_this, const void *pod_other) const
const uint8_t render_with_attributes
const DlImageSampling sampling
DisplayListCompare equals(const DrawAtlasCulledOp *other) const
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
DrawAtlasCulledOp(const sk_sp< DlImage > &atlas, int count, DlBlendMode mode, DlImageSampling sampling, bool has_colors, const SkRect &cull_rect, bool render_with_attributes)
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
DisplayListCompare equals(const DrawAtlasOp *other) const
DrawAtlasOp(const sk_sp< DlImage > &atlas, int count, DlBlendMode mode, DlImageSampling sampling, bool has_colors, bool render_with_attributes)
DrawColorOp(DlColor color, DlBlendMode mode)
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
DrawDashedLineOp(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length)
static constexpr auto kType
const SkScalar off_length
void dispatch(DispatchContext &ctx) const
DisplayListCompare equals(const DrawDisplayListOp *other) const
static constexpr auto kType
const sk_sp< DisplayList > display_list
DrawDisplayListOp(const sk_sp< DisplayList > &display_list, SkScalar opacity)
void dispatch(DispatchContext &ctx) const
const bool render_with_attributes
const sk_sp< DlImage > image
static constexpr auto kType
const DlImageSampling sampling
DrawImageRectOp(const sk_sp< DlImage > &image, const SkRect &src, const SkRect &dst, DlImageSampling sampling, bool render_with_attributes, DlCanvas::SrcRectConstraint constraint)
const DlCanvas::SrcRectConstraint constraint
void dispatch(DispatchContext &ctx) const
DisplayListCompare equals(const DrawImageRectOp *other) const
static constexpr uint32_t kRenderOpInc
bool op_needed(const DispatchContext &ctx) const
static constexpr uint32_t kDepthInc
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
DisplayListCompare equals(const DrawPathOp *other) const
DrawPathOp(const SkPath &path)
static constexpr auto kType
const DlOpReceiver::CacheablePath cached_path
void dispatch(DispatchContext &ctx) const
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
DrawTextBlobOp(const sk_sp< SkTextBlob > &blob, SkScalar x, SkScalar y)
const sk_sp< SkTextBlob > blob
const std::shared_ptr< impeller::TextFrame > text_frame
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
DrawTextFrameOp(const std::shared_ptr< impeller::TextFrame > &text_frame, SkScalar x, SkScalar y)
static constexpr auto kType
DrawVerticesOp(DlBlendMode mode)
void dispatch(DispatchContext &ctx) const
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
static constexpr uint32_t kRenderOpInc
static constexpr uint32_t kDepthInc
void dispatch(DispatchContext &ctx) const
RotateOp(SkScalar degrees)
static constexpr auto kType
DisplayListCompare equals(const SaveLayerBackdropOp *other) const
static constexpr auto kType
const std::shared_ptr< DlImageFilter > backdrop
SaveLayerBackdropOp(const SaveLayerOptions &options, const SkRect &rect, const DlImageFilter *backdrop)
void dispatch(DispatchContext &ctx) const
SaveLayerOpBase(const SaveLayerOptions &options, const SkRect &rect)
DlBlendMode max_blend_mode
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
SaveLayerOp(const SaveLayerOptions &options, const SkRect &rect)
uint32_t total_content_depth
static constexpr uint32_t kRenderOpInc
bool save_needed(DispatchContext &ctx) const
static constexpr uint32_t kDepthInc
SaveOpBase(const SaveLayerOptions &options)
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
ScaleOp(SkScalar sx, SkScalar sy)
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
SetBlendModeOp(DlBlendMode mode)
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
SetColorOp(DlColor color)
void dispatch(DispatchContext &ctx) const
SetImageColorSourceOp(const DlImageColorSource *source)
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
const DlImageColorSource source
SetRuntimeEffectColorSourceOp(const DlRuntimeEffectColorSource *source)
void dispatch(DispatchContext &ctx) const
const DlRuntimeEffectColorSource source
static constexpr auto kType
DisplayListCompare equals(const SetRuntimeEffectColorSourceOp *other) const
SetSharedImageFilterOp(const DlImageFilter *filter)
DisplayListCompare equals(const SetSharedImageFilterOp *other) const
const std::shared_ptr< DlImageFilter > filter
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
SetStrokeMiterOp(float limit)
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
static constexpr auto kType
SetStrokeWidthOp(float width)
void dispatch(DispatchContext &ctx) const
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
SetStyleOp(DlDrawStyle style)
SkewOp(SkScalar sx, SkScalar sy)
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
static constexpr auto kType
void dispatch(DispatchContext &ctx) const
TranslateOp(SkScalar tx, SkScalar ty)