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 DlRenderer &dl_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 DlRendererdl_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
 
DisplayListAttributeFlags flags () 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 652 of file dl_rendering_unittests.cc.

Constructor & Destructor Documentation

◆ TestParameters()

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

Definition at line 654 of file dl_rendering_unittests.cc.

656 : dl_renderer_(dl_renderer), flags_(flags) {}
DisplayListAttributeFlags flags() const

Member Function Documentation

◆ adjust()

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

Definition at line 773 of file dl_rendering_unittests.cc.

775 {
776 if (is_draw_text_blob() && tolerance.discrete_offset() > 0) {
777 // drawTextBlob needs just a little more leeway when using a
778 // discrete path effect.
779 return tolerance.addBoundsPadding(2, 2);
780 }
781 if (is_draw_line()) {
782 return lineAdjust(tolerance, paint, matrix);
783 }
784 if (is_draw_arc_center()) {
785 if (paint.getDrawStyle() != DlDrawStyle::kFill &&
786 paint.getStrokeJoin() == DlStrokeJoin::kMiter) {
787 // the miter join at the center of an arc does not really affect
788 // its bounds in any of our test cases, but the bounds code needs
789 // to take it into account for the cases where it might, so we
790 // relax our tolerance to reflect the miter bounds padding.
791 DlScalar miter_pad =
792 paint.getStrokeMiter() * paint.getStrokeWidth() * 0.5f;
793 return tolerance.addBoundsPadding(miter_pad, miter_pad);
794 }
795 }
796 return tolerance;
797 }
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().

◆ dl_renderer()

◆ flags()

DisplayListAttributeFlags flutter::testing::TestParameters::flags ( ) const
inline

Definition at line 859 of file dl_rendering_unittests.cc.

859{ return flags_; }

◆ getCap()

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

Definition at line 764 of file dl_rendering_unittests.cc.

765 {
766 DlStrokeCap cap = attr.getStrokeCap();
767 if (geo_flags.butt_cap_becomes_square() && cap == DlStrokeCap::kButt) {
769 }
770 return cap;
771 }
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 857 of file dl_rendering_unittests.cc.

857{ return ignores_dashes_; }

◆ impeller_compatible()

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

Definition at line 661 of file dl_rendering_unittests.cc.

661 {
662 if (is_draw_text_blob()) {
663 // Non-color text is rendered as paths
664 if (paint.getColorSourcePtr()) {
665 return false;
666 }
667 // Non-filled text (stroke or stroke and fill) is rendered as paths
668 if (paint.getDrawStyle() != DlDrawStyle::kFill) {
669 return false;
670 }
671 }
672 return true;
673 }

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

◆ is_draw_arc_center()

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

Definition at line 853 of file dl_rendering_unittests.cc.

