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

Side by Side Diff: cc/playback/display_item_list_unittest.cc

Issue 2297213003: Fix CSS reference filters with negative transformed children. (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « cc/output/software_renderer.cc ('k') | cc/playback/filter_display_item.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/playback/display_item_list.h" 5 #include "cc/playback/display_item_list.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // involve |src| at all. Incorrectly assuming such a relationship (e.g. by 472 // involve |src| at all. Incorrectly assuming such a relationship (e.g. by
473 // translating |dst| after it is computed by computeFastBounds, rather than 473 // translating |dst| after it is computed by computeFastBounds, rather than
474 // translating |src| before it provided to computedFastBounds) can cause 474 // translating |src| before it provided to computedFastBounds) can cause
475 // incorrect clipping of filter output. To test for this, we include an 475 // incorrect clipping of filter output. To test for this, we include an
476 // SkImageSource filter in |filters|. Here, |src| is |filter_bounds|, defined 476 // SkImageSource filter in |filters|. Here, |src| is |filter_bounds|, defined
477 // below. 477 // below.
478 sk_sp<SkImageFilter> image_filter = SkImageSource::Make(source_image); 478 sk_sp<SkImageFilter> image_filter = SkImageSource::Make(source_image);
479 filters.Append(FilterOperation::CreateReferenceFilter(image_filter)); 479 filters.Append(FilterOperation::CreateReferenceFilter(image_filter));
480 filters.Append(FilterOperation::CreateBrightnessFilter(0.5f)); 480 filters.Append(FilterOperation::CreateBrightnessFilter(0.5f));
481 gfx::RectF filter_bounds(10.f, 10.f, 50.f, 50.f); 481 gfx::RectF filter_bounds(10.f, 10.f, 50.f, 50.f);
482 list->CreateAndAppendPairedBeginItem<FilterDisplayItem>(filters, 482 list->CreateAndAppendPairedBeginItem<FilterDisplayItem>(
483 filter_bounds); 483 filters, filter_bounds, filter_bounds.origin());
484 484
485 // Include a rect drawing so that filter is actually applied to something. 485 // Include a rect drawing so that filter is actually applied to something.
486 { 486 {
487 SkPictureRecorder recorder; 487 SkPictureRecorder recorder;
488 sk_sp<SkCanvas> canvas; 488 sk_sp<SkCanvas> canvas;
489 489
490 SkPaint red_paint; 490 SkPaint red_paint;
491 red_paint.setColor(SK_ColorRED); 491 red_paint.setColor(SK_ColorRED);
492 492
493 canvas = sk_ref_sp(recorder.beginRecording( 493 canvas = sk_ref_sp(recorder.beginRecording(
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5)); 920 EXPECT_RECT_EQ(merged_drawing_bounds, list->VisualRectForTesting(5));
921 } 921 }
922 922
923 TEST(DisplayItemListTest, AppendVisualRectOneFilterNoDrawings) { 923 TEST(DisplayItemListTest, AppendVisualRectOneFilterNoDrawings) {
924 scoped_refptr<DisplayItemList> list = CreateDefaultList(); 924 scoped_refptr<DisplayItemList> list = CreateDefaultList();
925 925
926 // One filter containing no drawings: Bf, Ef 926 // One filter containing no drawings: Bf, Ef
927 927
928 gfx::Rect filter_bounds(5, 6, 1, 1); 928 gfx::Rect filter_bounds(5, 6, 1, 1);
929 list->CreateAndAppendPairedBeginItemWithVisualRect<FilterDisplayItem>( 929 list->CreateAndAppendPairedBeginItemWithVisualRect<FilterDisplayItem>(
930 filter_bounds, FilterOperations(), gfx::RectF(filter_bounds)); 930 filter_bounds, FilterOperations(), gfx::RectF(filter_bounds),
931 gfx::PointF(filter_bounds.origin()));
931 932
932 list->CreateAndAppendPairedEndItem<EndFilterDisplayItem>(); 933 list->CreateAndAppendPairedEndItem<EndFilterDisplayItem>();
933 934
934 EXPECT_EQ(2u, list->size()); 935 EXPECT_EQ(2u, list->size());
935 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0)); 936 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0));
936 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1)); 937 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1));
937 } 938 }
938 939
939 TEST(DisplayItemListTest, AppendVisualRectBlockContainingFilterNoDrawings) { 940 TEST(DisplayItemListTest, AppendVisualRectBlockContainingFilterNoDrawings) {
940 scoped_refptr<DisplayItemList> list = CreateDefaultList(); 941 scoped_refptr<DisplayItemList> list = CreateDefaultList();
941 942
942 // One block containing one filter and no drawings: B1, Bf, Ef, E1. 943 // One block containing one filter and no drawings: B1, Bf, Ef, E1.
943 944
944 gfx::Rect clip_bounds(5, 6, 7, 8); 945 gfx::Rect clip_bounds(5, 6, 7, 8);
945 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>( 946 list->CreateAndAppendPairedBeginItem<ClipDisplayItem>(
946 clip_bounds, std::vector<SkRRect>(), true); 947 clip_bounds, std::vector<SkRRect>(), true);
947 948
948 gfx::Rect filter_bounds(5, 6, 1, 1); 949 gfx::Rect filter_bounds(5, 6, 1, 1);
949 list->CreateAndAppendPairedBeginItemWithVisualRect<FilterDisplayItem>( 950 list->CreateAndAppendPairedBeginItemWithVisualRect<FilterDisplayItem>(
950 filter_bounds, FilterOperations(), gfx::RectF(filter_bounds)); 951 filter_bounds, FilterOperations(), gfx::RectF(filter_bounds),
952 gfx::PointF(filter_bounds.origin()));
951 953
952 list->CreateAndAppendPairedEndItem<EndFilterDisplayItem>(); 954 list->CreateAndAppendPairedEndItem<EndFilterDisplayItem>();
953 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>(); 955 list->CreateAndAppendPairedEndItem<EndClipDisplayItem>();
954 956
955 EXPECT_EQ(4u, list->size()); 957 EXPECT_EQ(4u, list->size());
956 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0)); 958 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(0));
957 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1)); 959 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(1));
958 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(2)); 960 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(2));
959 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(3)); 961 EXPECT_RECT_EQ(filter_bounds, list->VisualRectForTesting(3));
960 } 962 }
961 963
962 } // namespace cc 964 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/software_renderer.cc ('k') | cc/playback/filter_display_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698