5#ifndef FLUTTER_DISPLAY_LIST_DL_OP_RECORDS_H_
6#define FLUTTER_DISPLAY_LIST_DL_OP_RECORDS_H_
45#pragma pack(push, DLOpPackLabel, 8)
71#define DEFINE_SET_BOOL_OP(name) \
72 struct Set##name##Op final : DLOp { \
73 static constexpr auto kType = DisplayListOpType::kSet##name; \
75 explicit Set##name##Op(bool value) : DLOp(kType), value(value) {} \
79 void dispatch(DlOpReceiver& receiver) const { \
80 receiver.set##name(value); \
85#undef DEFINE_SET_BOOL_OP
88#define DEFINE_SET_ENUM_OP(name) \
89 struct SetStroke##name##Op final : DLOp { \
90 static constexpr auto kType = DisplayListOpType::kSetStroke##name; \
92 explicit SetStroke##name##Op(DlStroke##name value) \
93 : DLOp(kType), value(value) {} \
95 const DlStroke##name value; \
97 void dispatch(DlOpReceiver& receiver) const { \
98 receiver.setStroke##name(value); \
103#undef DEFINE_SET_ENUM_OP
107 static constexpr auto kType = DisplayListOpType::kSetStyle;
119 static constexpr auto kType = DisplayListOpType::kSetStrokeWidth;
131 static constexpr auto kType = DisplayListOpType::kSetStrokeMiter;
144 static constexpr auto kType = DisplayListOpType::kSetColor;
154 static constexpr auto kType = DisplayListOpType::kSetBlendMode;
171#define DEFINE_SET_CLEAR_DLATTR_OP(name, field) \
172 struct Clear##name##Op final : DLOp { \
173 static constexpr auto kType = DisplayListOpType::kClear##name; \
175 Clear##name##Op() : DLOp(kType) {} \
177 void dispatch(DlOpReceiver& receiver) const { \
178 receiver.set##name(nullptr); \
181 struct SetPod##name##Op final : DLOp { \
182 static constexpr auto kType = DisplayListOpType::kSetPod##name; \
184 SetPod##name##Op() : DLOp(kType) {} \
186 void dispatch(DlOpReceiver& receiver) const { \
187 const Dl##name* filter = reinterpret_cast<const Dl##name*>(this + 1); \
188 receiver.set##name(filter); \
195#undef DEFINE_SET_CLEAR_DLATTR_OP
200 static constexpr auto kType = DisplayListOpType::kSetImageColorSource;
205 source->horizontal_tile_mode(),
206 source->vertical_tile_mode(),
220 static constexpr auto kType = DisplayListOpType::kSetRuntimeEffectColorSource;
227 source->uniform_data()) {}
243 static constexpr auto kType = DisplayListOpType::kSetSharedImageFilter;
248 const std::shared_ptr<DlImageFilter>
filter;
285 static constexpr auto kType = DisplayListOpType::kSave;
307 static constexpr auto kType = DisplayListOpType::kSaveLayer;
319 static constexpr auto kType = DisplayListOpType::kSaveLayerBackdrop;
324 std::optional<int64_t> backdrop_id)
347 static constexpr auto kType = DisplayListOpType::kRestore;
367 static constexpr auto kType = DisplayListOpType::kTranslate;
382 static constexpr auto kType = DisplayListOpType::kScale;
396 static constexpr auto kType = DisplayListOpType::kRotate;
410 static constexpr auto kType = DisplayListOpType::kSkew;
425 static constexpr auto kType = DisplayListOpType::kTransform2DAffine;
446 static constexpr auto kType = DisplayListOpType::kTransformFullPerspective;
476 static constexpr auto kType = DisplayListOpType::kTransformReset;
495#define DEFINE_CLIP_SHAPE_OP(shapename, shapetype, clipop) \
496 struct Clip##clipop##shapename##Op final : TransformClipOpBase { \
497 static constexpr auto kType = DisplayListOpType::kClip##clipop##shapename; \
499 Clip##clipop##shapename##Op(shapetype shape, bool is_aa) \
500 : TransformClipOpBase(kType), is_aa(is_aa), shape(shape) {} \
503 const shapetype shape; \
505 void dispatch(DlOpReceiver& receiver) const { \
506 receiver.clip##shapename(shape, DlClipOp::k##clipop, is_aa); \
517#undef DEFINE_CLIP_SHAPE_OP
520#define DEFINE_CLIP_PATH_OP(clipop) \
521 struct Clip##clipop##PathOp final : TransformClipOpBase { \
522 static constexpr auto kType = DisplayListOpType::kClip##clipop##Path; \
524 Clip##clipop##PathOp(const DlPath& path, bool is_aa) \
525 : TransformClipOpBase(kType), is_aa(is_aa), path(path) {} \
530 void dispatch(DlOpReceiver& receiver) const { \
531 receiver.clipPath(path, DlClipOp::k##clipop, is_aa); \
534 DisplayListCompare equals(const Clip##clipop##PathOp* other) const { \
535 return is_aa == other->is_aa && path == other->path \
536 ? DisplayListCompare::kEqual \
537 : DisplayListCompare::kNotEqual; \
542#undef DEFINE_CLIP_PATH_OP
553 static constexpr auto kType = DisplayListOpType::kDrawPaint;
564 static constexpr auto kType = DisplayListOpType::kDrawColor;
584#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name) \
585 struct Draw##op_name##Op final : DrawOpBase { \
586 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
588 explicit Draw##op_name##Op(arg_type arg_name) \
589 : DrawOpBase(kType), arg_name(arg_name) {} \
591 const arg_type arg_name; \
593 void dispatch(DlOpReceiver& receiver) const { \
594 receiver.draw##op_name(arg_name); \
601#undef DEFINE_DRAW_1ARG_OP
606 static constexpr auto kType = DisplayListOpType::kDrawPath;
628#define DEFINE_DRAW_2ARG_OP(op_name, type1, name1, type2, name2) \
629 struct Draw##op_name##Op final : DrawOpBase { \
630 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
632 Draw##op_name##Op(type1 name1, type2 name2) \
633 : DrawOpBase(kType), name1(name1), name2(name2) {} \
638 void dispatch(DlOpReceiver& receiver) const { \
639 receiver.draw##op_name(name1, name2); \
645#undef DEFINE_DRAW_2ARG_OP
649 static constexpr auto kType = DisplayListOpType::kDrawDashedLine;
673 static constexpr auto kType = DisplayListOpType::kDrawArc;
698#define DEFINE_DRAW_POINTS_OP(name, mode) \
699 struct Draw##name##Op final : DrawOpBase { \
700 static constexpr auto kType = DisplayListOpType::kDraw##name; \
702 explicit Draw##name##Op(uint32_t count) \
703 : DrawOpBase(kType), count(count) {} \
705 const uint32_t count; \
707 void dispatch(DlOpReceiver& receiver) const { \
708 const DlPoint* pts = reinterpret_cast<const DlPoint*>(this + 1); \
709 receiver.drawPoints(DlPointMode::mode, count, pts); \
715#undef DEFINE_DRAW_POINTS_OP
719 static constexpr auto kType = DisplayListOpType::kDrawVertices;
735#define DEFINE_DRAW_IMAGE_OP(name, with_attributes) \
736 struct name##Op final : DrawOpBase { \
737 static constexpr auto kType = DisplayListOpType::k##name; \
739 name##Op(const sk_sp<DlImage>& image, \
740 const DlPoint& point, \
741 DlImageSampling sampling) \
742 : DrawOpBase(kType), \
744 sampling(sampling), \
745 image(std::move(image)) {} \
747 const DlPoint point; \
748 const DlImageSampling sampling; \
749 const sk_sp<DlImage> image; \
751 void dispatch(DlOpReceiver& receiver) const { \
752 receiver.drawImage(image, point, sampling, with_attributes); \
755 DisplayListCompare equals(const name##Op* other) const { \
756 return (point == other->point && sampling == other->sampling && \
757 image->Equals(other->image)) \
758 ? DisplayListCompare::kEqual \
759 : DisplayListCompare::kNotEqual; \
764#undef DEFINE_DRAW_IMAGE_OP
769 static constexpr auto kType = DisplayListOpType::kDrawImageRect;
808#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes) \
809 struct name##Op final : DrawOpBase { \
810 static constexpr auto kType = DisplayListOpType::k##name; \
811 static constexpr uint32_t kDepthInc = 9; \
813 name##Op(const sk_sp<DlImage>& image, \
814 const DlIRect& center, \
817 : DrawOpBase(kType), \
821 image(std::move(image)) {} \
823 const DlIRect center; \
825 const DlFilterMode mode; \
826 const sk_sp<DlImage> image; \
828 void dispatch(DlOpReceiver& receiver) const { \
829 receiver.drawImageNine(image, center, dst, mode, \
830 render_with_attributes); \
833 DisplayListCompare equals(const name##Op* other) const { \
834 return (center == other->center && dst == other->dst && \
835 mode == other->mode && image->Equals(other->image)) \
836 ? DisplayListCompare::kEqual \
837 : DisplayListCompare::kNotEqual; \
842#undef DEFINE_DRAW_IMAGE_NINE_OP
853 const sk_sp<DlImage>&
atlas,
875 const void* pod_this,
876 const void* pod_other)
const {
886 ret = (memcmp(pod_this, pod_other, bytes) == 0);
895 static constexpr auto kType = DisplayListOpType::kDrawAtlas;
923 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
924 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
936 static constexpr auto kType = DisplayListOpType::kDrawAtlasCulled;
968 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
969 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
980 static constexpr auto kType = DisplayListOpType::kDrawDisplayList;
1004 static constexpr auto kType = DisplayListOpType::kDrawText;
1011 const std::shared_ptr<DlText>
text;
1023#define DEFINE_DRAW_SHADOW_OP(name, transparent_occluder) \
1024 struct Draw##name##Op final : DrawOpBase { \
1025 static constexpr auto kType = DisplayListOpType::kDraw##name; \
1027 Draw##name##Op(const DlPath& path, \
1029 DlScalar elevation, \
1031 : DrawOpBase(kType), \
1033 elevation(elevation), \
1037 const DlColor color; \
1038 const DlScalar elevation; \
1039 const DlScalar dpr; \
1040 const DlPath path; \
1042 void dispatch(DlOpReceiver& receiver) const { \
1043 receiver.drawShadow(path, color, elevation, transparent_occluder, dpr); \
1046 DisplayListCompare equals(const Draw##name##Op* other) const { \
1047 return color == other->color && elevation == other->elevation && \
1048 dpr == other->dpr && path == other->path \
1049 ? DisplayListCompare::kEqual \
1050 : DisplayListCompare::kNotEqual; \
1055#undef DEFINE_DRAW_SHADOW_OP
1057#pragma pack(pop, DLOpPackLabel)
Internal API for rendering recorded display lists to backends.
virtual void drawText(const std::shared_ptr< DlText > &text, DlScalar x, DlScalar y)=0
virtual void setStrokeMiter(float limit)=0
virtual void transformReset()=0
virtual void drawPath(const DlPath &path)=0
virtual void drawImageRect(const sk_sp< DlImage > image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, bool render_with_attributes, DlSrcRectConstraint constraint=DlSrcRectConstraint::kFast)=0
virtual void drawArc(const DlRect &oval_bounds, DlScalar start_degrees, DlScalar sweep_degrees, bool use_center)=0
virtual void translate(DlScalar tx, DlScalar ty)=0
virtual void scale(DlScalar sx, DlScalar sy)=0
virtual void setStrokeWidth(float width)=0
virtual void rotate(DlScalar degrees)=0
virtual void drawVertices(const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode)=0
virtual void drawDisplayList(const sk_sp< DisplayList > display_list, DlScalar opacity=SK_Scalar1)=0
virtual void transform2DAffine(DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt)=0
virtual void transformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt)=0
virtual void skew(DlScalar sx, DlScalar sy)=0
virtual void drawColor(DlColor color, DlBlendMode mode)=0
virtual void drawAtlas(const sk_sp< DlImage > atlas, const DlRSTransform xform[], const DlRect tex[], const DlColor colors[], int count, DlBlendMode mode, DlImageSampling sampling, const DlRect *cull_rect, bool render_with_attributes)=0
virtual void drawDashedLine(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length)=0
virtual void setImageFilter(const DlImageFilter *filter)=0
virtual void setColorSource(const DlColorSource *source)=0
virtual void drawPaint()=0
virtual void setDrawStyle(DlDrawStyle style)=0
virtual void setBlendMode(DlBlendMode mode)=0
virtual void setColor(DlColor color)=0
virtual void saveLayer(const DlRect &bounds, const SaveLayerOptions options, const DlImageFilter *backdrop=nullptr, std::optional< int64_t > backdrop_id=std::nullopt)=0
#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes)
#define DEFINE_SET_BOOL_OP(name)
#define DEFINE_CLIP_SHAPE_OP(shapename, shapetype, clipop)
#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_DRAW_POINTS_OP(name, mode)
#define DEFINE_CLIP_PATH_OP(clipop)
#define DEFINE_SET_CLEAR_DLATTR_OP(name, field)
#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name)
#define DEFINE_SET_ENUM_OP(name)
FlutterVulkanImage * image
impeller::Scalar DlScalar
impeller::RoundRect DlRoundRect
impeller::RSTransform DlRSTransform
impeller::RoundSuperellipse DlRoundSuperellipse
@ kLines
draw each separate pair of points as a line segment
@ kPolygon
draw each pair of overlapping points as a line segment
@ kPoints
draw each point separately
bool Equals(const T *a, const U *b)
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all 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
Join
An enum that describes ways to join two segments of a path.
Cap
An enum that describes ways to decorate the end of a path contour.
static constexpr uint32_t kRenderOpInc
DisplayListCompare equals(const DLOp *other) const
DLOp(DisplayListOpType type)
const DisplayListOpType type
static constexpr uint32_t kDepthInc
DrawArcOp(DlRect bounds, DlScalar start, DlScalar sweep, bool center)
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
DrawAtlasBaseOp(DisplayListOpType type, const sk_sp< DlImage > &atlas, int count, DlBlendMode mode, DlImageSampling sampling, bool has_colors, bool render_with_attributes)
const sk_sp< DlImage > atlas
const uint16_t mode_index
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
DrawAtlasCulledOp(const sk_sp< DlImage > &atlas, int count, DlBlendMode mode, DlImageSampling sampling, bool has_colors, const DlRect &cull_rect, bool render_with_attributes)
void dispatch(DlOpReceiver &receiver) const
void dispatch(DlOpReceiver &receiver) 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(DlOpReceiver &receiver) const
DrawDashedLineOp(const DlPoint &p0, const DlPoint &p1, DlScalar on_length, DlScalar off_length)
void dispatch(DlOpReceiver &receiver) const
const DlScalar off_length
static constexpr auto kType
DrawDisplayListOp(const sk_sp< DisplayList > &display_list, DlScalar opacity)
DisplayListCompare equals(const DrawDisplayListOp *other) const
static constexpr auto kType
const sk_sp< DisplayList > display_list
void dispatch(DlOpReceiver &receiver) const
const bool render_with_attributes
const sk_sp< DlImage > image
static constexpr auto kType
const DlSrcRectConstraint constraint
const DlImageSampling sampling
DrawImageRectOp(const sk_sp< DlImage > &image, const DlRect &src, const DlRect &dst, DlImageSampling sampling, bool render_with_attributes, DlSrcRectConstraint constraint)
DisplayListCompare equals(const DrawImageRectOp *other) const
void dispatch(DlOpReceiver &receiver) const
static constexpr uint32_t kRenderOpInc
DrawOpBase(DisplayListOpType type)
static constexpr uint32_t kDepthInc
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
DisplayListCompare equals(const DrawPathOp *other) const
static constexpr auto kType
DrawPathOp(const DlPath &path)
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
DrawTextOp(const std::shared_ptr< DlText > &text, DlScalar x, DlScalar y)
DisplayListCompare equals(const DrawTextOp *other) const
const std::shared_ptr< DlText > text
void dispatch(DlOpReceiver &receiver) const
const std::shared_ptr< DlVertices > vertices
DrawVerticesOp(const std::shared_ptr< DlVertices > &vertices, DlBlendMode mode)
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
static constexpr uint32_t kRenderOpInc
static constexpr uint32_t kDepthInc
RotateOp(DlScalar degrees)
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
void dispatch(DlOpReceiver &receiver) const
SaveLayerBackdropOp(const SaveLayerOptions &options, const DlRect &rect, const DlImageFilter *backdrop, std::optional< int64_t > backdrop_id)
DisplayListCompare equals(const SaveLayerBackdropOp *other) const
static constexpr auto kType
const std::shared_ptr< DlImageFilter > backdrop
std::optional< int64_t > backdrop_id_
SaveLayerOpBase(DisplayListOpType type, const SaveLayerOptions &options, const DlRect &rect)
DlBlendMode max_blend_mode
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
SaveLayerOp(const SaveLayerOptions &options, const DlRect &rect)
uint32_t total_content_depth
SaveOpBase(DisplayListOpType type)
static constexpr uint32_t kRenderOpInc
SaveOpBase(DisplayListOpType type, const SaveLayerOptions &options)
static constexpr uint32_t kDepthInc
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
ScaleOp(DlScalar sx, DlScalar sy)
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
SetBlendModeOp(DlBlendMode mode)
static constexpr auto kType
SetColorOp(DlColor color)
void dispatch(DlOpReceiver &receiver) const
SetImageColorSourceOp(const DlImageColorSource *source)
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
const DlImageColorSource source
SetRuntimeEffectColorSourceOp(const DlRuntimeEffectColorSource *source)
void dispatch(DlOpReceiver &receiver) 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(DlOpReceiver &receiver) const
static constexpr auto kType
SetStrokeMiterOp(float limit)
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
SetStrokeWidthOp(float width)
void dispatch(DlOpReceiver &receiver) const
static constexpr auto kType
SetStyleOp(DlDrawStyle style)
void dispatch(DlOpReceiver &receiver) const
SkewOp(DlScalar sx, DlScalar sy)
static constexpr auto kType
static constexpr auto kType
TranslateOp(DlScalar tx, DlScalar ty)
void dispatch(DlOpReceiver &receiver) const