| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 177 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 178 } | 178 } |
| 179 | 179 |
| 180 TEST(FilterOperationsTest, MapRectReverseDropShadow) { | 180 TEST(FilterOperationsTest, MapRectReverseDropShadow) { |
| 181 FilterOperations ops; | 181 FilterOperations ops; |
| 182 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); | 182 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 20, 0)); |
| 183 EXPECT_EQ(gfx::Rect(-63, -68, 130, 130), | 183 EXPECT_EQ(gfx::Rect(-63, -68, 130, 130), |
| 184 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); | 184 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 185 } | 185 } |
| 186 | 186 |
| 187 TEST(FilterOperationsTest, GetOutsetsDropShadowDoesNotContract) { |
| 188 // Even with a drop-shadow, the original content is still drawn. Thus the |
| 189 // content bounds are never contracted due to a drop-shadow. |
| 190 FilterOperations ops; |
| 191 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0)); |
| 192 int top, right, bottom, left; |
| 193 top = right = bottom = left = 0; |
| 194 ops.GetOutsets(&top, &right, &bottom, &left); |
| 195 EXPECT_EQ(0, top); |
| 196 EXPECT_EQ(3, right); |
| 197 EXPECT_EQ(8, bottom); |
| 198 EXPECT_EQ(0, left); |
| 199 } |
| 200 |
| 201 TEST(FilterOperationsTest, MapRectDropShadowDoesNotContract) { |
| 202 // Even with a drop-shadow, the original content is still drawn. Thus the |
| 203 // content bounds are never contracted due to a drop-shadow. |
| 204 FilterOperations ops; |
| 205 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0)); |
| 206 EXPECT_EQ(gfx::Rect(0, 0, 13, 18), |
| 207 ops.MapRect(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 208 } |
| 209 |
| 210 TEST(FilterOperationsTest, MapRectReverseDropShadowDoesNotContract) { |
| 211 // Even with a drop-shadow, the original content is still drawn. Thus the |
| 212 // content bounds are never contracted due to a drop-shadow. |
| 213 FilterOperations ops; |
| 214 ops.Append(FilterOperation::CreateDropShadowFilter(gfx::Point(3, 8), 0, 0)); |
| 215 EXPECT_EQ(gfx::Rect(-3, -8, 13, 18), |
| 216 ops.MapRectReverse(gfx::Rect(0, 0, 10, 10), SkMatrix::I())); |
| 217 } |
| 218 |
| 187 #define SAVE_RESTORE_AMOUNT(filter_name, filter_type, a) \ | 219 #define SAVE_RESTORE_AMOUNT(filter_name, filter_type, a) \ |
| 188 { \ | 220 { \ |
| 189 FilterOperation op = FilterOperation::Create##filter_name##Filter(a); \ | 221 FilterOperation op = FilterOperation::Create##filter_name##Filter(a); \ |
| 190 EXPECT_EQ(FilterOperation::filter_type, op.type()); \ | 222 EXPECT_EQ(FilterOperation::filter_type, op.type()); \ |
| 191 EXPECT_EQ(a, op.amount()); \ | 223 EXPECT_EQ(a, op.amount()); \ |
| 192 \ | 224 \ |
| 193 FilterOperation op2 = FilterOperation::CreateEmptyFilter(); \ | 225 FilterOperation op2 = FilterOperation::CreateEmptyFilter(); \ |
| 194 op2.set_type(FilterOperation::filter_type); \ | 226 op2.set_type(FilterOperation::filter_type); \ |
| 195 \ | 227 \ |
| 196 EXPECT_NE(a, op2.amount()); \ | 228 EXPECT_NE(a, op2.amount()); \ |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 blended = to.Blend(from, -0.75); | 874 blended = to.Blend(from, -0.75); |
| 843 EXPECT_EQ(to, blended); | 875 EXPECT_EQ(to, blended); |
| 844 blended = to.Blend(from, 0.75); | 876 blended = to.Blend(from, 0.75); |
| 845 EXPECT_EQ(to, blended); | 877 EXPECT_EQ(to, blended); |
| 846 blended = to.Blend(from, 1.5); | 878 blended = to.Blend(from, 1.5); |
| 847 EXPECT_EQ(to, blended); | 879 EXPECT_EQ(to, blended); |
| 848 } | 880 } |
| 849 | 881 |
| 850 } // namespace | 882 } // namespace |
| 851 } // namespace cc | 883 } // namespace cc |
| OLD | NEW |