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 553e66e8dba352e4acf121e0a2d040319d932523..8305d46ec299e50fe016dd224042f00ba147d5da 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,49 @@ 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)); |
+ |
danakj
2013/08/29 02:07:16
// Make the foreground layer's render surface be c
Stephen White
2013/08/29 17:07:00
Done.
|
+ background->SetMasksToBounds(true); |
+ foreground->SetFilter(filter); |
+ |
+ // Then we translate the foreground up by 100 pixels in Y, so the cropped |
+ // region scrolls to the top. This ensures that the crop rect is being |
danakj
2013/08/29 02:07:16
nit: s/scrolls/is moved to/
Stephen White
2013/08/29 17:07:00
Done.
|
+ // 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 |