Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3087)

Unified Diff: cc/output/filter_operations_unittest.cc

Issue 2114303002: cc: Add unit tests for non-identity matrix for FilterOperation::MapRect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after skia roll (https://codereview.chromium.org/2114313002 was detected by this test) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/filter_operation.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/filter_operations_unittest.cc
diff --git a/cc/output/filter_operations_unittest.cc b/cc/output/filter_operations_unittest.cc
index a992086e3920057eb2ff8ccc6c2bf52ce86ab867..0913202209f19f8d946372afb8d5e0dd33a9e318 100644
--- a/cc/output/filter_operations_unittest.cc
+++ b/cc/output/filter_operations_unittest.cc
@@ -15,6 +15,12 @@
namespace cc {
namespace {
+SkMatrix MakeScaleMatrix(float x_scale, float y_scale) {
Stephen White 2016/07/14 22:03:14 BTW, this is SkMatrix::MakeScale().
jbroman 2016/07/14 22:24:06 Done. Don't know how I missed that, it being the v
+ SkMatrix matrix;
+ matrix.setScale(x_scale, y_scale);
+ return matrix;
+}
+
TEST(FilterOperationsTest, GetOutsetsBlur) {
FilterOperations ops;
ops.Append(FilterOperation::CreateBlurFilter(20));
@@ -32,6 +38,10 @@ TEST(FilterOperationsTest, MapRectBlur) {
ops.Append(FilterOperation::CreateBlurFilter(20));
EXPECT_EQ(gfx::Rect(-60, -60, 130, 130),
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-120, -120, 260, 260),
+ ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(gfx::Rect(-60, -70, 130, 130),
+ ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectReverseBlur) {
@@ -39,6 +49,11 @@ TEST(FilterOperationsTest, MapRectReverseBlur) {
ops.Append(FilterOperation::CreateBlurFilter(20));
EXPECT_EQ(gfx::Rect(-60, -60, 130, 130),
ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-120, -120, 260, 260),
+ ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(
+ gfx::Rect(-60, -70, 130, 130),
+ ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, GetOutsetsDropShadowReferenceFilter) {
@@ -71,6 +86,10 @@ TEST(FilterOperationsTest, MapRectDropShadowReferenceFilter) {
nullptr)));
EXPECT_EQ(gfx::Rect(-9, -19, 34, 64),
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-18, -38, 68, 128),
+ ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(gfx::Rect(-9, -45, 34, 64),
+ ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectReverseDropShadowReferenceFilter) {
@@ -83,6 +102,11 @@ TEST(FilterOperationsTest, MapRectReverseDropShadowReferenceFilter) {
nullptr)));
EXPECT_EQ(gfx::Rect(-15, -35, 34, 64),
ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-30, -70, 68, 128),
+ ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(
+ gfx::Rect(-15, -29, 34, 64),
+ ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectOffsetReferenceFilter) {
@@ -91,6 +115,10 @@ TEST(FilterOperationsTest, MapRectOffsetReferenceFilter) {
ops.Append(FilterOperation::CreateReferenceFilter(std::move(filter)));
EXPECT_EQ(gfx::Rect(30, 40, 10, 10),
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(60, 80, 20, 20),
+ ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(gfx::Rect(30, -50, 10, 10),
+ ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectReverseOffsetReferenceFilter) {
@@ -99,6 +127,11 @@ TEST(FilterOperationsTest, MapRectReverseOffsetReferenceFilter) {
ops.Append(FilterOperation::CreateReferenceFilter(std::move(filter)));
EXPECT_EQ(gfx::Rect(-30, -40, 10, 10),
ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-60, -80, 20, 20),
+ ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(
+ gfx::Rect(-30, 30, 10, 10),
+ ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectCombineNonCommutative) {
@@ -114,6 +147,10 @@ TEST(FilterOperationsTest, MapRectCombineNonCommutative) {
EXPECT_EQ(gfx::Rect(200, 200, 20, 20),
ops.MapRect(gfx::Rect(10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(400, 400, 40, 40),
+ ops.MapRect(gfx::Rect(20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(gfx::Rect(200, -220, 20, 20),
+ ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectReverseCombineNonCommutative) {
@@ -129,6 +166,11 @@ TEST(FilterOperationsTest, MapRectReverseCombineNonCommutative) {
EXPECT_EQ(gfx::Rect(10, 10),
ops.MapRectReverse(gfx::Rect(200, 200, 20, 20), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(20, 20), ops.MapRectReverse(gfx::Rect(400, 400, 40, 40),
+ MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(
+ gfx::Rect(0, -10, 10, 10),
+ ops.MapRectReverse(gfx::Rect(200, -220, 20, 20), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, GetOutsetsNullReferenceFilter) {
@@ -149,6 +191,10 @@ TEST(FilterOperationsTest, MapRectNullReferenceFilter) {
ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
EXPECT_EQ(gfx::Rect(0, 0, 10, 10),
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
+ ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(gfx::Rect(0, -10, 10, 10),
+ ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectReverseNullReferenceFilter) {
@@ -156,6 +202,11 @@ TEST(FilterOperationsTest, MapRectReverseNullReferenceFilter) {
ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
EXPECT_EQ(gfx::Rect(0, 0, 10, 10),
ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(0, 0, 20, 20),
+ ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(
+ gfx::Rect(0, -10, 10, 10),
+ ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, GetOutsetsDropShadow) {
@@ -175,6 +226,10 @@ TEST(FilterOperationsTest, MapRectDropShadow) {
ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0));
EXPECT_EQ(gfx::Rect(-57, -52, 130, 130),
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-114, -104, 260, 260),
+ ops.MapRect(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(gfx::Rect(-57, -78, 130, 130),
+ ops.MapRect(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, MapRectReverseDropShadow) {
@@ -182,6 +237,11 @@ TEST(FilterOperationsTest, MapRectReverseDropShadow) {
ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0));
EXPECT_EQ(gfx::Rect(-63, -68, 130, 130),
ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+ EXPECT_EQ(gfx::Rect(-126, -136, 260, 260),
+ ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), MakeScaleMatrix(2, 2)));
+ EXPECT_EQ(
+ gfx::Rect(-63, -62, 130, 130),
+ ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), MakeScaleMatrix(1, -1)));
}
TEST(FilterOperationsTest, GetOutsetsDropShadowDoesNotContract) {
« no previous file with comments | « cc/output/filter_operation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698