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

Unified Diff: cc/output/filter_operations_unittest.cc

Issue 1867913002: Implement cc::FilterOperations::MapRect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: IWYU: <numeric> Created 4 years, 8 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.h ('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 05c0289ea9f3b7af83a016efb97b93d841c45531..59a07bbd2e8a230305aedd6a2d3336f868f8679f 100644
--- a/cc/output/filter_operations_unittest.cc
+++ b/cc/output/filter_operations_unittest.cc
@@ -10,6 +10,7 @@
#include "third_party/skia/include/effects/SkBlurImageFilter.h"
#include "third_party/skia/include/effects/SkDropShadowImageFilter.h"
#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/geometry/rect.h"
namespace cc {
namespace {
@@ -26,6 +27,13 @@ TEST(FilterOperationsTest, GetOutsetsBlur) {
EXPECT_EQ(57, left);
}
+TEST(FilterOperationsTest, MapRectBlur) {
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateBlurFilter(20));
+ EXPECT_EQ(gfx::Rect(-57, -57, 124, 124),
+ ops.MapRect(gfx::Rect(0, 0, 10, 10)));
+}
+
TEST(FilterOperationsTest, GetOutsetsDropShadowReferenceFilter) {
// TODO(hendrikw): We need to make outsets for reference filters be in line
// with non-reference filters. See crbug.com/523534
@@ -46,6 +54,19 @@ TEST(FilterOperationsTest, GetOutsetsDropShadowReferenceFilter) {
EXPECT_EQ(15, left);
}
+TEST(FilterOperationsTest, MapRectDropShadowReferenceFilter) {
+ // TODO(hendrikw): We need to make outsets for reference filters be in line
Stephen White 2016/04/11 18:05:00 Is this comment still valid? If not, remove it.
jbroman 2016/04/11 20:21:52 I'm not entirely clear on what it means, so I figu
Stephen White 2016/04/11 20:56:04 The referenced bug is basically what you're doing
jbroman 2016/04/12 19:32:36 Done.
+ // with non-reference filters. See crbug.com/523534
+ skia::RefPtr<SkImageFilter> filter =
+ skia::AdoptRef(SkDropShadowImageFilter::Create(
+ SkIntToScalar(3), SkIntToScalar(8), SkIntToScalar(4),
+ SkIntToScalar(9), SK_ColorBLACK,
+ SkDropShadowImageFilter::kDrawShadowAndForeground_ShadowMode));
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateReferenceFilter(filter));
+ EXPECT_EQ(gfx::Rect(-15, -35, 34, 64), ops.MapRect(gfx::Rect(0, 0, 10, 10)));
Stephen White 2016/04/11 18:05:00 This does look like a reverse mapping. Maybe the c
jbroman 2016/04/11 20:21:52 These expectations were taken from GetOutsets (wit
Stephen White 2016/04/11 20:56:04 Yeah, I think there is/was a bug in GetOutsets().
jbroman 2016/04/12 19:32:37 Acknowledged.
+}
+
TEST(FilterOperationsTest, GetOutsetsNullReferenceFilter) {
FilterOperations ops;
ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
@@ -59,6 +80,12 @@ TEST(FilterOperationsTest, GetOutsetsNullReferenceFilter) {
EXPECT_EQ(0, left);
}
+TEST(FilterOperationsTest, MapRectNullReferenceFilter) {
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateReferenceFilter(nullptr));
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 10), ops.MapRect(gfx::Rect(0, 0, 10, 10)));
Stephen White 2016/04/11 18:05:00 Could you add a test for a non-null Reference filt
jbroman 2016/04/11 20:21:52 Is the drop shadow reference filter (above) insuff
Stephen White 2016/04/11 20:56:04 The advantage of SkOffsetImageFilter is that it do
jbroman 2016/04/12 19:32:36 Done.
+}
+
TEST(FilterOperationsTest, GetOutsetsDropShadow) {
FilterOperations ops;
ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0));
@@ -71,6 +98,13 @@ TEST(FilterOperationsTest, GetOutsetsDropShadow) {
EXPECT_EQ(54, left);
}
+TEST(FilterOperationsTest, MapRectDropShadow) {
+ FilterOperations ops;
+ ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0));
+ EXPECT_EQ(gfx::Rect(-54, -49, 124, 124),
+ ops.MapRect(gfx::Rect(0, 0, 10, 10)));
+}
+
#define SAVE_RESTORE_AMOUNT(filter_name, filter_type, a) \
{ \
FilterOperation op = FilterOperation::Create##filter_name##Filter(a); \
« cc/output/filter_operations.h ('K') | « cc/output/filter_operations.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698