Skip to content

Commit a9fa7b2

Browse files
Jason SamsAndroid (Google) Code Review
authored andcommitted
Merge "save 2ms replace div with mul." into jb-mr1-dev
2 parents 22a7b9d + 41bd350 commit a9fa7b2

File tree

1 file changed

+7
-5
lines changed
  • tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image

1 file changed

+7
-5
lines changed

tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/vignette.rsh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
static float2 scale;
1818
static float2 center, dimensions;
1919
static float range, inv_max_dist, shade, slope;
20+
static float2 overDimensions;
2021

2122
void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_y,
2223
float desired_scale, float desired_shade, float desired_slope) {
@@ -43,20 +44,21 @@ void init_vignette(uint32_t dim_x, uint32_t dim_y, float center_x, float center_
4344
range = 1.3 - 0.7*sqrt(desired_scale);
4445
shade = desired_shade;
4546
slope = desired_slope;
47+
48+
overDimensions = ((float2)1.f) / dimensions;
4649
}
4750

4851
void root(const uchar4 *in, uchar4 *out, uint32_t x, uint32_t y) {
4952
// Convert x and y to floating point coordinates with center as origin
50-
const float4 fin = rsUnpackColor8888(*in);
51-
float2 coord;
52-
coord.x = (float)x / dimensions.x;
53-
coord.y = (float)y / dimensions.y;
53+
const float4 fin = convert_float4(*in);
54+
float2 coord = {(float)x, (float)y};
55+
coord *= overDimensions;
5456
coord -= center;
5557
const float dist = length(scale * coord);
5658
const float lumen = shade / (1.0 + exp((dist * inv_max_dist - range) * slope)) + (1.0 - shade);
5759
float4 fout;
5860
fout.rgb = fin.rgb * lumen;
5961
fout.w = fin.w;
60-
*out = rsPackColorTo8888(fout);
62+
*out = convert_uchar4(fout);
6163
}
6264

0 commit comments

Comments
 (0)