| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.renderscript; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
@Deprecated |
| 28 |
public final class ScriptIntrinsicBlur extends ScriptIntrinsic { |
| 29 |
private final float[] mValues = new float[9]; |
| 30 |
private Allocation mInput; |
| 31 |
|
| 32 |
private ScriptIntrinsicBlur(long id, RenderScript rs) { |
| 33 |
super(id, rs); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public static ScriptIntrinsicBlur create(RenderScript rs, Element e) { |
| 49 |
if ((!e.isCompatible(Element.U8_4(rs))) && (!e.isCompatible(Element.U8(rs)))) { |
| 50 |
throw new RSIllegalArgumentException("Unsupported element type."); |
| 51 |
} |
| 52 |
long id = rs.nScriptIntrinsicCreate(5, e.getID(rs)); |
| 53 |
ScriptIntrinsicBlur sib = new ScriptIntrinsicBlur(id, rs); |
| 54 |
sib.setRadius(5.f); |
| 55 |
return sib; |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
public void setInput(Allocation ain) { |
| 65 |
if (ain.getType().getY() == 0) { |
| 66 |
throw new RSIllegalArgumentException("Input set to a 1D Allocation"); |
| 67 |
} |
| 68 |
Element e = ain.getElement(); |
| 69 |
if ((!e.isCompatible(Element.U8_4(mRS))) && (!e.isCompatible(Element.U8(mRS)))) { |
| 70 |
throw new RSIllegalArgumentException("Unsupported element type."); |
| 71 |
} |
| 72 |
mInput = ain; |
| 73 |
setVar(1, ain); |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public void setRadius(float radius) { |
| 84 |
if (radius <= 0 || radius > 25) { |
| 85 |
throw new RSIllegalArgumentException("Radius out of range (0 < r <= 25)."); |
| 86 |
} |
| 87 |
setVar(0, radius); |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public void forEach(Allocation aout) { |
| 98 |
if (aout.getType().getY() == 0) { |
| 99 |
throw new RSIllegalArgumentException("Output is a 1D Allocation"); |
| 100 |
} |
| 101 |
forEach(0, (Allocation) null, aout, null); |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public void forEach(Allocation aout, Script.LaunchOptions opt) { |
| 113 |
if (aout.getType().getY() == 0) { |
| 114 |
throw new RSIllegalArgumentException("Output is a 1D Allocation"); |
| 115 |
} |
| 116 |
forEach(0, (Allocation) null, aout, null, opt); |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
public Script.KernelID getKernelID() { |
| 126 |
return createKernelID(0, 2, null, null); |
| 127 |
} |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
public Script.FieldID getFieldID_Input() { |
| 135 |
return createFieldID(1, null); |
| 136 |
} |
| 137 |
} |