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

Unified Diff: cc/trees/layer_tree_host_pixeltest_filters.cc

Issue 23060011: Pass the quad's rect (contents_rect) origin to skia image filters as an offset in the CTM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add pixel test. Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« cc/output/gl_renderer.cc ('K') | « cc/output/gl_renderer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3369a996ba7427c86d002748ae11d4d955e85f74 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,48 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) {
"background_filter_blur_off_axis.png")));
}
+TEST_F(LayerTreeHostFiltersPixelTest, ImageFilterClipped) {
+ scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer(
+ gfx::Rect(200, 200), SK_ColorBLUE);
+
+ scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
+ gfx::Rect(200, 200), SK_ColorGREEN);
+ root->AddChild(background);
+
+ scoped_refptr<SolidColorLayer> foreground = CreateSolidColorLayer(
+ gfx::Rect(200, 200), SK_ColorGREEN);
+ background->AddChild(foreground);
+
+ SkScalar matrix[20];
+ memset(matrix, 0, 20 * sizeof(matrix[0]));
+ matrix[1] = matrix[5] = matrix[12] = matrix[18] = SK_Scalar1;
+ skia::RefPtr<SkColorFilter> colorFilter(skia::AdoptRef(
+ new SkColorMatrixFilter(matrix)));
+ // We filter only the top 200x100 pixels of the foreground.
+ SkIRect cropRect = SkIRect::MakeWH(200, 100);
+ skia::RefPtr<SkImageFilter> filter =
+ skia::AdoptRef(SkColorFilterImageFilter::Create(
+ colorFilter.get(),
+ NULL,
+ &cropRect));
+
+ background->SetMasksToBounds(true);
+ foreground->SetFilter(filter);
+
+ // Then we translate the foreground up by 100 pixels in Y, so the cropped
+ // region scrolls off. This ensures that the crop rect is being correctly
danakj 2013/08/28 22:26:58 If you translated by the origin twice in the rende
Stephen White 2013/08/29 00:36:34 Yes, it would still pass. But the layout tests I'v
+ // 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(
+ "green.png")));
+}
+
} // namespace
} // namespace cc
« cc/output/gl_renderer.cc ('K') | « cc/output/gl_renderer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698