summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-05-13 21:59:35 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-13 21:59:36 +0000
commitbee74c2b479153bb6a4b9e03f068658042a5fdfc (patch)
treee0b2cb552d72dda832873b07d4ca2925e7926201 /libs
parent191437447a2a3f2e58aec18e894ad571932dff6e (diff)
parent531ee701ddca2d1604fcce8e5d6d8837a3f651ac (diff)
downloadframeworks_base-bee74c2b479153bb6a4b9e03f068658042a5fdfc.zip
frameworks_base-bee74c2b479153bb6a4b9e03f068658042a5fdfc.tar.gz
frameworks_base-bee74c2b479153bb6a4b9e03f068658042a5fdfc.tar.bz2
Merge "Clamp to uint8 for alpha"
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Animator.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/libs/hwui/Animator.cpp b/libs/hwui/Animator.cpp
index 6a3003e..a033f86 100644
--- a/libs/hwui/Animator.cpp
+++ b/libs/hwui/Animator.cpp
@@ -199,13 +199,18 @@ float CanvasPropertyPaintAnimator::getValue() const {
return -1;
}
+static uint8_t to_uint8(float value) {
+ int c = (int) (value + .5f);
+ return static_cast<uint8_t>( c < 0 ? 0 : c > 255 ? 255 : c );
+}
+
void CanvasPropertyPaintAnimator::setValue(float value) {
switch (mField) {
case STROKE_WIDTH:
mProperty->value.setStrokeWidth(value);
return;
case ALPHA:
- mProperty->value.setAlpha(value);
+ mProperty->value.setAlpha(to_uint8(value));
return;
}
LOG_ALWAYS_FATAL("Unknown field %d", (int) mField);