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