5#include "flutter/display_list/utils/dl_matrix_clip_tracker.h"
6#include "flutter/testing/assertions_skia.h"
7#include "gtest/gtest.h"
29 EXPECT_EQ(state1.
matrix(), dl_matrix);
36 EXPECT_EQ(state2.
matrix(), dl_matrix);
43 EXPECT_EQ(state3.
matrix(), dl_matrix);
68 EXPECT_EQ(state1.
matrix(), dl_matrix);
74 EXPECT_EQ(state2.
matrix(), dl_matrix);
102 EXPECT_EQ(state1.
matrix(), dl_matrix);
109 EXPECT_EQ(state2.
matrix(), dl_matrix);
137 EXPECT_EQ(state1.
matrix(), dl_matrix);
144 EXPECT_EQ(state2.
matrix(), dl_matrix);
155 const SkM44 translated_m44 =
SkM44(translated_matrix);
156 const DlMatrix dl_translated_matrix =
170 EXPECT_EQ(state1.
matrix_3x3(), translated_matrix);
171 EXPECT_EQ(state1.
matrix_4x4(), translated_m44);
172 EXPECT_EQ(state1.
matrix(), dl_translated_matrix);
177 EXPECT_EQ(state2.
matrix_3x3(), translated_matrix);
178 EXPECT_EQ(state2.
matrix_4x4(), translated_m44);
179 EXPECT_EQ(state2.
matrix(), dl_translated_matrix);
184 EXPECT_EQ(state3.
matrix_3x3(), translated_matrix);
185 EXPECT_EQ(state3.
matrix_4x4(), translated_m44);
186 EXPECT_EQ(state3.
matrix(), dl_translated_matrix);
199 const SkM44 scaled_m44 =
SkM44(scaled_matrix);
200 const DlMatrix scaled_dl_matrix = dl_matrix.
Scale({0.5, 2, 1});
206 state1.
scale(0.5, 2);
207 state2.
scale(0.5, 2);
208 state3.
scale(0.5, 2);
213 EXPECT_EQ(state1.
matrix_3x3(), scaled_matrix);
215 EXPECT_EQ(state1.
matrix(), scaled_dl_matrix);
220 EXPECT_EQ(state2.
matrix_3x3(), scaled_matrix);
222 EXPECT_EQ(state2.
matrix(), scaled_dl_matrix);
227 EXPECT_EQ(state3.
matrix_3x3(), scaled_matrix);
229 EXPECT_EQ(state3.
matrix(), scaled_dl_matrix);
240 const SkM44 skewed_m44 =
SkM44(skewed_matrix);
254 EXPECT_EQ(state1.
matrix_3x3(), skewed_matrix);
256 EXPECT_EQ(state1.
matrix(), skewed_dl_matrix);
261 EXPECT_EQ(state2.
matrix_3x3(), skewed_matrix);
263 EXPECT_EQ(state2.
matrix(), skewed_dl_matrix);
268 EXPECT_EQ(state3.
matrix_3x3(), skewed_matrix);
270 EXPECT_EQ(state3.
matrix(), skewed_dl_matrix);
281 const SkM44 rotated_m44 =
SkM44(rotated_matrix);
296 EXPECT_EQ(state1.
matrix_3x3(), rotated_matrix);
298 EXPECT_EQ(state1.
matrix(), rotated_dl_matrix);
303 EXPECT_EQ(state2.
matrix_3x3(), rotated_matrix);
305 EXPECT_EQ(state2.
matrix(), rotated_dl_matrix);
310 EXPECT_EQ(state3.
matrix_3x3(), rotated_matrix);
312 EXPECT_EQ(state3.
matrix(), rotated_dl_matrix);
326 const SkM44 transformed_m44 =
SkM44(transformed_matrix);
327 const DlMatrix transformed_dl_matrix =
347 EXPECT_EQ(state1.
matrix_3x3(), transformed_matrix);
348 EXPECT_EQ(state1.
matrix_4x4(), transformed_m44);
349 EXPECT_EQ(state1.
matrix(), transformed_dl_matrix);
354 EXPECT_EQ(state2.
matrix_3x3(), transformed_matrix);
355 EXPECT_EQ(state2.
matrix_4x4(), transformed_m44);
356 EXPECT_EQ(state2.
matrix(), transformed_dl_matrix);
361 EXPECT_EQ(state3.
matrix_3x3(), transformed_matrix);
362 EXPECT_EQ(state3.
matrix_4x4(), transformed_m44);
363 EXPECT_EQ(state3.
matrix(), transformed_dl_matrix);
377 const SkM44 transformed_m44 =
SkM44(transformed_matrix);
378 const DlMatrix transformed_dl_matrix =
404 EXPECT_EQ(state1.
matrix_3x3(), transformed_matrix);
405 EXPECT_EQ(state1.
matrix_4x4(), transformed_m44);
406 EXPECT_EQ(state1.
matrix(), transformed_dl_matrix);
411 EXPECT_EQ(state2.
matrix_3x3(), transformed_matrix);
412 EXPECT_EQ(state2.
matrix_4x4(), transformed_m44);
413 EXPECT_EQ(state2.
matrix(), transformed_dl_matrix);
418 EXPECT_EQ(state3.
matrix_3x3(), transformed_matrix);
419 EXPECT_EQ(state3.
matrix_4x4(), transformed_m44);
420 EXPECT_EQ(state3.
matrix(), transformed_dl_matrix);
434 const DlMatrix transformed_dl_matrix =
460 EXPECT_EQ(state1.
matrix_4x4(), transformed_m44);
461 EXPECT_EQ(state1.
matrix(), transformed_dl_matrix);
466 EXPECT_EQ(state2.
matrix_4x4(), transformed_m44);
467 EXPECT_EQ(state2.
matrix(), transformed_dl_matrix);
472 EXPECT_EQ(state3.
matrix_4x4(), transformed_m44);
473 EXPECT_EQ(state3.
matrix(), transformed_dl_matrix);
479 auto non_reducing = [&cull_rect](
const SkRect& diff_rect,
480 const std::string& label) {
484 EXPECT_EQ(
state.device_cull_rect(), cull_rect) << label;
490 EXPECT_EQ(
state.device_cull_rect(), cull_rect) << label <<
" (RRect)";
496 EXPECT_EQ(
state.device_cull_rect(), cull_rect) << label <<
" (RRect)";
500 auto reducing = [&cull_rect](
const SkRect& diff_rect,
501 const SkRect& result_rect,
502 const std::string& label) {
507 EXPECT_EQ(
state.device_cull_rect(), result_rect) << label;
513 EXPECT_EQ(
state.device_cull_rect(), result_rect) << label <<
" (RRect)";
519 EXPECT_EQ(
state.device_cull_rect(), result_rect) << label <<
" (RRect)";
543 non_reducing(
SkRect::MakeLTRB(35, 21, 45, 40),
"Right edge, bottom-biased");
545 non_reducing(
SkRect::MakeLTRB(21, 35, 40, 45),
"Bottom edge, right-biased");
551 non_reducing(
SkRect::MakeLTRB(15, 25, 45, 35),
"Horizontal interior slice");
584 EXPECT_EQ(
state.local_cull_rect(), cull_rect);
585 EXPECT_EQ(
state.device_cull_rect(), cull_rect);
597 EXPECT_EQ(
state.local_cull_rect(), clip_bounds);
598 EXPECT_EQ(
state.device_cull_rect(), clip_bounds);
609 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
616 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
623 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
630 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
644 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
658 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
672 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
692 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
699 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
706 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
713 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
727 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
741 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
755 EXPECT_FALSE(
state.mapAndClipRect(&
rect));
776 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
777 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
778 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
779 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
796 state.scale(DPR, DPR);
803 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
804 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
805 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
806 EXPECT_FALSE(
state.rect_covers_cull(
rect.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
812 state.scale(2.0f, 2.0f);
833 for (
int i = 0;
i <= 360;
i++) {
837 <<
" testing " << test_true << std::endl
838 <<
" contains " <<
state.local_cull_rect() << std::endl
839 <<
" at " <<
i <<
" degrees";
840 if ((
i % 90) == 45) {
843 EXPECT_FALSE(
state.rect_covers_cull(test_false))
844 <<
" testing " << test_false << std::endl
845 <<
" contains " <<
state.local_cull_rect() << std::endl
846 <<
" at " <<
i <<
" degrees";
851 <<
" testing " << test_false << std::endl
852 <<
" contains " <<
state.local_cull_rect() << std::endl
853 <<
" at " <<
i <<
" degrees";
872 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
873 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
874 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
875 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
881 state.scale(2.0f, 2.0f);
895 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(-0.1f, 0.0f, 0.0f, 0.0f)));
896 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(0.0f, -0.1f, 0.0f, 0.0f)));
897 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(0.0f, 0.0f, -0.1f, 0.0f)));
898 EXPECT_FALSE(
state.oval_covers_cull(
test.Expand(0.0f, 0.0f, 0.0f, -0.1f)));
912 for (
int i = 0;
i <= 360;
i++) {
916 <<
" testing " << test_true << std::endl
917 <<
" contains " <<
state.local_cull_rect() << std::endl
918 <<
" at " <<
i <<
" degrees";
919 EXPECT_FALSE(
state.oval_covers_cull(test_false))
920 <<
" testing " << test_false << std::endl
921 <<
" contains " <<
state.local_cull_rect() << std::endl
922 <<
" at " <<
i <<
" degrees";
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static SkM44 Scale(SkScalar x, SkScalar y, SkScalar z=1)
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix RotateDeg(SkScalar deg)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
static SkMatrix MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, SkScalar transY, SkScalar pers0, SkScalar pers1, SkScalar pers2)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
static const SkMatrix & I()
static SkMatrix Skew(SkScalar kx, SkScalar ky)
SkPath & addCircle(SkScalar x, SkScalar y, SkScalar radius, SkPathDirection dir=SkPathDirection::kCW)
void setFillType(SkPathFillType ft)
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
static SkRRect MakeRect(const SkRect &r)
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
void scale(SkScalar sx, SkScalar sy)
bool using_4x4_matrix() const
SkMatrix matrix_3x3() const
const DlMatrix & matrix() const
void rotate(SkScalar degrees)
void transform2DAffine(SkScalar mxx, SkScalar mxy, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myt)
SkRect device_cull_rect() const
void setTransform(const DlMatrix &matrix)
void transformFullPerspective(SkScalar mxx, SkScalar mxy, SkScalar mxz, SkScalar mxt, SkScalar myx, SkScalar myy, SkScalar myz, SkScalar myt, SkScalar mzx, SkScalar mzy, SkScalar mzz, SkScalar mzt, SkScalar mwx, SkScalar mwy, SkScalar mwz, SkScalar mwt)
void skew(SkScalar skx, SkScalar sky)
SkRect local_cull_rect() const
void transform(const DlMatrix &matrix)
void translate(SkScalar tx, SkScalar ty)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< SkBlender > blender SkRect rect
TEST(DisplayListComplexity, EmptyDisplayList)
impeller::Scalar DlScalar
impeller::Matrix DlMatrix
impeller::Degrees DlDegrees
static constexpr SkRect MakeEmpty()
SkRect makeOutset(float dx, float dy) const
bool contains(SkScalar x, SkScalar y) const
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
A 4x4 matrix using column-major storage.
static constexpr Matrix MakeTranslation(const Vector3 &t)
static constexpr Matrix MakeRow(Scalar m0, Scalar m1, Scalar m2, Scalar m3, Scalar m4, Scalar m5, Scalar m6, Scalar m7, Scalar m8, Scalar m9, Scalar m10, Scalar m11, Scalar m12, Scalar m13, Scalar m14, Scalar m15)
static constexpr Matrix MakeSkew(Scalar sx, Scalar sy)
constexpr Matrix Scale(const Vector3 &s) const
static Matrix MakeRotationZ(Radians r)
static constexpr Matrix MakeScale(const Vector3 &s)
constexpr TRect Scale(Type scale) const
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
static constexpr TRect MakeLTRB(Type left, Type top, Type right, Type bottom)
#define EXPECT_TRUE(handle)