From 6c00058c5db8d2f439258af2b063c3902323b97d Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 20 Jun 2016 08:41:10 -0700 Subject: [PATCH] webrender: Don't use OpenGL round() for snapping pixels Fixes #11751. --- resources/shaders/es2_common.vs.glsl | 2 +- resources/shaders/gl3_common.vs.glsl | 5 +++- tests/wpt/mozilla/meta/MANIFEST.json | 24 +++++++++++++++++++ .../meta/css/pixel_snapping_glyphs.html.ini | 4 ++++ .../tests/css/pixel_snapping_glyphs.html | 5 ++++ .../tests/css/pixel_snapping_glyphs_ref.html | 4 ++++ 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tests/wpt/mozilla/meta/css/pixel_snapping_glyphs.html.ini create mode 100644 tests/wpt/mozilla/tests/css/pixel_snapping_glyphs.html create mode 100644 tests/wpt/mozilla/tests/css/pixel_snapping_glyphs_ref.html diff --git a/resources/shaders/es2_common.vs.glsl b/resources/shaders/es2_common.vs.glsl index ccb8c3dcec5..91d72015e49 100644 --- a/resources/shaders/es2_common.vs.glsl +++ b/resources/shaders/es2_common.vs.glsl @@ -65,6 +65,6 @@ vec2 SnapToPixels(vec2 pos) // Snap the vertex to pixel position to guarantee correct texture // sampling when using bilinear filtering. - // TODO(gw): ES2 doesn't have round(). Do we ever get negative coords here? + // TODO(gw): Do we ever get negative coords here? return floor(0.5 + pos * uDevicePixelRatio) / uDevicePixelRatio; } diff --git a/resources/shaders/gl3_common.vs.glsl b/resources/shaders/gl3_common.vs.glsl index cffcfc80eb7..e24cef9437e 100644 --- a/resources/shaders/gl3_common.vs.glsl +++ b/resources/shaders/gl3_common.vs.glsl @@ -62,5 +62,8 @@ vec2 SnapToPixels(vec2 pos) { // Snap the vertex to pixel position to guarantee correct texture // sampling when using bilinear filtering. - return round(pos * uDevicePixelRatio) / uDevicePixelRatio; + + // Don't use round() because its behavior is implementation-defined on 0.5. + // TODO: Do we ever get negative coords here? + return floor(0.5 + pos * uDevicePixelRatio) / uDevicePixelRatio; } diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 24af8aa6f41..7518ae0a495 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -3986,6 +3986,18 @@ "viewport_size": "300x300" } ], + "css/pixel_snapping_glyphs.html": [ + { + "path": "css/pixel_snapping_glyphs.html", + "references": [ + [ + "/_mozilla/css/pixel_snapping_glyphs_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/pixel_snapping_glyphs.html" + } + ], "css/pixel_snapping_position_a.html": [ { "dpi": "2", @@ -11026,6 +11038,18 @@ "viewport_size": "300x300" } ], + "css/pixel_snapping_glyphs.html": [ + { + "path": "css/pixel_snapping_glyphs.html", + "references": [ + [ + "/_mozilla/css/pixel_snapping_glyphs_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/pixel_snapping_glyphs.html" + } + ], "css/pixel_snapping_position_a.html": [ { "dpi": "2", diff --git a/tests/wpt/mozilla/meta/css/pixel_snapping_glyphs.html.ini b/tests/wpt/mozilla/meta/css/pixel_snapping_glyphs.html.ini new file mode 100644 index 00000000000..76450e5e84d --- /dev/null +++ b/tests/wpt/mozilla/meta/css/pixel_snapping_glyphs.html.ini @@ -0,0 +1,4 @@ +[pixel_snapping_glyphs.html] + type: reftest + expected: + if os == "mac": FAIL diff --git a/tests/wpt/mozilla/tests/css/pixel_snapping_glyphs.html b/tests/wpt/mozilla/tests/css/pixel_snapping_glyphs.html new file mode 100644 index 00000000000..a423250c4d4 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/pixel_snapping_glyphs.html @@ -0,0 +1,5 @@ + + +pixel snapping glyphs test + +
illisible
diff --git a/tests/wpt/mozilla/tests/css/pixel_snapping_glyphs_ref.html b/tests/wpt/mozilla/tests/css/pixel_snapping_glyphs_ref.html new file mode 100644 index 00000000000..92ef1f14e7f --- /dev/null +++ b/tests/wpt/mozilla/tests/css/pixel_snapping_glyphs_ref.html @@ -0,0 +1,4 @@ + + +pixel snapping glyphs reference +
illisible