Skip to content

Commit

Permalink
Auto merge of #11801 - mbrubeck:snaptopix, r=pcwalton
Browse files Browse the repository at this point in the history
webrender: Don't use OpenGL round() for snapping pixels

Fixes #11751. See servo/webrender#294 for some details. r? @pcwalton

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11801)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jun 30, 2016
2 parents 0f7e196 + 6c00058 commit 461d7c4
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/shaders/es2_common.vs.glsl
Expand Up @@ -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;
}
5 changes: 4 additions & 1 deletion resources/shaders/gl3_common.vs.glsl
Expand Up @@ -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;
}
24 changes: 24 additions & 0 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -4022,6 +4022,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",
Expand Down Expand Up @@ -11122,6 +11134,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",
Expand Down
4 changes: 4 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions tests/wpt/mozilla/tests/css/pixel_snapping_glyphs.html
@@ -0,0 +1,5 @@
<!doctype html>
<meta charset="utf-8">
<title>pixel snapping glyphs test</title>
<link rel="match" href="pixel_snapping_glyphs_ref.html">
<div style="font: 13px 'Helvetica Neue'; padding: 0.5px;">illisible</div>
4 changes: 4 additions & 0 deletions tests/wpt/mozilla/tests/css/pixel_snapping_glyphs_ref.html
@@ -0,0 +1,4 @@
<!doctype html>
<meta charset="utf-8">
<title>pixel snapping glyphs reference</title>
<div style="font: 13px 'Helvetica Neue'; padding: 1px;">illisible</div>

0 comments on commit 461d7c4

Please sign in to comment.