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