summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2011-09-13 11:29:02 -0700
committerJason Sams <rjsams@android.com>2011-09-13 11:29:02 -0700
commit53fc3e18675d47face40b4726414fdc4aacb7d2f (patch)
tree0c22ad4d8c135d6255980929da0b97828d5c8101 /tests/RenderScriptTests
parent7fc8f515a0add6837d525b4f2b4baa7ebe37fc7f (diff)
downloadframeworks_base-53fc3e18675d47face40b4726414fdc4aacb7d2f.zip
frameworks_base-53fc3e18675d47face40b4726414fdc4aacb7d2f.tar.gz
frameworks_base-53fc3e18675d47face40b4726414fdc4aacb7d2f.tar.bz2
Cleanup example code.
Change-Id: I060ea53c867ded0e6956776859fc2710c7302148
Diffstat (limited to 'tests/RenderScriptTests')
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs15
-rw-r--r--tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vertical_blur.rs15
2 files changed, 10 insertions, 20 deletions
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs
index 45eea5e..86479d5 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs
@@ -2,29 +2,26 @@
#include "ip.rsh"
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- float4 *output = (float4 *)v_out;
+void root(float4 *out, const void *usrData, uint32_t x, uint32_t y) {
const FilterStruct *fs = (const FilterStruct *)usrData;
- const float4 *input = (const float4 *)rsGetElementAt(fs->ain, 0, y);
-
float3 blurredPixel = 0;
const float *gPtr = fs->gaussian;
if ((x > fs->radius) && (x < (fs->width - fs->radius))) {
- const float4 *i = input + (x - fs->radius);
for (int r = -fs->radius; r <= fs->radius; r ++) {
+ const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x + r, y);
blurredPixel += i->xyz * gPtr[0];
gPtr++;
- i++;
}
} else {
for (int r = -fs->radius; r <= fs->radius; r ++) {
// Stepping left and right away from the pixel
- int validW = rsClamp((int)x + r, (int)0, (int)(fs->width - 1));
- blurredPixel += input[validW].xyz * gPtr[0];
+ int validX = rsClamp((int)x + r, (int)0, (int)(fs->width - 1));
+ const float4 *i = (const float4 *)rsGetElementAt(fs->ain, validX, y);
+ blurredPixel += i->xyz * gPtr[0];
gPtr++;
}
}
- output->xyz = blurredPixel;
+ out->xyz = blurredPixel;
}
diff --git a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vertical_blur.rs b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
index 6b0cde0..8b07bc2 100644
--- a/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
+++ b/tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vertical_blur.rs
@@ -55,27 +55,20 @@ void setGamma(float g) {
gamma = (float3)g;
}
-//sliao
-extern uchar3 __attribute__((overloadable)) convert2uchar3(float3 xyz);
-
-void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
- uchar4 *output = (uchar4 *)v_out;
+void root(uchar4 *out, const void *usrData, uint32_t x, uint32_t y) {
const FilterStruct *fs = (const FilterStruct *)usrData;
- const float4 *input = (const float4 *)rsGetElementAt(fs->ain, x, 0);
-
float3 blurredPixel = 0;
const float *gPtr = fs->gaussian;
if ((y > fs->radius) && (y < (fs->height - fs->radius))) {
- const float4 *i = input + ((y - fs->radius) * fs->width);
for (int r = -fs->radius; r <= fs->radius; r ++) {
+ const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x, y + r);
blurredPixel += i->xyz * gPtr[0];
gPtr++;
- i += fs->width;
}
} else {
for (int r = -fs->radius; r <= fs->radius; r ++) {
int validH = rsClamp((int)y + r, (int)0, (int)(fs->height - 1));
- const float4 *i = input + validH * fs->width;
+ const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x, validH);
blurredPixel += i->xyz * gPtr[0];
gPtr++;
}
@@ -87,7 +80,7 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32
temp = pow(temp, (float3)gamma);
temp = clamp(temp * outWMinOutB + outBlack, 0.f, 255.f);
- output->xyz = convert_uchar3(temp);
+ out->xyz = convert_uchar3(temp);
//output->w = input->w;
}