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 "cc/output/filter_operations.h" | 5 #include "cc/output/filter_operations.h" |
6 #include "skia/ext/refptr.h" | 6 #include "skia/ext/refptr.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "third_party/skia/include/effects/SkBlurImageFilter.h" | 8 #include "third_party/skia/include/effects/SkBlurImageFilter.h" |
9 #include "ui/gfx/point.h" | 9 #include "ui/gfx/point.h" |
10 | 10 |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 FilterOperations blended = empty.Blend(empty, -0.75); | 637 FilterOperations blended = empty.Blend(empty, -0.75); |
638 EXPECT_EQ(blended, empty); | 638 EXPECT_EQ(blended, empty); |
639 | 639 |
640 blended = empty.Blend(empty, 0.75); | 640 blended = empty.Blend(empty, 0.75); |
641 EXPECT_EQ(blended, empty); | 641 EXPECT_EQ(blended, empty); |
642 | 642 |
643 blended = empty.Blend(empty, 1.5); | 643 blended = empty.Blend(empty, 1.5); |
644 EXPECT_EQ(blended, empty); | 644 EXPECT_EQ(blended, empty); |
645 } | 645 } |
646 | 646 |
647 // Tests blending non-empty sequences that either have different lengths or | 647 // Tests blending non-empty sequences that have non-matching operations. |
648 // have non-matching operations. | |
649 TEST(FilterOperationsTest, BlendNonMatchingSequences) { | 648 TEST(FilterOperationsTest, BlendNonMatchingSequences) { |
650 FilterOperations from; | 649 FilterOperations from; |
651 FilterOperations to; | 650 FilterOperations to; |
652 | 651 |
653 from.Append(FilterOperation::CreateSaturateFilter(3.f)); | 652 from.Append(FilterOperation::CreateSaturateFilter(3.f)); |
654 from.Append(FilterOperation::CreateBlurFilter(2.f)); | 653 from.Append(FilterOperation::CreateBlurFilter(2.f)); |
655 to.Append(FilterOperation::CreateSaturateFilter(4.f)); | 654 to.Append(FilterOperation::CreateSaturateFilter(4.f)); |
| 655 to.Append(FilterOperation::CreateHueRotateFilter(0.5f)); |
656 | 656 |
657 FilterOperations blended = to.Blend(from, -0.75); | 657 FilterOperations blended = to.Blend(from, -0.75); |
658 EXPECT_EQ(to, blended); | 658 EXPECT_EQ(to, blended); |
659 blended = to.Blend(from, 0.75); | 659 blended = to.Blend(from, 0.75); |
660 EXPECT_EQ(to, blended); | 660 EXPECT_EQ(to, blended); |
661 blended = to.Blend(from, 1.5); | 661 blended = to.Blend(from, 1.5); |
662 EXPECT_EQ(to, blended); | 662 EXPECT_EQ(to, blended); |
| 663 } |
663 | 664 |
664 to.Append(FilterOperation::CreateHueRotateFilter(0.5f)); | 665 // Tests blending non-empty sequences of different sizes. |
| 666 TEST(FilterOperationsTest, BlendRaggedSequences) { |
| 667 FilterOperations from; |
| 668 FilterOperations to; |
| 669 |
| 670 from.Append(FilterOperation::CreateSaturateFilter(3.f)); |
| 671 from.Append(FilterOperation::CreateBlurFilter(2.f)); |
| 672 to.Append(FilterOperation::CreateSaturateFilter(4.f)); |
| 673 |
| 674 FilterOperations blended = to.Blend(from, -0.75); |
| 675 FilterOperations expected; |
| 676 expected.Append(FilterOperation::CreateSaturateFilter(2.25f)); |
| 677 expected.Append(FilterOperation::CreateBlurFilter(3.5f)); |
| 678 EXPECT_EQ(expected, blended); |
| 679 |
| 680 blended = to.Blend(from, 0.75); |
| 681 expected.Clear(); |
| 682 expected.Append(FilterOperation::CreateSaturateFilter(3.75f)); |
| 683 expected.Append(FilterOperation::CreateBlurFilter(0.5f)); |
| 684 EXPECT_EQ(expected, blended); |
| 685 |
| 686 blended = to.Blend(from, 1.5); |
| 687 expected.Clear(); |
| 688 expected.Append(FilterOperation::CreateSaturateFilter(4.5f)); |
| 689 expected.Append(FilterOperation::CreateBlurFilter(0.f)); |
| 690 EXPECT_EQ(expected, blended); |
| 691 |
| 692 from.Append(FilterOperation::CreateOpacityFilter(1.f)); |
| 693 to.Append(FilterOperation::CreateOpacityFilter(1.f)); |
665 blended = to.Blend(from, -0.75); | 694 blended = to.Blend(from, -0.75); |
666 EXPECT_EQ(to, blended); | 695 EXPECT_EQ(to, blended); |
667 blended = to.Blend(from, 0.75); | 696 blended = to.Blend(from, 0.75); |
668 EXPECT_EQ(to, blended); | 697 EXPECT_EQ(to, blended); |
669 blended = to.Blend(from, 1.5); | 698 blended = to.Blend(from, 1.5); |
670 EXPECT_EQ(to, blended); | 699 EXPECT_EQ(to, blended); |
671 } | 700 } |
672 | 701 |
673 } // namespace | 702 } // namespace |
674 } // namespace cc | 703 } // namespace cc |
OLD | NEW |