diff options
author | John Reck <jreck@google.com> | 2014-05-13 10:06:08 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2014-05-13 10:06:08 -0700 |
commit | 531ee701ddca2d1604fcce8e5d6d8837a3f651ac (patch) | |
tree | 0b40cb225e49a6c63d4f01270c85e916b9395a62 /libs | |
parent | 515396a6b5ee3eab57fed87ee0f4aa63783e2e61 (diff) | |
download | frameworks_base-531ee701ddca2d1604fcce8e5d6d8837a3f651ac.zip frameworks_base-531ee701ddca2d1604fcce8e5d6d8837a3f651ac.tar.gz frameworks_base-531ee701ddca2d1604fcce8e5d6d8837a3f651ac.tar.bz2 |
Clamp to uint8 for alpha
Change-Id: Id3e51671297bfb879969ad2fe7a5741dd4cf4c29
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Animator.cpp | 7 |
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); |