| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "cc/output/filter_operations.h" | 7 #include "cc/output/filter_operations.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 9 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
| 10 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" | 10 #include "third_party/skia/include/effects/SkDropShadowImageFilter.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 FilterOperations ops; | 32 FilterOperations ops; |
| 33 ops.Append(FilterOperation::CreateBlurFilter(20)); | 33 ops.Append(FilterOperation::CreateBlurFilter(20)); |
| 34 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), | 34 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), |
| 35 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 35 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 36 EXPECT_EQ(gfx::Rect(-120, -120, 260, 260), | 36 EXPECT_EQ(gfx::Rect(-120, -120, 260, 260), |
| 37 ops.MapRect(gfx::Rect(0, 0, 20, 20), SkMatrix::MakeScale(2, 2))); | 37 ops.MapRect(gfx::Rect(0, 0, 20, 20), SkMatrix::MakeScale(2, 2))); |
| 38 EXPECT_EQ(gfx::Rect(-60, -70, 130, 130), | 38 EXPECT_EQ(gfx::Rect(-60, -70, 130, 130), |
| 39 ops.MapRect(gfx::Rect(0, -10, 10, 10), SkMatrix::MakeScale(1, -1))); | 39 ops.MapRect(gfx::Rect(0, -10, 10, 10), SkMatrix::MakeScale(1, -1))); |
| 40 } | 40 } |
| 41 | 41 |
| 42 TEST(FilterOperationsTest, MapRectBlurOverflow) { |
| 43 // Passes if float-cast-overflow does not occur in ubsan builds. |
| 44 // The blur spread exceeds INT_MAX. |
| 45 FilterOperations ops; |
| 46 ops.Append(FilterOperation::CreateBlurFilter(2e9f)); |
| 47 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I()); |
| 48 } |
| 49 |
| 42 TEST(FilterOperationsTest, MapRectReverseBlur) { | 50 TEST(FilterOperationsTest, MapRectReverseBlur) { |
| 43 FilterOperations ops; | 51 FilterOperations ops; |
| 44 ops.Append(FilterOperation::CreateBlurFilter(20)); | 52 ops.Append(FilterOperation::CreateBlurFilter(20)); |
| 45 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), | 53 EXPECT_EQ(gfx::Rect(-60, -60, 130, 130), |
| 46 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 54 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 47 EXPECT_EQ( | 55 EXPECT_EQ( |
| 48 gfx::Rect(-120, -120, 260, 260), | 56 gfx::Rect(-120, -120, 260, 260), |
| 49 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), SkMatrix::MakeScale(2, 2))); | 57 ops.MapRectReverse(gfx::Rect(0, 0, 20, 20), SkMatrix::MakeScale(2, 2))); |
| 50 EXPECT_EQ(gfx::Rect(-60, -70, 130, 130), | 58 EXPECT_EQ(gfx::Rect(-60, -70, 130, 130), |
| 51 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), | 59 ops.MapRectReverse(gfx::Rect(0, -10, 10, 10), |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 970 |
| 963 filters.Append(FilterOperation::CreateSaturateFilter(3.f)); | 971 filters.Append(FilterOperation::CreateSaturateFilter(3.f)); |
| 964 filters.Append(FilterOperation::CreateBlurFilter(2.f)); | 972 filters.Append(FilterOperation::CreateBlurFilter(2.f)); |
| 965 EXPECT_EQ(std::string("{\"FilterOperations\":[{\"amount\":3.0,\"type\":2}," | 973 EXPECT_EQ(std::string("{\"FilterOperations\":[{\"amount\":3.0,\"type\":2}," |
| 966 "{\"amount\":2.0,\"type\":8}]}"), | 974 "{\"amount\":2.0,\"type\":8}]}"), |
| 967 filters.ToString()); | 975 filters.ToString()); |
| 968 } | 976 } |
| 969 | 977 |
| 970 } // namespace | 978 } // namespace |
| 971 } // namespace cc | 979 } // namespace cc |
| OLD | NEW |