summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2012-09-13 14:44:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-13 14:44:34 -0700
commitbd6acda96f8bcff8b47502e2fca8672972013abe (patch)
treee6d9e84695a513b365fedd2381bfd3ec1c33460d /tests/RenderScriptTests
parent24271a8c4c55a60047fd3d35c8a7af98b0f4e666 (diff)
parent8a95803738bd178876363406309ff2ae1570c8fe (diff)
downloadframeworks_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.rs7
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;