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); \
235#undef DEFINE_SET_CLEAR_DLATTR_OP
240 static constexpr auto kType = DisplayListOpType::kSetImageColorSource;
244 source->horizontal_tile_mode(),
245 source->vertical_tile_mode(),
259 static constexpr auto kType = DisplayListOpType::kSetRuntimeEffectColorSource;
265 source->uniform_data()) {}
279#ifdef IMPELLER_ENABLE_3D
280struct SetSceneColorSourceOp : DLOp {
281 static constexpr auto kType = DisplayListOpType::kSetSceneColorSource;
283 explicit SetSceneColorSourceOp(
const DlSceneColorSource*
source)
286 const DlSceneColorSource
source;
288 void dispatch(DispatchContext& ctx)
const {
289 ctx.receiver.setColorSource(&
source);
293 return (
source == other->source) ? DisplayListCompare::kEqual
294 : DisplayListCompare::kNotEqual;
301 static constexpr auto kType = DisplayListOpType::kSetSharedImageFilter;
306 const std::shared_ptr<DlImageFilter>
filter;
345 static constexpr auto kType = DisplayListOpType::kSave;
365 static constexpr auto kType = DisplayListOpType::kSaveLayer;
378 static constexpr auto kType = DisplayListOpType::kSaveLayerBackdrop;
403 static constexpr auto kType = DisplayListOpType::kRestore;
411 if (
info.save_was_needed) {
430 static constexpr auto kType = DisplayListOpType::kTranslate;
446 static constexpr auto kType = DisplayListOpType::kScale;
461 static constexpr auto kType = DisplayListOpType::kRotate;
476 static constexpr auto kType = DisplayListOpType::kSkew;
492 static constexpr auto kType = DisplayListOpType::kTransform2DAffine;
513 static constexpr auto kType = DisplayListOpType::kTransformFullPerspective;
544 static constexpr auto kType = DisplayListOpType::kTransformReset;
565#define DEFINE_CLIP_SHAPE_OP(shapetype, clipop) \
566 struct Clip##clipop##shapetype##Op final : TransformClipOpBase { \
567 static constexpr auto kType = DisplayListOpType::kClip##clipop##shapetype; \
569 Clip##clipop##shapetype##Op(Sk##shapetype shape, bool is_aa) \
570 : is_aa(is_aa), shape(shape) {} \
573 const Sk##shapetype shape; \
575 void dispatch(DispatchContext& ctx) const { \
576 if (op_needed(ctx)) { \
577 ctx.receiver.clip##shapetype(shape, DlCanvas::ClipOp::k##clipop, \
586#undef DEFINE_CLIP_SHAPE_OP
588#define DEFINE_CLIP_PATH_OP(clipop) \
589 struct Clip##clipop##PathOp final : TransformClipOpBase { \
590 static constexpr auto kType = DisplayListOpType::kClip##clipop##Path; \
592 Clip##clipop##PathOp(const SkPath& path, bool is_aa) \
593 : is_aa(is_aa), cached_path(path) {} \
596 const DlOpReceiver::CacheablePath cached_path; \
598 void dispatch(DispatchContext& ctx) const { \
599 if (op_needed(ctx)) { \
600 if (ctx.receiver.PrefersImpellerPaths()) { \
601 ctx.receiver.clipPath(cached_path, DlCanvas::ClipOp::k##clipop, \
604 ctx.receiver.clipPath(cached_path.sk_path, \
605 DlCanvas::ClipOp::k##clipop, is_aa); \
610 DisplayListCompare equals(const Clip##clipop##PathOp* other) const { \
611 return is_aa == other->is_aa && cached_path == other->cached_path \
612 ? DisplayListCompare::kEqual \
613 : DisplayListCompare::kNotEqual; \
618#undef DEFINE_CLIP_PATH_OP
631 static constexpr auto kType = DisplayListOpType::kDrawPaint;
644 static constexpr auto kType = DisplayListOpType::kDrawColor;
663#define DEFINE_DRAW_1ARG_OP(op_name, arg_type, arg_name) \
664 struct Draw##op_name##Op final : DrawOpBase { \
665 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
667 explicit Draw##op_name##Op(arg_type arg_name) : arg_name(arg_name) {} \
669 const arg_type arg_name; \
671 void dispatch(DispatchContext& ctx) const { \
672 if (op_needed(ctx)) { \
673 ctx.receiver.draw##op_name(arg_name); \
680#undef DEFINE_DRAW_1ARG_OP
685 static constexpr auto kType = DisplayListOpType::kDrawPath;
713#define DEFINE_DRAW_2ARG_OP(op_name, type1, name1, type2, name2) \
714 struct Draw##op_name##Op final : DrawOpBase { \
715 static constexpr auto kType = DisplayListOpType::kDraw##op_name; \
717 Draw##op_name##Op(type1 name1, type2 name2) \
718 : name1(name1), name2(name2) {} \
723 void dispatch(DispatchContext& ctx) const { \
724 if (op_needed(ctx)) { \
725 ctx.receiver.draw##op_name(name1, name2); \
732#undef DEFINE_DRAW_2ARG_OP
736 static constexpr auto kType = DisplayListOpType::kDrawArc;
759#define DEFINE_DRAW_POINTS_OP(name, mode) \
760 struct Draw##name##Op final : DrawOpBase { \
761 static constexpr auto kType = DisplayListOpType::kDraw##name; \
763 explicit Draw##name##Op(uint32_t count) : count(count) {} \
765 const uint32_t count; \
767 void dispatch(DispatchContext& ctx) const { \
768 if (op_needed(ctx)) { \
769 const SkPoint* pts = reinterpret_cast<const SkPoint*>(this + 1); \
770 ctx.receiver.drawPoints(DlCanvas::PointMode::mode, count, pts); \
777#undef DEFINE_DRAW_POINTS_OP
787 static constexpr auto kType = DisplayListOpType::kDrawVertices;
796 reinterpret_cast<const DlVertices*
>(
this + 1);
804#define DEFINE_DRAW_IMAGE_OP(name, with_attributes) \
805 struct name##Op final : DrawOpBase { \
806 static constexpr auto kType = DisplayListOpType::k##name; \
808 name##Op(const sk_sp<DlImage>& image, \
809 const SkPoint& point, \
810 DlImageSampling sampling) \
811 : point(point), sampling(sampling), image(std::move(image)) {} \
813 const SkPoint point; \
814 const DlImageSampling sampling; \
815 const sk_sp<DlImage> image; \
817 void dispatch(DispatchContext& ctx) const { \
818 if (op_needed(ctx)) { \
819 ctx.receiver.drawImage(image, point, sampling, with_attributes); \
823 DisplayListCompare equals(const name##Op* other) const { \
824 return (point == other->point && sampling == other->sampling && \
825 image->Equals(other->image)) \
826 ? DisplayListCompare::kEqual \
827 : DisplayListCompare::kNotEqual; \
832#undef DEFINE_DRAW_IMAGE_OP
837 static constexpr auto kType = DisplayListOpType::kDrawImageRect;
877#define DEFINE_DRAW_IMAGE_NINE_OP(name, render_with_attributes) \
878 struct name##Op final : DrawOpBase { \
879 static constexpr auto kType = DisplayListOpType::k##name; \
881 name##Op(const sk_sp<DlImage>& image, \
882 const SkIRect& center, \
885 : center(center), dst(dst), mode(mode), image(std::move(image)) {} \
887 const SkIRect center; \
889 const DlFilterMode mode; \
890 const sk_sp<DlImage> image; \
892 void dispatch(DispatchContext& ctx) const { \
893 if (op_needed(ctx)) { \
894 ctx.receiver.drawImageNine(image, center, dst, mode, \
895 render_with_attributes); \
899 DisplayListCompare equals(const name##Op* other) const { \
900 return (center == other->center && dst == other->dst && \
901 mode == other->mode && image->Equals(other->image)) \
902 ? DisplayListCompare::kEqual \
903 : DisplayListCompare::kNotEqual; \
908#undef DEFINE_DRAW_IMAGE_NINE_OP
939 const void* pod_this,
940 const void* pod_other)
const {
950 ret = (memcmp(pod_this, pod_other, bytes) == 0);
959 static constexpr auto kType = DisplayListOpType::kDrawAtlas;
987 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
988 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
1000 static constexpr auto kType = DisplayListOpType::kDrawAtlasCulled;
1032 const void* pod_this =
reinterpret_cast<const void*
>(
this + 1);
1033 const void* pod_other =
reinterpret_cast<const void*
>(other + 1);
1044 static constexpr auto kType = DisplayListOpType::kDrawDisplayList;
1070 static constexpr auto kType = DisplayListOpType::kDrawTextBlob;
1087 static constexpr auto kType = DisplayListOpType::kDrawTextFrame;
1106#define DEFINE_DRAW_SHADOW_OP(name, transparent_occluder) \
1107 struct Draw##name##Op final : DrawOpBase { \
1108 static constexpr auto kType = DisplayListOpType::kDraw##name; \
1110 Draw##name##Op(const SkPath& path, \
1112 SkScalar elevation, \
1114 : color(color), elevation(elevation), dpr(dpr), cached_path(path) {} \
1116 const DlColor color; \
1117 const SkScalar elevation; \
1118 const SkScalar dpr; \
1119 const DlOpReceiver::CacheablePath cached_path; \
1121 void dispatch(DispatchContext& ctx) const { \
1122 if (op_needed(ctx)) { \
1123 if (ctx.receiver.PrefersImpellerPaths()) { \
1124 ctx.receiver.drawShadow(cached_path, color, elevation, \
1125 transparent_occluder, dpr); \
1127 ctx.receiver.drawShadow(cached_path.sk_path, color, elevation, \
1128 transparent_occluder, dpr); \
1133 DisplayListCompare equals(const Draw##name##Op* other) const { \
1134 return color == other->color && elevation == other->elevation && \
1135 dpr == other->dpr && cached_path == other->cached_path \
1136 ? DisplayListCompare::kEqual \
1137 : DisplayListCompare::kNotEqual; \
1142#undef DEFINE_DRAW_SHADOW_OP
1144#pragma pack(pop, DLOpPackLabel)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static bool equals(T *a, T *b)
static SkScalar center(float pos0, float pos1)
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 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_DRAW_POINTS_OP(name, mode)
#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)
static const SkPoint kPoints[kNumLabels]
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
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
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
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)
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)