diff options
author | Jason Sams <jsams@google.com> | 2012-09-13 14:44:34 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-13 14:44:34 -0700 |
commit | bd6acda96f8bcff8b47502e2fca8672972013abe (patch) | |
tree | e6d9e84695a513b365fedd2381bfd3ec1c33460d /tests/RenderScriptTests | |
parent | 24271a8c4c55a60047fd3d35c8a7af98b0f4e666 (diff) | |
parent | 8a95803738bd178876363406309ff2ae1570c8fe (diff) | |
download | frameworks_base-bd6acda96f8bcff8b47502e2fca8672972013abe.zip frameworks_base-bd6acda96f8bcff8b47502e2fca8672972013abe.tar.gz frameworks_base-bd6acda96f8bcff8b47502e2fca8672972013abe.tar.bz2 |
Merge "Fix bugs in grain where values could go out of bounds." into jb-mr1-dev
Diffstat (limited to 'tests/RenderScriptTests')
-rw-r--r-- | tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs index 7d9d3ac..783bc4a 100644 --- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs +++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/grain.rs @@ -43,9 +43,9 @@ int32_t gHeight; rs_allocation gBlendSource; void blend9(uchar *out, uint32_t x, uint32_t y) { - uint32_t x1 = min((int32_t)x+1, (int32_t)gWidth); + uint32_t x1 = min((int32_t)x+1, (int32_t)(gWidth -1)); uint32_t x2 = max((int32_t)x-1, (int32_t)0); - uint32_t y1 = min((int32_t)y+1, (int32_t)gHeight); + uint32_t y1 = min((int32_t)y+1, (int32_t)(gHeight -1)); uint32_t y2 = max((int32_t)y-1, (int32_t)0); uint p00 = 56 * ((uchar *)rsGetElementAt(gBlendSource, x1, y1))[0]; @@ -69,7 +69,8 @@ void blend9(uchar *out, uint32_t x, uint32_t y) { p20 += p22; p20 += p02; - *out = (uchar)(p20 >> 10); + p20 = min(p20 >> 10, (uint)255); + *out = (uchar)p20; } float gNoiseStrength; |