summaryrefslogtreecommitdiff
path: root/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs
diff options
context:
space:
mode:
Diffstat (limited to 'java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs')
-rw-r--r--java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs33
1 files changed, 16 insertions, 17 deletions
diff --git a/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs b/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs
index 90757a37..107fd3a5 100644
--- a/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs
+++ b/java/tests/ImageProcessing_jb/src/com/android/rs/image/shadows.rs
@@ -17,18 +17,18 @@
#include "ip.rsh"
#pragma rs_fp_relaxed
-static double shadowFilterMap[] = {
- -0.00591, 0.0001,
- 1.16488, 0.01668,
- -0.18027, -0.06791,
- -0.12625, 0.09001,
- 0.15065, -0.03897
+static float shadowFilterMap[] = {
+ -0.00591f, 0.0001f,
+ 1.16488f, 0.01668f,
+ -0.18027f, -0.06791f,
+ -0.12625f, 0.09001f,
+ 0.15065f, -0.03897f
};
-static double poly[] = {
- 0., 0.,
- 0., 0.,
- 0.
+static float poly[] = {
+ 0.f, 0.f,
+ 0.f, 0.f,
+ 0.f
};
static const int ABITS = 4;
@@ -36,10 +36,10 @@ static const int HSCALE = 256;
static const int k1=255 << ABITS;
static const int k2=HSCALE << ABITS;
-static double fastevalPoly(double *poly,int n, double x){
+static float fastevalPoly(float *poly,int n, float x){
- double f =x;
- double sum = poly[0]+poly[1]*f;
+ float f =x;
+ float sum = poly[0]+poly[1]*f;
int i;
for (i = 2; i < n; i++) {
f*=x;
@@ -177,7 +177,7 @@ static uchar4 hsv2rgb(ushort3 hsv)
}
void prepareShadows(float scale) {
- double s = (scale>=0)?scale:scale/5;
+ float s = (scale>=0) ? scale : scale / 5.f;
for (int i = 0; i < 5; i++) {
poly[i] = fastevalPoly(shadowFilterMap+i*2,2 , s);
}
@@ -185,8 +185,7 @@ void prepareShadows(float scale) {
void shadowsKernel(const uchar4 *in, uchar4 *out) {
ushort3 hsv = rgb2hsv(*in);
- double v = (fastevalPoly(poly,5,hsv.x/4080.)*4080);
- if (v>4080) v = 4080;
- hsv.x = (unsigned short) ((v>0)?v:0);
+ float v = (fastevalPoly(poly, 5, hsv.x * (1.f / 4080.f)) * 4080.f);
+ hsv.x = (unsigned short) clamp(v, 0.f, 4080.f);
*out = hsv2rgb(hsv);
}