Flutter Engine
 
Loading...
Searching...
No Matches
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 DlMatrix &matrix) const
 
const BoundsTolerance lineAdjust (const BoundsTolerance &tolerance, const DlPaint &paint, const DlMatrix &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 840 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 842 of file dl_rendering_unittests.cc.

TestParameters(const SkRenderer &sk_renderer, const DlRenderer &dl_renderer, const DisplayListAttributeFlags &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 847 of file dl_rendering_unittests.cc.

851 : sk_renderer_(sk_renderer),
852 dl_renderer_(dl_renderer),
853 imp_renderer_(imp_renderer),
854 flags_(flags) {}

Member Function Documentation

◆ adjust()

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

Definition at line 970 of file dl_rendering_unittests.cc.

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

References flutter::testing::BoundsTolerance::addBoundsPadding(), flutter::testing::BoundsTolerance::discrete_offset(), flutter::DlPaint::getDrawStyle(), flutter::DlPaint::getStrokeJoin(), flutter::DlPaint::getStrokeMiter(), flutter::DlPaint::getStrokeWidth(), is_draw_arc_center(), is_draw_line(), is_draw_text_blob(), flutter::kFill, flutter::kMiter, and lineAdjust().

Referenced by lineAdjust(), and flutter::testing::CanvasCompareTester::RenderWith().

◆ dl_renderer()

◆ getCap()

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

Definition at line 961 of file dl_rendering_unittests.cc.

962 {
963 DlStrokeCap cap = attr.getStrokeCap();
964 if (geo_flags.butt_cap_becomes_square() && cap == DlStrokeCap::kButt) {
966 }
967 return cap;
968 }
DlStrokeCap
Definition dl_paint.h:28
@ kButt
no stroke extension
@ kSquare
adds square

References flutter::DisplayListSpecialGeometryFlags::butt_cap_becomes_square(), flutter::DlPaint::getStrokeCap(), flutter::kButt, and flutter::kSquare.

Referenced by should_match().

◆ ignores_dashes()

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

Definition at line 1056 of file dl_rendering_unittests.cc.

1056{ return ignores_dashes_; }

◆ imp_renderer()

◆ impeller_compatible()

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

Definition at line 859 of file dl_rendering_unittests.cc.

859 {
860 if (is_draw_text_blob()) {
861 // Non-color text is rendered as paths
862 if (paint.getColorSourcePtr()) {
863 return false;
864 }
865 // Non-filled text (stroke or stroke and fill) is rendered as paths
866 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
867 return false;
868 }
869 }
870 return true;
871 }

References flutter::DlPaint::getColorSourcePtr(), flutter::DlPaint::getDrawStyle(), is_draw_text_blob(), and flutter::kFill.

Referenced by flutter::testing::CanvasCompareTester::RenderWith().

◆ is_draw_arc_center()

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

Definition at line 1052 of file dl_rendering_unittests.cc.

1052{ return is_draw_arc_center_; }

Referenced by adjust().

◆ is_draw_display_list()

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

Definition at line 1050 of file dl_rendering_unittests.cc.

1050{ return is_draw_display_list_; }

Referenced by flutter::testing::CanvasCompareTester::RenderWith().

◆ is_draw_line()

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

Definition at line 1051 of file dl_rendering_unittests.cc.

1051{ return is_draw_line_; }

Referenced by adjust().

◆ is_draw_path()

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

Definition at line 1053 of file dl_rendering_unittests.cc.

1053{ return is_draw_path_; }

Referenced by flutter::testing::CanvasCompareTester::RenderWithStrokes().

◆ is_draw_text_blob()

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

Definition at line 1049 of file dl_rendering_unittests.cc.

1049{ return is_draw_text_blob_; }

Referenced by adjust(), and impeller_compatible().

◆ is_horizontal_line()

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

Definition at line 1054 of file dl_rendering_unittests.cc.

1054{ return is_horizontal_line_; }

Referenced by lineAdjust().

◆ is_vertical_line()

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

Definition at line 1055 of file dl_rendering_unittests.cc.

1055{ return is_vertical_line_; }

Referenced by lineAdjust().

◆ lineAdjust()

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

Definition at line 996 of file dl_rendering_unittests.cc.

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

References flutter::testing::BoundsTolerance::addBoundsPadding(), adjust(), flutter::DisplayListSpecialGeometryFlags::butt_cap_becomes_square(), flutter::testing::BoundsTolerance::discrete_offset(), FML_DCHECK, flutter::DisplayListAttributeFlags::GeometryFlags(), flutter::DlPaint::getStrokeCap(), flutter::DlPaint::getStrokeMiter(), flutter::DlPaint::getStrokeWidth(), is_horizontal_line(), is_vertical_line(), and flutter::kButt.

Referenced by adjust().

◆ set_draw_arc_center()

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

Definition at line 1070 of file dl_rendering_unittests.cc.

1070 {
1071 is_draw_arc_center_ = true;
1072 return *this;
1073 }

◆ set_draw_display_list()

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

Definition at line 1062 of file dl_rendering_unittests.cc.

1062 {
1063 is_draw_display_list_ = true;
1064 return *this;
1065 }

◆ set_draw_line()

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

Definition at line 1066 of file dl_rendering_unittests.cc.

1066 {
1067 is_draw_line_ = true;
1068 return *this;
1069 }

◆ set_draw_path()

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

Definition at line 1074 of file dl_rendering_unittests.cc.

1074 {
1075 is_draw_path_ = true;
1076 return *this;
1077 }

◆ set_draw_text_blob()

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

Definition at line 1058 of file dl_rendering_unittests.cc.

1058 {
1059 is_draw_text_blob_ = true;
1060 return *this;
1061 }

◆ set_horizontal_line()

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

Definition at line 1082 of file dl_rendering_unittests.cc.

1082 {
1083 is_horizontal_line_ = true;
1084 return *this;
1085 }

Referenced by flutter::testing::TEST_F().

◆ set_ignores_dashes()

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

Definition at line 1078 of file dl_rendering_unittests.cc.

1078 {
1079 ignores_dashes_ = true;
1080 return *this;
1081 }

Referenced by flutter::testing::TEST_F().

◆ set_vertical_line()

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

Definition at line 1086 of file dl_rendering_unittests.cc.

1086 {
1087 is_vertical_line_ = true;
1088 return *this;
1089 }

Referenced by flutter::testing::TEST_F().

◆ 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 873 of file dl_rendering_unittests.cc.

876 {
877 if (caseP.has_mutating_save_layer()) {
878 return false;
879 }
880 if (env.ref_clip_bounds() != renderer.setup_clip_bounds() ||
881 caseP.has_diff_clip()) {
882 return false;
883 }
884 if (env.ref_matrix() != renderer.setup_matrix() && !flags_.is_flood()) {
885 return false;
886 }
887 if (flags_.ignores_paint()) {
888 return true;
889 }
890 const DlPaint& ref_attr = env.ref_dl_paint();
891 if (flags_.applies_anti_alias() && //
892 ref_attr.isAntiAlias() != attr.isAntiAlias()) {
893 if (renderer.targets_impeller()) {
894 // Impeller only does MSAA, ignoring the AA attribute
895 // https://github.com/flutter/flutter/issues/104721
896 } else {
897 return false;
898 }
899 }
900 if (flags_.applies_color() && //
901 ref_attr.getColor() != attr.getColor()) {
902 return false;
903 }
904 if (flags_.applies_blend() && //
905 ref_attr.getBlendMode() != attr.getBlendMode()) {
906 return false;
907 }
908 if (flags_.applies_color_filter() && //
909 (ref_attr.isInvertColors() != attr.isInvertColors() ||
910 NotEquals(ref_attr.getColorFilter(), attr.getColorFilter()))) {
911 return false;
912 }
913 if (flags_.applies_mask_filter() && //
914 NotEquals(ref_attr.getMaskFilter(), attr.getMaskFilter())) {
915 return false;
916 }
917 if (flags_.applies_image_filter() && //
918 ref_attr.getImageFilter() != attr.getImageFilter()) {
919 return false;
920 }
921 if (flags_.applies_shader() && //
922 NotEquals(ref_attr.getColorSource(), attr.getColorSource())) {
923 return false;
924 }
925
926 bool is_stroked = flags_.is_stroked(attr.getDrawStyle());
927 if (flags_.is_stroked(ref_attr.getDrawStyle()) != is_stroked) {
928 return false;
929 }
930 if (!is_stroked) {
931 return true;
932 }
933 if (ref_attr.getStrokeWidth() != attr.getStrokeWidth()) {
934 return false;
935 }
936 DisplayListSpecialGeometryFlags geo_flags =
937 flags_.GeometryFlags(is_stroked);
938 if (geo_flags.may_have_end_caps() && //
939 getCap(ref_attr, geo_flags) != getCap(attr, geo_flags)) {
940 return false;
941 }
942 if (geo_flags.may_have_joins()) {
943 if (ref_attr.getStrokeJoin() != attr.getStrokeJoin()) {
944 return false;
945 }
946 if (ref_attr.getStrokeJoin() == DlStrokeJoin::kMiter) {
947 DlScalar ref_miter = ref_attr.getStrokeMiter();
948 DlScalar test_miter = attr.getStrokeMiter();
949 // miter limit < 1.4 affects right angles
950 if (geo_flags.may_have_acute_joins() || //
951 ref_miter < 1.4 || test_miter < 1.4) {
952 if (ref_miter != test_miter) {
953 return false;
954 }
955 }
956 }
957 }
958 return true;
959 }
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_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
bool NotEquals(const T *a, const U *b)
flutter::DlPaint DlPaint

References flutter::DisplayListAttributeFlags::applies_anti_alias(), flutter::DisplayListAttributeFlags::applies_blend(), flutter::DisplayListAttributeFlags::applies_color(), flutter::DisplayListAttributeFlags::applies_color_filter(), flutter::DisplayListAttributeFlags::applies_image_filter(), flutter::DisplayListAttributeFlags::applies_mask_filter(), flutter::DisplayListAttributeFlags::applies_shader(), flutter::DisplayListAttributeFlags::GeometryFlags(), flutter::DlPaint::getBlendMode(), getCap(), flutter::DlPaint::getColor(), flutter::DlPaint::getColorFilter(), flutter::DlPaint::getColorSource(), flutter::DlPaint::getDrawStyle(), flutter::DlPaint::getImageFilter(), flutter::DlPaint::getMaskFilter(), flutter::DlPaint::getStrokeJoin(), flutter::DlPaint::getStrokeMiter(), flutter::DlPaint::getStrokeWidth(), flutter::testing::CaseParameters::has_diff_clip(), flutter::testing::CaseParameters::has_mutating_save_layer(), flutter::DisplayListAttributeFlags::ignores_paint(), flutter::DisplayListAttributeFlags::is_flood(), flutter::DisplayListAttributeFlags::is_stroked(), flutter::DlPaint::isAntiAlias(), flutter::DlPaint::isInvertColors(), flutter::kMiter, flutter::DisplayListSpecialGeometryFlags::may_have_acute_joins(), flutter::DisplayListSpecialGeometryFlags::may_have_end_caps(), flutter::DisplayListSpecialGeometryFlags::may_have_joins(), flutter::NotEquals(), flutter::testing::RenderEnvironment::ref_clip_bounds(), flutter::testing::RenderEnvironment::ref_dl_paint(), flutter::testing::RenderEnvironment::ref_matrix(), flutter::testing::MatrixClipJobRenderer::setup_clip_bounds(), flutter::testing::MatrixClipJobRenderer::setup_matrix(), and flutter::testing::JobRenderer::targets_impeller().

Referenced by flutter::testing::CanvasCompareTester::RenderWith().

◆ sk_renderer()

◆ uses_gradient()

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

◆ uses_paint()

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

Definition at line 856 of file dl_rendering_unittests.cc.

856{ return !flags_.ignores_paint(); }

References flutter::DisplayListAttributeFlags::ignores_paint().


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