Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
flutter::testing::TestParameters Class Reference

Public Member Functions

 TestParameters (const SkRenderer &sk_renderer, const DlRenderer &dl_renderer, const DisplayListAttributeFlags &flags)
 
 TestParameters (const SkRenderer &sk_renderer, const DlRenderer &dl_renderer, const DlRenderer &imp_renderer, const DisplayListAttributeFlags &flags)
 
bool uses_paint () const
 
bool uses_gradient () const
 
bool impeller_compatible (const DlPaint &paint) const
 
bool should_match (const RenderEnvironment &env, const CaseParameters &caseP, const DlPaint &attr, const MatrixClipJobRenderer &renderer) const
 
DlStrokeCap getCap (const DlPaint &attr, DisplayListSpecialGeometryFlags geo_flags) const
 
const BoundsTolerance adjust (const BoundsTolerance &tolerance, const DlPaint &paint, const SkMatrix &matrix) const
 
const BoundsTolerance lineAdjust (const BoundsTolerance &tolerance, const DlPaint &paint, const SkMatrix &matrix) const
 
const SkRenderersk_renderer () const
 
const DlRendererdl_renderer () const
 
const DlRendererimp_renderer () const
 
bool is_draw_text_blob () const
 
bool is_draw_display_list () const
 
bool is_draw_line () const
 
bool is_draw_arc_center () const
 
bool is_draw_path () const
 
bool is_horizontal_line () const
 
bool is_vertical_line () const
 
bool ignores_dashes () const
 
TestParametersset_draw_text_blob ()
 
TestParametersset_draw_display_list ()
 
TestParametersset_draw_line ()
 
TestParametersset_draw_arc_center ()
 
TestParametersset_draw_path ()
 
TestParametersset_ignores_dashes ()
 
TestParametersset_horizontal_line ()
 
TestParametersset_vertical_line ()
 

Detailed Description

Definition at line 820 of file dl_rendering_unittests.cc.

Constructor & Destructor Documentation

◆ TestParameters() [1/2]

flutter::testing::TestParameters::TestParameters ( const SkRenderer sk_renderer,
const DlRenderer dl_renderer,
const DisplayListAttributeFlags flags 
)
inline

Definition at line 822 of file dl_rendering_unittests.cc.

TestParameters(const SkRenderer &sk_renderer, const DlRenderer &dl_renderer, const DisplayListAttributeFlags &flags)
FlutterSemanticsFlag flags

◆ TestParameters() [2/2]

flutter::testing::TestParameters::TestParameters ( const SkRenderer sk_renderer,
const DlRenderer dl_renderer,
const DlRenderer imp_renderer,
const DisplayListAttributeFlags flags 
)
inline

Definition at line 827 of file dl_rendering_unittests.cc.

831 : sk_renderer_(sk_renderer),
832 dl_renderer_(dl_renderer),
833 imp_renderer_(imp_renderer),
834 flags_(flags) {}

Member Function Documentation

◆ adjust()

const BoundsTolerance flutter::testing::TestParameters::adjust ( const BoundsTolerance tolerance,
const DlPaint paint,
const SkMatrix matrix 
) const
inline

Definition at line 966 of file dl_rendering_unittests.cc.

968 {
969 if (is_draw_text_blob() && tolerance.discrete_offset() > 0) {
970 // drawTextBlob needs just a little more leeway when using a
971 // discrete path effect.
972 return tolerance.addBoundsPadding(2, 2);
973 }
974 if (is_draw_line()) {
975 return lineAdjust(tolerance, paint, matrix);
976 }
977 if (is_draw_arc_center()) {
978 if (paint.getDrawStyle() != DlDrawStyle::kFill &&
979 paint.getStrokeJoin() == DlStrokeJoin::kMiter) {
980 // the miter join at the center of an arc does not really affect
981 // its bounds in any of our test cases, but the bounds code needs
982 // to take it into account for the cases where it might, so we
983 // relax our tolerance to reflect the miter bounds padding.
984 SkScalar miter_pad =
985 paint.getStrokeMiter() * paint.getStrokeWidth() * 0.5f;
986 return tolerance.addBoundsPadding(miter_pad, miter_pad);
987 }
988 }
989 return tolerance;
990 }
const BoundsTolerance lineAdjust(const BoundsTolerance &tolerance, const DlPaint &paint, const SkMatrix &matrix) const
const Paint & paint
float SkScalar
Definition extension.cpp:12
@ kMiter
extends to miter limit
@ kFill
fills interior of shapes

