Joe Onorato | 9383905 | 2009-08-06 20:34:32 -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 com.android.launcher2; |
| 18 | |
| 19 | import java.io.Writer; |
| 20 | import java.util.ArrayList; |
| 21 | import java.util.concurrent.Semaphore; |
| 22 | import java.lang.Float; |
| 23 | |
| 24 | import android.renderscript.RSSurfaceView; |
| 25 | import android.renderscript.RenderScript; |
| 26 | |
| 27 | import android.renderscript.RenderScript; |
| 28 | import android.renderscript.ProgramVertex; |
| 29 | import android.renderscript.Element; |
| 30 | import android.renderscript.Allocation; |
| 31 | import android.renderscript.Script; |
| 32 | import android.renderscript.ScriptC; |
| 33 | import android.renderscript.ProgramFragment; |
| 34 | import android.renderscript.ProgramStore; |
| 35 | import android.renderscript.Sampler; |
| 36 | |
| 37 | import android.content.Context; |
| 38 | import android.content.res.Resources; |
| 39 | import android.graphics.Bitmap; |
| 40 | import android.graphics.BitmapFactory; |
| 41 | import android.graphics.Canvas; |
| 42 | import android.graphics.Paint; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 43 | import android.graphics.drawable.BitmapDrawable; |
| 44 | import android.graphics.drawable.Drawable; |
| 45 | import android.os.Handler; |
| 46 | import android.os.Message; |
| 47 | import android.util.AttributeSet; |
| 48 | import android.util.Log; |
| 49 | import android.view.Surface; |
| 50 | import android.view.SurfaceHolder; |
| 51 | import android.view.SurfaceView; |
| 52 | import android.view.KeyEvent; |
| 53 | import android.view.MotionEvent; |
| 54 | import android.graphics.PixelFormat; |
| 55 | |
| 56 | |
| 57 | public class AllAppsView extends RSSurfaceView { |
| 58 | public AllAppsView(Context context) { |
| 59 | super(context); |
| 60 | setFocusable(true); |
| 61 | getHolder().setFormat(PixelFormat.TRANSLUCENT); |
| 62 | } |
| 63 | |
| 64 | public AllAppsView(Context context, AttributeSet attrs) { |
| 65 | this(context); |
| 66 | } |
| 67 | |
| 68 | public AllAppsView(Context context, AttributeSet attrs, int defStyle) { |
| 69 | this(context); |
| 70 | } |
| 71 | |
| 72 | private RenderScript mRS; |
| 73 | private RolloRS mRender; |
| 74 | |
| 75 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { |
| 76 | super.surfaceChanged(holder, format, w, h); |
| 77 | |
| 78 | mRS = createRenderScript(); |
| 79 | mRender = new RolloRS(); |
| 80 | mRender.init(mRS, getResources(), w, h); |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public boolean onKeyDown(int keyCode, KeyEvent event) |
| 85 | { |
| 86 | // break point at here |
| 87 | // this method doesn't work when 'extends View' include 'extends ScrollView'. |
| 88 | return super.onKeyDown(keyCode, event); |
| 89 | } |
| 90 | |
| 91 | boolean mControlMode = false; |
| 92 | boolean mZoomMode = false; |
| 93 | boolean mFlingMode = false; |
| 94 | float mFlingX = 0; |
| 95 | float mFlingY = 0; |
| 96 | float mColumn = -1; |
| 97 | float mOldColumn; |
| 98 | float mZoom = 1; |
| 99 | |
| 100 | int mIconCount = 29; |
| 101 | int mRows = 4; |
| 102 | int mColumns = (mIconCount + mRows - 1) / mRows; |
| 103 | |
| 104 | float mMaxZoom = ((float)mColumns) / 3.f; |
| 105 | |
| 106 | |
| 107 | void setColumn(boolean clamp) |
| 108 | { |
| 109 | //Log.e("rs", " col = " + Float.toString(mColumn)); |
| 110 | float c = mColumn; |
| 111 | if(c > (mColumns -2)) { |
| 112 | c = (mColumns -2); |
| 113 | } |
| 114 | if(c < 0) { |
| 115 | c = 0; |
| 116 | } |
| 117 | mRender.setPosition(c); |
| 118 | if(clamp) { |
| 119 | mColumn = c; |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | void computeSelection(float x, float y) |
| 124 | { |
| 125 | float col = mColumn + (x - 0.5f) * 4 + 1.25f; |
| 126 | int iCol = (int)(col + 0.25f); |
| 127 | |
| 128 | float row = (y / 0.8f) * mRows; |
| 129 | int iRow = (int)(row - 0.5f); |
| 130 | |
| 131 | mRender.setSelected(iCol * mRows + iRow); |
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public boolean onTouchEvent(MotionEvent ev) |
| 136 | { |
| 137 | boolean ret = true; |
| 138 | int act = ev.getAction(); |
| 139 | if (act == ev.ACTION_UP) { |
| 140 | ret = false; |
| 141 | } |
| 142 | |
| 143 | float nx = ev.getX() / getWidth(); |
| 144 | float ny = ev.getY() / getHeight(); |
| 145 | |
| 146 | //Log.e("rs", "width=" + Float.toString(getWidth())); |
| 147 | //Log.e("rs", "height=" + Float.toString(getHeight())); |
| 148 | |
| 149 | mRender.setTouch(ret); |
| 150 | |
| 151 | if((ny > 0.85f) || mControlMode) { |
| 152 | mFlingMode = false; |
| 153 | |
| 154 | // Projector control |
| 155 | if((nx > 0.2f) && (nx < 0.8f) || mControlMode) { |
| 156 | if(act != ev.ACTION_UP) { |
| 157 | float zoom = mMaxZoom; |
| 158 | if(mControlMode) { |
| 159 | if(!mZoomMode) { |
| 160 | zoom = 1.f; |
| 161 | } |
| 162 | float dx = nx - mFlingX; |
| 163 | |
| 164 | if((ny < 0.9) && mZoomMode) { |
| 165 | zoom = mMaxZoom - ((0.9f - ny) * 10.f); |
| 166 | if(zoom < 1) { |
| 167 | zoom = 1; |
| 168 | mZoomMode = false; |
| 169 | } |
| 170 | mOldColumn = mColumn; |
| 171 | } |
| 172 | mColumn += dx * 4;// * zoom; |
| 173 | if(zoom > 1.01f) { |
| 174 | mColumn += (mZoom - zoom) * (nx - 0.5f) * 4 * zoom; |
| 175 | } |
| 176 | } else { |
| 177 | mOldColumn = mColumn; |
| 178 | mColumn = ((float)mColumns) / 2; |
| 179 | mControlMode = true; |
| 180 | mZoomMode = true; |
| 181 | } |
| 182 | mZoom = zoom; |
| 183 | mFlingX = nx; |
| 184 | mRender.setZoom(zoom); |
| 185 | if(mZoom < 1.01f) { |
| 186 | computeSelection(nx, ny); |
| 187 | } |
| 188 | } else { |
| 189 | mControlMode = false; |
| 190 | mColumn = mOldColumn; |
| 191 | mRender.setZoom(1.f); |
| 192 | mRender.setSelected(-1); |
| 193 | } |
| 194 | } else { |
| 195 | // Do something with corners here.... |
| 196 | } |
| 197 | setColumn(true); |
| 198 | |
| 199 | } else { |
| 200 | // icon control |
| 201 | if(act != ev.ACTION_UP) { |
| 202 | if(mFlingMode) { |
| 203 | mColumn += (mFlingX - nx) * 4; |
| 204 | setColumn(true); |
| 205 | } |
| 206 | mFlingMode = true; |
| 207 | mFlingX = nx; |
| 208 | mFlingY = ny; |
| 209 | } else { |
| 210 | mFlingMode = false; |
| 211 | mColumn = (float)(java.lang.Math.floor(mColumn * 0.25f + 0.3f) * 4.f) + 1.f; |
| 212 | setColumn(true); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | |
| 217 | return ret; |
| 218 | } |
| 219 | |
| 220 | @Override |
| 221 | public boolean onTrackballEvent(MotionEvent ev) |
| 222 | { |
| 223 | float x = ev.getX(); |
| 224 | float y = ev.getY(); |
| 225 | //Float tx = new Float(x); |
| 226 | //Float ty = new Float(y); |
| 227 | //Log.e("rs", "tbe " + tx.toString() + ", " + ty.toString()); |
| 228 | |
| 229 | |
| 230 | return true; |
| 231 | } |
| 232 | |
| 233 | public class RolloRS { |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 234 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 235 | //public static final int STATE_SELECTED_ID = 0; |
| 236 | public static final int STATE_DONE = 1; |
| 237 | //public static final int STATE_PRESSURE = 2; |
| 238 | public static final int STATE_ZOOM = 3; |
| 239 | //public static final int STATE_WARP = 4; |
| 240 | public static final int STATE_ORIENTATION = 5; |
| 241 | public static final int STATE_SELECTION = 6; |
| 242 | public static final int STATE_FIRST_VISIBLE = 7; |
| 243 | public static final int STATE_COUNT = 8; |
| 244 | public static final int STATE_TOUCH = 9; |
| 245 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 246 | static final int ALLOC_PARAMS = 0; |
| 247 | static final int ALLOC_STATE = 1; |
| 248 | static final int ALLOC_SCRATCH = 2; |
| 249 | static final int ALLOC_ICON_IDS = 3; |
| 250 | static final int ALLOC_LABEL_IDS = 4; |
| 251 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 252 | public RolloRS() { |
| 253 | } |
| 254 | |
| 255 | public void init(RenderScript rs, Resources res, int width, int height) { |
| 256 | mRS = rs; |
| 257 | mRes = res; |
| 258 | mWidth = width; |
| 259 | mHeight = height; |
| 260 | initNamed(); |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 261 | initIcons(29); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 262 | initRS(); |
| 263 | } |
| 264 | |
| 265 | public void setPosition(float column) { |
| 266 | mAllocStateBuf[STATE_FIRST_VISIBLE] = (int)(column * (-20)); |
| 267 | mAllocState.data(mAllocStateBuf); |
| 268 | } |
| 269 | |
| 270 | public void setTouch(boolean touch) { |
| 271 | mAllocStateBuf[STATE_TOUCH] = touch ? 1 : 0; |
| 272 | mAllocState.data(mAllocStateBuf); |
| 273 | } |
| 274 | |
| 275 | public void setZoom(float z) { |
| 276 | //Log.e("rs", "zoom " + Float.toString(z)); |
| 277 | |
| 278 | mAllocStateBuf[STATE_ZOOM] = (int)(z * 1000.f); |
| 279 | mAllocState.data(mAllocStateBuf); |
| 280 | } |
| 281 | |
| 282 | public void setSelected(int index) { |
| 283 | //Log.e("rs", "setSelected " + Integer.toString(index)); |
| 284 | |
| 285 | mAllocStateBuf[STATE_SELECTION] = index; |
| 286 | mAllocStateBuf[STATE_DONE] = 1; |
| 287 | mAllocState.data(mAllocStateBuf); |
| 288 | } |
| 289 | |
| 290 | private int mWidth; |
| 291 | private int mHeight; |
| 292 | |
| 293 | private Resources mRes; |
| 294 | private RenderScript mRS; |
| 295 | private Script mScript; |
| 296 | private Sampler mSampler; |
| 297 | private Sampler mSamplerText; |
| 298 | private ProgramStore mPSBackground; |
| 299 | private ProgramStore mPSText; |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 300 | private ProgramFragment mPFDebug; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 301 | private ProgramFragment mPFImages; |
| 302 | private ProgramFragment mPFText; |
| 303 | private ProgramVertex mPV; |
| 304 | private ProgramVertex.MatrixAllocation mPVAlloc; |
| 305 | private ProgramVertex mPVOrtho; |
| 306 | private ProgramVertex.MatrixAllocation mPVOrthoAlloc; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 307 | |
| 308 | private int[] mAllocStateBuf; |
| 309 | private Allocation mAllocState; |
| 310 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 311 | private Allocation[] mIcons; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 312 | private int[] mAllocIconIDBuf; |
| 313 | private Allocation mAllocIconID; |
| 314 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 315 | private Allocation[] mLabels; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 316 | private int[] mAllocLabelIDBuf; |
| 317 | private Allocation mAllocLabelID; |
| 318 | |
| 319 | private int[] mAllocScratchBuf; |
| 320 | private Allocation mAllocScratch; |
| 321 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 322 | Params mParams; |
| 323 | |
| 324 | class Params extends IntAllocation { |
| 325 | Params(RenderScript rs) { |
| 326 | super(rs); |
| 327 | } |
| 328 | @AllocationIndex(0) public int bubbleWidth; |
| 329 | @AllocationIndex(1) public int bubbleHeight; |
| 330 | @AllocationIndex(2) public int bubbleBitmapWidth; |
| 331 | @AllocationIndex(3) public int bubbleBitmapHeight; |
| 332 | } |
| 333 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 334 | private void initNamed() { |
| 335 | Sampler.Builder sb = new Sampler.Builder(mRS); |
| 336 | sb.setMin(Sampler.Value.LINEAR);//_MIP_LINEAR); |
| 337 | sb.setMag(Sampler.Value.LINEAR); |
| 338 | sb.setWrapS(Sampler.Value.CLAMP); |
| 339 | sb.setWrapT(Sampler.Value.CLAMP); |
| 340 | mSampler = sb.create(); |
| 341 | |
| 342 | sb.setMin(Sampler.Value.NEAREST); |
| 343 | sb.setMag(Sampler.Value.NEAREST); |
| 344 | mSamplerText = sb.create(); |
| 345 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 346 | ProgramFragment.Builder dbg = new ProgramFragment.Builder(mRS, null, null); |
| 347 | mPFDebug = dbg.create(); |
| 348 | mPFDebug.setName("PFDebug"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 349 | |
| 350 | ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS, null, null); |
| 351 | bf.setTexEnable(true, 0); |
| 352 | bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); |
| 353 | mPFImages = bf.create(); |
| 354 | mPFImages.setName("PF"); |
| 355 | mPFImages.bindSampler(mSampler, 0); |
| 356 | |
| 357 | bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); |
| 358 | mPFText = bf.create(); |
| 359 | mPFText.setName("PFText"); |
| 360 | mPFText.bindSampler(mSamplerText, 0); |
| 361 | |
| 362 | ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null); |
| 363 | bs.setDepthFunc(ProgramStore.DepthFunc.LESS); |
| 364 | bs.setDitherEnable(false); |
| 365 | bs.setDepthMask(true); |
| 366 | bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA, |
| 367 | ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 368 | mPSBackground = bs.create(); |
| 369 | mPSBackground.setName("PFS"); |
| 370 | |
| 371 | bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 372 | bs.setDepthMask(false); |
| 373 | bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA, |
| 374 | ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 375 | mPSText = bs.create(); |
| 376 | mPSText.setName("PFSText"); |
| 377 | |
| 378 | mPVAlloc = new ProgramVertex.MatrixAllocation(mRS); |
| 379 | mPVAlloc.setupProjectionNormalized(mWidth, mHeight); |
| 380 | |
| 381 | ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null); |
| 382 | mPV = pvb.create(); |
| 383 | mPV.setName("PV"); |
| 384 | mPV.bindAllocation(mPVAlloc); |
| 385 | |
| 386 | mPVOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS); |
| 387 | mPVOrthoAlloc.setupOrthoWindow(mWidth, mHeight); |
| 388 | |
| 389 | pvb.setTextureMatrixEnable(true); |
| 390 | mPVOrtho = pvb.create(); |
| 391 | mPVOrtho.setName("PVOrtho"); |
| 392 | mPVOrtho.bindAllocation(mPVOrthoAlloc); |
| 393 | |
| 394 | mRS.contextBindProgramVertex(mPV); |
| 395 | |
| 396 | mAllocScratchBuf = new int[32]; |
| 397 | mAllocScratch = Allocation.createSized(mRS, |
| 398 | Element.USER_I32, mAllocScratchBuf.length); |
| 399 | mAllocScratch.data(mAllocScratchBuf); |
| 400 | |
| 401 | Log.e("rs", "Done loading named"); |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | private void initIcons(int count) { |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 405 | mParams = new Params(mRS); |
| 406 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 407 | mIcons = new Allocation[count]; |
| 408 | mAllocIconIDBuf = new int[count]; |
| 409 | mAllocIconID = Allocation.createSized(mRS, |
| 410 | Element.USER_I32, mAllocIconIDBuf.length); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 411 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 412 | mLabels = new Allocation[count]; |
| 413 | mAllocLabelIDBuf = new int[mLabels.length]; |
| 414 | mAllocLabelID = Allocation.createSized(mRS, |
| 415 | Element.USER_I32, mLabels.length); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 416 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 417 | Element ie8888 = Element.RGBA_8888; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 418 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 419 | final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 420 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 421 | mParams.bubbleWidth = bubble.getBubbleWidth(); |
| 422 | mParams.bubbleHeight = bubble.getMaxBubbleHeight(); |
| 423 | mParams.bubbleBitmapWidth = bubble.getBitmapWidth(); |
| 424 | mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); |
| 425 | mParams.save(); |
| 426 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 427 | for (int i=0; i<count; i++) { |
| 428 | mIcons[i] = Allocation.createFromBitmapResource( |
| 429 | mRS, mRes, R.raw.maps, ie8888, true); |
| 430 | mLabels[i] = makeTextBitmap(bubble, i%9==0 ? "Google Maps" : "Maps"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 431 | } |
| 432 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 433 | for(int ct=0; ct < count; ct++) { |
| 434 | mIcons[ct].uploadToTexture(0); |
| 435 | mLabels[ct].uploadToTexture(0); |
| 436 | mAllocIconIDBuf[ct] = mIcons[ct].getID(); |
| 437 | mAllocLabelIDBuf[ct] = mLabels[ct].getID(); |
| 438 | } |
| 439 | mAllocIconID.data(mAllocIconIDBuf); |
| 440 | mAllocLabelID.data(mAllocLabelIDBuf); |
| 441 | |
| 442 | Log.e("rs", "Done loading icons"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 443 | } |
| 444 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 445 | Allocation makeTextBitmap(Utilities.BubbleText bubble, String label) { |
| 446 | Bitmap b = bubble.createTextBitmap(label); |
| 447 | Allocation a = Allocation.createFromBitmap(mRS, b, Element.RGBA_8888, true); |
| 448 | b.recycle(); |
| 449 | return a; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 450 | } |
| 451 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 452 | private void initRS() { |
| 453 | ScriptC.Builder sb = new ScriptC.Builder(mRS); |
| 454 | sb.setScript(mRes, R.raw.rollo); |
| 455 | //sb.setScript(mRes, R.raw.rollo2); |
| 456 | sb.setRoot(true); |
| 457 | mScript = sb.create(); |
| 458 | mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 459 | |
| 460 | mAllocStateBuf = new int[] {0, 0, 0, 8, 0, 0, -1, 0, mAllocIconIDBuf.length, 0, 0}; |
| 461 | mAllocState = Allocation.createSized(mRS, |
| 462 | Element.USER_I32, mAllocStateBuf.length); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame^] | 463 | |
| 464 | mScript.bindAllocation(mParams.getAllocation(), ALLOC_PARAMS); |
| 465 | mScript.bindAllocation(mAllocState, ALLOC_STATE); |
| 466 | mScript.bindAllocation(mAllocIconID, ALLOC_ICON_IDS); |
| 467 | mScript.bindAllocation(mAllocScratch, ALLOC_SCRATCH); |
| 468 | mScript.bindAllocation(mAllocLabelID, ALLOC_LABEL_IDS); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 469 | setPosition(0); |
| 470 | setZoom(1); |
| 471 | |
| 472 | //RenderScript.File f = mRS.fileOpen("/sdcard/test.a3d"); |
| 473 | |
| 474 | mRS.contextBindRootScript(mScript); |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | } |
| 479 | |
| 480 | |
| 481 | |