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; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 47 | import android.os.SystemClock; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 48 | import android.util.AttributeSet; |
| 49 | import android.util.Log; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 50 | import android.view.KeyEvent; |
| 51 | import android.view.MotionEvent; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 52 | import android.view.Surface; |
| 53 | import android.view.SurfaceHolder; |
| 54 | import android.view.SurfaceView; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 55 | import android.view.VelocityTracker; |
| 56 | import android.view.ViewConfiguration; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 57 | import android.graphics.PixelFormat; |
| 58 | |
| 59 | |
| 60 | public class AllAppsView extends RSSurfaceView { |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 61 | private RenderScript mRS; |
| 62 | private RolloRS mRollo; |
| 63 | |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 64 | private ViewConfiguration mConfig; |
| 65 | private VelocityTracker mVelocity; |
| 66 | private int mLastScrollX; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 67 | private int mLastMotionX; |
| 68 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 69 | public AllAppsView(Context context) { |
| 70 | super(context); |
| 71 | setFocusable(true); |
| 72 | getHolder().setFormat(PixelFormat.TRANSLUCENT); |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 73 | mConfig = ViewConfiguration.get(context); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | public AllAppsView(Context context, AttributeSet attrs) { |
| 77 | this(context); |
| 78 | } |
| 79 | |
| 80 | public AllAppsView(Context context, AttributeSet attrs, int defStyle) { |
| 81 | this(context); |
| 82 | } |
| 83 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 84 | @Override |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 85 | public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) { |
| 86 | super.surfaceChanged(holder, format, w, h); |
| 87 | |
| 88 | mRS = createRenderScript(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 89 | mRollo = new RolloRS(); |
| 90 | mRollo.init(getResources(), w, h); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public boolean onKeyDown(int keyCode, KeyEvent event) |
| 95 | { |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 96 | // this method doesn't work when 'extends View' include 'extends ScrollView'. |
| 97 | return super.onKeyDown(keyCode, event); |
| 98 | } |
| 99 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 100 | @Override |
| 101 | public boolean onTouchEvent(MotionEvent ev) |
| 102 | { |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 103 | int x = (int)ev.getX(); |
| 104 | int deltaX; |
| 105 | switch (ev.getAction()) { |
| 106 | case MotionEvent.ACTION_DOWN: |
| 107 | mLastMotionX = x; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 108 | mRollo.mState.read(); |
| 109 | mRollo.mState.scrollX = mLastScrollX = mRollo.mState.currentScrollX; |
| 110 | mRollo.mState.flingVelocityX = 0; |
| 111 | mRollo.mState.adjustedDeceleration = 0; |
| 112 | mRollo.mState.save(); |
| 113 | mVelocity = VelocityTracker.obtain(); |
| 114 | mVelocity.addMovement(ev); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 115 | break; |
| 116 | case MotionEvent.ACTION_MOVE: |
| 117 | case MotionEvent.ACTION_OUTSIDE: |
| 118 | deltaX = x - mLastMotionX; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 119 | mVelocity.addMovement(ev); |
| 120 | mRollo.mState.currentScrollX = mLastScrollX; |
| 121 | mLastScrollX += deltaX; |
| 122 | mRollo.mState.scrollX = mLastScrollX; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 123 | mRollo.mState.save(); |
| 124 | mLastMotionX = x; |
| 125 | break; |
| 126 | case MotionEvent.ACTION_UP: |
| 127 | case MotionEvent.ACTION_CANCEL: |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 128 | mVelocity.computeCurrentVelocity(1000 /* px/sec */, |
| 129 | mConfig.getScaledMaximumFlingVelocity()); |
| 130 | mRollo.mState.flingTimeMs = (int)SystemClock.uptimeMillis(); // TODO: use long |
| 131 | mRollo.mState.flingVelocityX = (int)mVelocity.getXVelocity(); |
| 132 | mRollo.mState.save(); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 133 | mLastMotionX = -10000; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 134 | mVelocity.recycle(); |
| 135 | mVelocity = null; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 136 | break; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 137 | } |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 138 | return true; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public boolean onTrackballEvent(MotionEvent ev) |
| 143 | { |
| 144 | float x = ev.getX(); |
| 145 | float y = ev.getY(); |
| 146 | //Float tx = new Float(x); |
| 147 | //Float ty = new Float(y); |
| 148 | //Log.e("rs", "tbe " + tx.toString() + ", " + ty.toString()); |
| 149 | |
| 150 | |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | public class RolloRS { |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 155 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 156 | // Allocations ====== |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 157 | |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 158 | private int mWidth; |
| 159 | private int mHeight; |
| 160 | |
| 161 | private Resources mRes; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 162 | private Script mScript; |
| 163 | private Sampler mSampler; |
| 164 | private Sampler mSamplerText; |
| 165 | private ProgramStore mPSBackground; |
| 166 | private ProgramStore mPSText; |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 167 | private ProgramFragment mPFDebug; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 168 | private ProgramFragment mPFImages; |
| 169 | private ProgramFragment mPFText; |
| 170 | private ProgramVertex mPV; |
| 171 | private ProgramVertex.MatrixAllocation mPVAlloc; |
| 172 | private ProgramVertex mPVOrtho; |
| 173 | private ProgramVertex.MatrixAllocation mPVOrthoAlloc; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 174 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 175 | private Allocation[] mIcons; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 176 | private int[] mAllocIconIDBuf; |
| 177 | private Allocation mAllocIconID; |
| 178 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 179 | private Allocation[] mLabels; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 180 | private int[] mAllocLabelIDBuf; |
| 181 | private Allocation mAllocLabelID; |
| 182 | |
| 183 | private int[] mAllocScratchBuf; |
| 184 | private Allocation mAllocScratch; |
| 185 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 186 | Params mParams; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 187 | State mState; |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 188 | |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 189 | class Defines { |
| 190 | public static final int ALLOC_PARAMS = 0; |
| 191 | public static final int ALLOC_STATE = 1; |
| 192 | public static final int ALLOC_SCRATCH = 2; |
| 193 | public static final int ALLOC_ICON_IDS = 3; |
| 194 | public static final int ALLOC_LABEL_IDS = 4; |
| 195 | } |
| 196 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 197 | class Params extends IntAllocation { |
| 198 | Params(RenderScript rs) { |
| 199 | super(rs); |
| 200 | } |
| 201 | @AllocationIndex(0) public int bubbleWidth; |
| 202 | @AllocationIndex(1) public int bubbleHeight; |
| 203 | @AllocationIndex(2) public int bubbleBitmapWidth; |
| 204 | @AllocationIndex(3) public int bubbleBitmapHeight; |
| 205 | } |
| 206 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 207 | class State extends IntAllocation { |
| 208 | State(RenderScript rs) { |
| 209 | super(rs); |
| 210 | } |
| 211 | @AllocationIndex(0) public int iconCount; |
| 212 | @AllocationIndex(1) public int scrollX; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 213 | @AllocationIndex(2) public int flingTimeMs; |
| 214 | @AllocationIndex(3) public int flingVelocityX; |
| 215 | @AllocationIndex(4) public int adjustedDeceleration; |
| 216 | @AllocationIndex(5) public int currentScrollX; |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | public RolloRS() { |
| 220 | } |
| 221 | |
| 222 | public void init(Resources res, int width, int height) { |
| 223 | mRes = res; |
| 224 | mWidth = width; |
| 225 | mHeight = height; |
| 226 | initGl(); |
| 227 | initData(); |
| 228 | initRs(); |
| 229 | } |
| 230 | |
| 231 | private void initGl() { |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 232 | Sampler.Builder sb = new Sampler.Builder(mRS); |
| 233 | sb.setMin(Sampler.Value.LINEAR);//_MIP_LINEAR); |
| 234 | sb.setMag(Sampler.Value.LINEAR); |
| 235 | sb.setWrapS(Sampler.Value.CLAMP); |
| 236 | sb.setWrapT(Sampler.Value.CLAMP); |
| 237 | mSampler = sb.create(); |
| 238 | |
| 239 | sb.setMin(Sampler.Value.NEAREST); |
| 240 | sb.setMag(Sampler.Value.NEAREST); |
| 241 | mSamplerText = sb.create(); |
| 242 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 243 | ProgramFragment.Builder dbg = new ProgramFragment.Builder(mRS, null, null); |
| 244 | mPFDebug = dbg.create(); |
| 245 | mPFDebug.setName("PFDebug"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 246 | |
| 247 | ProgramFragment.Builder bf = new ProgramFragment.Builder(mRS, null, null); |
| 248 | bf.setTexEnable(true, 0); |
| 249 | bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); |
| 250 | mPFImages = bf.create(); |
| 251 | mPFImages.setName("PF"); |
| 252 | mPFImages.bindSampler(mSampler, 0); |
| 253 | |
| 254 | bf.setTexEnvMode(ProgramFragment.EnvMode.MODULATE, 0); |
| 255 | mPFText = bf.create(); |
| 256 | mPFText.setName("PFText"); |
| 257 | mPFText.bindSampler(mSamplerText, 0); |
| 258 | |
| 259 | ProgramStore.Builder bs = new ProgramStore.Builder(mRS, null, null); |
| 260 | bs.setDepthFunc(ProgramStore.DepthFunc.LESS); |
| 261 | bs.setDitherEnable(false); |
| 262 | bs.setDepthMask(true); |
| 263 | bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA, |
| 264 | ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 265 | mPSBackground = bs.create(); |
| 266 | mPSBackground.setName("PFS"); |
| 267 | |
| 268 | bs.setDepthFunc(ProgramStore.DepthFunc.ALWAYS); |
| 269 | bs.setDepthMask(false); |
| 270 | bs.setBlendFunc(ProgramStore.BlendSrcFunc.SRC_ALPHA, |
| 271 | ProgramStore.BlendDstFunc.ONE_MINUS_SRC_ALPHA); |
| 272 | mPSText = bs.create(); |
| 273 | mPSText.setName("PFSText"); |
| 274 | |
| 275 | mPVAlloc = new ProgramVertex.MatrixAllocation(mRS); |
| 276 | mPVAlloc.setupProjectionNormalized(mWidth, mHeight); |
| 277 | |
| 278 | ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS, null, null); |
| 279 | mPV = pvb.create(); |
| 280 | mPV.setName("PV"); |
| 281 | mPV.bindAllocation(mPVAlloc); |
| 282 | |
| 283 | mPVOrthoAlloc = new ProgramVertex.MatrixAllocation(mRS); |
| 284 | mPVOrthoAlloc.setupOrthoWindow(mWidth, mHeight); |
| 285 | |
| 286 | pvb.setTextureMatrixEnable(true); |
| 287 | mPVOrtho = pvb.create(); |
| 288 | mPVOrtho.setName("PVOrtho"); |
| 289 | mPVOrtho.bindAllocation(mPVOrthoAlloc); |
| 290 | |
| 291 | mRS.contextBindProgramVertex(mPV); |
| 292 | |
| 293 | mAllocScratchBuf = new int[32]; |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 294 | mAllocScratch = Allocation.createSized(mRS, Element.USER_I32, mAllocScratchBuf.length); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 295 | mAllocScratch.data(mAllocScratchBuf); |
| 296 | |
| 297 | Log.e("rs", "Done loading named"); |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 300 | private void initData() { |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 301 | final int count = 100; |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 302 | mParams = new Params(mRS); |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 303 | mState = new State(mRS); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 304 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 305 | mIcons = new Allocation[count]; |
| 306 | mAllocIconIDBuf = new int[count]; |
| 307 | mAllocIconID = Allocation.createSized(mRS, |
| 308 | Element.USER_I32, mAllocIconIDBuf.length); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 309 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 310 | mLabels = new Allocation[count]; |
| 311 | mAllocLabelIDBuf = new int[mLabels.length]; |
| 312 | mAllocLabelID = Allocation.createSized(mRS, |
| 313 | Element.USER_I32, mLabels.length); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 314 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 315 | Element ie8888 = Element.RGBA_8888; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 316 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 317 | final Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 318 | |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 319 | mParams.bubbleWidth = bubble.getBubbleWidth(); |
| 320 | mParams.bubbleHeight = bubble.getMaxBubbleHeight(); |
| 321 | mParams.bubbleBitmapWidth = bubble.getBitmapWidth(); |
| 322 | mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); |
Joe Onorato | 43e7bcf | 2009-08-08 18:53:53 -0700 | [diff] [blame] | 323 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 324 | for (int i=0; i<count; i++) { |
| 325 | mIcons[i] = Allocation.createFromBitmapResource( |
| 326 | mRS, mRes, R.raw.maps, ie8888, true); |
| 327 | mLabels[i] = makeTextBitmap(bubble, i%9==0 ? "Google Maps" : "Maps"); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 330 | for (int i=0; i<count; i++) { |
| 331 | mIcons[i].uploadToTexture(0); |
| 332 | mLabels[i].uploadToTexture(0); |
| 333 | mAllocIconIDBuf[i] = mIcons[i].getID(); |
| 334 | mAllocLabelIDBuf[i] = mLabels[i].getID(); |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 335 | } |
| 336 | mAllocIconID.data(mAllocIconIDBuf); |
| 337 | mAllocLabelID.data(mAllocLabelIDBuf); |
| 338 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 339 | mState.iconCount = count; |
| 340 | |
| 341 | mParams.save(); |
| 342 | mState.save(); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Joe Onorato | bf15cb4 | 2009-08-07 14:33:40 -0700 | [diff] [blame] | 345 | Allocation makeTextBitmap(Utilities.BubbleText bubble, String label) { |
| 346 | Bitmap b = bubble.createTextBitmap(label); |
| 347 | Allocation a = Allocation.createFromBitmap(mRS, b, Element.RGBA_8888, true); |
| 348 | b.recycle(); |
| 349 | return a; |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Joe Onorato | 1feb3a8 | 2009-08-08 22:32:00 -0700 | [diff] [blame] | 352 | private void initRs() { |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 353 | ScriptC.Builder sb = new ScriptC.Builder(mRS); |
| 354 | sb.setScript(mRes, R.raw.rollo); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 355 | sb.setRoot(true); |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 356 | sb.addDefines(Defines.class); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 357 | mScript = sb.create(); |
| 358 | mScript.setClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 359 | |
Joe Onorato | d769a63 | 2009-08-11 17:09:02 -0700 | [diff] [blame^] | 360 | mScript.bindAllocation(mParams.getAllocation(), Defines.ALLOC_PARAMS); |
| 361 | mScript.bindAllocation(mState.getAllocation(), Defines.ALLOC_STATE); |
| 362 | mScript.bindAllocation(mAllocIconID, Defines.ALLOC_ICON_IDS); |
| 363 | mScript.bindAllocation(mAllocScratch, Defines.ALLOC_SCRATCH); |
| 364 | mScript.bindAllocation(mAllocLabelID, Defines.ALLOC_LABEL_IDS); |
Joe Onorato | 9383905 | 2009-08-06 20:34:32 -0700 | [diff] [blame] | 365 | |
| 366 | mRS.contextBindRootScript(mScript); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | } |
| 371 | |
| 372 | |
| 373 | |