| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -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 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 19 | import java.io.IOException; |
| 20 | import java.io.InputStream; |
| 21 | |
| 22 | import android.content.res.Resources; |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 23 | import android.content.res.AssetManager; |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 24 | import android.graphics.Bitmap; |
| 25 | import android.graphics.BitmapFactory; |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 26 | import android.util.Log; |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 27 | import android.util.TypedValue; |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * @hide |
| 31 | * |
| 32 | **/ |
| 33 | public class Allocation extends BaseObj { |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 34 | Type mType; |
| 35 | |
| 36 | Allocation(int id, RenderScript rs, Type t) { |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 37 | super(rs); |
| 38 | mID = id; |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 39 | mType = t; |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | public void uploadToTexture(int baseMipLevel) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 43 | mRS.validate(); |
| 44 | mRS.validateSurface(); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 45 | mRS.nAllocationUploadToTexture(mID, baseMipLevel); |
| 46 | } |
| 47 | |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 48 | public void uploadToBufferObject() { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 49 | mRS.validate(); |
| 50 | mRS.validateSurface(); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 51 | mRS.nAllocationUploadToBufferObject(mID); |
| 52 | } |
| 53 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 54 | public void data(int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 55 | mRS.validate(); |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 56 | subData1D(0, mType.getElementCount(), d); |
| 57 | } |
| 58 | public void data(short[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 59 | mRS.validate(); |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 60 | subData1D(0, mType.getElementCount(), d); |
| 61 | } |
| 62 | public void data(byte[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 63 | mRS.validate(); |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 64 | subData1D(0, mType.getElementCount(), d); |
| 65 | } |
| 66 | public void data(float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 67 | mRS.validate(); |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 68 | subData1D(0, mType.getElementCount(), d); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 71 | private void data1DChecks(int off, int count, int len, int dataSize) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 72 | mRS.validate(); |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 73 | if((off < 0) || (count < 1) || ((off + count) > mType.getElementCount())) { |
| 74 | throw new IllegalArgumentException("Offset or Count out of bounds."); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 75 | } |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 76 | if((len) < dataSize) { |
| 77 | throw new IllegalArgumentException("Array too small for allocation type."); |
| 78 | } |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | public void subData1D(int off, int count, int[] d) { |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 82 | int dataSize = mType.mElement.getSizeBytes() * count; |
| 83 | data1DChecks(off, count, d.length * 4, dataSize); |
| 84 | mRS.nAllocationSubData1D(mID, off, count, d, dataSize); |
| 85 | } |
| 86 | public void subData1D(int off, int count, short[] d) { |
| 87 | int dataSize = mType.mElement.getSizeBytes() * count; |
| 88 | data1DChecks(off, count, d.length * 2, dataSize); |
| 89 | mRS.nAllocationSubData1D(mID, off, count, d, dataSize); |
| 90 | } |
| 91 | public void subData1D(int off, int count, byte[] d) { |
| 92 | int dataSize = mType.mElement.getSizeBytes() * count; |
| 93 | data1DChecks(off, count, d.length, dataSize); |
| 94 | mRS.nAllocationSubData1D(mID, off, count, d, dataSize); |
| 95 | } |
| 96 | public void subData1D(int off, int count, float[] d) { |
| 97 | int dataSize = mType.mElement.getSizeBytes() * count; |
| 98 | data1DChecks(off, count, d.length * 4, dataSize); |
| 99 | mRS.nAllocationSubData1D(mID, off, count, d, dataSize); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 102 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 103 | |
| 104 | public void subData2D(int xoff, int yoff, int w, int h, int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 105 | mRS.validate(); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 106 | mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | public void subData2D(int xoff, int yoff, int w, int h, float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 110 | mRS.validate(); |
| Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 111 | mRS.nAllocationSubData2D(mID, xoff, yoff, w, h, d, d.length * 4); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 114 | public void readData(int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 115 | mRS.validate(); |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 116 | mRS.nAllocationRead(mID, d); |
| 117 | } |
| 118 | |
| 119 | public void readData(float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 120 | mRS.validate(); |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 121 | mRS.nAllocationRead(mID, d); |
| 122 | } |
| 123 | |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 124 | public void data(Object o) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 125 | mRS.validate(); |
| Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 126 | mRS.nAllocationSubDataFromObject(mID, mType, 0, o); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| Jason Sams | 5f43fd2 | 2009-09-15 12:39:22 -0700 | [diff] [blame] | 129 | public void read(Object o) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 130 | mRS.validate(); |
| Jason Sams | 5f43fd2 | 2009-09-15 12:39:22 -0700 | [diff] [blame] | 131 | mRS.nAllocationSubReadFromObject(mID, mType, 0, o); |
| 132 | } |
| 133 | |
| Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 134 | public void subData(int offset, Object o) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 135 | mRS.validate(); |
| Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 136 | mRS.nAllocationSubDataFromObject(mID, mType, offset, o); |
| 137 | } |
| Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 138 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 139 | public class Adapter1D extends BaseObj { |
| 140 | Adapter1D(int id, RenderScript rs) { |
| 141 | super(rs); |
| 142 | mID = id; |
| 143 | } |
| 144 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 145 | public void setConstraint(Dimension dim, int value) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 146 | mRS.validate(); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 147 | mRS.nAdapter1DSetConstraint(mID, dim.mID, value); |
| 148 | } |
| 149 | |
| 150 | public void data(int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 151 | mRS.validate(); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 152 | mRS.nAdapter1DData(mID, d); |
| 153 | } |
| 154 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 155 | public void data(float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 156 | mRS.validate(); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 157 | mRS.nAdapter1DData(mID, d); |
| 158 | } |
| 159 | |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 160 | public void subData(int off, int count, int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 161 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 162 | mRS.nAdapter1DSubData(mID, off, count, d); |
| 163 | } |
| 164 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 165 | public void subData(int off, int count, float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 166 | mRS.validate(); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 167 | mRS.nAdapter1DSubData(mID, off, count, d); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | public Adapter1D createAdapter1D() { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 172 | mRS.validate(); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 173 | int id = mRS.nAdapter1DCreate(); |
| 174 | if (id != 0) { |
| 175 | mRS.nAdapter1DBindAllocation(id, mID); |
| 176 | } |
| 177 | return new Adapter1D(id, mRS); |
| 178 | } |
| 179 | |
| 180 | |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 181 | public class Adapter2D extends BaseObj { |
| 182 | Adapter2D(int id, RenderScript rs) { |
| 183 | super(rs); |
| 184 | mID = id; |
| 185 | } |
| 186 | |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 187 | public void setConstraint(Dimension dim, int value) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 188 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 189 | mRS.nAdapter2DSetConstraint(mID, dim.mID, value); |
| 190 | } |
| 191 | |
| 192 | public void data(int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 193 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 194 | mRS.nAdapter2DData(mID, d); |
| 195 | } |
| 196 | |
| 197 | public void data(float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 198 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 199 | mRS.nAdapter2DData(mID, d); |
| 200 | } |
| 201 | |
| 202 | public void subData(int xoff, int yoff, int w, int h, int[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 203 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 204 | mRS.nAdapter2DSubData(mID, xoff, yoff, w, h, d); |
| 205 | } |
| 206 | |
| 207 | public void subData(int xoff, int yoff, int w, int h, float[] d) { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 208 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 209 | mRS.nAdapter2DSubData(mID, xoff, yoff, w, h, d); |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | public Adapter2D createAdapter2D() { |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 214 | mRS.validate(); |
| Jason Sams | bd1c3ad | 2009-08-03 16:03:08 -0700 | [diff] [blame] | 215 | int id = mRS.nAdapter2DCreate(); |
| 216 | if (id != 0) { |
| 217 | mRS.nAdapter2DBindAllocation(id, mID); |
| 218 | } |
| 219 | return new Adapter2D(id, mRS); |
| 220 | } |
| 221 | |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 222 | |
| 223 | // creation |
| 224 | |
| 225 | private static BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options(); |
| 226 | static { |
| 227 | mBitmapOptions.inScaled = false; |
| 228 | } |
| 229 | |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 230 | static public Allocation createTyped(RenderScript rs, Type type) |
| 231 | throws IllegalArgumentException { |
| 232 | |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 233 | rs.validate(); |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 234 | if(type.mID == 0) { |
| 235 | throw new IllegalStateException("Bad Type"); |
| 236 | } |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 237 | int id = rs.nAllocationCreateTyped(type.mID); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 238 | return new Allocation(id, rs, type); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 239 | } |
| 240 | |
| Jason Sams | 1bada8c | 2009-08-09 17:01:55 -0700 | [diff] [blame] | 241 | static public Allocation createSized(RenderScript rs, Element e, int count) |
| 242 | throws IllegalArgumentException { |
| 243 | |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 244 | rs.validate(); |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 245 | Type.Builder b = new Type.Builder(rs, e); |
| 246 | b.add(Dimension.X, count); |
| 247 | Type t = b.create(); |
| 248 | |
| 249 | int id = rs.nAllocationCreateTyped(t.mID); |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 250 | if(id == 0) { |
| 251 | throw new IllegalStateException("Bad element."); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 252 | } |
| Jason Sams | 768bc02 | 2009-09-21 19:41:04 -0700 | [diff] [blame] | 253 | return new Allocation(id, rs, t); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips) |
| 257 | throws IllegalArgumentException { |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 258 | |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 259 | rs.validate(); |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 260 | int id = rs.nAllocationCreateFromBitmap(dstFmt.mID, genMips, b); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 261 | return new Allocation(id, rs, null); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static public Allocation createFromBitmapBoxed(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips) |
| 265 | throws IllegalArgumentException { |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 266 | |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 267 | rs.validate(); |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 268 | int id = rs.nAllocationCreateFromBitmapBoxed(dstFmt.mID, genMips, b); |
| Jason Sams | 43ee0685 | 2009-08-12 17:54:11 -0700 | [diff] [blame] | 269 | return new Allocation(id, rs, null); |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, Element dstFmt, boolean genMips) |
| 273 | throws IllegalArgumentException { |
| 274 | |
| Jason Sams | 771bebb | 2009-12-07 12:40:12 -0800 | [diff] [blame] | 275 | rs.validate(); |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 276 | InputStream is = null; |
| 277 | try { |
| 278 | final TypedValue value = new TypedValue(); |
| 279 | is = res.openRawResource(id, value); |
| 280 | |
| 281 | int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 282 | int allocationId = rs.nAllocationCreateFromAssetStream(dstFmt.mID, genMips, |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 283 | asset); |
| 284 | |
| Jason Sams | ea84a7c | 2009-09-04 14:42:41 -0700 | [diff] [blame] | 285 | return new Allocation(allocationId, rs, null); |
| Romain Guy | 650a3eb | 2009-08-31 14:06:43 -0700 | [diff] [blame] | 286 | } catch (Exception e) { |
| 287 | // Ignore |
| 288 | } finally { |
| 289 | if (is != null) { |
| 290 | try { |
| 291 | is.close(); |
| 292 | } catch (IOException e) { |
| 293 | // Ignore |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | return null; |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | static public Allocation createFromBitmapResourceBoxed(RenderScript rs, Resources res, int id, Element dstFmt, boolean genMips) |
| 302 | throws IllegalArgumentException { |
| 303 | |
| 304 | Bitmap b = BitmapFactory.decodeResource(res, id, mBitmapOptions); |
| 305 | return createFromBitmapBoxed(rs, b, dstFmt, genMips); |
| 306 | } |
| Jason Sams | b8c5a84 | 2009-07-31 20:40:47 -0700 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | |