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

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: Created 4 years, 7 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
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..aaf40b90fe519cacaae0a3b27ab73959331d9b1f 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,14 @@ 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, GetOutsetsNullReferenceFilter) {
FilterOperations ops;
ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
@@ -94,6 +121,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 +147,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); \

Powered by Google App Engine
This is Rietveld 408576698