diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/layer_tree_host_pixeltest_filters.cc | 62 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.cc | 28 | ||||
-rw-r--r-- | cc/test/layer_tree_pixel_test.h | 5 |
3 files changed, 95 insertions, 0 deletions
diff --git a/cc/layer_tree_host_pixeltest_filters.cc b/cc/layer_tree_host_pixeltest_filters.cc index 37d2931..18d51b4 100644 --- a/cc/layer_tree_host_pixeltest_filters.cc +++ b/cc/layer_tree_host_pixeltest_filters.cc @@ -33,6 +33,68 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlur) { "background_filter_blur.png"))); } +TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOutsets) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(200, 200), SK_ColorWHITE); + + // The green border is outside the layer with background blur, but the + // background blur should use pixels from outside its layer borders, up to the + // radius of the blur effect. So the border should be blurred underneath the + // top layer causing the green to bleed under the transparent layer, but not + // in the 1px region between the transparent layer and the green border. + scoped_refptr<SolidColorLayer> green_border = CreateSolidColorLayerWithBorder( + gfx::Rect(1, 1, 198, 198), SK_ColorWHITE, 10, kCSSGreen); + scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer( + gfx::Rect(12, 12, 176, 176), SK_ColorTRANSPARENT); + background->AddChild(green_border); + background->AddChild(blur); + + WebKit::WebFilterOperations filters; + filters.append(WebKit::WebFilterOperation::createBlurFilter(5)); + blur->SetBackgroundFilters(filters); + + RunPixelTest(background, + base::FilePath(FILE_PATH_LITERAL( + "background_filter_blur_outsets.png"))); +} + +TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) { + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( + gfx::Rect(200, 200), SK_ColorWHITE); + + // This verifies that the perspective of the clear layer (with black border) + // does not influence the blending of the green box behind it. Also verifies + // that the blur is correctly clipped inside the transformed clear layer. + scoped_refptr<SolidColorLayer> green = CreateSolidColorLayer( + gfx::Rect(50, 50, 100, 100), kCSSGreen); + scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayerWithBorder( + gfx::Rect(30, 30, 120, 120), SK_ColorTRANSPARENT, 1, SK_ColorBLACK); + background->AddChild(green); + background->AddChild(blur); + + background->SetPreserves3d(true); + gfx::Transform background_transform; + background_transform.ApplyPerspectiveDepth(200.0); + background->SetTransform(background_transform); + + blur->SetPreserves3d(true); + gfx::Transform blur_transform; + blur_transform.Translate(55.0, 65.0); + blur_transform.RotateAboutXAxis(85.0); + blur_transform.RotateAboutYAxis(180.0); + blur_transform.RotateAboutZAxis(20.0); + blur_transform.Translate(-60.0, -60.0); + blur->SetTransform(blur_transform); + + WebKit::WebFilterOperations filters; + filters.append(WebKit::WebFilterOperation::createBlurFilter(2)); + blur->SetBackgroundFilters(filters); + + RunPixelTest(background, + base::FilePath(FILE_PATH_LITERAL( + "background_filter_blur_off_axis.png"))); +} + } // namespace } // namespace cc diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 87cbd8f..d4b3701 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -90,6 +90,34 @@ scoped_refptr<SolidColorLayer> LayerTreePixelTest::CreateSolidColorLayer( return layer; } +scoped_refptr<SolidColorLayer> LayerTreePixelTest:: + CreateSolidColorLayerWithBorder( + gfx::Rect rect, SkColor color, int border_width, SkColor border_color) { + scoped_refptr<SolidColorLayer> layer = CreateSolidColorLayer(rect, color); + scoped_refptr<SolidColorLayer> border_top = CreateSolidColorLayer( + gfx::Rect(0, 0, rect.width(), border_width), border_color); + scoped_refptr<SolidColorLayer> border_left = CreateSolidColorLayer( + gfx::Rect(0, + border_width, + border_width, + rect.height() - border_width * 2), + border_color); + scoped_refptr<SolidColorLayer> border_right = CreateSolidColorLayer( + gfx::Rect(rect.width() - border_width, + border_width, + border_width, + rect.height() - border_width * 2), + border_color); + scoped_refptr<SolidColorLayer> border_bottom = CreateSolidColorLayer( + gfx::Rect(0, rect.height() - border_width, rect.width(), border_width), + border_color); + layer->AddChild(border_top); + layer->AddChild(border_left); + layer->AddChild(border_right); + layer->AddChild(border_bottom); + return layer; +} + void LayerTreePixelTest::RunPixelTest( scoped_refptr<Layer> content_root, base::FilePath file_name) diff --git a/cc/test/layer_tree_pixel_test.h b/cc/test/layer_tree_pixel_test.h index 4682d9e..58ec11f 100644 --- a/cc/test/layer_tree_pixel_test.h +++ b/cc/test/layer_tree_pixel_test.h @@ -34,6 +34,11 @@ class LayerTreePixelTest : public ThreadedTest { scoped_refptr<SolidColorLayer> CreateSolidColorLayer(gfx::Rect rect, SkColor color); + scoped_refptr<SolidColorLayer> CreateSolidColorLayerWithBorder( + gfx::Rect rect, + SkColor color, + int border_width, + SkColor border_color); void RunPixelTest(scoped_refptr<Layer> content_root, base::FilePath file_name); |