Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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 841 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 843 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 848 of file dl_rendering_unittests.cc.

852 : sk_renderer_(sk_renderer),
853 dl_renderer_(dl_renderer),
854 imp_renderer_(imp_renderer),
855 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 971 of file dl_rendering_unittests.cc.

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

963 {
964 DlStrokeCap cap = attr.getStrokeCap();
965 if (geo_flags.butt_cap_becomes_square() && cap == DlStrokeCap::kButt) {
967 }
968 return cap;
969 }
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 1057 of file dl_rendering_unittests.cc.

1057{ return ignores_dashes_; }

◆ imp_renderer()

◆ impeller_compatible()

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

Definition at line 860 of file dl_rendering_unittests.cc.

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

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

1053{ 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 1051 of file dl_rendering_unittests.cc.

1051{ 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 1052 of file dl_rendering_unittests.cc.

1052{ return is_draw_line_; }

Referenced by adjust().

◆ is_draw_path()

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

Definition at line 1054 of file dl_rendering_unittests.cc.

1054{ 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 1050 of file dl_rendering_unittests.cc.

1050{ 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 1055 of file dl_rendering_unittests.cc.

1055{ return is_horizontal_line_; }

Referenced by lineAdjust().

◆ is_vertical_line()

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

Definition at line 1056 of file dl_rendering_unittests.cc.

1056{ 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 997 of file dl_rendering_unittests.cc.

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

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

◆ set_draw_display_list()

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

Definition at line 1063 of file dl_rendering_unittests.cc.

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

◆ set_draw_line()

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

Definition at line 1067 of file dl_rendering_unittests.cc.

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

◆ set_draw_path()

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

Definition at line 1075 of file dl_rendering_unittests.cc.

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

◆ set_draw_text_blob()

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

Definition at line 1059 of file dl_rendering_unittests.cc.

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

◆ set_horizontal_line()

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

Definition at line 1083 of file dl_rendering_unittests.cc.

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

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

◆ set_ignores_dashes()

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

Definition at line 1079 of file dl_rendering_unittests.cc.

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

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

◆ set_vertical_line()

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

Definition at line 1087 of file dl_rendering_unittests.cc.

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

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

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

857{ return !flags_.ignores_paint(); }

References flutter::DisplayListAttributeFlags::ignores_paint().


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