| Index: cc/trees/layer_tree_host_pixeltest_filters.cc
|
| diff --git a/cc/trees/layer_tree_host_pixeltest_filters.cc b/cc/trees/layer_tree_host_pixeltest_filters.cc
|
| index e73164649728cca197408c1ea697937ad1e30d3f..7068b4b1047379c896d5c504f776e57dcc225150 100644
|
| --- a/cc/trees/layer_tree_host_pixeltest_filters.cc
|
| +++ b/cc/trees/layer_tree_host_pixeltest_filters.cc
|
| @@ -6,6 +6,8 @@
|
| #include "cc/layers/solid_color_layer.h"
|
| #include "cc/test/layer_tree_pixel_test.h"
|
| #include "cc/test/pixel_comparator.h"
|
| +#include "third_party/skia/include/effects/SkColorFilterImageFilter.h"
|
| +#include "third_party/skia/include/effects/SkColorMatrixFilter.h"
|
|
|
| #if !defined(OS_ANDROID)
|
|
|
| @@ -148,6 +150,51 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) {
|
| "background_filter_blur_off_axis.png")));
|
| }
|
|
|
| +TEST_F(LayerTreeHostFiltersPixelTest, ImageFilterClipped) {
|
| + scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer(
|
| + gfx::Rect(200, 200), SK_ColorBLACK);
|
| +
|
| + scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
|
| + gfx::Rect(200, 200), SK_ColorYELLOW);
|
| + root->AddChild(background);
|
| +
|
| + scoped_refptr<SolidColorLayer> foreground = CreateSolidColorLayer(
|
| + gfx::Rect(200, 200), SK_ColorRED);
|
| + background->AddChild(foreground);
|
| +
|
| + SkScalar matrix[20];
|
| + memset(matrix, 0, 20 * sizeof(matrix[0]));
|
| + // This filter does a red-blue swap, so the foreground becomes blue.
|
| + matrix[2] = matrix[6] = matrix[10] = matrix[18] = SK_Scalar1;
|
| + skia::RefPtr<SkColorFilter> colorFilter(skia::AdoptRef(
|
| + new SkColorMatrixFilter(matrix)));
|
| + // We filter only the bottom 200x100 pixels of the foreground.
|
| + SkIRect cropRect = SkIRect::MakeXYWH(0, 100, 200, 100);
|
| + skia::RefPtr<SkImageFilter> filter =
|
| + skia::AdoptRef(SkColorFilterImageFilter::Create(
|
| + colorFilter.get(),
|
| + NULL,
|
| + &cropRect));
|
| +
|
| + // Make the foreground layer's render surface be clipped by the background
|
| + // layer.
|
| + background->SetMasksToBounds(true);
|
| + foreground->SetFilter(filter);
|
| +
|
| + // Then we translate the foreground up by 100 pixels in Y, so the cropped
|
| + // region is moved to to the top. This ensures that the crop rect is being
|
| + // correctly transformed in skia by the amount of clipping that the
|
| + // compositor performs.
|
| + gfx::Transform transform;
|
| + transform.Translate(0.0, -100.0);
|
| + foreground->SetTransform(transform);
|
| +
|
| + RunPixelTest(GL_WITH_BITMAP,
|
| + background,
|
| + base::FilePath(FILE_PATH_LITERAL(
|
| + "blue_yellow.png")));
|
| +}
|
| +
|
| } // namespace
|
| } // namespace cc
|
|
|
|
|