Commit c54b712d authored by Malay Keshav's avatar Malay Keshav Committed by Commit Bot

Viz: Update float precision for rounded corner fragment shader

This patch changes the float precision from 'mediump' to 'highp'. This
is needed for android.

Bug: 1009322
Test: Manually tested various websites that were reported on the bug
Change-Id: I87b57d57c43093b590741393dfef3c75c151c1cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913708
Commit-Queue: Malay Keshav <malaykeshav@chromium.org>
Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Reviewed-by: default avatarDaniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719419}
parent 364c198f
......@@ -612,8 +612,10 @@ void FragmentShader::SetRoundedCornerFunctions(
if (r == 0.0)
return src;
// Vector to the corner's center this frag is in.
vec2 cornerCenter = GetCenter(isCorner, r);
// Vector to the corner's center this fragment is in.
// Due to precision errors on android, this variable requires a highp.
// See https://crbug.com/1009322
RoundedCornerPrecision vec2 cornerCenter = GetCenter(isCorner, r);
// Vector from the center of the corner to the current fragment center
vec2 cxy = rcCoord - cornerCenter;
......@@ -630,6 +632,12 @@ void FragmentShader::SetRoundedCornerFunctions(
std::string shader;
shader.reserve(shader_string->size() + 2048);
shader += "precision mediump float;";
shader +=
"\n#ifdef GL_FRAGMENT_PRECISION_HIGH\n"
" #define RoundedCornerPrecision highp\n"
"#else\n"
" #define RoundedCornerPrecision mediump\n"
"#endif\n";
kUniforms.AppendToString(&shader);
kFunctionRcUtility.AppendToString(&shader);
kFunctionApplyRoundedCorner.AppendToString(&shader);
......
<!DOCTYPE HTML>
<!-- READ BEFORE UPDATING:
If this test is updated make sure to increment the "revision" value of the
associated test in content/test/gpu/page_sets/pixel_tests.py. This will ensure
that the baseline images are regenerated on the next run.
-->
<html>
<head>
<meta name="viewport" content="initial-scale=1">
<title>Rounded corner Float Precision test</title>
<style>
#circle {
transform-origin: 0 0;
transform: scale(5);
width: 300px;
height: 300px;
border-radius: 50%;
overflow: hidden;
}
#rotate {
width: 400px;
height: 400px;
background: lightblue;
will-change: transform;
}
</style>
<script>
function finish() {
domAutomationController.send("SUCCESS");
}
window.requestAnimationFrame(finish);
</script>
</head>
<body onload="main()">
<div id="circle">
<div id="rotate">
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -780,7 +780,12 @@ class PixelTestPages(object):
'size': [1, 1],
'color': [255, 215, 0],
}
])
]),
PixelTestPage(
'pixel_precision_rounded_corner.html',
base_name + '_PrecisionRoundedCorner',
test_rect=[0, 0, 400, 400],
browser_args=browser_args)
]
# Pages that should be run with experimental canvas features.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment