| 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); \
|
|
|