Update AppApps to use reflected files.
Previous files were hand written placeholders. This also fixed the physics bug where movement was right. Change-Id: I98838084d60f0eaf22f7fbd148a80b2f73f9a14c
This commit is contained in:
@@ -965,7 +965,7 @@ public class AllApps3D extends RSSurfaceView
|
||||
private int mHeight;
|
||||
|
||||
private Resources mRes;
|
||||
ScriptC_allapps mScript;
|
||||
ScriptC_Allapps mScript;
|
||||
|
||||
//private ProgramStore mPSIcons;
|
||||
private ProgramFragment mPFTexMip;
|
||||
@@ -1033,7 +1033,7 @@ public class AllApps3D extends RSSurfaceView
|
||||
mRes = res;
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
mScript = new ScriptC_allapps(sRS, mRes, R.raw.allapps_bc, true);
|
||||
mScript = new ScriptC_Allapps(sRS, mRes, R.raw.allapps_bc, true);
|
||||
|
||||
initProgramVertex();
|
||||
initProgramFragment();
|
||||
@@ -1264,7 +1264,7 @@ public class AllApps3D extends RSSurfaceView
|
||||
sRollo.mScript.set_gZoomTarget(0);
|
||||
}
|
||||
if (!animate) {
|
||||
sRollo.mScript.invokable_SetZoom();
|
||||
sRollo.mScript.invoke_setZoom();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1368,16 +1368,16 @@ public class AllApps3D extends RSSurfaceView
|
||||
}
|
||||
|
||||
void fling() {
|
||||
mScript.invokable_Fling();
|
||||
mScript.invoke_fling();
|
||||
}
|
||||
|
||||
void move() {
|
||||
mScript.invokable_Move();
|
||||
mScript.invoke_move();
|
||||
}
|
||||
|
||||
void moveTo(float row) {
|
||||
mScript.set_gTargetPos(row);
|
||||
mScript.invokable_MoveTo();
|
||||
mScript.invoke_moveTo();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.renderscript.*;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptC_Allapps extends ScriptC {
|
||||
// Constructor
|
||||
public ScriptC_Allapps(RenderScript rs, Resources resources, int id, boolean isRoot) {
|
||||
super(rs, resources, id, isRoot);
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_COLUMNS_PER_PAGE_PORTRAIT = 0;
|
||||
private int mExportVar_COLUMNS_PER_PAGE_PORTRAIT;
|
||||
public void set_COLUMNS_PER_PAGE_PORTRAIT(int v) {
|
||||
mExportVar_COLUMNS_PER_PAGE_PORTRAIT = v;
|
||||
setVar(mExportVarIdx_COLUMNS_PER_PAGE_PORTRAIT, v);
|
||||
}
|
||||
|
||||
public int get_COLUMNS_PER_PAGE_PORTRAIT() {
|
||||
return mExportVar_COLUMNS_PER_PAGE_PORTRAIT;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_ROWS_PER_PAGE_PORTRAIT = 1;
|
||||
private int mExportVar_ROWS_PER_PAGE_PORTRAIT;
|
||||
public void set_ROWS_PER_PAGE_PORTRAIT(int v) {
|
||||
mExportVar_ROWS_PER_PAGE_PORTRAIT = v;
|
||||
setVar(mExportVarIdx_ROWS_PER_PAGE_PORTRAIT, v);
|
||||
}
|
||||
|
||||
public int get_ROWS_PER_PAGE_PORTRAIT() {
|
||||
return mExportVar_ROWS_PER_PAGE_PORTRAIT;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_COLUMNS_PER_PAGE_LANDSCAPE = 2;
|
||||
private int mExportVar_COLUMNS_PER_PAGE_LANDSCAPE;
|
||||
public void set_COLUMNS_PER_PAGE_LANDSCAPE(int v) {
|
||||
mExportVar_COLUMNS_PER_PAGE_LANDSCAPE = v;
|
||||
setVar(mExportVarIdx_COLUMNS_PER_PAGE_LANDSCAPE, v);
|
||||
}
|
||||
|
||||
public int get_COLUMNS_PER_PAGE_LANDSCAPE() {
|
||||
return mExportVar_COLUMNS_PER_PAGE_LANDSCAPE;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_ROWS_PER_PAGE_LANDSCAPE = 3;
|
||||
private int mExportVar_ROWS_PER_PAGE_LANDSCAPE;
|
||||
public void set_ROWS_PER_PAGE_LANDSCAPE(int v) {
|
||||
mExportVar_ROWS_PER_PAGE_LANDSCAPE = v;
|
||||
setVar(mExportVarIdx_ROWS_PER_PAGE_LANDSCAPE, v);
|
||||
}
|
||||
|
||||
public int get_ROWS_PER_PAGE_LANDSCAPE() {
|
||||
return mExportVar_ROWS_PER_PAGE_LANDSCAPE;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gNewPositionX = 4;
|
||||
private float mExportVar_gNewPositionX;
|
||||
public void set_gNewPositionX(float v) {
|
||||
mExportVar_gNewPositionX = v;
|
||||
setVar(mExportVarIdx_gNewPositionX, v);
|
||||
}
|
||||
|
||||
public float get_gNewPositionX() {
|
||||
return mExportVar_gNewPositionX;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gNewTouchDown = 5;
|
||||
private int mExportVar_gNewTouchDown;
|
||||
public void set_gNewTouchDown(int v) {
|
||||
mExportVar_gNewTouchDown = v;
|
||||
setVar(mExportVarIdx_gNewTouchDown, v);
|
||||
}
|
||||
|
||||
public int get_gNewTouchDown() {
|
||||
return mExportVar_gNewTouchDown;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gFlingVelocity = 6;
|
||||
private float mExportVar_gFlingVelocity;
|
||||
public void set_gFlingVelocity(float v) {
|
||||
mExportVar_gFlingVelocity = v;
|
||||
setVar(mExportVarIdx_gFlingVelocity, v);
|
||||
}
|
||||
|
||||
public float get_gFlingVelocity() {
|
||||
return mExportVar_gFlingVelocity;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gIconCount = 7;
|
||||
private int mExportVar_gIconCount;
|
||||
public void set_gIconCount(int v) {
|
||||
mExportVar_gIconCount = v;
|
||||
setVar(mExportVarIdx_gIconCount, v);
|
||||
}
|
||||
|
||||
public int get_gIconCount() {
|
||||
return mExportVar_gIconCount;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gSelectedIconIndex = 8;
|
||||
private int mExportVar_gSelectedIconIndex;
|
||||
public void set_gSelectedIconIndex(int v) {
|
||||
mExportVar_gSelectedIconIndex = v;
|
||||
setVar(mExportVarIdx_gSelectedIconIndex, v);
|
||||
}
|
||||
|
||||
public int get_gSelectedIconIndex() {
|
||||
return mExportVar_gSelectedIconIndex;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gSelectedIconTexture = 9;
|
||||
private Allocation mExportVar_gSelectedIconTexture;
|
||||
public void set_gSelectedIconTexture(Allocation v) {
|
||||
mExportVar_gSelectedIconTexture = v;
|
||||
setVar(mExportVarIdx_gSelectedIconTexture, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public Allocation get_gSelectedIconTexture() {
|
||||
return mExportVar_gSelectedIconTexture;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gZoomTarget = 10;
|
||||
private float mExportVar_gZoomTarget;
|
||||
public void set_gZoomTarget(float v) {
|
||||
mExportVar_gZoomTarget = v;
|
||||
setVar(mExportVarIdx_gZoomTarget, v);
|
||||
}
|
||||
|
||||
public float get_gZoomTarget() {
|
||||
return mExportVar_gZoomTarget;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gHomeButton = 11;
|
||||
private Allocation mExportVar_gHomeButton;
|
||||
public void set_gHomeButton(Allocation v) {
|
||||
mExportVar_gHomeButton = v;
|
||||
setVar(mExportVarIdx_gHomeButton, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public Allocation get_gHomeButton() {
|
||||
return mExportVar_gHomeButton;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gTargetPos = 12;
|
||||
private float mExportVar_gTargetPos;
|
||||
public void set_gTargetPos(float v) {
|
||||
mExportVar_gTargetPos = v;
|
||||
setVar(mExportVarIdx_gTargetPos, v);
|
||||
}
|
||||
|
||||
public float get_gTargetPos() {
|
||||
return mExportVar_gTargetPos;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gPFTexNearest = 13;
|
||||
private ProgramFragment mExportVar_gPFTexNearest;
|
||||
public void set_gPFTexNearest(ProgramFragment v) {
|
||||
mExportVar_gPFTexNearest = v;
|
||||
setVar(mExportVarIdx_gPFTexNearest, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public ProgramFragment get_gPFTexNearest() {
|
||||
return mExportVar_gPFTexNearest;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gPFTexMip = 14;
|
||||
private ProgramFragment mExportVar_gPFTexMip;
|
||||
public void set_gPFTexMip(ProgramFragment v) {
|
||||
mExportVar_gPFTexMip = v;
|
||||
setVar(mExportVarIdx_gPFTexMip, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public ProgramFragment get_gPFTexMip() {
|
||||
return mExportVar_gPFTexMip;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gPFTexMipAlpha = 15;
|
||||
private ProgramFragment mExportVar_gPFTexMipAlpha;
|
||||
public void set_gPFTexMipAlpha(ProgramFragment v) {
|
||||
mExportVar_gPFTexMipAlpha = v;
|
||||
setVar(mExportVarIdx_gPFTexMipAlpha, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public ProgramFragment get_gPFTexMipAlpha() {
|
||||
return mExportVar_gPFTexMipAlpha;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gPVCurve = 16;
|
||||
private ProgramVertex mExportVar_gPVCurve;
|
||||
public void set_gPVCurve(ProgramVertex v) {
|
||||
mExportVar_gPVCurve = v;
|
||||
setVar(mExportVarIdx_gPVCurve, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public ProgramVertex get_gPVCurve() {
|
||||
return mExportVar_gPVCurve;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gPS = 17;
|
||||
private ProgramStore mExportVar_gPS;
|
||||
public void set_gPS(ProgramStore v) {
|
||||
mExportVar_gPS = v;
|
||||
setVar(mExportVarIdx_gPS, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public ProgramStore get_gPS() {
|
||||
return mExportVar_gPS;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gSMCell = 18;
|
||||
private SimpleMesh mExportVar_gSMCell;
|
||||
public void set_gSMCell(SimpleMesh v) {
|
||||
mExportVar_gSMCell = v;
|
||||
setVar(mExportVarIdx_gSMCell, (v == null) ? 0 : v.getID());
|
||||
}
|
||||
|
||||
public SimpleMesh get_gSMCell() {
|
||||
return mExportVar_gSMCell;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gIconIDs = 19;
|
||||
private Allocation mExportVar_gIconIDs;
|
||||
public void bind_gIconIDs(Allocation v) {
|
||||
mExportVar_gIconIDs = v;
|
||||
if(v == null) bindAllocation(null, mExportVarIdx_gIconIDs);
|
||||
else bindAllocation(v, mExportVarIdx_gIconIDs);
|
||||
}
|
||||
|
||||
public Allocation get_gIconIDs() {
|
||||
return mExportVar_gIconIDs;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_gLabelIDs = 20;
|
||||
private Allocation mExportVar_gLabelIDs;
|
||||
public void bind_gLabelIDs(Allocation v) {
|
||||
mExportVar_gLabelIDs = v;
|
||||
if(v == null) bindAllocation(null, mExportVarIdx_gLabelIDs);
|
||||
else bindAllocation(v, mExportVarIdx_gLabelIDs);
|
||||
}
|
||||
|
||||
public Allocation get_gLabelIDs() {
|
||||
return mExportVar_gLabelIDs;
|
||||
}
|
||||
|
||||
private final static int mExportVarIdx_vpConstants = 21;
|
||||
private ScriptField_VpConsts mExportVar_vpConstants;
|
||||
public void bind_vpConstants(ScriptField_VpConsts v) {
|
||||
mExportVar_vpConstants = v;
|
||||
if(v == null) bindAllocation(null, mExportVarIdx_vpConstants);
|
||||
else bindAllocation(v.getAllocation(), mExportVarIdx_vpConstants);
|
||||
}
|
||||
|
||||
public ScriptField_VpConsts get_vpConstants() {
|
||||
return mExportVar_vpConstants;
|
||||
}
|
||||
|
||||
private final static int mExportFuncIdx_resetHWWar = 0;
|
||||
public void invoke_resetHWWar() {
|
||||
invoke(mExportFuncIdx_resetHWWar);
|
||||
}
|
||||
|
||||
private final static int mExportFuncIdx_move = 1;
|
||||
public void invoke_move() {
|
||||
invoke(mExportFuncIdx_move);
|
||||
}
|
||||
|
||||
private final static int mExportFuncIdx_moveTo = 2;
|
||||
public void invoke_moveTo() {
|
||||
invoke(mExportFuncIdx_moveTo);
|
||||
}
|
||||
|
||||
private final static int mExportFuncIdx_setZoom = 3;
|
||||
public void invoke_setZoom() {
|
||||
invoke(mExportFuncIdx_setZoom);
|
||||
}
|
||||
|
||||
private final static int mExportFuncIdx_fling = 4;
|
||||
public void invoke_fling() {
|
||||
invoke(mExportFuncIdx_fling);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptC_allapps
|
||||
extends android.renderscript.ScriptC
|
||||
{
|
||||
public ScriptC_allapps(RenderScript rs, Resources resources, int id, boolean isRoot) {
|
||||
super(rs, resources, id, isRoot);
|
||||
}
|
||||
|
||||
private int mField_COLUMNS_PER_PAGE_PORTRAIT;
|
||||
public void set_COLUMNS_PER_PAGE_PORTRAIT(int v) {
|
||||
mField_COLUMNS_PER_PAGE_PORTRAIT = v;
|
||||
setVar(0, v);
|
||||
}
|
||||
|
||||
private int mField_ROWS_PER_PAGE_PORTRAIT;
|
||||
public void set_ROWS_PER_PAGE_PORTRAIT(int v) {
|
||||
mField_ROWS_PER_PAGE_PORTRAIT = v;
|
||||
setVar(1, v);
|
||||
}
|
||||
|
||||
private int mField_COLUMNS_PER_PAGE_LANDSCAPE;
|
||||
public void set_COLUMNS_PER_PAGE_LANDSCAPE(int v) {
|
||||
mField_COLUMNS_PER_PAGE_LANDSCAPE = v;
|
||||
setVar(2, v);
|
||||
}
|
||||
|
||||
private int mField_ROWS_PER_PAGE_LANDSCAPE;
|
||||
public void set_ROWS_PER_PAGE_LANDSCAPE(int v) {
|
||||
mField_ROWS_PER_PAGE_LANDSCAPE = v;
|
||||
setVar(3, v);
|
||||
}
|
||||
|
||||
|
||||
private float mField_gNewPositionX;
|
||||
public void set_gNewPositionX(float v) {
|
||||
mField_gNewPositionX = v;
|
||||
setVar(4, v);
|
||||
}
|
||||
|
||||
private int mField_gNewTouchDown;
|
||||
public void set_gNewTouchDown(int v) {
|
||||
mField_gNewTouchDown = v;
|
||||
setVar(5, v);
|
||||
}
|
||||
|
||||
private float mField_gFlingVelocity;
|
||||
public void set_gFlingVelocity(float v) {
|
||||
mField_gFlingVelocity = v;
|
||||
setVar(6, v);
|
||||
}
|
||||
|
||||
private int mField_gIconCount;
|
||||
public void set_gIconCount(int v) {
|
||||
mField_gIconCount = v;
|
||||
setVar(7, v);
|
||||
}
|
||||
public int get_gIconCount() {
|
||||
return mField_gIconCount;
|
||||
}
|
||||
|
||||
private int mField_gSelectedIconIndex;
|
||||
public void set_gSelectedIconIndex(int v) {
|
||||
mField_gSelectedIconIndex = v;
|
||||
setVar(8, v);
|
||||
}
|
||||
public int get_gSelectedIconIndex() {
|
||||
return mField_gSelectedIconIndex;
|
||||
}
|
||||
|
||||
private Allocation mField_gSelectedIconTexture;
|
||||
public void set_gSelectedIconTexture(Allocation v) {
|
||||
mField_gSelectedIconTexture = v;
|
||||
setVar(9, v.getID());
|
||||
}
|
||||
|
||||
private float mField_gZoomTarget;
|
||||
public void set_gZoomTarget(float v) {
|
||||
mField_gZoomTarget = v;
|
||||
setVar(10, v);
|
||||
}
|
||||
|
||||
private Allocation mField_gHomeButton;
|
||||
public void set_gHomeButton(Allocation v) {
|
||||
mField_gHomeButton = v;
|
||||
setVar(11, v.getID());
|
||||
}
|
||||
|
||||
private float mField_gTargetPos;
|
||||
public void set_gTargetPos(float v) {
|
||||
mField_gTargetPos = v;
|
||||
setVar(12, v);
|
||||
}
|
||||
|
||||
|
||||
private ProgramFragment mField_gPFTexNearest;
|
||||
public void set_gPFTexNearest(ProgramFragment v) {
|
||||
mField_gPFTexNearest = v;
|
||||
setVar(13, v.getID());
|
||||
}
|
||||
|
||||
private ProgramFragment mField_gPFTexMip;
|
||||
public void set_gPFTexMip(ProgramFragment v) {
|
||||
mField_gPFTexMip = v;
|
||||
setVar(14, v.getID());
|
||||
}
|
||||
|
||||
private ProgramFragment mField_gPFTexMipAlpha;
|
||||
public void set_gPFTexMipAlpha(ProgramFragment v) {
|
||||
mField_gPFTexMipAlpha = v;
|
||||
setVar(15, v.getID());
|
||||
}
|
||||
|
||||
private ProgramVertex mField_gPVCurve;
|
||||
public void set_gPVCurve(ProgramVertex v) {
|
||||
mField_gPVCurve = v;
|
||||
setVar(16, v.getID());
|
||||
}
|
||||
|
||||
private ProgramStore mField_gPS;
|
||||
public void set_gPS(ProgramStore v) {
|
||||
mField_gPS = v;
|
||||
setVar(17, v.getID());
|
||||
}
|
||||
|
||||
private SimpleMesh mField_gSMCell;
|
||||
public void set_gSMCell(SimpleMesh v) {
|
||||
mField_gSMCell = v;
|
||||
setVar(18, v.getID());
|
||||
}
|
||||
|
||||
|
||||
// binds
|
||||
private Allocation mField_gIconIDs;
|
||||
public void bind_gIconIDs(Allocation f) {
|
||||
mField_gIconIDs = f;
|
||||
bindAllocation(f, 19);
|
||||
}
|
||||
public Allocation get_gIconIDs() {
|
||||
return mField_gIconIDs;
|
||||
}
|
||||
|
||||
private Allocation mField_gLabelIDs;
|
||||
public void bind_gLabelIDs(Allocation f) {
|
||||
mField_gLabelIDs = f;
|
||||
bindAllocation(f, 20);
|
||||
}
|
||||
public Allocation get_gLabelIDs() {
|
||||
return mField_gLabelIDs;
|
||||
}
|
||||
|
||||
private ScriptField_VpConsts mField_vpConstants;
|
||||
public void bind_vpConstants(ScriptField_VpConsts f) {
|
||||
android.util.Log.e("rs", "bind_vpConstants " + f);
|
||||
mField_vpConstants = f;
|
||||
if (f == null) {
|
||||
bindAllocation(null, 21);
|
||||
} else {
|
||||
bindAllocation(f.getAllocation(), 21);
|
||||
}
|
||||
}
|
||||
public ScriptField_VpConsts get_vpConstants() {
|
||||
return mField_vpConstants;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#pragma rs export_func(resetHWWar, move, moveTo, setZoom, fling)
|
||||
|
||||
public void invokable_Move() {
|
||||
//android.util.Log.e("rs", "invokable_Move");
|
||||
invoke(7); // verified
|
||||
}
|
||||
public void invokable_MoveTo() {
|
||||
//android.util.Log.e("rs", "invokable_MoveTo");
|
||||
invoke(8); // verified
|
||||
}
|
||||
public void invokable_Fling() {
|
||||
//android.util.Log.e("rs", "invokable_Fling");
|
||||
invoke(2);
|
||||
}
|
||||
//public void invokable_ResetWAR() {
|
||||
//android.util.Log.e("rs", "invokable_WAR");
|
||||
//invoke(9); // verified
|
||||
//}
|
||||
public void invokable_SetZoom() {
|
||||
//android.util.Log.e("rs", "invokable_SetZoom");
|
||||
invoke(12);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,34 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.launcher2;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.renderscript.*;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
public class ScriptField_VpConsts
|
||||
extends android.renderscript.Script.FieldBase
|
||||
{
|
||||
|
||||
public class ScriptField_VpConsts extends android.renderscript.Script.FieldBase {
|
||||
static public class Item {
|
||||
public static final int sizeof = 48;
|
||||
|
||||
Float4 Position;
|
||||
Float4 ScaleOffset;
|
||||
Float2 BendPos;
|
||||
Float2 ImgSize;
|
||||
|
||||
Item() {
|
||||
Position = new Float4();
|
||||
ScaleOffset = new Float4();
|
||||
@@ -17,32 +36,27 @@ public class ScriptField_VpConsts
|
||||
ImgSize = new Float2();
|
||||
}
|
||||
|
||||
public static final int sizeof = (12*4);
|
||||
|
||||
Float4 Position;
|
||||
Float4 ScaleOffset;
|
||||
Float2 BendPos;
|
||||
Float2 ImgSize;
|
||||
}
|
||||
|
||||
private Item mItemArray[];
|
||||
|
||||
|
||||
public ScriptField_VpConsts(RenderScript rs, int count) {
|
||||
// Allocate a pack/unpack buffer
|
||||
mIOBuffer = new FieldPacker(Item.sizeof * count);
|
||||
mItemArray = new Item[count];
|
||||
|
||||
Element.Builder eb = new Element.Builder(rs);
|
||||
eb.add(Element.F32_4(rs), "Position");
|
||||
eb.add(Element.F32_4(rs), "ScaleOffset");
|
||||
eb.add(Element.F32_2(rs), "BendPos");
|
||||
eb.add(Element.F32_2(rs), "ImgSize");
|
||||
mElement = eb.create();
|
||||
private FieldPacker mIOBuffer;
|
||||
public ScriptField_VpConsts(RenderScript rs, int count) {
|
||||
mItemArray = null;
|
||||
mIOBuffer = null;
|
||||
{
|
||||
Element.Builder eb = new Element.Builder(rs);
|
||||
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 4), "Position");
|
||||
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 4), "ScaleOffset");
|
||||
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "BendPos");
|
||||
eb.add(Element.createVector(rs, Element.DataType.FLOAT_32, 2), "ImgSize");
|
||||
mElement = eb.create();
|
||||
}
|
||||
|
||||
init(rs, count);
|
||||
}
|
||||
|
||||
private void copyToArray(Item i, int index) {
|
||||
if (mIOBuffer == null) mIOBuffer = new FieldPacker(Item.sizeof * mType.getX() /* count */);
|
||||
mIOBuffer.reset(index * Item.sizeof);
|
||||
mIOBuffer.addF32(i.Position);
|
||||
mIOBuffer.addF32(i.ScaleOffset);
|
||||
@@ -51,23 +65,19 @@ public class ScriptField_VpConsts
|
||||
}
|
||||
|
||||
public void set(Item i, int index, boolean copyNow) {
|
||||
if (mItemArray == null) mItemArray = new Item[mType.getX() /* count */];
|
||||
mItemArray[index] = i;
|
||||
if (copyNow) {
|
||||
if (copyNow) {
|
||||
copyToArray(i, index);
|
||||
mAllocation.subData1D(index * Item.sizeof, Item.sizeof, mIOBuffer.getData());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void copyAll() {
|
||||
for (int ct=0; ct < mItemArray.length; ct++) {
|
||||
copyToArray(mItemArray[ct], ct);
|
||||
}
|
||||
for (int ct=0; ct < mItemArray.length; ct++) copyToArray(mItemArray[ct], ct);
|
||||
mAllocation.data(mIOBuffer.getData());
|
||||
}
|
||||
|
||||
|
||||
private FieldPacker mIOBuffer;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user