◆ dl_renderer()

const DlRenderer & flutter::testing::TestParameters::dl_renderer ( ) const
inline

Definition at line 1040 of file dl_rendering_unittests.cc.

1040{ return dl_renderer_; }

◆ getCap()

DlStrokeCap flutter::testing::TestParameters::getCap ( const DlPaint attr,
DisplayListSpecialGeometryFlags  geo_flags 
) const
inline

Definition at line 957 of file dl_rendering_unittests.cc.

958 {
959 DlStrokeCap cap = attr.getStrokeCap();
960 if (geo_flags.butt_cap_becomes_square() && cap == DlStrokeCap::kButt) {
962 }
963 return cap;
964 }
DlStrokeCap
Definition dl_paint.h:29
@ kButt
no stroke extension
@ kSquare
adds square

◆ ignores_dashes()

bool flutter::testing::TestParameters::ignores_dashes ( ) const
inline

Definition at line 1054 of file dl_rendering_unittests.cc.

1054{ return ignores_dashes_; }

◆ imp_renderer()

const DlRenderer & flutter::testing::TestParameters::imp_renderer ( ) const
inline

Definition at line 1041 of file dl_rendering_unittests.cc.

1041{ return imp_renderer_; }

◆ impeller_compatible()

bool flutter::testing::TestParameters::impeller_compatible ( const DlPaint paint) const
inline

Definition at line 839 of file dl_rendering_unittests.cc.

839 {
840 if (is_draw_text_blob()) {
841 // Non-color text is rendered as paths
842 if (paint.getColorSourcePtr() && !paint.getColorSourcePtr()->asColor()) {
843 return false;
844 }
845 // Non-filled text (stroke or stroke and fill) is rendered as paths
846 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
847 return false;
848 }
849 }
850 return true;
851 }

◆ is_draw_arc_center()

bool flutter::testing::TestParameters::is_draw_arc_center ( ) const
inline

Definition at line 1050 of file dl_rendering_unittests.cc.

1050{ return is_draw_arc_center_; }

◆ is_draw_display_list()

bool flutter::testing::TestParameters::is_draw_display_list ( ) const
inline

Definition at line 1048 of file dl_rendering_unittests.cc.

1048{ return is_draw_display_list_; }

◆ is_draw_line()

bool flutter::testing::TestParameters::is_draw_line ( ) const
inline

Definition at line 1049 of file dl_rendering_unittests.cc.

1049{ return is_draw_line_; }

◆ is_draw_path()

bool flutter::testing::TestParameters::is_draw_path ( ) const
inline

Definition at line 1051 of file dl_rendering_unittests.cc.

1051{ return is_draw_path_; }

◆ is_draw_text_blob()

bool flutter::testing::TestParameters::is_draw_text_blob ( ) const
inline

Definition at line 1047 of file dl_rendering_unittests.cc.

1047{ return is_draw_text_blob_; }

◆ is_horizontal_line()

bool flutter::testing::TestParameters::is_horizontal_line ( ) const
inline

Definition at line 1052 of file dl_rendering_unittests.cc.

1052{ return is_horizontal_line_; }

◆ is_vertical_line()

bool flutter::testing::TestParameters::is_vertical_line ( ) const
inline

Definition at line 1053 of file dl_rendering_unittests.cc.

1053{ return is_vertical_line_; }

◆ lineAdjust()

const BoundsTolerance flutter::testing::TestParameters::lineAdjust ( const BoundsTolerance tolerance,
const DlPaint paint,
const SkMatrix matrix 
) const
inline

Definition at line 992 of file dl_rendering_unittests.cc.

