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

Unified Diff: cc/output/filter_operations_unittest.cc

Issue 2115163002: cc: Fix a bug where filter outsets for drop-shadow could be negative. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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
« cc/output/filter_operations.cc ('K') | « cc/output/filter_operations.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 b3ee515415fad50969566fd802e5bcabf69e3ec7..a992086e3920057eb2ff8ccc6c2bf52ce86ab867 100644
--- a/cc/output/filter_operations_unittest.cc
+++ b/cc/output/filter_operations_unittest.cc
@@ -184,6 +184,38 @@ TEST(FilterOperationsTest, MapRectReverseDropShadow) {
ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
}
+TEST(FilterOperationsTest, GetOutsetsDropShadowDoesNotContract) {
+ // Even with a drop-shadow, the original content is still drawn. Thus the
+ // content bounds are never contracted due to a drop-shadow.
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0));
+ int top, right, bottom, left;
+ top = right = bottom = left = 0;
+ ops.GetOutsets(&top, &right, &bottom, &left);
+ EXPECT_EQ(0, top);
+ EXPECT_EQ(3, right);
+ EXPECT_EQ(8, bottom);
+ EXPECT_EQ(0, left);
+}
+
+TEST(FilterOperationsTest, MapRectDropShadowDoesNotContract) {
+ // Even with a drop-shadow, the original content is still drawn. Thus the
+ // content bounds are never contracted due to a drop-shadow.
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0));
+ EXPECT_EQ(gfx::Rect(0, 0, 13, 18),
+ ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()));
+}
+
+TEST(FilterOperationsTest, MapRectReverseDropShadowDoesNotContract) {
+ // Even with a drop-shadow, the original content is still drawn. Thus the
+ // content bounds are never contracted due to a drop-shadow.
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0));
+ EXPECT_EQ(gfx::Rect(-3, -8, 13, 18),
+ 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); \
« cc/output/filter_operations.cc ('K') | « cc/output/filter_operations.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698