Flutter Engine
The Flutter Engine
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 825 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 827 of file dl_rendering_unittests.cc.

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

836 : sk_renderer_(sk_renderer),
837 dl_renderer_(dl_renderer),
838 imp_renderer_(imp_renderer),
839 flags_(flags) {}
const DlRenderer & imp_renderer() const

Member Function Documentation

◆ adjust()

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

Definition at line 955 of file dl_rendering_unittests.cc.

957 {
958 if (is_draw_text_blob() && tolerance.discrete_offset() > 0) {
959 // drawTextBlob needs just a little more leeway when using a
960 // discrete path effect.
961 return tolerance.addBoundsPadding(2, 2);
962 }
963 if (is_draw_line()) {
964 return lineAdjust(tolerance, paint, matrix);
965 }
966 if (is_draw_arc_center()) {
967 if (paint.getDrawStyle() != DlDrawStyle::kFill &&
968 paint.getStrokeJoin() == DlStrokeJoin::kMiter) {
969 // the miter join at the center of an arc does not really affect
970 // its bounds in any of our test cases, but the bounds code needs
971 // to take it into account for the cases where it might, so we
972 // relax our tolerance to reflect the miter bounds padding.
973 SkScalar miter_pad =
974 paint.getStrokeMiter() * paint.getStrokeWidth() * 0.5f;
975 return tolerance.addBoundsPadding(miter_pad, miter_pad);
976 }
977 }
978 return tolerance;
979 }
const BoundsTolerance lineAdjust(const BoundsTolerance &tolerance, const DlPaint &paint, const SkMatrix &matrix) const
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
@ kMiter
extends to miter limit
@ kFill
fills interior of shapes

◆ dl_renderer()

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

Definition at line 1027 of file dl_rendering_unittests.cc.

1027{ return dl_renderer_; }

◆ getCap()

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

Definition at line 946 of file dl_rendering_unittests.cc.

947 {
948 DlStrokeCap cap = attr.getStrokeCap();
949 if (geo_flags.butt_cap_becomes_square() && cap == DlStrokeCap::kButt) {
951 }
952 return cap;
953 }
DlStrokeCap
Definition: dl_paint.h:28
@ kButt
no stroke extension
@ kSquare
adds square

◆ ignores_dashes()

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

Definition at line 1041 of file dl_rendering_unittests.cc.

1041{ return ignores_dashes_; }

◆ imp_renderer()

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

Definition at line 1028 of file dl_rendering_unittests.cc.

1028{ return imp_renderer_; }

◆ impeller_compatible()

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

Definition at line 844 of file dl_rendering_unittests.cc.

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

◆ is_draw_arc_center()

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

Definition at line 1037 of file dl_rendering_unittests.cc.

1037{ return is_draw_arc_center_; }

◆ is_draw_display_list()

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

Definition at line 1035 of file dl_rendering_unittests.cc.

1035{ return is_draw_display_list_; }

◆ is_draw_line()

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

Definition at line 1036 of file dl_rendering_unittests.cc.

1036{ return is_draw_line_; }

◆ is_draw_path()

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

Definition at line 1038 of file dl_rendering_unittests.cc.

1038{ return is_draw_path_; }

◆ is_draw_text_blob()

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

Definition at line 1034 of file dl_rendering_unittests.cc.

1034{ return is_draw_text_blob_; }

◆ is_horizontal_line()

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

Definition at line 1039 of file dl_rendering_unittests.cc.

1039{ return is_horizontal_line_; }

◆ is_vertical_line()

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

Definition at line 1040 of file dl_rendering_unittests.cc.

1040{ 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 981 of file dl_rendering_unittests.cc.

983 {
984 SkScalar adjust = 0.0;
985 SkScalar half_width = paint.getStrokeWidth() * 0.5f;
986 if (tolerance.discrete_offset() > 0) {
987 // When a discrete path effect is added, the bounds calculations must
988 // allow for miters in any direction, but a horizontal line will not
989 // have miters in the horizontal direction, similarly for vertical
990 // lines, and diagonal lines will have miters off at a "45 degree"
991 // angle that don't expand the bounds much at all.
992 // Also, the discrete offset will not move any points parallel with
993 // the line, so provide tolerance for both miters and offset.
994 adjust =
995 half_width * paint.getStrokeMiter() + tolerance.discrete_offset();
996 }
997
998 DisplayListSpecialGeometryFlags geo_flags = flags_.GeometryFlags(true);
999 if (paint.getStrokeCap() == DlStrokeCap::kButt &&
1000 !geo_flags.butt_cap_becomes_square()) {
1001 adjust = std::max(adjust, half_width);
1002 }
1003 if (adjust == 0) {
1004 return tolerance;
1005 }
1006 SkScalar h_tolerance;
1007 SkScalar v_tolerance;
1008 if (is_horizontal_line()) {
1010 h_tolerance = adjust;
1011 v_tolerance = 0;
1012 } else if (is_vertical_line()) {
1013 h_tolerance = 0;
1014 v_tolerance = adjust;
1015 } else {
1016 // The perpendicular miters just do not impact the bounds of
1017 // diagonal lines at all as they are aimed in the wrong direction
1018 // to matter. So allow tolerance in both axes.
1019 h_tolerance = v_tolerance = adjust;
1020 }
1021 BoundsTolerance new_tolerance =
1022 tolerance.addBoundsPadding(h_tolerance, v_tolerance);
1023 return new_tolerance;
1024 }
const DisplayListSpecialGeometryFlags GeometryFlags(bool is_stroked) const
Definition: dl_op_flags.h:165
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
static float max(float r, float g, float b)
Definition: hsl.cpp:49

◆ set_draw_arc_center()

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

Definition at line 1055 of file dl_rendering_unittests.cc.

1055 {
1056 is_draw_arc_center_ = true;
1057 return *this;
1058 }

◆ set_draw_display_list()

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

Definition at line 1047 of file dl_rendering_unittests.cc.

1047 {
1048 is_draw_display_list_ = true;
1049 return *this;
1050 }

◆ set_draw_line()

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

Definition at line 1051 of file dl_rendering_unittests.cc.

1051 {
1052 is_draw_line_ = true;
1053 return *this;
1054 }

◆ set_draw_path()

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

Definition at line 1059 of file dl_rendering_unittests.cc.

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

◆ set_draw_text_blob()

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

Definition at line 1043 of file dl_rendering_unittests.cc.

1043 {
1044 is_draw_text_blob_ = true;
1045 return *this;
1046 }

◆ set_horizontal_line()

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

Definition at line 1067 of file dl_rendering_unittests.cc.

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

◆ set_ignores_dashes()

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

Definition at line 1063 of file dl_rendering_unittests.cc.

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

◆ set_vertical_line()

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

Definition at line 1071 of file dl_rendering_unittests.cc.

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

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

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

◆ sk_renderer()

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

Definition at line 1026 of file dl_rendering_unittests.cc.

1026{ return sk_renderer_; }

◆ uses_gradient()

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

Definition at line 842 of file dl_rendering_unittests.cc.

842{ return flags_.applies_shader(); }

◆ uses_paint()

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

Definition at line 841 of file dl_rendering_unittests.cc.

841{ return !flags_.ignores_paint(); }

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