@@ -831,6 +831,13 @@ struct DrawVerticesOp final : DrawOpBase {
831
831
if (op_needed (ctx)) { \
832
832
ctx.dispatcher .drawImage (image, point, sampling, with_attributes); \
833
833
} \
834
+ } \
835
+ \
836
+ DisplayListCompare equals (const name##Op* other) const { \
837
+ return (point == other->point && sampling == other->sampling && \
838
+ image->Equals (other->image )) \
839
+ ? DisplayListCompare::kEqual \
840
+ : DisplayListCompare::kNotEqual ; \
834
841
} \
835
842
};
836
843
DEFINE_DRAW_IMAGE_OP (DrawImage, false )
@@ -868,30 +875,46 @@ struct DrawImageRectOp final : DrawOpBase {
868
875
render_with_attributes, constraint);
869
876
}
870
877
}
878
+
879
+ DisplayListCompare equals (const DrawImageRectOp* other) const {
880
+ return (src == other->src && dst == other->dst &&
881
+ sampling == other->sampling &&
882
+ render_with_attributes == other->render_with_attributes &&
883
+ constraint == other->constraint && image->Equals (other->image ))
884
+ ? DisplayListCompare::kEqual
885
+ : DisplayListCompare::kNotEqual ;
886
+ }
871
887
};
872
888
873
889
// 4 byte header + 44 byte payload packs efficiently into 48 bytes
874
- #define DEFINE_DRAW_IMAGE_NINE_OP (name, render_with_attributes ) \
875
- struct name ##Op final : DrawOpBase { \
876
- static const auto kType = DisplayListOpType::k##name; \
877
- \
878
- name##Op(const sk_sp<DlImage> image, \
879
- const SkIRect& center, \
880
- const SkRect& dst, \
881
- DlFilterMode filter) \
882
- : center(center), dst(dst), filter(filter), image(std::move(image)) {} \
883
- \
884
- const SkIRect center; \
885
- const SkRect dst; \
886
- const DlFilterMode filter; \
887
- const sk_sp<DlImage> image; \
888
- \
889
- void dispatch (DispatchContext& ctx) const { \
890
- if (op_needed (ctx)) { \
891
- ctx.dispatcher .drawImageNine (image, center, dst, filter, \
892
- render_with_attributes); \
893
- } \
894
- } \
890
+ #define DEFINE_DRAW_IMAGE_NINE_OP (name, render_with_attributes ) \
891
+ struct name ##Op final : DrawOpBase { \
892
+ static const auto kType = DisplayListOpType::k##name; \
893
+ \
894
+ name##Op(const sk_sp<DlImage> image, \
895
+ const SkIRect& center, \
896
+ const SkRect& dst, \
897
+ DlFilterMode mode) \
898
+ : center(center), dst(dst), mode(mode), image(std::move(image)) {} \
899
+ \
900
+ const SkIRect center; \
901
+ const SkRect dst; \
902
+ const DlFilterMode mode; \
903
+ const sk_sp<DlImage> image; \
904
+ \
905
+ void dispatch (DispatchContext& ctx) const { \
906
+ if (op_needed (ctx)) { \
907
+ ctx.dispatcher .drawImageNine (image, center, dst, mode, \
908
+ render_with_attributes); \
909
+ } \
910
+ } \
911
+ \
912
+ DisplayListCompare equals (const name##Op* other) const { \
913
+ return (center == other->center && dst == other->dst && \
914
+ mode == other->mode && image->Equals (other->image )) \
915
+ ? DisplayListCompare::kEqual \
916
+ : DisplayListCompare::kNotEqual ; \
917
+ } \
895
918
};
896
919
DEFINE_DRAW_IMAGE_NINE_OP (DrawImageNine, false )
897
920
DEFINE_DRAW_IMAGE_NINE_OP(DrawImageNineWithAttr, true )
@@ -924,6 +947,23 @@ struct DrawAtlasBaseOp : DrawOpBase {
924
947
const uint8_t render_with_attributes;
925
948
const DlImageSampling sampling;
926
949
const sk_sp<DlImage> atlas;
950
+
951
+ bool equals (const DrawAtlasBaseOp* other,
952
+ const void * pod_this,
953
+ const void * pod_other) const {
954
+ bool ret = (count == other->count && mode_index == other->mode_index &&
955
+ has_colors == other->has_colors &&
956
+ render_with_attributes == other->render_with_attributes &&
957
+ sampling == other->sampling && atlas->Equals (other->atlas ));
958
+ if (ret) {
959
+ size_t bytes = count * (sizeof (SkRSXform) + sizeof (SkRect));
960
+ if (has_colors) {
961
+ bytes += count * sizeof (DlColor);
962
+ }
963
+ ret = (memcmp (pod_this, pod_other, bytes) == 0 );
964
+ }
965
+ return ret;
966
+ }
927
967
};
928
968
929
969
// Packs into 48 bytes as per DrawAtlasBaseOp
@@ -955,6 +995,14 @@ struct DrawAtlasOp final : DrawAtlasBaseOp {
955
995
nullptr , render_with_attributes);
956
996
}
957
997
}
998
+
999
+ DisplayListCompare equals (const DrawAtlasOp* other) const {
1000
+ const void * pod_this = reinterpret_cast <const void *>(this + 1 );
1001
+ const void * pod_other = reinterpret_cast <const void *>(other + 1 );
1002
+ return (DrawAtlasBaseOp::equals (other, pod_this, pod_other))
1003
+ ? DisplayListCompare::kEqual
1004
+ : DisplayListCompare::kNotEqual ;
1005
+ }
958
1006
};
959
1007
960
1008
// Packs into 48 bytes as per DrawAtlasBaseOp plus
@@ -992,6 +1040,15 @@ struct DrawAtlasCulledOp final : DrawAtlasBaseOp {
992
1040
&cull_rect, render_with_attributes);
993
1041
}
994
1042
}
1043
+
1044
+ DisplayListCompare equals (const DrawAtlasCulledOp* other) const {
1045
+ const void * pod_this = reinterpret_cast <const void *>(this + 1 );
1046
+ const void * pod_other = reinterpret_cast <const void *>(other + 1 );
1047
+ return (cull_rect == other->cull_rect &&
1048
+ DrawAtlasBaseOp::equals (other, pod_this, pod_other))
1049
+ ? DisplayListCompare::kEqual
1050
+ : DisplayListCompare::kNotEqual ;
1051
+ }
995
1052
};
996
1053
997
1054
// 4 byte header + ptr aligned payload uses 12 bytes round up to 16
0 commit comments