summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alec Mouri <alecmouri@google.com> 2019-04-23 18:27:16 -0700
committer Alec Mouri <alecmouri@google.com> 2019-04-23 18:27:16 -0700
commit4346189ae473119cdeeb470c02f5d204837772fb (patch)
tree198d305f7c19c3bb60c6f0803cc18aabb7ca67fd
parentbc703749ae4b3614bcf9e7ef20ebb0cefcd3bc5f (diff)
Increase precision in rounded corner shader
Otherwise, there's some floating point error when the corner radius is large. In testing, this is the smallest change that allows for rendering reasonably correct corners. Bug: 129866411 Test: launcher animation Change-Id: I5c016b6454e9fb9b4d5ed6e42e36c23da83430a8
-rw-r--r--libs/renderengine/gl/ProgramCache.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libs/renderengine/gl/ProgramCache.cpp b/libs/renderengine/gl/ProgramCache.cpp
index cd1182c89a..086a324999 100644
--- a/libs/renderengine/gl/ProgramCache.cpp
+++ b/libs/renderengine/gl/ProgramCache.cpp
@@ -575,7 +575,9 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
float applyCornerRadius(vec2 cropCoords)
{
vec2 position = cropCoords - cropCenter;
- vec2 dist = abs(position) + vec2(cornerRadius) - cropCenter;
+ // Increase precision here so that a large corner radius doesn't
+ // cause floating point error
+ highp vec2 dist = abs(position) + vec2(cornerRadius) - cropCenter;
float plane = length(max(dist, vec2(0.0)));
return 1.0 - clamp(plane - cornerRadius, 0.0, 1.0);
}