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 { receiver.set##name(value); } \
83#undef DEFINE_SET_BOOL_OP
86#define DEFINE_SET_ENUM_OP(name) \
87 struct SetStroke##name##Op final : DLOp { \
88 static constexpr auto kType = DisplayListOpType::kSetStroke##name; \
90 explicit SetStroke##name##Op(DlStroke##name value) \
91 : DLOp(kType), value(value) {} \
93 const DlStroke##name value; \
95 void dispatch(DlOpReceiver& receiver) const { \
96 receiver.setStroke##name(value); \
101#undef DEFINE_SET_ENUM_OP
105 static constexpr auto kType = DisplayListOpType::kSetStyle;
117 static constexpr auto kType = DisplayListOpType::kSetStrokeWidth;
129 static constexpr auto kType = DisplayListOpType::kSetStrokeMiter;
142 static constexpr auto kType = DisplayListOpType::kSetColor;
152 static constexpr auto kType = DisplayListOpType::kSetBlendMode;
169#define DEFINE_SET_CLEAR_DLATTR_OP(name, field) \
170 struct Clear##name##Op final : DLOp { \
171 static constexpr auto kType = DisplayListOpType::kClear##name; \
173 Clear##name##Op() : DLOp(kType) {} \
175 void dispatch(DlOpReceiver& receiver) const { \
176 receiver.set##name(nullptr); \
179 struct SetPod##name##Op final : DLOp { \
180 static constexpr auto kType = DisplayListOpType::kSetPod##name; \
182 SetPod##name##Op() : DLOp(kType) {} \
184 void dispatch(DlOpReceiver& receiver) const { \
185 const Dl##name* filter = reinterpret_cast<const Dl##name*>(this + 1); \
186 receiver.set##name(filter); \
193#undef DEFINE_SET_CLEAR_DLATTR_OP
198 static constexpr auto kType = DisplayListOpType::kSetImageColorSource;
203 source->horizontal_tile_mode(),
204 source->vertical_tile_mode(),
218 static constexpr auto kType = DisplayListOpType::kSetRuntimeEffectColorSource;
225 source->uniform_data()) {}
241 static constexpr auto kType = DisplayListOpType::kSetSharedImageFilter;
246 const std::shared_ptr<DlImageFilter>
filter;
283 static constexpr auto kType = DisplayListOpType::kSave;
305 static constexpr auto kType = DisplayListOpType::kSaveLayer;
317 static constexpr auto kType = DisplayListOpType::kSaveLayerBackdrop;
322 std::optional<int64_t> backdrop_id)
345 static constexpr auto kType = DisplayListOpType::kRestore;
365 static constexpr auto kType = DisplayListOpType::kTranslate;
380 static constexpr auto kType = DisplayListOpType::kScale;
394 static constexpr auto kType = DisplayListOpType::kRotate;
408 static constexpr auto kType = DisplayListOpType::kSkew;
423 static constexpr auto kType = DisplayListOpType::kTransform2DAffine;
444 static constexpr auto kType = DisplayListOpType::kTransformFullPerspective;
474 static constexpr auto kType = DisplayListOpType::kTransformReset;
493#define DEFINE_CLIP_SHAPE_OP(shapename, shapetype, clipop) \
494 struct Clip##clipop##shapename##Op final : TransformClipOpBase { \
495 static constexpr auto kType = DisplayListOpType::kClip##clipop##shapename; \
497 Clip##clipop##shapename##Op(shapetype shape, bool is_aa) \
498 : TransformClipOpBase(kType), is_aa(is_aa), shape(shape) {} \
501 const shapetype shape; \
503 void dispatch(DlOpReceiver& receiver) const { \
504 receiver.clip##shapename(shape, DlClipOp::k##clipop, is_aa); \
515#undef DEFINE_CLIP_SHAPE_OP
518#define DEFINE_CLIP_PATH_OP(clipop) \
519 struct Clip##clipop##PathOp final : TransformClipOpBase { \
520 static constexpr auto kType = DisplayListOpType::kClip##clipop##Path; \
522 Clip##clipop##PathOp(const DlPath& path, bool is_aa) \
523 : TransformClipOpBase(kType), is_aa(is_aa), path(path) {} \
528 void dispatch(DlOpReceiver& receiver) const { \
529 receiver.clipPath(path, DlClipOp::k##clipop, is_aa); \
532 DisplayListCompare equals(const Clip##clipop##PathOp* other) const { \
533 return is_aa == other->is_aa && path == other->path \
534 ? DisplayListCompare::kEqual \
535 : DisplayListCompare::kNotEqual; \
540#undef DEFINE_CLIP_PATH_OP
551 static constexpr auto kType = DisplayListOpType::kDrawPaint;
562 static constexpr auto kType = DisplayListOpType::kDrawColor;
582#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name) \
583 struct Draw##op_name##Op final : DrawOpBase { \
584 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
586 explicit Draw##op_name##Op(arg_type arg_name) \
587 : DrawOpBase(kType), arg_name(arg_name) {} \
589 const arg_type arg_name; \
591 void dispatch(DlOpReceiver& receiver) const { \
592 receiver.draw##op_name(arg_name); \
599#undef DEFINE_DRAW_1ARG_OP
604 static constexpr auto kType = DisplayListOpType::kDrawPath;
626#define DEFINE_DRAW_2ARG_OP(op_name, type1, name1, type2, name2) \
627 struct Draw##op_name##Op final : DrawOpBase { \
628 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
630 Draw##op_name##Op(type1 name1, type2 name2) \
631 : DrawOpBase(kType), name1(name1), name2(name2) {} \
636 void dispatch(DlOpReceiver& receiver) const { \
637 receiver.draw##op_name(name1, name2); \
643#undef DEFINE_DRAW_2ARG_OP
647 static constexpr auto kType = DisplayListOpType::kDrawDashedLine;
671 static constexpr auto kType = DisplayListOpType::kDrawArc;
696#define DEFINE_DRAW_POINTS_OP(name, mode) \
697 struct Draw##name##Op final : DrawOpBase { \
698 static constexpr auto kType = DisplayListOpType::kDraw##name; \
700 explicit Draw##name##Op(uint32_t count) \
701 : DrawOpBase(kType), count(count) {} \
703 const uint32_t count; \
705 void dispatch(DlOpReceiver& receiver) const { \
706 const DlPoint* pts = reinterpret_cast<const DlPoint*>(this + 1); \
707 receiver.drawPoints(DlPointMode::mode, count, pts); \
713#undef DEFINE_DRAW_POINTS_OP
717 static constexpr auto kType = DisplayListOpType::kDrawVertices;
733#define DEFINE_DRAW_IMAGE_OP(name, with_attributes) \
734 struct name##Op final : DrawOpBase { \
735 static constexpr auto kType = DisplayListOpType::k##name; \
737 name##Op(const sk_sp<DlImage>& image, \
738 const DlPoint& point, \
739 DlImageSampling sampling) \
740 : DrawOpBase(kType), \
742 sampling(sampling), \
743 image(std::move(image)) {} \
745 const DlPoint point; \
746 const DlImageSampling sampling; \
747 const sk_sp<DlImage> image; \
749 void dispatch(DlOpReceiver& receiver) const { \
750 receiver.drawImage(image, point, sampling, with_attributes); \
753 DisplayListCompare equals(const name##Op* other) const { \
754 return (point == other->point && sampling == other->sampling && \
755 image->Equals(other->image)) \
756 ? DisplayListCompare::kEqual \
757 : DisplayListCompare::kNotEqual; \
762#undef DEFINE_DRAW_IMAGE_OP
767 static constexpr auto kType = DisplayListOpType::kDrawImageRect;
806#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes) \
807 struct name##Op final : DrawOpBase { \
808 static constexpr auto kType = DisplayListOpType::k##name; \
809 static constexpr uint32_t kDepthInc = 9; \
811 name##Op(const sk_sp<DlImage>& image, \
812 const DlIRect& center, \
815 : DrawOpBase(kType), \
819 image(std::move(image)) {} \
821 const DlIRect center; \
823 const DlFilterMode mode; \
824 const sk_sp<DlImage> image; \
826 void dispatch(DlOpReceiver& receiver) const { \
827 receiver.drawImageNine(image, center, dst, mode, \
828 render_with_attributes); \
831 DisplayListCompare equals(const name##Op* other) const { \
832 return (center == other->center && dst == other->dst && \
833 mode == other->mode && image->Equals(other->image)) \
834 ? DisplayListCompare::kEqual \
835 : DisplayListCompare::kNotEqual; \
840#undef DEFINE_DRAW_IMAGE_NINE_OP
851 const sk_sp<DlImage>&
atlas,
873 const void* pod_this,
874 const void* pod_other)
const {
884 ret = (memcmp(pod_this, pod_other, bytes) == 0);
893 static constexpr auto kType = DisplayListOpType::kDrawAtlas;
921 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
922 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
934 static constexpr auto kType = DisplayListOpType::kDrawAtlasCulled;
966 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
967 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
978 static constexpr auto kType = DisplayListOpType::kDrawDisplayList;
1002 static constexpr auto kType = DisplayListOpType::kDrawText;
1009 const std::shared_ptr<DlText>
text;
1021#define DEFINE_DRAW_SHADOW_OP(name, transparent_occluder) \
1022 struct Draw##name##Op final : DrawOpBase { \
1023 static constexpr auto kType = DisplayListOpType::kDraw##name; \
1025 Draw##name##Op(const DlPath& path, \
1027 DlScalar elevation, \
1029 : DrawOpBase(kType), \
1031 elevation(elevation), \
1035 const DlColor color; \
1036 const DlScalar elevation; \
1037 const DlScalar dpr; \
1038 const DlPath path; \
1040 void dispatch(DlOpReceiver& receiver) const { \
1041 receiver.drawShadow(path, color, elevation, transparent_occluder, dpr); \
1044 DisplayListCompare equals(const Draw##name##Op* other) const { \
1045 return color == other->color && elevation == other->elevation && \
1046 dpr == other->dpr && path == other->path \
1047 ? DisplayListCompare::kEqual \
1048 : DisplayListCompare::kNotEqual; \
1053#undef DEFINE_DRAW_SHADOW_OP
1055#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