diff options
author | Jason Sams <rjsams@android.com> | 2010-12-20 14:28:52 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-12-20 14:28:52 -0800 |
commit | e688213f6f2b2e10eb7a5c70b43fe0c3ad45db81 (patch) | |
tree | 384a415a84710d90953aefbbb7408444cdf5ea2c /graphics | |
parent | b89e142949127502c5ecd3f221d5ac0d30ac9a54 (diff) | |
parent | d19524047fa2d12ecd45ebcf69543836e1b45579 (diff) | |
download | frameworks_base-e688213f6f2b2e10eb7a5c70b43fe0c3ad45db81.zip frameworks_base-e688213f6f2b2e10eb7a5c70b43fe0c3ad45db81.tar.gz frameworks_base-e688213f6f2b2e10eb7a5c70b43fe0c3ad45db81.tar.bz2 |
Merge "Clean up Allocation buffer object api."
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 19 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Mesh.java | 28 |
2 files changed, 20 insertions, 27 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 3ff483d..0dbc204 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -102,12 +102,6 @@ public class Allocation extends BaseObj { mRS.nAllocationSyncAll(getID(), srcLocation); } - public void uploadToBufferObject() { - mRS.validate(); - mRS.nAllocationUploadToBufferObject(getID()); - } - - public void copyFrom(BaseObj[] d) { mRS.validate(); if (d.length != mType.getCount()) { @@ -516,19 +510,6 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_TEXTURE); } -/* - static public Allocation createFromBitmapResource(RenderScript rs, - Resources res, - int id, - Element dstFmt, - boolean genMips) { - MipmapControl mc = MipmapControl.MIPMAP_NONE; - if (genMips) { - mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; - } - return createFromBitmapResource(rs, res, id, mc, USAGE_GRAPHICS_TEXTURE); - } -*/ static public Allocation createFromString(RenderScript rs, String str, int usage) { diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index b103af4..950a91a 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -93,20 +93,23 @@ public class Mesh extends BaseObj { public static class Builder { RenderScript mRS; + int mUsage; class Entry { Type t; Element e; int size; Primitive prim; + int usage; } int mVertexTypeCount; Entry[] mVertexTypes; Vector mIndexTypes; - public Builder(RenderScript rs) { + public Builder(RenderScript rs, int usage) { mRS = rs; + mUsage = usage; mVertexTypeCount = 0; mVertexTypes = new Entry[16]; mIndexTypes = new Vector(); @@ -190,10 +193,10 @@ public class Mesh extends BaseObj { Allocation alloc = null; Entry entry = (Entry)b.mIndexTypes.elementAt(ct); if (entry.t != null) { - alloc = Allocation.createTyped(rs, entry.t); + alloc = Allocation.createTyped(rs, entry.t, b.mUsage); } else if(entry.e != null) { - alloc = Allocation.createSized(rs, entry.e, entry.size); + alloc = Allocation.createSized(rs, entry.e, entry.size, b.mUsage); } int allocID = (alloc == null) ? 0 : alloc.getID(); rs.nMeshBindIndex(id, allocID, entry.prim.mID, ct); @@ -205,9 +208,9 @@ public class Mesh extends BaseObj { Allocation alloc = null; Entry entry = b.mVertexTypes[ct]; if (entry.t != null) { - alloc = Allocation.createTyped(rs, entry.t); + alloc = Allocation.createTyped(rs, entry.t, b.mUsage); } else if(entry.e != null) { - alloc = Allocation.createSized(rs, entry.e, entry.size); + alloc = Allocation.createSized(rs, entry.e, entry.size, b.mUsage); } rs.nMeshBindVertex(id, alloc.getID(), ct); newMesh.mVertexBuffers[ct] = alloc; @@ -460,7 +463,12 @@ public class Mesh extends BaseObj { } mElement = b.create(); - Builder smb = new Builder(mRS); + int usage = Allocation.USAGE_SCRIPT; + if (uploadToBufferObject) { + usage |= Allocation.USAGE_GRAPHICS_VERTEX; + } + + Builder smb = new Builder(mRS, usage); smb.addVertexType(mElement, mVtxCount / floatCount); smb.addIndexType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE); @@ -468,11 +476,15 @@ public class Mesh extends BaseObj { sm.getVertexAllocation(0).copyFrom(mVtxData); if(uploadToBufferObject) { - sm.getVertexAllocation(0).uploadToBufferObject(); + if (uploadToBufferObject) { + sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT); + } } sm.getIndexAllocation(0).copyFrom(mIndexData); - sm.getIndexAllocation(0).uploadToBufferObject(); + if (uploadToBufferObject) { + sm.getIndexAllocation(0).syncAll(Allocation.USAGE_SCRIPT); + } return sm; } |