summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-07-28 22:26:42 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-07-28 22:26:42 +0000
commit2173449d9dccb15b87c9df5d373dc32e1dcabed6 (patch)
tree3acf4f324407858d1e3fc6ef1960b52a8fd7f929
parentfa7b4252fb8ee083b44e37c450b96b48d5208490 (diff)
parent295f80cecebb4d48edb58838f75a596db36d02c5 (diff)
downloadnative-android10-s2-release.tar.gz
Change-Id: I10d7f5b7ccd28effeb39bbbbb7a454d819e1f93d
-rw-r--r--libs/renderengine/gl/ProgramCache.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/libs/renderengine/gl/ProgramCache.cpp b/libs/renderengine/gl/ProgramCache.cpp
index 086a324999..d242677f0c 100644
--- a/libs/renderengine/gl/ProgramCache.cpp
+++ b/libs/renderengine/gl/ProgramCache.cpp
@@ -575,10 +575,11 @@ String8 ProgramCache::generateFragmentShader(const Key& needs) {
float applyCornerRadius(vec2 cropCoords)
{
vec2 position = cropCoords - 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)));
+ // Scale down the dist vector here, as otherwise large corner
+ // radii can cause floating point issues when computing the norm
+ vec2 dist = (abs(position) - cropCenter + vec2(cornerRadius)) / 16.0;
+ // Once we've found the norm, then scale back up.
+ float plane = length(max(dist, vec2(0.0))) * 16.0;
return 1.0 - clamp(plane - cornerRadius, 0.0, 1.0);
}
)__SHADER__";