994 {
995 SkScalar adjust = 0.0;
996 SkScalar half_width = paint.getStrokeWidth() * 0.5f;
997 if (tolerance.discrete_offset() > 0) {
998 // When a discrete path effect is added, the bounds calculations must
999 // allow for miters in any direction, but a horizontal line will not
1000 // have miters in the horizontal direction, similarly for vertical
1001 // lines, and diagonal lines will have miters off at a "45 degree"
1002 // angle that don't expand the bounds much at all.
1003 // Also, the discrete offset will not move any points parallel with
1004 // the line, so provide tolerance for both miters and offset.
1005 adjust =
1006 half_width * paint.getStrokeMiter() + tolerance.discrete_offset();
1007 }
1008 auto path_effect = paint.getPathEffect();
1009
1010 DisplayListSpecialGeometryFlags geo_flags =
1011 flags_.WithPathEffect(path_effect.get(), true);
1012 if (paint.getStrokeCap() == DlStrokeCap::kButt &&
1013 !geo_flags.butt_cap_becomes_square()) {
1014 adjust = std::max(adjust, half_width);
1015 }
1016 if (adjust == 0) {
1017 return tolerance;
1018 }
1019 SkScalar h_tolerance;
1020 SkScalar v_tolerance;
1021 if (is_horizontal_line()) {
1023 h_tolerance = adjust;
1024 v_tolerance = 0;
1025 } else if (is_vertical_line()) {
1026 h_tolerance = 0;
1027 v_tolerance = adjust;
1028 } else {
1029 // The perpendicular miters just do not impact the bounds of
1030 // diagonal lines at all as they are aimed in the wrong direction
1031 // to matter. So allow tolerance in both axes.
1032 h_tolerance = v_tolerance = adjust;
1033 }
1034 BoundsTolerance new_tolerance =
1035 tolerance.addBoundsPadding(h_tolerance, v_tolerance);
1036 return new_tolerance;
1037 }
const DisplayListSpecialGeometryFlags WithPathEffect(const DlPathEffect *effect, bool is_stroked) const
BoundsTolerance addBoundsPadding(SkScalar bounds_pad_x, SkScalar bounds_pad_y) const
const BoundsTolerance adjust(const BoundsTolerance &tolerance, const DlPaint &paint, const SkMatrix &matrix) const
#define FML_DCHECK(condition)
Definition logging.h:103

◆ set_draw_arc_center()

TestParameters & flutter::testing::TestParameters::set_draw_arc_center ( )
inline

Definition at line 1068 of file dl_rendering_unittests.cc.

1068 {
1069 is_draw_arc_center_ = true;
1070 return *this;
1071 }

◆ set_draw_display_list()

TestParameters & flutter::testing::TestParameters::set_draw_display_list ( )
inline

Definition at line 1060 of file dl_rendering_unittests.cc.

1060 {
1061 is_draw_display_list_ = true;
1062 return *this;
1063 }

◆ set_draw_line()

TestParameters & flutter::testing::TestParameters::set_draw_line ( )
inline

Definition at line 1064 of file dl_rendering_unittests.cc.

1064 {
1065 is_draw_line_ = true;
1066 return *this;
1067 }

◆ set_draw_path()

TestParameters & flutter::testing::TestParameters::set_draw_path ( )
inline

Definition at line 1072 of file dl_rendering_unittests.cc.

1072 {
1073 is_draw_path_ = true;
1074 return *this;
1075 }

◆ set_draw_text_blob()

TestParameters & flutter::testing::TestParameters::set_draw_text_blob ( )
inline

Definition at line 1056 of file dl_rendering_unittests.cc.

1056 {
1057 is_draw_text_blob_ = true;
1058 return *this;
1059 }

◆ set_horizontal_line()

TestParameters & flutter::testing::TestParameters::set_horizontal_line ( )
inline

Definition at line 1080 of file dl_rendering_unittests.cc.

1080 {
1081 is_horizontal_line_ = true;
1082 return *this;
1083 }

◆ set_ignores_dashes()

TestParameters & flutter::testing::TestParameters::set_ignores_dashes ( )
inline

Definition at line 1076 of file dl_rendering_unittests.cc.

1076 {
1077 ignores_dashes_ = true;
1078 return *this;
1079 }

◆ set_vertical_line()

TestParameters & flutter::testing::TestParameters::set_vertical_line ( )
inline

Definition at line 1084 of file dl_rendering_unittests.cc.

1084 {
1085 is_vertical_line_ = true;
1086 return *this;
1087 }

◆ should_match()

bool flutter::testing::TestParameters::should_match ( const RenderEnvironment env,
const CaseParameters caseP,
const DlPaint attr,
const MatrixClipJobRenderer renderer 
) const
inline

Definition at line 853 of file dl_rendering_unittests.cc.

