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

Unified Diff: cc/output/filter_operations_unittest.cc

Issue 1998233002: cc: Implement and use FilterOperations::MapRectReverse for mapping backdrop bounding box. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit test Created 4 years, 6 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_operations.cc ('k') | cc/output/gl_renderer.cc » ('j') | 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 64c127c29f2891c032efc6be41fa6045b1f2da25..b3ee515415fad50969566fd802e5bcabf69e3ec7 100644
--- a/cc/output/filter_operations_unittest.cc
+++ b/cc/output/filter_operations_unittest.cc
@@ -34,6 +34,13 @@ TEST(FilterOperationsTest, MapRectBlur) {
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
}
+TEST(FilterOperationsTest, MapRectReverseBlur) {
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateBlurFilter(20));
+ EXPECT_EQ(gfx::Rect(-60, -60, 130, 130),
+ ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+}
+
TEST(FilterOperationsTest, GetOutsetsDropShadowReferenceFilter) {
// TODO(hendrikw): We need to make outsets for reference filters be in line
// with non-reference filters. See crbug.com/523534
@@ -66,6 +73,18 @@ TEST(FilterOperationsTest, MapRectDropShadowReferenceFilter) {
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
}
+TEST(FilterOperationsTest, MapRectReverseDropShadowReferenceFilter) {
+ FilterOperations ops;
+ ops.Append(
+ FilterOperation::CreateReferenceFilter(SkDropShadowImageFilter::Make(
+ SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4),
+ SkIntToScalar(9), SK_ColorBLACK,
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode,
+ nullptr)));
+ EXPECT_EQ(gfx::Rect(-15, -35, 34, 64),
+ ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+}
+
TEST(FilterOperationsTest, MapRectOffsetReferenceFilter) {
sk_sp<SkImageFilter> filter = SkOffsetImageFilter::Make(30, 40, nullptr);
FilterOperations ops;
@@ -74,6 +93,44 @@ TEST(FilterOperationsTest, MapRectOffsetReferenceFilter) {
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
}
+TEST(FilterOperationsTest, MapRectReverseOffsetReferenceFilter) {
+ sk_sp<SkImageFilter> filter = SkOffsetImageFilter::Make(30, 40, nullptr);
+ FilterOperations ops;
+ 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()));
+}
+
+TEST(FilterOperationsTest, MapRectCombineNonCommutative) {
+ // Offsets by 100px in each axis, then scales the resulting image by 2.
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateReferenceFilter(
+ SkOffsetImageFilter::Make(100, 100, nullptr)));
+ SkMatrix scaleMatrix;
+ scaleMatrix.setScale(2, 2);
+ ops.Append(
+ FilterOperation::CreateReferenceFilter(SkImageFilter::MakeMatrixFilter(
+ scaleMatrix, kNone_SkFilterQuality, nullptr)));
+
+ EXPECT_EQ(gfx::Rect(200, 200, 20, 20),
+ ops.MapRect(gfx::Rect(10, 10), SkMatrix::I()));
+}
+
+TEST(FilterOperationsTest, MapRectReverseCombineNonCommutative) {
+ // Offsets by 100px in each axis, then scales the resulting image by 2.
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateReferenceFilter(
+ SkOffsetImageFilter::Make(100, 100, nullptr)));
+ SkMatrix scaleMatrix;
+ scaleMatrix.setScale(2, 2);
+ ops.Append(
+ FilterOperation::CreateReferenceFilter(SkImageFilter::MakeMatrixFilter(
+ scaleMatrix, kNone_SkFilterQuality, nullptr)));
+
+ EXPECT_EQ(gfx::Rect(10, 10),
+ ops.MapRectReverse(gfx::Rect(200, 200, 20, 20), SkMatrix::I()));
+}
+
TEST(FilterOperationsTest, GetOutsetsNullReferenceFilter) {
FilterOperations ops;
ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
@@ -94,6 +151,13 @@ TEST(FilterOperationsTest, MapRectNullReferenceFilter) {
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
}
+TEST(FilterOperationsTest, MapRectReverseNullReferenceFilter) {
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 10),
+ ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+}
+
TEST(FilterOperationsTest, GetOutsetsDropShadow) {
FilterOperations ops;
ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0));
@@ -113,6 +177,13 @@ TEST(FilterOperationsTest, MapRectDropShadow) {
ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
}
+TEST(FilterOperationsTest, MapRectReverseDropShadow) {
+ FilterOperations ops;
+ 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()));
+}
+
#define SAVE_RESTORE_AMOUNT(filter_name, filter_type, a) \
{ \
FilterOperation op = FilterOperation::Create##filter_name##Filter(a); \
« no previous file with comments | « cc/output/filter_operations.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698