Skip to content

Commit 53fc3e1

Browse files
author
Jason Sams
committed
Cleanup example code.
Change-Id: I060ea53c867ded0e6956776859fc2710c7302148
1 parent 7fc8f51 commit 53fc3e1

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/horizontal_blur.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,26 @@
22

33
#include "ip.rsh"
44

5-
void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
6-
float4 *output = (float4 *)v_out;
5+
void root(float4 *out, const void *usrData, uint32_t x, uint32_t y) {
76
const FilterStruct *fs = (const FilterStruct *)usrData;
8-
const float4 *input = (const float4 *)rsGetElementAt(fs->ain, 0, y);
9-
107
float3 blurredPixel = 0;
118
const float *gPtr = fs->gaussian;
129
if ((x > fs->radius) && (x < (fs->width - fs->radius))) {
13-
const float4 *i = input + (x - fs->radius);
1410
for (int r = -fs->radius; r <= fs->radius; r ++) {
11+
const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x + r, y);
1512
blurredPixel += i->xyz * gPtr[0];
1613
gPtr++;
17-
i++;
1814
}
1915
} else {
2016
for (int r = -fs->radius; r <= fs->radius; r ++) {
2117
// Stepping left and right away from the pixel
22-
int validW = rsClamp((int)x + r, (int)0, (int)(fs->width - 1));
23-
blurredPixel += input[validW].xyz * gPtr[0];
18+
int validX = rsClamp((int)x + r, (int)0, (int)(fs->width - 1));
19+
const float4 *i = (const float4 *)rsGetElementAt(fs->ain, validX, y);
20+
blurredPixel += i->xyz * gPtr[0];
2421
gPtr++;
2522
}
2623
}
2724

28-
output->xyz = blurredPixel;
25+
out->xyz = blurredPixel;
2926
}
3027

tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vertical_blur.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,20 @@ void setGamma(float g) {
5555
gamma = (float3)g;
5656
}
5757

58-
//sliao
59-
extern uchar3 __attribute__((overloadable)) convert2uchar3(float3 xyz);
60-
61-
void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32_t y) {
62-
uchar4 *output = (uchar4 *)v_out;
58+
void root(uchar4 *out, const void *usrData, uint32_t x, uint32_t y) {
6359
const FilterStruct *fs = (const FilterStruct *)usrData;
64-
const float4 *input = (const float4 *)rsGetElementAt(fs->ain, x, 0);
65-
6660
float3 blurredPixel = 0;
6761
const float *gPtr = fs->gaussian;
6862
if ((y > fs->radius) && (y < (fs->height - fs->radius))) {
69-
const float4 *i = input + ((y - fs->radius) * fs->width);
7063
for (int r = -fs->radius; r <= fs->radius; r ++) {
64+
const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x, y + r);
7165
blurredPixel += i->xyz * gPtr[0];
7266
gPtr++;
73-
i += fs->width;
7467
}
7568
} else {
7669
for (int r = -fs->radius; r <= fs->radius; r ++) {
7770
int validH = rsClamp((int)y + r, (int)0, (int)(fs->height - 1));
78-
const float4 *i = input + validH * fs->width;
71+
const float4 *i = (const float4 *)rsGetElementAt(fs->ain, x, validH);
7972
blurredPixel += i->xyz * gPtr[0];
8073
gPtr++;
8174
}
@@ -87,7 +80,7 @@ void root(const void *v_in, void *v_out, const void *usrData, uint32_t x, uint32
8780
temp = pow(temp, (float3)gamma);
8881
temp = clamp(temp * outWMinOutB + outBlack, 0.f, 255.f);
8982

90-
output->xyz = convert_uchar3(temp);
83+
out->xyz = convert_uchar3(temp);
9184
//output->w = input->w;
9285
}
9386

0 commit comments

Comments
 (0)