UT_alloc.java revision 648a1c137663ef7207684d0d7009dd5518942111
1cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck/* 2cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Copyright (C) 2013 The Android Open Source Project 3cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 4cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Licensed under the Apache License, Version 2.0 (the "License"); 5cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * you may not use this file except in compliance with the License. 6cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * You may obtain a copy of the License at 7cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 8cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * http://www.apache.org/licenses/LICENSE-2.0 9cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * 10cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * Unless required by applicable law or agreed to in writing, software 11cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * distributed under the License is distributed on an "AS IS" BASIS, 12cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * See the License for the specific language governing permissions and 14cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck * limitations under the License. 15cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck */ 16cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 1723b797ab5151eb2474f3bdd679f2f07bfd723042John Reckpackage com.android.rs.test_compatlegacy; 18cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 19e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reckimport android.content.Context; 20e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reckimport android.content.res.Resources; 21cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckimport android.support.v8.renderscript.*; 22cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 23cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reckpublic class UT_alloc extends UnitTest { 24cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck private Resources mRes; 254f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck 264f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck protected UT_alloc(RSTestCore rstc, Resources res, Context ctx) { 274f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck super(rstc, "Alloc", ctx); 284f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck mRes = res; 2966f0be65a1046f54ddce0498b242c1fa0776b1eaJohn Reck } 3066f0be65a1046f54ddce0498b242c1fa0776b1eaJohn Reck 3152244fff29042926e21fa897ef5ab11148e35299John Reck private void initializeGlobals(RenderScript RS, ScriptC_alloc s) { 32e45b1fd03b524d2b57cc6c222d89076a31a08beaJohn Reck Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS)); 3366f0be65a1046f54ddce0498b242c1fa0776b1eaJohn Reck int X = 5; 344f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck int Y = 7; 35cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck int Z = 0; 36cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.set_dimX(X); 37797b95b26bbb7557678af78b9a2a61830158920fChris Craik s.set_dimY(Y); 38cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.set_dimZ(Z); 39cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck typeBuilder.setX(X).setY(Y); 40cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck Allocation A = Allocation.createTyped(RS, typeBuilder.create()); 41cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.bind_a(A); 42cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.set_aRaw(A); 434f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck 444f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck typeBuilder = new Type.Builder(RS, Element.I32(RS)); 45cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck typeBuilder.setX(X).setY(Y).setFaces(true); 46cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck Allocation AFaces = Allocation.createTyped(RS, typeBuilder.create()); 47cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.set_aFaces(AFaces); 484f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck typeBuilder.setFaces(false).setMipmaps(true); 49cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck Allocation ALOD = Allocation.createTyped(RS, typeBuilder.create()); 50cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.set_aLOD(ALOD); 51cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck typeBuilder.setFaces(true).setMipmaps(true); 52cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck Allocation AFacesLOD = Allocation.createTyped(RS, typeBuilder.create()); 53cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.set_aFacesLOD(AFacesLOD); 54cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck 55cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck return; 56cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 574f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck 584f02bf4eef6af47f35c70c4dda5b7b9523d89ca0John Reck public void run() { 59cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck RenderScript pRS = RenderScript.create(mCtx); 60cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck ScriptC_alloc s = new ScriptC_alloc(pRS); 61cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck pRS.setMessageHandler(mRsMessage); 62cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck initializeGlobals(pRS, s); 63cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.forEach_root(s.get_aRaw()); 64cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck s.invoke_alloc_test(); 65cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck pRS.finish(); 66cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck waitForMessage(); 67cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck pRS.destroy(); 68cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck } 69cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck} 70cec24ae16e9a0a7c3075f1a8d9149bb7fb3813fcJohn Reck