Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.renderscript; |
| 18 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 19 | /** |
Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 20 | * Sampler object that defines how Allocations can be read as textures within a |
| 21 | * kernel. Samplers are used in conjunction with the {@code rsSample} runtime |
| 22 | * function to return values from normalized coordinates. |
| 23 | * |
| 24 | * Any Allocation used with a Sampler must have been created with {@link |
| 25 | * android.renderscript.Allocation#USAGE_GRAPHICS_TEXTURE}; using a Sampler on |
| 26 | * an {@link android.renderscript.Allocation} that was not created with {@link |
| 27 | * android.renderscript.Allocation#USAGE_GRAPHICS_TEXTURE} is undefined. |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 28 | **/ |
| 29 | public class Sampler extends BaseObj { |
| 30 | public enum Value { |
| 31 | NEAREST (0), |
| 32 | LINEAR (1), |
| 33 | LINEAR_MIP_LINEAR (2), |
Alex Sakhartchouk | 0857196 | 2010-12-15 09:59:58 -0800 | [diff] [blame] | 34 | LINEAR_MIP_NEAREST (5), |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 35 | WRAP (3), |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 36 | CLAMP (4), |
| 37 | MIRRORED_REPEAT (6); |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 38 | |
| 39 | int mID; |
| 40 | Value(int id) { |
| 41 | mID = id; |
| 42 | } |
| 43 | } |
| 44 | |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 45 | Value mMin; |
| 46 | Value mMag; |
| 47 | Value mWrapS; |
| 48 | Value mWrapT; |
| 49 | Value mWrapR; |
| 50 | float mAniso; |
| 51 | |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 52 | Sampler(long id, RenderScript rs) { |
Alex Sakhartchouk | 0de9444 | 2010-08-11 14:41:28 -0700 | [diff] [blame] | 53 | super(id, rs); |
Yang Ni | 6484b6b | 2016-03-24 09:40:32 -0700 | [diff] [blame] | 54 | guard.open("destroy"); |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 57 | /** |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 58 | * @return minification setting for the sampler |
| 59 | */ |
| 60 | public Value getMinification() { |
| 61 | return mMin; |
| 62 | } |
| 63 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 64 | /** |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 65 | * @return magnification setting for the sampler |
| 66 | */ |
| 67 | public Value getMagnification() { |
| 68 | return mMag; |
| 69 | } |
| 70 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 71 | /** |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 72 | * @return S wrapping mode for the sampler |
| 73 | */ |
| 74 | public Value getWrapS() { |
| 75 | return mWrapS; |
| 76 | } |
| 77 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 78 | /** |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 79 | * @return T wrapping mode for the sampler |
| 80 | */ |
| 81 | public Value getWrapT() { |
| 82 | return mWrapT; |
| 83 | } |
| 84 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 85 | /** |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 86 | * @return anisotropy setting for the sampler |
| 87 | */ |
| 88 | public float getAnisotropy() { |
| 89 | return mAniso; |
| 90 | } |
| 91 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 92 | /** |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 93 | * Retrieve a sampler with min and mag set to nearest and wrap modes set to |
| 94 | * clamp. |
| 95 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 96 | * @param rs Context to which the sampler will belong. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 97 | * |
| 98 | * @return Sampler |
| 99 | */ |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 100 | public static Sampler CLAMP_NEAREST(RenderScript rs) { |
| 101 | if(rs.mSampler_CLAMP_NEAREST == null) { |
| 102 | Builder b = new Builder(rs); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 103 | b.setMinification(Value.NEAREST); |
| 104 | b.setMagnification(Value.NEAREST); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 105 | b.setWrapS(Value.CLAMP); |
| 106 | b.setWrapT(Value.CLAMP); |
| 107 | rs.mSampler_CLAMP_NEAREST = b.create(); |
| 108 | } |
| 109 | return rs.mSampler_CLAMP_NEAREST; |
| 110 | } |
| 111 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 112 | /** |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 113 | * Retrieve a sampler with min and mag set to linear and wrap modes set to |
| 114 | * clamp. |
| 115 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 116 | * @param rs Context to which the sampler will belong. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 117 | * |
| 118 | * @return Sampler |
| 119 | */ |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 120 | public static Sampler CLAMP_LINEAR(RenderScript rs) { |
| 121 | if(rs.mSampler_CLAMP_LINEAR == null) { |
| 122 | Builder b = new Builder(rs); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 123 | b.setMinification(Value.LINEAR); |
| 124 | b.setMagnification(Value.LINEAR); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 125 | b.setWrapS(Value.CLAMP); |
| 126 | b.setWrapT(Value.CLAMP); |
| 127 | rs.mSampler_CLAMP_LINEAR = b.create(); |
| 128 | } |
| 129 | return rs.mSampler_CLAMP_LINEAR; |
| 130 | } |
| 131 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 132 | /** |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 133 | * Retrieve a sampler with mag set to linear, min linear mipmap linear, and |
| 134 | * wrap modes set to clamp. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 135 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 136 | * @param rs Context to which the sampler will belong. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 137 | * |
| 138 | * @return Sampler |
| 139 | */ |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 140 | public static Sampler CLAMP_LINEAR_MIP_LINEAR(RenderScript rs) { |
| 141 | if(rs.mSampler_CLAMP_LINEAR_MIP_LINEAR == null) { |
| 142 | Builder b = new Builder(rs); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 143 | b.setMinification(Value.LINEAR_MIP_LINEAR); |
| 144 | b.setMagnification(Value.LINEAR); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 145 | b.setWrapS(Value.CLAMP); |
| 146 | b.setWrapT(Value.CLAMP); |
| 147 | rs.mSampler_CLAMP_LINEAR_MIP_LINEAR = b.create(); |
| 148 | } |
| 149 | return rs.mSampler_CLAMP_LINEAR_MIP_LINEAR; |
| 150 | } |
| 151 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 152 | /** |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 153 | * Retrieve a sampler with min and mag set to nearest and wrap modes set to |
| 154 | * wrap. |
| 155 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 156 | * @param rs Context to which the sampler will belong. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 157 | * |
| 158 | * @return Sampler |
| 159 | */ |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 160 | public static Sampler WRAP_NEAREST(RenderScript rs) { |
| 161 | if(rs.mSampler_WRAP_NEAREST == null) { |
| 162 | Builder b = new Builder(rs); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 163 | b.setMinification(Value.NEAREST); |
| 164 | b.setMagnification(Value.NEAREST); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 165 | b.setWrapS(Value.WRAP); |
| 166 | b.setWrapT(Value.WRAP); |
| 167 | rs.mSampler_WRAP_NEAREST = b.create(); |
| 168 | } |
| 169 | return rs.mSampler_WRAP_NEAREST; |
| 170 | } |
| 171 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 172 | /** |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 173 | * Retrieve a sampler with min and mag set to linear and wrap modes set to |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 174 | * wrap. |
| 175 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 176 | * @param rs Context to which the sampler will belong. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 177 | * |
| 178 | * @return Sampler |
| 179 | */ |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 180 | public static Sampler WRAP_LINEAR(RenderScript rs) { |
| 181 | if(rs.mSampler_WRAP_LINEAR == null) { |
| 182 | Builder b = new Builder(rs); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 183 | b.setMinification(Value.LINEAR); |
| 184 | b.setMagnification(Value.LINEAR); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 185 | b.setWrapS(Value.WRAP); |
| 186 | b.setWrapT(Value.WRAP); |
| 187 | rs.mSampler_WRAP_LINEAR = b.create(); |
| 188 | } |
| 189 | return rs.mSampler_WRAP_LINEAR; |
| 190 | } |
| 191 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 192 | /** |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 193 | * Retrieve a sampler with mag set to linear, min linear mipmap linear, and |
| 194 | * wrap modes set to wrap. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 195 | * |
Alex Sakhartchouk | f5c876e | 2011-01-13 14:53:43 -0800 | [diff] [blame] | 196 | * @param rs Context to which the sampler will belong. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 197 | * |
| 198 | * @return Sampler |
| 199 | */ |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 200 | public static Sampler WRAP_LINEAR_MIP_LINEAR(RenderScript rs) { |
| 201 | if(rs.mSampler_WRAP_LINEAR_MIP_LINEAR == null) { |
| 202 | Builder b = new Builder(rs); |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 203 | b.setMinification(Value.LINEAR_MIP_LINEAR); |
| 204 | b.setMagnification(Value.LINEAR); |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 205 | b.setWrapS(Value.WRAP); |
| 206 | b.setWrapT(Value.WRAP); |
| 207 | rs.mSampler_WRAP_LINEAR_MIP_LINEAR = b.create(); |
| 208 | } |
| 209 | return rs.mSampler_WRAP_LINEAR_MIP_LINEAR; |
| 210 | } |
| 211 | |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 212 | /** |
| 213 | * Retrieve a sampler with min and mag set to nearest and wrap modes set to |
| 214 | * mirrored repeat. |
| 215 | * |
| 216 | * @param rs Context to which the sampler will belong. |
| 217 | * |
| 218 | * @return Sampler |
| 219 | */ |
| 220 | public static Sampler MIRRORED_REPEAT_NEAREST(RenderScript rs) { |
| 221 | if(rs.mSampler_MIRRORED_REPEAT_NEAREST == null) { |
| 222 | Builder b = new Builder(rs); |
| 223 | b.setMinification(Value.NEAREST); |
| 224 | b.setMagnification(Value.NEAREST); |
| 225 | b.setWrapS(Value.MIRRORED_REPEAT); |
| 226 | b.setWrapT(Value.MIRRORED_REPEAT); |
| 227 | rs.mSampler_MIRRORED_REPEAT_NEAREST = b.create(); |
| 228 | } |
| 229 | return rs.mSampler_MIRRORED_REPEAT_NEAREST; |
| 230 | } |
| 231 | |
| 232 | /** |
| 233 | * Retrieve a sampler with min and mag set to linear and wrap modes set to |
| 234 | * mirrored repeat. |
| 235 | * |
| 236 | * @param rs Context to which the sampler will belong. |
| 237 | * |
| 238 | * @return Sampler |
| 239 | */ |
| 240 | public static Sampler MIRRORED_REPEAT_LINEAR(RenderScript rs) { |
| 241 | if(rs.mSampler_MIRRORED_REPEAT_LINEAR == null) { |
| 242 | Builder b = new Builder(rs); |
| 243 | b.setMinification(Value.LINEAR); |
| 244 | b.setMagnification(Value.LINEAR); |
| 245 | b.setWrapS(Value.MIRRORED_REPEAT); |
| 246 | b.setWrapT(Value.MIRRORED_REPEAT); |
| 247 | rs.mSampler_MIRRORED_REPEAT_LINEAR = b.create(); |
| 248 | } |
| 249 | return rs.mSampler_MIRRORED_REPEAT_LINEAR; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Retrieve a sampler with min and mag set to linear and wrap modes set to |
| 254 | * mirrored repeat. |
| 255 | * |
| 256 | * @param rs Context to which the sampler will belong. |
| 257 | * |
| 258 | * @return Sampler |
| 259 | */ |
| 260 | public static Sampler MIRRORED_REPEAT_LINEAR_MIP_LINEAR(RenderScript rs) { |
| 261 | if(rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR == null) { |
| 262 | Builder b = new Builder(rs); |
| 263 | b.setMinification(Value.LINEAR_MIP_LINEAR); |
| 264 | b.setMagnification(Value.LINEAR); |
| 265 | b.setWrapS(Value.MIRRORED_REPEAT); |
| 266 | b.setWrapT(Value.MIRRORED_REPEAT); |
| 267 | rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR = b.create(); |
| 268 | } |
| 269 | return rs.mSampler_MIRRORED_REPEAT_LINEAR_MIP_LINEAR; |
| 270 | } |
Jason Sams | 4d33993 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 271 | |
Stephen Hines | 9c9ad3f8c2 | 2012-05-07 15:34:29 -0700 | [diff] [blame] | 272 | /** |
Tim Murray | c11e25c | 2013-04-09 11:01:01 -0700 | [diff] [blame] | 273 | * Builder for creating non-standard samplers. This is only necessary if |
| 274 | * a Sampler with different min and mag modes is desired. |
Jason Sams | bf6ef8d | 2010-12-06 15:59:59 -0800 | [diff] [blame] | 275 | */ |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 276 | public static class Builder { |
| 277 | RenderScript mRS; |
| 278 | Value mMin; |
| 279 | Value mMag; |
| 280 | Value mWrapS; |
| 281 | Value mWrapT; |
| 282 | Value mWrapR; |
Alex Sakhartchouk | f5b3510 | 2010-09-30 11:36:37 -0700 | [diff] [blame] | 283 | float mAniso; |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 284 | |
| 285 | public Builder(RenderScript rs) { |
| 286 | mRS = rs; |
| 287 | mMin = Value.NEAREST; |
| 288 | mMag = Value.NEAREST; |
| 289 | mWrapS = Value.WRAP; |
| 290 | mWrapT = Value.WRAP; |
| 291 | mWrapR = Value.WRAP; |
Alex Sakhartchouk | f5b3510 | 2010-09-30 11:36:37 -0700 | [diff] [blame] | 292 | mAniso = 1.0f; |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 295 | public void setMinification(Value v) { |
Jason Sams | 8bb41dd | 2009-12-16 15:59:59 -0800 | [diff] [blame] | 296 | if (v == Value.NEAREST || |
| 297 | v == Value.LINEAR || |
Alex Sakhartchouk | 0857196 | 2010-12-15 09:59:58 -0800 | [diff] [blame] | 298 | v == Value.LINEAR_MIP_LINEAR || |
| 299 | v == Value.LINEAR_MIP_NEAREST) { |
Jason Sams | 8bb41dd | 2009-12-16 15:59:59 -0800 | [diff] [blame] | 300 | mMin = v; |
| 301 | } else { |
| 302 | throw new IllegalArgumentException("Invalid value"); |
| 303 | } |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Alex Sakhartchouk | b4d7bb6 | 2010-12-21 14:42:26 -0800 | [diff] [blame] | 306 | public void setMagnification(Value v) { |
Jason Sams | 8bb41dd | 2009-12-16 15:59:59 -0800 | [diff] [blame] | 307 | if (v == Value.NEAREST || v == Value.LINEAR) { |
| 308 | mMag = v; |
| 309 | } else { |
| 310 | throw new IllegalArgumentException("Invalid value"); |
| 311 | } |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | public void setWrapS(Value v) { |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 315 | if (v == Value.WRAP || v == Value.CLAMP || v == Value.MIRRORED_REPEAT) { |
Jason Sams | 8bb41dd | 2009-12-16 15:59:59 -0800 | [diff] [blame] | 316 | mWrapS = v; |
| 317 | } else { |
| 318 | throw new IllegalArgumentException("Invalid value"); |
| 319 | } |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | public void setWrapT(Value v) { |
Tim Murray | 6b9b2ca | 2013-02-15 13:25:55 -0800 | [diff] [blame] | 323 | if (v == Value.WRAP || v == Value.CLAMP || v == Value.MIRRORED_REPEAT) { |
Jason Sams | 8bb41dd | 2009-12-16 15:59:59 -0800 | [diff] [blame] | 324 | mWrapT = v; |
| 325 | } else { |
| 326 | throw new IllegalArgumentException("Invalid value"); |
| 327 | } |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Alex Sakhartchouk | f5b3510 | 2010-09-30 11:36:37 -0700 | [diff] [blame] | 330 | public void setAnisotropy(float v) { |
| 331 | if(v >= 0.0f) { |
| 332 | mAniso = v; |
| 333 | } else { |
| 334 | throw new IllegalArgumentException("Invalid value"); |
| 335 | } |
| 336 | } |
| 337 | |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 338 | public Sampler create() { |
Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 339 | mRS.validate(); |
Ashok Bhat | 0e0c088 | 2014-02-04 14:57:58 +0000 | [diff] [blame] | 340 | long id = mRS.nSamplerCreate(mMag.mID, mMin.mID, |
Alex Sakhartchouk | 7d5f5e7 | 2011-10-18 11:08:31 -0700 | [diff] [blame] | 341 | mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso); |
| 342 | Sampler sampler = new Sampler(id, mRS); |
| 343 | sampler.mMin = mMin; |
| 344 | sampler.mMag = mMag; |
| 345 | sampler.mWrapS = mWrapS; |
| 346 | sampler.mWrapT = mWrapT; |
| 347 | sampler.mWrapR = mWrapR; |
| 348 | sampler.mAniso = mAniso; |
| 349 | return sampler; |
Jason Sams | 0835d42 | 2009-08-04 17:58:23 -0700 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
| 353 | } |
| 354 | |