Skip to content

Commit 833a89c

Browse files
Jason SamsAndroid (Google) Code Review
authored andcommitted
Merge "Fix range on blur intrinsic." into jb-mr1-dev
2 parents b8bb7a0 + 31864d7 commit 833a89c

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

graphics/java/android/renderscript/ScriptIntrinsicBlur.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ public void setInput(Allocation ain) {
6969
/**
7070
* Set the radius of the Blur.
7171
*
72-
* Supported range 0-25
72+
* Supported range 0 < radius <= 25
7373
*
7474
* @param radius The radius of the blur
7575
*/
7676
public void setRadius(float radius) {
77-
if (radius < 0 || radius > 25) {
78-
throw new RSIllegalArgumentException("Radius out of range (0-25).");
77+
if (radius <= 0 || radius > 25) {
78+
throw new RSIllegalArgumentException("Radius out of range (0 < r <= 25).");
7979
}
8080
setVar(0, radius);
8181
}

tests/RenderScriptTests/ImageProcessing/src/com/android/rs/image/Blur25.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class Blur25 extends TestBase {
3333

3434
private int MAX_RADIUS = 25;
3535
private ScriptC_threshold mScript;
36-
private int mRadius = MAX_RADIUS;
36+
private float mRadius = MAX_RADIUS;
3737
private float mSaturation = 1.0f;
3838
private Allocation mScratchPixelsAllocation1;
3939
private Allocation mScratchPixelsAllocation2;
@@ -51,13 +51,14 @@ public boolean onBar1Setup(SeekBar b, TextView t) {
5151

5252

5353
public void onBar1Changed(int progress) {
54-
float fRadius = progress / 100.0f;
55-
fRadius *= (float)(MAX_RADIUS);
56-
mRadius = (int)fRadius;
54+
mRadius = ((float)progress) / 100.0f * MAX_RADIUS;
55+
if (mRadius <= 0.10f) {
56+
mRadius = 0.10f;
57+
}
5758
if (mUseIntrinsic) {
5859
mIntrinsic.setRadius(mRadius);
5960
} else {
60-
mScript.invoke_setRadius(mRadius);
61+
mScript.invoke_setRadius((int)mRadius);
6162
}
6263
}
6364

@@ -111,7 +112,7 @@ public void exitBenchmark() {
111112
if (mUseIntrinsic) {
112113
mIntrinsic.setRadius(mRadius);
113114
} else {
114-
mScript.invoke_setRadius(mRadius);
115+
mScript.invoke_setRadius((int)mRadius);
115116
}
116117
}
117118
}

0 commit comments

Comments
 (0)