7#include "gtest/gtest.h"
22 EXPECT_EQ(state.
matrix(), matrix);
42 EXPECT_EQ(state.
matrix(), matrix);
62 EXPECT_EQ(state.
matrix(), matrix);
78 EXPECT_EQ(state.
matrix(), translated_matrix);
95 EXPECT_EQ(state.
matrix(), scaled_matrix);
110 EXPECT_EQ(state.
matrix(), skewed_matrix);
126 EXPECT_EQ(state.
matrix(), rotated_matrix);
147 EXPECT_EQ(state.
matrix(), transformed_matrix);
170 EXPECT_EQ(state.
matrix(), transformed_matrix);
193 EXPECT_EQ(state.
matrix(), transformed_matrix);
199 auto non_reducing = [&cull_rect](
const DlRect& diff_rect,
200 const std::string& label) {
211 << label <<
" (RRect)";
218 << label <<
" (RRect)";
222 auto reducing = [&cull_rect](
const DlRect& diff_rect,
223 const DlRect& result_rect,
224 const std::string& label) {
225 EXPECT_TRUE(result_rect.IsEmpty() || cull_rect.
Contains(result_rect));
236 << label <<
" (RRect)";
243 << label <<
" (RRect)";
267 non_reducing(
DlRect::MakeLTRB(35, 21, 45, 40),
"Right edge, bottom-biased");
269 non_reducing(
DlRect::MakeLTRB(21, 35, 40, 45),
"Bottom edge, right-biased");
275 non_reducing(
DlRect::MakeLTRB(15, 25, 45, 35),
"Horizontal interior slice");
295 reducing(cull_rect,
DlRect(),
"Perfectly covering");
309 EXPECT_FALSE(state.mapAndClipRect(&rect));
316 EXPECT_FALSE(state.mapAndClipRect(&rect));
323 EXPECT_FALSE(state.mapAndClipRect(&rect));
330 EXPECT_FALSE(state.mapAndClipRect(&rect));
337 EXPECT_TRUE(state.mapAndClipRect(&rect));
344 EXPECT_FALSE(state.mapAndClipRect(&rect));
351 EXPECT_TRUE(state.mapAndClipRect(&rect));
358 EXPECT_FALSE(state.mapAndClipRect(&rect));
365 EXPECT_TRUE(state.mapAndClipRect(&rect));
372 EXPECT_FALSE(state.mapAndClipRect(&rect));
379 EXPECT_TRUE(state.mapAndClipRect(&rect));
392 EXPECT_FALSE(state.mapAndClipRect(&rect));
399 EXPECT_FALSE(state.mapAndClipRect(&rect));
406 EXPECT_FALSE(state.mapAndClipRect(&rect));
413 EXPECT_FALSE(state.mapAndClipRect(&rect));
420 EXPECT_TRUE(state.mapAndClipRect(&rect));
427 EXPECT_FALSE(state.mapAndClipRect(&rect));
434 EXPECT_TRUE(state.mapAndClipRect(&rect));
441 EXPECT_FALSE(state.mapAndClipRect(&rect));
448 EXPECT_TRUE(state.mapAndClipRect(&rect));
455 EXPECT_FALSE(state.mapAndClipRect(&rect));
462 EXPECT_TRUE(state.mapAndClipRect(&rect));
471 auto test_rect = [&state](
const DlRect& test_rect,
bool expect) {
479 test_rect(rect,
true);
480 test_rect(rect.
Expand(0.1f, 0.0f, 0.0f, 0.0f),
true);
481 test_rect(rect.
Expand(0.0f, 0.1f, 0.0f, 0.0f),
true);
482 test_rect(rect.
Expand(0.0f, 0.0f, 0.1f, 0.0f),
true);
483 test_rect(rect.
Expand(0.0f, 0.0f, 0.0f, 0.1f),
true);
484 test_rect(rect.
Expand(-0.1f, 0.0f, 0.0f, 0.0f),
false);
485 test_rect(rect.
Expand(0.0f, -0.1f, 0.0f, 0.0f),
false);
486 test_rect(rect.
Expand(0.0f, 0.0f, -0.1f, 0.0f),
false);
487 test_rect(rect.
Expand(0.0f, 0.0f, 0.0f, -0.1f),
false);
504 state.
scale(DPR, DPR);
506 auto test_rect = [&state](
const DlRect& test_rect,
bool expect) {
514 test_rect(rect,
true);
515 test_rect(rect.
Expand(0.1f, 0.0f, 0.0f, 0.0f),
true);
516 test_rect(rect.
Expand(0.0f, 0.1f, 0.0f, 0.0f),
true);
517 test_rect(rect.
Expand(0.0f, 0.0f, 0.1f, 0.0f),
true);
518 test_rect(rect.
Expand(0.0f, 0.0f, 0.0f, 0.1f),
true);
519 test_rect(rect.
Expand(-0.1f, 0.0f, 0.0f, 0.0f),
false);
520 test_rect(rect.
Expand(0.0f, -0.1f, 0.0f, 0.0f),
false);
521 test_rect(rect.
Expand(0.0f, 0.0f, -0.1f, 0.0f),
false);
522 test_rect(rect.
Expand(0.0f, 0.0f, 0.0f, -0.1f),
false);
528 state.
scale(2.0f, 2.0f);
530 auto test_rect = [&state](
const DlRect& test_rect,
bool expect) {
557 for (
int i = 0;
i <= 360;
i++) {
561 <<
" testing " << test_true << std::endl
563 <<
" at " <<
i <<
" degrees";
566 <<
" testing " << test_true << std::endl
568 <<
" at " <<
i <<
" degrees";
569 if ((
i % 90) == 45) {
573 <<
" testing " << test_false << std::endl
575 <<
" at " <<
i <<
" degrees";
578 <<
" testing " << test_false << std::endl
580 <<
" at " <<
i <<
" degrees";
585 <<
" testing " << test_false << std::endl
587 <<
" at " <<
i <<
" degrees";
590 <<
" testing " << test_false << std::endl
592 <<
" at " <<
i <<
" degrees";
606 auto test_oval = [&state](
const DlRect& test_rect,
bool expect) {
614 test_oval(test,
true);
615 test_oval(test.
Expand(0.1f, 0.0f, 0.0f, 0.0f),
true);
616 test_oval(test.
Expand(0.0f, 0.1f, 0.0f, 0.0f),
true);
617 test_oval(test.
Expand(0.0f, 0.0f, 0.1f, 0.0f),
true);
618 test_oval(test.
Expand(0.0f, 0.0f, 0.0f, 0.1f),
true);
619 test_oval(test.
Expand(-0.1f, 0.0f, 0.0f, 0.0f),
false);
620 test_oval(test.
Expand(0.0f, -0.1f, 0.0f, 0.0f),
false);
621 test_oval(test.
Expand(0.0f, 0.0f, -0.1f, 0.0f),
false);
622 test_oval(test.
Expand(0.0f, 0.0f, 0.0f, -0.1f),
false);
628 state.
scale(2.0f, 2.0f);
637 auto test_oval = [&state](
const DlRect& test_rect,
bool expect) {
645 test_oval(test,
true);
646 test_oval(test.
Expand(0.1f, 0.0f, 0.0f, 0.0f),
true);
647 test_oval(test.
Expand(0.0f, 0.1f, 0.0f, 0.0f),
true);
648 test_oval(test.
Expand(0.0f, 0.0f, 0.1f, 0.0f),
true);
649 test_oval(test.
Expand(0.0f, 0.0f, 0.0f, 0.1f),
true);
650 test_oval(test.
Expand(-0.1f, 0.0f, 0.0f, 0.0f),
false);
651 test_oval(test.
Expand(0.0f, -0.1f, 0.0f, 0.0f),
false);
652 test_oval(test.
Expand(0.0f, 0.0f, -0.1f, 0.0f),
false);
653 test_oval(test.
Expand(0.0f, 0.0f, 0.0f, -0.1f),
false);
667 for (
int i = 0;
i <= 360;
i++) {
671 <<
" testing " << test_true << std::endl
673 <<
" at " <<
i <<
" degrees";
675 <<
" testing " << test_false << std::endl
677 <<
" at " <<
i <<
" degrees";
681 <<
" testing " << test_true << std::endl
683 <<
" at " <<
i <<
" degrees";
686 <<
" testing " << test_false << std::endl
688 <<
" at " <<
i <<
" degrees";
void translate(DlScalar tx, DlScalar ty)
static bool TransformedRectCoversBounds(const DlRect &local_rect, const DlMatrix &matrix, const DlRect &cull_bounds)
Checks if the local rect, when transformed by the matrix, completely covers the indicated culling bou...
DlRect GetDeviceCullCoverage() const
bool using_4x4_matrix() const
void transform2DAffine(DlScalar mxx, DlScalar mxy, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myt)
void scale(DlScalar sx, DlScalar sy)
void clipRect(const DlRect &rect, DlClipOp op, bool is_aa)
const DlMatrix & matrix() const
bool rrect_covers_cull(const DlRoundRect &content) const
void clipRRect(const DlRoundRect &rrect, DlClipOp op, bool is_aa)
void transformFullPerspective(DlScalar mxx, DlScalar mxy, DlScalar mxz, DlScalar mxt, DlScalar myx, DlScalar myy, DlScalar myz, DlScalar myt, DlScalar mzx, DlScalar mzy, DlScalar mzz, DlScalar mzt, DlScalar mwx, DlScalar mwy, DlScalar mwz, DlScalar mwt)
void setTransform(const DlMatrix &matrix)
static bool TransformedRRectCoversBounds(const DlRoundRect &local_rrect, const DlMatrix &matrix, const DlRect &cull_bounds)
Checks if the local round rect, when transformed by the matrix, completely covers the indicated culli...
void transform(const DlMatrix &matrix)
void rotate(DlRadians angle)
void clipPath(const DlPath &path, DlClipOp op, bool is_aa)
bool oval_covers_cull(const DlRect &content_bounds) const
DlRect GetLocalCullCoverage() const
bool rect_covers_cull(const DlRect &content) const
void skew(DlScalar skx, DlScalar sky)
static bool TransformedOvalCoversBounds(const DlRect &local_oval_bounds, const DlMatrix &matrix, const DlRect &cull_bounds)
Checks if an oval defined by the local bounds, when transformed by the matrix, completely covers the ...
static DlPath MakeRect(const DlRect &rect)
TEST(NativeAssetsManagerTest, NoAvailableAssets)
impeller::Scalar DlScalar
impeller::Matrix DlMatrix
impeller::Degrees DlDegrees
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)
static RoundRect MakeRectXY(const Rect &rect, Scalar x_radius, Scalar y_radius)
static RoundRect MakeRect(const Rect &rect)
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
constexpr bool Contains(const TPoint< Type > &p) const
Returns true iff the provided point |p| is inside the half-open interior of this rectangle.
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)