853{ 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 851 of file dl_rendering_unittests.cc.

851{ return is_draw_display_list_; }

◆ is_draw_line()

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

Definition at line 852 of file dl_rendering_unittests.cc.

852{ return is_draw_line_; }

Referenced by adjust().

◆ is_draw_path()

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

Definition at line 854 of file dl_rendering_unittests.cc.

854{ 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 850 of file dl_rendering_unittests.cc.

850{ 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 855 of file dl_rendering_unittests.cc.

855{ return is_horizontal_line_; }

Referenced by lineAdjust().

◆ is_vertical_line()

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

Definition at line 856 of file dl_rendering_unittests.cc.

856{ 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 799 of file dl_rendering_unittests.cc.

801 {
802 DlScalar adjust = 0.0;
803 DlScalar half_width = paint.getStrokeWidth() * 0.5f;
804 if (tolerance.discrete_offset() > 0) {
805 // When a discrete path effect is added, the bounds calculations must
806 // allow for miters in any direction, but a horizontal line will not
807 // have miters in the horizontal direction, similarly for vertical
808 // lines, and diagonal lines will have miters off at a "45 degree"
809 // angle that don't expand the bounds much at all.
810 // Also, the discrete offset will not move any points parallel with
811 // the line, so provide tolerance for both miters and offset.
812 adjust =
813 half_width * paint.getStrokeMiter() + tolerance.discrete_offset();
814 }
815
816 DisplayListSpecialGeometryFlags geo_flags = flags_.GeometryFlags(true);
817 if (paint.getStrokeCap() == DlStrokeCap::kButt &&
818 !geo_flags.butt_cap_becomes_square()) {
819 adjust = std::max(adjust, half_width);
820 }
821 if (adjust == 0) {
822 return tolerance;
823 }
824 DlScalar h_tolerance;
825 DlScalar v_tolerance;
826 if (is_horizontal_line()) {
828 h_tolerance = adjust;
829 v_tolerance = 0;
830 } else if (is_vertical_line()) {
831 h_tolerance = 0;
832 v_tolerance = adjust;
833 } else {
834 // The perpendicular miters just do not impact the bounds of
835 // diagonal lines at all as they are aimed in the wrong direction
836 // to matter. So allow tolerance in both axes.
837 h_tolerance = v_tolerance = adjust;
838 }
839 BoundsTolerance new_tolerance =
840 tolerance.addBoundsPadding(h_tolerance, v_tolerance);
841 return new_tolerance;
842 }
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 873 of file dl_rendering_unittests.cc.

873 {
874 is_draw_arc_center_ = true;
875 return *this;
876 }

◆ set_draw_display_list()

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

Definition at line 865 of file dl_rendering_unittests.cc.

865 {
866 is_draw_display_list_ = true;
867 return *this;
868 }

◆ set_draw_line()

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

Definition at line 869 of file dl_rendering_unittests.cc.

869 {
870 is_draw_line_ = true;
871 return *this;
872 }

◆ set_draw_path()

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

Definition at line 877 of file dl_rendering_unittests.cc.

877 {
878 is_draw_path_ = true;
879 return *this;
880 }

◆ set_draw_text_blob()

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

Definition at line 861 of file dl_rendering_unittests.cc.

861 {
862 is_draw_text_blob_ = true;
863 return *this;
864 }

◆ set_horizontal_line()

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

Definition at line 885 of file dl_rendering_unittests.cc.

885 {
886 is_horizontal_line_ = true;
887 return *this;
888 }

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

◆ set_ignores_dashes()

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

Definition at line 881 of file dl_rendering_unittests.cc.

881 {
882 ignores_dashes_ = true;
883 return *this;
884 }

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

◆ set_vertical_line()

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

Definition at line 889 of file dl_rendering_unittests.cc.

889 {
890 is_vertical_line_ = true;
891 return *this;
892 }

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

678 {
679 if (caseP.has_mutating_save_layer()) {
680 return false;
681 }
682 if (env.GetReferenceClipBounds() != renderer.GetSetupClipBounds() ||
683 caseP.has_diff_clip()) {
684 return false;
685 }
686 if (env.GetReferenceMatrix() != renderer.GetSetupMatrix() &&
687 !flags_.is_flood()) {
688 return false;
689 }
690 if (flags_.ignores_paint()) {
691 return true;
692 }
693 const DlPaint& ref_attr = env.GetReferencePaint();
694 if (flags_.applies_anti_alias() && //
695 ref_attr.isAntiAlias() != attr.isAntiAlias()) {
696 if (env.GetProvider()->TargetsImpeller()) {
697 // Impeller only does MSAA, ignoring the AA attribute
698 // https://github.com/flutter/flutter/issues/104721
699 } else {
700 return false;
701 }
702 }
703 if (flags_.applies_color() && //
704 ref_attr.getColor() != attr.getColor()) {
705 return false;
706 }
707 if (flags_.applies_blend() && //
708 ref_attr.getBlendMode() != attr.getBlendMode()) {
709 return false;
710 }
711 if (flags_.applies_color_filter() && //
712 (ref_attr.isInvertColors() != attr.isInvertColors() ||
713 NotEquals(ref_attr.getColorFilter(), attr.getColorFilter()))) {
714 return false;
715 }
716 if (flags_.applies_mask_filter() && //
717 NotEquals(ref_attr.getMaskFilter(), attr.getMaskFilter())) {
718 return false;
719 }
720 if (flags_.applies_image_filter() && //
721 ref_attr.getImageFilter() != attr.getImageFilter()) {
722 return false;
723 }
724 if (flags_.applies_shader() && //
725 NotEquals(ref_attr.getColorSource(), attr.getColorSource())) {
726 return false;
727 }
728
729 bool is_stroked = flags_.is_stroked(attr.getDrawStyle());
730 if (flags_.is_stroked(ref_attr.getDrawStyle()) != is_stroked) {
731 return false;
732 }
733 if (!is_stroked) {
734 return true;
735 }
736 if (ref_attr.getStrokeWidth() != attr.getStrokeWidth()) {
737 return false;
738 }
739 DisplayListSpecialGeometryFlags geo_flags =
740 flags_.GeometryFlags(is_stroked);
741 if (geo_flags.may_have_end_caps() && //
742 getCap(ref_attr, geo_flags) != getCap(attr, geo_flags)) {
743 return false;
744 }
745 if (geo_flags.may_have_joins()) {
746 if (ref_attr.getStrokeJoin() != attr.getStrokeJoin()) {
747 return false;
748 }
749 if (ref_attr.getStrokeJoin() == DlStrokeJoin::kMiter) {
750 DlScalar ref_miter = ref_attr.getStrokeMiter();
751 DlScalar test_miter = attr.getStrokeMiter();
752 // miter limit < 1.4 affects right angles
753 if (geo_flags.may_have_acute_joins() || //
754 ref_miter < 1.4 || test_miter < 1.4) {
755 if (ref_miter != test_miter) {
756 return false;
757 }
758 }
759 }
760 }
761 return true;
762 }
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::testing::RenderEnvironment::GetProvider(), flutter::testing::RenderEnvironment::GetReferenceClipBounds(), flutter::testing::RenderEnvironment::GetReferenceMatrix(), flutter::testing::RenderEnvironment::GetReferencePaint(), flutter::testing::MatrixClipJobRenderer::GetSetupClipBounds(), flutter::testing::MatrixClipJobRenderer::GetSetupMatrix(), 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(), and flutter::testing::DlSurfaceProvider::TargetsImpeller().

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

◆ uses_gradient()

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

Definition at line 659 of file dl_rendering_unittests.cc.

659{ return flags_.applies_shader(); }

References flutter::DisplayListAttributeFlags::applies_shader().

◆ uses_paint()

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

Definition at line 658 of file dl_rendering_unittests.cc.

658{ return !flags_.ignores_paint(); }

References flutter::DisplayListAttributeFlags::ignores_paint().


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