summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 00:31:41 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 00:31:41 +0000
commit00b9838b129511ed29680f001a33cc7858179397 (patch)
treeeb367ce86342c77795c239d0a0a70526a951dbe7 /cc
parente859d06015371958d9015f9b2e26e38c76d76614 (diff)
downloadchromium_src-00b9838b129511ed29680f001a33cc7858179397.zip
chromium_src-00b9838b129511ed29680f001a33cc7858179397.tar.gz
chromium_src-00b9838b129511ed29680f001a33cc7858179397.tar.bz2
cc: Add remaining pixel tests for background blur.
This replicates the following layout tests with compositor pixel tests: platform/chromium/compositing/filters/background-filter-blur-outsets.html platform/chromium/compositing/filters/background-filter-blur-off-axis.html The first test verifies that pixels from outside the bounds of the layer with background blur are used to contribute to the background behind the blurred layer. The second test verifies that the blur layer's transform does not affect the rendering of the blurred content behind it. New test: LayerTreeHostFiltersPixelTest.BackgroundFilterBlurOutsets LayerTreeHostFiltersPixelTest.BackgroundFilterBlurOffAxis R=jamesr,enne BUG=191170 Depends on: https://codereview.chromium.org/12518026/ Review URL: https://codereview.chromium.org/12571010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188524 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layer_tree_host_pixeltest_filters.cc62
-rw-r--r--cc/test/layer_tree_pixel_test.cc28
-rw-r--r--cc/test/layer_tree_pixel_test.h5
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);