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 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 FilterOperation expected = | 498 FilterOperation expected = |
499 FilterOperation::CreateSaturatingBrightnessFilter(0.75f); | 499 FilterOperation::CreateSaturatingBrightnessFilter(0.75f); |
500 EXPECT_EQ(expected, blended); | 500 EXPECT_EQ(expected, blended); |
501 | 501 |
502 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 502 blended = FilterOperation::Blend(NULL, &filter, 0.25); |
503 expected = FilterOperation::CreateSaturatingBrightnessFilter(0.25f); | 503 expected = FilterOperation::CreateSaturatingBrightnessFilter(0.25f); |
504 EXPECT_EQ(expected, blended); | 504 EXPECT_EQ(expected, blended); |
505 } | 505 } |
506 | 506 |
507 TEST(FilterOperationsTest, BlendReferenceFilters) { | 507 TEST(FilterOperationsTest, BlendReferenceFilters) { |
508 skia::RefPtr<SkImageFilter> from_filter = skia::AdoptRef( | 508 skia::RefPtr<SkImageFilter> from_filter = |
509 new SkBlurImageFilter(1.f, 1.f)); | 509 skia::AdoptRef(SkBlurImageFilter::Create(1.f, 1.f)); |
510 skia::RefPtr<SkImageFilter> to_filter = skia::AdoptRef( | 510 skia::RefPtr<SkImageFilter> to_filter = |
511 new SkBlurImageFilter(2.f, 2.f)); | 511 skia::AdoptRef(SkBlurImageFilter::Create(2.f, 2.f)); |
512 FilterOperation from = FilterOperation::CreateReferenceFilter(from_filter); | 512 FilterOperation from = FilterOperation::CreateReferenceFilter(from_filter); |
513 FilterOperation to = FilterOperation::CreateReferenceFilter(to_filter); | 513 FilterOperation to = FilterOperation::CreateReferenceFilter(to_filter); |
514 | 514 |
515 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); | 515 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75); |
516 EXPECT_EQ(from, blended); | 516 EXPECT_EQ(from, blended); |
517 | 517 |
518 blended = FilterOperation::Blend(&from, &to, 0.5); | 518 blended = FilterOperation::Blend(&from, &to, 0.5); |
519 EXPECT_EQ(from, blended); | 519 EXPECT_EQ(from, blended); |
520 | 520 |
521 blended = FilterOperation::Blend(&from, &to, 0.6); | 521 blended = FilterOperation::Blend(&from, &to, 0.6); |
522 EXPECT_EQ(to, blended); | 522 EXPECT_EQ(to, blended); |
523 | 523 |
524 blended = FilterOperation::Blend(&from, &to, 1.5); | 524 blended = FilterOperation::Blend(&from, &to, 1.5); |
525 EXPECT_EQ(to, blended); | 525 EXPECT_EQ(to, blended); |
526 } | 526 } |
527 | 527 |
528 TEST(FilterOperationsTest, BlendReferenceWithNull) { | 528 TEST(FilterOperationsTest, BlendReferenceWithNull) { |
529 skia::RefPtr<SkImageFilter> image_filter = skia::AdoptRef( | 529 skia::RefPtr<SkImageFilter> image_filter = |
530 new SkBlurImageFilter(1.f, 1.f)); | 530 skia::AdoptRef(SkBlurImageFilter::Create(1.f, 1.f)); |
531 FilterOperation filter = FilterOperation::CreateReferenceFilter(image_filter); | 531 FilterOperation filter = FilterOperation::CreateReferenceFilter(image_filter); |
532 FilterOperation null_filter = | 532 FilterOperation null_filter = |
533 FilterOperation::CreateReferenceFilter(skia::RefPtr<SkImageFilter>()); | 533 FilterOperation::CreateReferenceFilter(skia::RefPtr<SkImageFilter>()); |
534 | 534 |
535 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); | 535 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); |
536 EXPECT_EQ(filter, blended); | 536 EXPECT_EQ(filter, blended); |
537 blended = FilterOperation::Blend(&filter, NULL, 0.75); | 537 blended = FilterOperation::Blend(&filter, NULL, 0.75); |
538 EXPECT_EQ(null_filter, blended); | 538 EXPECT_EQ(null_filter, blended); |
539 | 539 |
540 blended = FilterOperation::Blend(NULL, &filter, 0.25); | 540 blended = FilterOperation::Blend(NULL, &filter, 0.25); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 blended = to.Blend(from, -0.75); | 694 blended = to.Blend(from, -0.75); |
695 EXPECT_EQ(to, blended); | 695 EXPECT_EQ(to, blended); |
696 blended = to.Blend(from, 0.75); | 696 blended = to.Blend(from, 0.75); |
697 EXPECT_EQ(to, blended); | 697 EXPECT_EQ(to, blended); |
698 blended = to.Blend(from, 1.5); | 698 blended = to.Blend(from, 1.5); |
699 EXPECT_EQ(to, blended); | 699 EXPECT_EQ(to, blended); |
700 } | 700 } |
701 | 701 |
702 } // namespace | 702 } // namespace |
703 } // namespace cc | 703 } // namespace cc |
OLD | NEW |