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

Unified Diff: cc/trees/layer_tree_host_pixeltest_filters.cc

Issue 1942863002: cc: fix pixel-moving filter effects on a rotated layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment Created 4 years, 8 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
« no previous file with comments | « cc/test/data/rotated_filter_sw.png ('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 135c4fda9f2da69473c62ff43a78cb5a95e0364a..14ba6adc11f43634bb952b8b986d829205791294 100644
--- a/cc/trees/layer_tree_host_pixeltest_filters.cc
+++ b/cc/trees/layer_tree_host_pixeltest_filters.cc
@@ -477,6 +477,97 @@ TEST_F(ImageScaledRenderSurface, ImageRenderSurfaceScaled_Software) {
base::FilePath(FILE_PATH_LITERAL("scaled_render_surface_layer_sw.png")));
}
+class RotatedFilterTest : public LayerTreeHostFiltersPixelTest {
+ protected:
+ void RunPixelTestType(PixelTestType test_type, base::FilePath image_name) {
+ scoped_refptr<SolidColorLayer> background =
+ CreateSolidColorLayer(gfx::Rect(300, 300), SK_ColorWHITE);
+
+ gfx::Rect rect(50, 50, 100, 100);
+
+ scoped_refptr<SolidColorLayer> child =
+ CreateSolidColorLayer(rect, SK_ColorBLUE);
+
+ gfx::Transform transform;
+ transform.Translate(50.0f, 50.0f);
+ transform.RotateAboutZAxis(1.0);
+ transform.Translate(-50.0f, -50.0f);
+ child->SetTransform(transform);
+ FilterOperations filters;
+ // We need a clamping brightness filter here to force the Skia filter path.
+ filters.Append(FilterOperation::CreateBrightnessFilter(1.1f));
+ filters.Append(FilterOperation::CreateGrayscaleFilter(1.0f));
+ child->SetFilters(filters);
+
+ background->AddChild(child);
+
+#if defined(OS_WIN)
+ // Windows has 1 pixel off by 1: crbug.com/259915
+ float percentage_pixels_large_error = 0.00111112f; // 1px / (300*300)
+ float percentage_pixels_small_error = 0.0f;
+ float average_error_allowed_in_bad_pixels = 1.f;
+ int large_error_allowed = 1;
+ int small_error_allowed = 0;
+ pixel_comparator_.reset(new FuzzyPixelComparator(
+ true, // discard_alpha
+ percentage_pixels_large_error, percentage_pixels_small_error,
+ average_error_allowed_in_bad_pixels, large_error_allowed,
+ small_error_allowed));
+#endif
+
+ RunPixelTest(test_type, background, image_name);
+ }
+};
+
+TEST_F(RotatedFilterTest, RotatedFilterTest_GL) {
+ RunPixelTestType(PIXEL_TEST_GL,
+ base::FilePath(FILE_PATH_LITERAL("rotated_filter_gl.png")));
+}
+
+TEST_F(RotatedFilterTest, RotatedFilterTest_Software) {
+ RunPixelTestType(PIXEL_TEST_SOFTWARE,
+ base::FilePath(FILE_PATH_LITERAL("rotated_filter_sw.png")));
+}
+
+class RotatedDropShadowFilterTest : public LayerTreeHostFiltersPixelTest {
+ protected:
+ void RunPixelTestType(PixelTestType test_type, base::FilePath image_name) {
+ scoped_refptr<SolidColorLayer> background =
+ CreateSolidColorLayer(gfx::Rect(300, 300), SK_ColorWHITE);
+
+ gfx::Rect rect(50, 50, 100, 100);
+
+ scoped_refptr<SolidColorLayer> child =
+ CreateSolidColorLayer(rect, SK_ColorBLUE);
+
+ gfx::Transform transform;
+ transform.Translate(50.0f, 50.0f);
+ transform.RotateAboutZAxis(1.0);
+ transform.Translate(-50.0f, -50.0f);
+ child->SetTransform(transform);
+ FilterOperations filters;
+ filters.Append(FilterOperation::CreateDropShadowFilter(
+ gfx::Point(10.0f, 10.0f), 0.0f, SK_ColorBLACK));
+ child->SetFilters(filters);
+
+ background->AddChild(child);
+
+ RunPixelTest(test_type, background, image_name);
+ }
+};
+
+TEST_F(RotatedDropShadowFilterTest, RotatedDropShadowFilterTest_GL) {
+ RunPixelTestType(
+ PIXEL_TEST_GL,
+ base::FilePath(FILE_PATH_LITERAL("rotated_drop_shadow_filter_gl.png")));
+}
+
+TEST_F(RotatedDropShadowFilterTest, RotatedDropShadowFilterTest_Software) {
+ RunPixelTestType(
+ PIXEL_TEST_SOFTWARE,
+ base::FilePath(FILE_PATH_LITERAL("rotated_drop_shadow_filter_sw.png")));
+}
+
class EnlargedTextureWithAlphaThresholdFilter
: public LayerTreeHostFiltersPixelTest {
protected:
« no previous file with comments | « cc/test/data/rotated_filter_sw.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698