diff options
author | John Reck <jreck@google.com> | 2014-08-06 10:19:32 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-08-06 10:19:32 -0700 |
commit | 3b52c03f5035b833d365215420739aa840ac5080 (patch) | |
tree | b3a4d200e2ebb00f7e15c507a76ea73459d511cf /libs/hwui/utils | |
parent | 65e2685dbd06cf151686132f64a9c50e07c77998 (diff) | |
download | frameworks_base-3b52c03f5035b833d365215420739aa840ac5080.zip frameworks_base-3b52c03f5035b833d365215420739aa840ac5080.tar.gz frameworks_base-3b52c03f5035b833d365215420739aa840ac5080.tar.bz2 |
clamp & round alpha
Bug: 16842521
Change-Id: Ifd93f40b5751746835c9d56bb3c2b5ba700bdccc
Diffstat (limited to 'libs/hwui/utils')
-rw-r--r-- | libs/hwui/utils/MathUtils.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/hwui/utils/MathUtils.h b/libs/hwui/utils/MathUtils.h index 2dfe9c6..66bc127 100644 --- a/libs/hwui/utils/MathUtils.h +++ b/libs/hwui/utils/MathUtils.h @@ -20,6 +20,7 @@ namespace android { namespace uirenderer { #define NON_ZERO_EPSILON (0.001f) +#define ALPHA_EPSILON (0.001f) class MathUtils { public: @@ -34,6 +35,16 @@ public: return value >= NON_ZERO_EPSILON; } + inline static float clampAlpha(float alpha) { + if (alpha <= ALPHA_EPSILON) { + return 0; + } else if (alpha >= (1 - ALPHA_EPSILON)) { + return 1; + } else { + return alpha; + } + } + inline static bool areEqual(float valueA, float valueB) { return isZero(valueA - valueB); } |