Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: cc/output/filter_operations_unittest.cc

Issue 21154002: Add support for converting cc::FilterOperations into an SkImageFilter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/output/filter_operations.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
7 #include "ui/gfx/point.h" 9 #include "ui/gfx/point.h"
8 10
9 namespace cc { 11 namespace cc {
10 namespace { 12 namespace {
11 13
12 TEST(FilterOperationsTest, GetOutsetsBlur) { 14 TEST(FilterOperationsTest, GetOutsetsBlur) {
13 FilterOperations ops; 15 FilterOperations ops;
14 ops.Append(FilterOperation::CreateBlurFilter(20)); 16 ops.Append(FilterOperation::CreateBlurFilter(20));
15 int top, right, bottom, left; 17 int top, right, bottom, left;
16 top = right = bottom = left = 0; 18 top = right = bottom = left = 0;
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25); 492 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25);
491 FilterOperation expected = 493 FilterOperation expected =
492 FilterOperation::CreateSaturatingBrightnessFilter(0.75f); 494 FilterOperation::CreateSaturatingBrightnessFilter(0.75f);
493 EXPECT_EQ(expected, blended); 495 EXPECT_EQ(expected, blended);
494 496
495 blended = FilterOperation::Blend(NULL, &filter, 0.25); 497 blended = FilterOperation::Blend(NULL, &filter, 0.25);
496 expected = FilterOperation::CreateSaturatingBrightnessFilter(0.25f); 498 expected = FilterOperation::CreateSaturatingBrightnessFilter(0.25f);
497 EXPECT_EQ(expected, blended); 499 EXPECT_EQ(expected, blended);
498 } 500 }
499 501
502 TEST(FilterOperationsTest, BlendReferenceFilters) {
503 skia::RefPtr<SkImageFilter> from_filter = skia::AdoptRef(
504 new SkBlurImageFilter(1.f, 1.f));
505 skia::RefPtr<SkImageFilter> to_filter = skia::AdoptRef(
506 new SkBlurImageFilter(2.f, 2.f));
507 FilterOperation from = FilterOperation::CreateReferenceFilter(from_filter);
508 FilterOperation to = FilterOperation::CreateReferenceFilter(to_filter);
509
510 FilterOperation blended = FilterOperation::Blend(&from, &to, -0.75);
511 EXPECT_EQ(from, blended);
512
513 blended = FilterOperation::Blend(&from, &to, 0.5);
514 EXPECT_EQ(from, blended);
515
516 blended = FilterOperation::Blend(&from, &to, 0.6);
517 EXPECT_EQ(to, blended);
518
519 blended = FilterOperation::Blend(&from, &to, 1.5);
520 EXPECT_EQ(to, blended);
521 }
522
523 TEST(FilterOperationsTest, BlendReferenceWithNull) {
524 skia::RefPtr<SkImageFilter> image_filter = skia::AdoptRef(
525 new SkBlurImageFilter(1.f, 1.f));
526 FilterOperation filter = FilterOperation::CreateReferenceFilter(image_filter);
527 FilterOperation null_filter =
528 FilterOperation::CreateReferenceFilter(skia::RefPtr<SkImageFilter>());
529
530 FilterOperation blended = FilterOperation::Blend(&filter, NULL, 0.25);
531 EXPECT_EQ(filter, blended);
532 blended = FilterOperation::Blend(&filter, NULL, 0.75);
533 EXPECT_EQ(null_filter, blended);
534
535 blended = FilterOperation::Blend(NULL, &filter, 0.25);
536 EXPECT_EQ(null_filter, blended);
537 blended = FilterOperation::Blend(NULL, &filter, 0.75);
538 EXPECT_EQ(filter, blended);
539 }
540
500 // Tests blending non-empty sequences that have the same length and matching 541 // Tests blending non-empty sequences that have the same length and matching
501 // operations. 542 // operations.
502 TEST(FilterOperationsTest, BlendMatchingSequences) { 543 TEST(FilterOperationsTest, BlendMatchingSequences) {
503 FilterOperations from; 544 FilterOperations from;
504 FilterOperations to; 545 FilterOperations to;
505 546
506 from.Append(FilterOperation::CreateBlurFilter(0.f)); 547 from.Append(FilterOperation::CreateBlurFilter(0.f));
507 to.Append(FilterOperation::CreateBlurFilter(2.f)); 548 to.Append(FilterOperation::CreateBlurFilter(2.f));
508 549
509 from.Append(FilterOperation::CreateSaturateFilter(4.f)); 550 from.Append(FilterOperation::CreateSaturateFilter(4.f));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 blended = to.Blend(from, -0.75); 660 blended = to.Blend(from, -0.75);
620 EXPECT_EQ(to, blended); 661 EXPECT_EQ(to, blended);
621 blended = to.Blend(from, 0.75); 662 blended = to.Blend(from, 0.75);
622 EXPECT_EQ(to, blended); 663 EXPECT_EQ(to, blended);
623 blended = to.Blend(from, 1.5); 664 blended = to.Blend(from, 1.5);
624 EXPECT_EQ(to, blended); 665 EXPECT_EQ(to, blended);
625 } 666 }
626 667
627 } // namespace 668 } // namespace
628 } // namespace cc 669 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/filter_operations.cc ('k') | cc/output/gl_renderer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698