856 {
857 if (caseP.has_mutating_save_layer()) {
858 return false;
859 }
860 if (env.ref_clip_bounds() != renderer.setup_clip_bounds() ||
861 caseP.has_diff_clip()) {
862 return false;
863 }
864 if (env.ref_matrix() != renderer.setup_matrix() && !flags_.is_flood()) {
865 return false;
866 }
867 if (flags_.ignores_paint()) {
868 return true;
869 }
870 const DlPaint& ref_attr = env.ref_dl_paint();
871 if (flags_.applies_anti_alias() && //
872 ref_attr.isAntiAlias() != attr.isAntiAlias()) {
873 if (renderer.targets_impeller()) {
874 // Impeller only does MSAA, ignoring the AA attribute
875 // https://github.com/flutter/flutter/issues/104721
876 } else {
877 return false;
878 }
879 }
880 if (flags_.applies_color() && //
881 ref_attr.getColor() != attr.getColor()) {
882 return false;
883 }
884 if (flags_.applies_blend() && //
885 ref_attr.getBlendMode() != attr.getBlendMode()) {
886 return false;
887 }
888 if (flags_.applies_color_filter() && //
889 (ref_attr.isInvertColors() != attr.isInvertColors() ||
890 NotEquals(ref_attr.getColorFilter(), attr.getColorFilter()))) {
891 return false;
892 }
893 if (flags_.applies_mask_filter() && //
894 NotEquals(ref_attr.getMaskFilter(), attr.getMaskFilter())) {
895 return false;
896 }
897 if (flags_.applies_image_filter() && //
898 ref_attr.getImageFilter() != attr.getImageFilter()) {
899 return false;
900 }
901 if (flags_.applies_shader() && //
902 NotEquals(ref_attr.getColorSource(), attr.getColorSource())) {
903 return false;
904 }
905
906 bool is_stroked = flags_.is_stroked(attr.getDrawStyle());
907 if (flags_.is_stroked(ref_attr.getDrawStyle()) != is_stroked) {
908 return false;
909 }
910 DisplayListSpecialGeometryFlags geo_flags =
911 flags_.WithPathEffect(attr.getPathEffect().get(), is_stroked);
912 if (flags_.applies_path_effect() && //
913 ref_attr.getPathEffect() != attr.getPathEffect()) {
914 if (renderer.targets_impeller()) {
915 // Impeller ignores DlPathEffect objects:
916 // https://github.com/flutter/flutter/issues/109736
917 } else {
918 switch (attr.getPathEffect()->type()) {
920 if (is_stroked && !ignores_dashes()) {
921 return false;
922 }
923 break;
924 }
925 }
926 }
927 }
928 if (!is_stroked) {
929 return true;
930 }
931 if (ref_attr.getStrokeWidth() != attr.getStrokeWidth()) {
932 return false;
933 }
934 if (geo_flags.may_have_end_caps() && //
935 getCap(ref_attr, geo_flags) != getCap(attr, geo_flags)) {
936 return false;
937 }
938 if (geo_flags.may_have_joins()) {
939 if (ref_attr.getStrokeJoin() != attr.getStrokeJoin()) {
940 return false;
941 }
942 if (ref_attr.getStrokeJoin() == DlStrokeJoin::kMiter) {
943 SkScalar ref_miter = ref_attr.getStrokeMiter();
944 SkScalar test_miter = attr.getStrokeMiter();
945 // miter limit < 1.4 affects right angles
946 if (geo_flags.may_have_acute_joins() || //
947 ref_miter < 1.4 || test_miter < 1.4) {
948 if (ref_miter != test_miter) {
949 return false;
950 }
951 }
952 }
953 }
954 return true;
955 }
constexpr bool applies_color() const
constexpr bool is_stroked(DlDrawStyle style=DlDrawStyle::kStroke) const
constexpr bool applies_color_filter() const
constexpr bool ignores_paint() const
constexpr bool applies_image_filter() const
constexpr bool applies_path_effect() const
constexpr bool applies_shader() const
constexpr bool applies_anti_alias() const
constexpr bool applies_mask_filter() const
constexpr bool applies_blend() const
The primitive honors the DlBlendMode.
constexpr bool is_flood() const
DlStrokeCap getCap(const DlPaint &attr, DisplayListSpecialGeometryFlags geo_flags) const
Definition __init__.py:1
bool NotEquals(const T *a, const T *b)

◆ sk_renderer()

const SkRenderer & flutter::testing::TestParameters::sk_renderer ( ) const
inline

Definition at line 1039 of file dl_rendering_unittests.cc.

1039{ return sk_renderer_; }

◆ uses_gradient()

bool flutter::testing::TestParameters::uses_gradient ( ) const
inline

Definition at line 837 of file dl_rendering_unittests.cc.

837{ return flags_.applies_shader(); }

◆ uses_paint()

bool flutter::testing::TestParameters::uses_paint ( ) const
inline

Definition at line 836 of file dl_rendering_unittests.cc.

836{ return !flags_.ignores_paint(); }

The documentation for this class was generated from the following file: