diff options
author | Jason Sams <rjsams@android.com> | 2010-12-13 15:32:35 -0800 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2010-12-13 15:32:35 -0800 |
commit | d4b23b54445b13dacaafad97d100999abb36ea6f (patch) | |
tree | 265a246ae22c5b726690c422bc5c5518e6d445a0 | |
parent | 666a5ed98142867bcd6658c97210b775c828dae5 (diff) | |
download | frameworks_base-d4b23b54445b13dacaafad97d100999abb36ea6f.zip frameworks_base-d4b23b54445b13dacaafad97d100999abb36ea6f.tar.gz frameworks_base-d4b23b54445b13dacaafad97d100999abb36ea6f.tar.bz2 |
More API updates.
Change-Id: I754dc645ac08fa25019eed8fd8b7b3c47f178ff2
-rw-r--r-- | graphics/java/android/renderscript/Allocation.java | 16 | ||||
-rw-r--r-- | graphics/java/android/renderscript/Mesh.java | 8 | ||||
-rw-r--r-- | graphics/java/android/renderscript/RenderScript.java | 6 | ||||
-rw-r--r-- | graphics/jni/android_renderscript_RenderScript.cpp | 10 | ||||
-rw-r--r-- | libs/rs/RenderScript.h | 14 | ||||
-rw-r--r-- | libs/rs/java/Balls/src/com/android/balls/BallsRS.java | 27 | ||||
-rw-r--r-- | libs/rs/java/Balls/src/com/android/balls/balls.rs | 22 | ||||
-rw-r--r-- | libs/rs/rs.spec | 8 | ||||
-rw-r--r-- | libs/rs/rsAllocation.cpp | 133 | ||||
-rw-r--r-- | libs/rs/rsAllocation.h | 12 |
10 files changed, 63 insertions, 193 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index b937721..30475bd 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -378,12 +378,12 @@ public class Allocation extends BaseObj { mBitmapOptions.inScaled = false; } - static public Allocation createTyped(RenderScript rs, Type type, int usage) { + static public Allocation createTyped(RenderScript rs, Type type, MipmapControl mc, int usage) { rs.validate(); if (type.getID() == 0) { throw new RSInvalidStateException("Bad Type"); } - int id = rs.nAllocationCreateTyped(type.getID(), usage); + int id = rs.nAllocationCreateTyped(type.getID(), mc.mID, usage); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); } @@ -391,7 +391,7 @@ public class Allocation extends BaseObj { } static public Allocation createTyped(RenderScript rs, Type type) { - return createTyped(rs, type, USAGE_ALL); + return createTyped(rs, type, MipmapControl.MIPMAP_NONE, USAGE_SCRIPT); } static public Allocation createSized(RenderScript rs, Element e, @@ -401,7 +401,7 @@ public class Allocation extends BaseObj { b.setX(count); Type t = b.create(); - int id = rs.nAllocationCreateTyped(t.getID(), usage); + int id = rs.nAllocationCreateTyped(t.getID(), MipmapControl.MIPMAP_NONE.mID, usage); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); } @@ -409,7 +409,7 @@ public class Allocation extends BaseObj { } static public Allocation createSized(RenderScript rs, Element e, int count) { - return createSized(rs, e, count, USAGE_ALL); + return createSized(rs, e, count, USAGE_SCRIPT); } static private Element elementFromBitmap(RenderScript rs, Bitmap b) { @@ -458,7 +458,7 @@ public class Allocation extends BaseObj { if (genMips) { mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } - return createFromBitmap(rs, b, mc, USAGE_ALL); + return createFromBitmap(rs, b, mc, USAGE_GRAPHICS_TEXTURE); } static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b, @@ -507,7 +507,7 @@ public class Allocation extends BaseObj { if (genMips) { mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } - return createCubemapFromBitmap(rs, b, mc, layout, USAGE_ALL); + return createCubemapFromBitmap(rs, b, mc, layout, USAGE_GRAPHICS_TEXTURE); } static public Allocation createFromBitmapResource(RenderScript rs, @@ -532,7 +532,7 @@ public class Allocation extends BaseObj { if (genMips) { mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } - return createFromBitmapResource(rs, res, id, mc, USAGE_ALL); + return createFromBitmapResource(rs, res, id, mc, USAGE_GRAPHICS_TEXTURE); } static public Allocation createFromString(RenderScript rs, diff --git a/graphics/java/android/renderscript/Mesh.java b/graphics/java/android/renderscript/Mesh.java index 44faa32..b103af4 100644 --- a/graphics/java/android/renderscript/Mesh.java +++ b/graphics/java/android/renderscript/Mesh.java @@ -77,18 +77,14 @@ public class Mesh extends BaseObj { for(int i = 0; i < vtxCount; i ++) { if(vtxIDs[i] != 0) { - mVertexBuffers[i] = new Allocation(vtxIDs[i], mRS, null, - Allocation.USAGE_GRAPHICS_VERTEX | - Allocation.USAGE_SCRIPT); + mVertexBuffers[i] = new Allocation(vtxIDs[i], mRS, null, Allocation.USAGE_SCRIPT); mVertexBuffers[i].updateFromNative(); } } for(int i = 0; i < idxCount; i ++) { if(idxIDs[i] != 0) { - mIndexBuffers[i] = new Allocation(idxIDs[i], mRS, null, - Allocation.USAGE_GRAPHICS_VERTEX | - Allocation.USAGE_SCRIPT); + mIndexBuffers[i] = new Allocation(idxIDs[i], mRS, null, Allocation.USAGE_SCRIPT); mIndexBuffers[i].updateFromNative(); } mPrimitives[i] = Primitive.values()[primitives[i]]; diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index 3fa9965..c6dcff5 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -191,9 +191,9 @@ public class RenderScript { rsnTypeGetNativeData(mContext, id, typeData); } - native int rsnAllocationCreateTyped(int con, int type, int usage); - synchronized int nAllocationCreateTyped(int type, int usage) { - return rsnAllocationCreateTyped(mContext, type, usage); + native int rsnAllocationCreateTyped(int con, int type, int mip, int usage); + synchronized int nAllocationCreateTyped(int type, int mip, int usage) { + return rsnAllocationCreateTyped(mContext, type, mip, usage); } native int rsnAllocationCreateFromBitmap(int con, int type, int mip, Bitmap bmp, int usage); synchronized int nAllocationCreateFromBitmap(int type, int mip, Bitmap bmp, int usage) { diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp index 8344842..04a7b41 100644 --- a/graphics/jni/android_renderscript_RenderScript.cpp +++ b/graphics/jni/android_renderscript_RenderScript.cpp @@ -377,8 +377,8 @@ nTypeGetNativeData(JNIEnv *_env, jobject _this, RsContext con, jint id, jintArra static jint nAllocationCreateTyped(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mips, jint usage) { - LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i)", con, (RsElement)type, mip, usage); - return (jint) rsaAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapGenerationControl)mips, (uint32_t)usage); + LOG_API("nAllocationCreateTyped, con(%p), type(%p), mip(%i), usage(%i)", con, (RsElement)type, mips, usage); + return (jint) rsaAllocationCreateTyped(con, (RsType)type, (RsAllocationMipmapControl)mips, (uint32_t)usage); } static void @@ -411,7 +411,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint typ bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); - jint id = (jint)rsaAllocationCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapGenerationControl)mip, ptr, usage); + jint id = (jint)rsaAllocationCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapControl)mip, ptr, usage); bitmap.unlockPixels(); return id; } @@ -425,7 +425,7 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); - jint id = (jint)rsaAllocationCubeCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapGenerationControl)mip, ptr, usage); + jint id = (jint)rsaAllocationCubeCreateFromBitmap(con, (RsType)type, (RsAllocationMipmapControl)mip, ptr, usage); bitmap.unlockPixels(); return id; } @@ -1245,7 +1245,7 @@ static JNINativeMethod methods[] = { {"rsnTypeCreate", "(IIIIIZZ)I", (void*)nTypeCreate }, {"rsnTypeGetNativeData", "(II[I)V", (void*)nTypeGetNativeData }, -{"rsnAllocationCreateTyped", "(III)I", (void*)nAllocationCreateTyped }, +{"rsnAllocationCreateTyped", "(IIII)I", (void*)nAllocationCreateTyped }, {"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, {"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, diff --git a/libs/rs/RenderScript.h b/libs/rs/RenderScript.h index 9e30799..43d4291 100644 --- a/libs/rs/RenderScript.h +++ b/libs/rs/RenderScript.h @@ -105,10 +105,10 @@ enum RsAllocationUsageType { RS_ALLOCATION_USAGE_ALL = 0x000F }; -enum RsAllocationMipmapGenerationControl { - RS_MIPMAP_NONE = 0, - RS_MIPMAP_FULL = 1, - RS_MIPMAP_TEXTURE_ONLY = 2 +enum RsAllocationMipmapControl { + RS_ALLOCATION_MIPMAP_NONE = 0, + RS_ALLOCATION_MIPMAP_FULL = 1, + RS_ALLOCATION_MIPMAP_ON_SYNC_TO_TEXTURE = 2 }; enum RsDataType { @@ -345,13 +345,13 @@ void rsaElementGetSubElements(RsContext, RsElement, uint32_t *ids, const char ** RsType rsaTypeCreate(RsContext, RsElement, uint32_t dimX, uint32_t dimY, uint32_t dimZ, bool mips, bool faces); RsAllocation rsaAllocationCreateTyped(RsContext rsc, RsType vtype, - RsAllocationMipmapGenerationControl mips, + RsAllocationMipmapControl mips, uint32_t usages); RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, - RsAllocationMipmapGenerationControl mips, + RsAllocationMipmapControl mips, const void *data, uint32_t usages); RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, - RsAllocationMipmapGenerationControl mips, + RsAllocationMipmapControl mips, const void *data, uint32_t usages); #ifndef NO_RS_FUNCS diff --git a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java index 4338f33..0a06394 100644 --- a/libs/rs/java/Balls/src/com/android/balls/BallsRS.java +++ b/libs/rs/java/Balls/src/com/android/balls/BallsRS.java @@ -34,11 +34,12 @@ public class BallsRS { private ProgramFragment mPFPoints; private ProgramVertex mPV; private ScriptField_Point mPoints; - private ScriptField_Point mArcs; private ScriptField_VpConsts mVpConsts; void updateProjectionMatrices() { - mVpConsts = new ScriptField_VpConsts(mRS, 1); + mVpConsts = new ScriptField_VpConsts(mRS, 1, + Allocation.USAGE_SCRIPT | + Allocation.USAGE_GRAPHICS_CONSTANTS); ScriptField_VpConsts.Item i = new ScriptField_VpConsts.Item(); Matrix4f mvp = new Matrix4f(); mvp.loadOrtho(0, mRS.getWidth(), mRS.getHeight(), 0, -1, 1); @@ -67,9 +68,10 @@ public class BallsRS { } private Allocation loadTexture(int id) { - final Allocation allocation = Allocation.createFromBitmapResource(mRS, mRes, - id, Element.RGB_565(mRS), false); - allocation.uploadToTexture(0); + final Allocation allocation = + Allocation.createFromBitmapResource(mRS, mRes, + id, Allocation.MipmapControl.MIPMAP_NONE, + Allocation.USAGE_GRAPHICS_TEXTURE); return allocation; } @@ -88,31 +90,24 @@ public class BallsRS { pfb.setVaryingColor(true); mPFLines = pfb.create(); + android.util.Log.e("rs", "Load texture"); mPFPoints.bindTexture(loadTexture(R.drawable.flares), 0); - mPoints = new ScriptField_Point(mRS, PART_COUNT); - mArcs = new ScriptField_Point(mRS, PART_COUNT * 2); + mPoints = new ScriptField_Point(mRS, PART_COUNT, Allocation.USAGE_SCRIPT); Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS); smb.addVertexAllocation(mPoints.getAllocation()); smb.addIndexType(Primitive.POINT); Mesh smP = smb.create(); - smb = new Mesh.AllocationBuilder(mRS); - smb.addVertexAllocation(mArcs.getAllocation()); - smb.addIndexType(Primitive.LINE); - Mesh smA = smb.create(); - mPhysicsScript = new ScriptC_ball_physics(mRS, mRes, R.raw.ball_physics); mScript = new ScriptC_balls(mRS, mRes, R.raw.balls); mScript.set_partMesh(smP); - mScript.set_arcMesh(smA); mScript.set_physics_script(mPhysicsScript); mScript.bind_point(mPoints); - mScript.bind_arc(mArcs); - mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT)); - mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT)); + mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); + mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); mScript.set_gPFLines(mPFLines); mScript.set_gPFPoints(mPFPoints); diff --git a/libs/rs/java/Balls/src/com/android/balls/balls.rs b/libs/rs/java/Balls/src/com/android/balls/balls.rs index c41ed0f..fed9963 100644 --- a/libs/rs/java/Balls/src/com/android/balls/balls.rs +++ b/libs/rs/java/Balls/src/com/android/balls/balls.rs @@ -10,18 +10,14 @@ rs_program_fragment gPFPoints; rs_program_fragment gPFLines; rs_mesh partMesh; -rs_mesh arcMesh; typedef struct __attribute__((packed, aligned(4))) Point { float2 position; - //uchar4 color; float size; } Point_t; Point_t *point; -Point_t *arc; typedef struct VpConsts { - //rs_matrix4x4 Proj; rs_matrix4x4 MVP; } VpConsts_t; VpConsts_t *vpConstants; @@ -42,8 +38,6 @@ void initParts(int w, int h) balls1[ct].position.y = rsRand(0.f, (float)h); balls1[ct].delta.x = 0.f; balls1[ct].delta.y = 0.f; - //balls1[ct].arcID = -1; - //balls1[ct].color = 0.f; balls1[ct].size = 1.f; float r = rsRand(100.f); @@ -76,28 +70,12 @@ int root() { rsForEach(physics_script, bc.ain, bc.aout, &bc); - uint32_t arcIdx = 0; for (uint32_t ct=0; ct < bc.dimX; ct++) { point[ct].position = bout[ct].position; - ///point[ct].color = 0xff;//rsPackColorTo8888(bout[ct].color); point[ct].size = 6.f /*+ bout[ct].color.g * 6.f*/ * bout[ct].size; -/* - if (bout[ct].arcID >= 0) { - arc[arcIdx].position = bout[ct].position; - arc[arcIdx].color.r = min(bout[ct].arcStr, 1.f) * 0xff; - arc[arcIdx].color.g = 0; - arc[arcIdx].color.b = 0; - arc[arcIdx].color.a = 0xff; - arc[arcIdx+1].position = bout[bout[ct].arcID].position; - arc[arcIdx+1].color = arc[arcIdx].color; - arcIdx += 2; - } - */ } frame++; - //rsgBindProgramFragment(gPFLines); - //rsgDrawMesh(arcMesh, 0, 0, arcIdx); rsgBindProgramFragment(gPFPoints); rsgDrawMesh(partMesh); rsClearObject(&bc.ain); diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec index 14094c4..9f817b6 100644 --- a/libs/rs/rs.spec +++ b/libs/rs/rs.spec @@ -89,14 +89,6 @@ AllocationCopyToBitmap { param size_t dataLen } -AllocationCreateBitmapRef { - param RsType type - param RsAsyncVoidPtr bmpPtr - param RsAsyncVoidPtr callbackData - param RsBitmapCallback_t callback - ret RsAllocation - } - AllocationUploadToTexture { param RsAllocation alloc param bool genMipMaps diff --git a/libs/rs/rsAllocation.cpp b/libs/rs/rsAllocation.cpp index 10a5caf..aab789a 100644 --- a/libs/rs/rsAllocation.cpp +++ b/libs/rs/rsAllocation.cpp @@ -45,17 +45,6 @@ Allocation::Allocation(Context *rsc, const Type *type, uint32_t usages) : Object } } -Allocation::Allocation(Context *rsc, const Type *type, void *bmp, - void *callbackData, RsBitmapCallback_t callback) - : ObjectBase(rsc) { - init(rsc, type); - - mUsageFlags = RS_ALLOCATION_USAGE_SCRIPT | RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; - - mPtr = bmp; - mUserBitmapCallback = callback; - mUserBitmapCallbackData = callbackData; -} void Allocation::init(Context *rsc, const Type *type) { mPtr = NULL; @@ -67,10 +56,10 @@ void Allocation::init(Context *rsc, const Type *type) { mReadWriteRatio = 0; mUpdateSize = 0; + mUsageFlags = 0; + mMipmapControl = RS_ALLOCATION_MIPMAP_NONE; - mIsTexture = false; mTextureID = 0; - mIsVertexBuffer = false; mBufferID = 0; mUploadDefered = false; @@ -121,21 +110,21 @@ bool Allocation::fixAllocation() { void Allocation::deferedUploadToTexture(const Context *rsc, bool genMipmap, uint32_t lodOffset) { rsAssert(lodOffset < mType->getLODCount()); - mIsTexture = true; + mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; mTextureLOD = lodOffset; mUploadDefered = true; mTextureGenMipmap = !mType->getDimLOD() && genMipmap; } uint32_t Allocation::getGLTarget() const { - if (mIsTexture) { + if (getIsTexture()) { if (mType->getDimFaces()) { return GL_TEXTURE_CUBE_MAP; } else { return GL_TEXTURE_2D; } } - if (mIsVertexBuffer) { + if (getIsBufferObject()) { return GL_ARRAY_BUFFER; } return 0; @@ -144,10 +133,10 @@ uint32_t Allocation::getGLTarget() const { void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) { rsAssert(src == RS_ALLOCATION_USAGE_SCRIPT); - if (mIsTexture) { + if (getIsTexture()) { uploadToTexture(rsc); } - if (mIsVertexBuffer) { + if (getIsBufferObject()) { uploadToBufferObject(rsc); } @@ -156,7 +145,7 @@ void Allocation::syncAll(Context *rsc, RsAllocationUsageType src) { void Allocation::uploadToTexture(const Context *rsc) { - mIsTexture = true; + mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE; GLenum type = mType->getElement()->getComponent().getGLType(); GLenum format = mType->getElement()->getComponent().getGLFormat(); @@ -257,7 +246,7 @@ void Allocation::uploadCubeTexture(bool isFirstUpload) { } void Allocation::deferedUploadToBufferObject(const Context *rsc) { - mIsVertexBuffer = true; + mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX; mUploadDefered = true; } @@ -265,7 +254,7 @@ void Allocation::uploadToBufferObject(const Context *rsc) { rsAssert(!mType->getDimY()); rsAssert(!mType->getDimZ()); - mIsVertexBuffer = true; + mUsageFlags |= RS_ALLOCATION_USAGE_GRAPHICS_VERTEX; if (!mBufferID) { glGenBuffers(1, &mBufferID); @@ -470,8 +459,8 @@ void Allocation::dumpLOGV(const char *prefix) const { LOGV("%s allocation ptr=%p mCpuWrite=%i, mCpuRead=%i, mGpuWrite=%i, mGpuRead=%i", prefix, mPtr, mCpuWrite, mCpuRead, mGpuWrite, mGpuRead); - LOGV("%s allocation mIsTexture=%i mTextureID=%i, mIsVertexBuffer=%i, mBufferID=%i", - prefix, mIsTexture, mTextureID, mIsVertexBuffer, mBufferID); + LOGV("%s allocation mUsageFlags=0x04%x, mMipmapControl=0x%04x, mTextureID=%i, mBufferID=%i", + prefix, mUsageFlags, mMipmapControl, mTextureID, mBufferID); } void Allocation::serialize(OStream *stream) const { @@ -517,7 +506,7 @@ Allocation *Allocation::createFromStream(Context *rsc, IStream *stream) { return NULL; } - Allocation *alloc = new Allocation(rsc, type, RS_ALLOCATION_USAGE_ALL); + Allocation *alloc = new Allocation(rsc, type, RS_ALLOCATION_USAGE_SCRIPT); alloc->setName(name.string(), name.size()); // Read in all of our allocation data @@ -672,81 +661,6 @@ static void mip(const Adapter2D &out, const Adapter2D &in) { } } -typedef void (*ElementConverter_t)(void *dst, const void *src, uint32_t count); - -static void elementConverter_cpy_16(void *dst, const void *src, uint32_t count) { - memcpy(dst, src, count * 2); -} -static void elementConverter_cpy_8(void *dst, const void *src, uint32_t count) { - memcpy(dst, src, count); -} -static void elementConverter_cpy_32(void *dst, const void *src, uint32_t count) { - memcpy(dst, src, count * 4); -} - -static void elementConverter_888_to_565(void *dst, const void *src, uint32_t count) { - uint16_t *d = static_cast<uint16_t *>(dst); - const uint8_t *s = static_cast<const uint8_t *>(src); - - while (count--) { - *d = rs888to565(s[0], s[1], s[2]); - d++; - s+= 3; - } -} - -static void elementConverter_8888_to_565(void *dst, const void *src, uint32_t count) { - uint16_t *d = static_cast<uint16_t *>(dst); - const uint8_t *s = static_cast<const uint8_t *>(src); - - while (count--) { - *d = rs888to565(s[0], s[1], s[2]); - d++; - s+= 4; - } -} - -static ElementConverter_t pickConverter(const Element *dst, const Element *src) { - GLenum srcGLType = src->getComponent().getGLType(); - GLenum srcGLFmt = src->getComponent().getGLFormat(); - GLenum dstGLType = dst->getComponent().getGLType(); - GLenum dstGLFmt = dst->getComponent().getGLFormat(); - - if (srcGLFmt == dstGLFmt && srcGLType == dstGLType) { - switch (dst->getSizeBytes()) { - case 4: - return elementConverter_cpy_32; - case 2: - return elementConverter_cpy_16; - case 1: - return elementConverter_cpy_8; - } - } - - if (srcGLType == GL_UNSIGNED_BYTE && - srcGLFmt == GL_RGB && - dstGLType == GL_UNSIGNED_SHORT_5_6_5 && - dstGLFmt == GL_RGB) { - - return elementConverter_888_to_565; - } - - if (srcGLType == GL_UNSIGNED_BYTE && - srcGLFmt == GL_RGBA && - dstGLType == GL_UNSIGNED_SHORT_5_6_5 && - dstGLFmt == GL_RGB) { - - return elementConverter_8888_to_565; - } - - LOGE("pickConverter, unsuported combo, src %p, dst %p", src, dst); - LOGE("pickConverter, srcGLType = %x, srcGLFmt = %x", srcGLType, srcGLFmt); - LOGE("pickConverter, dstGLType = %x, dstGLFmt = %x", dstGLType, dstGLFmt); - src->dumpLOGV("SRC "); - dst->dumpLOGV("DST "); - return 0; -} - #ifndef ANDROID_RS_BUILD_FOR_HOST void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType src) { @@ -754,15 +668,6 @@ void rsi_AllocationSyncAll(Context *rsc, RsAllocation va, RsAllocationUsageType a->syncAll(rsc, src); } -RsAllocation rsi_AllocationCreateBitmapRef(Context *rsc, RsType vtype, - void *bmp, void *callbackData, - RsBitmapCallback_t callback) { - const Type * type = static_cast<const Type *>(vtype); - Allocation * alloc = new Allocation(rsc, type, bmp, callbackData, callback); - alloc->incUserRef(); - return alloc; -} - void rsi_AllocationCopyFromBitmap(Context *rsc, RsAllocation va, const void *data, size_t dataLen) { Allocation *texAlloc = static_cast<Allocation *>(va); const Type * t = texAlloc->getType(); @@ -854,7 +759,7 @@ const void * rsaAllocationGetType(RsContext con, RsAllocation va) { } RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype, - RsAllocationMipmapGenerationControl mips, + RsAllocationMipmapControl mips, uint32_t usages) { Context *rsc = static_cast<Context *>(con); Allocation * alloc = new Allocation(rsc, static_cast<Type *>(vtype), usages); @@ -864,7 +769,7 @@ RsAllocation rsaAllocationCreateTyped(RsContext con, RsType vtype, RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, - RsAllocationMipmapGenerationControl mips, + RsAllocationMipmapControl mips, const void *data, uint32_t usages) { Context *rsc = static_cast<Context *>(con); Type *t = static_cast<Type *>(vtype); @@ -877,7 +782,7 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, } memcpy(texAlloc->getPtr(), data, t->getDimX() * t->getDimY() * t->getElementSizeBytes()); - if (mips == RS_MIPMAP_FULL) { + if (mips == RS_ALLOCATION_MIPMAP_FULL) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); for (uint32_t lod=0; lod < (texAlloc->getType()->getLODCount() -1); lod++) { @@ -887,11 +792,12 @@ RsAllocation rsaAllocationCreateFromBitmap(RsContext con, RsType vtype, } } + texAlloc->deferedUploadToTexture(rsc, false, 0); return texAlloc; } RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, - RsAllocationMipmapGenerationControl mips, + RsAllocationMipmapControl mips, const void *data, uint32_t usages) { Context *rsc = static_cast<Context *>(con); Type *t = static_cast<Type *>(vtype); @@ -917,7 +823,7 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, // Move the data pointer to the next cube face sourcePtr += cpySize; - if (mips == RS_MIPMAP_FULL) { + if (mips == RS_ALLOCATION_MIPMAP_FULL) { Adapter2D adapt(rsc, texAlloc); Adapter2D adapt2(rsc, texAlloc); adapt.setFace(face); @@ -930,5 +836,6 @@ RsAllocation rsaAllocationCubeCreateFromBitmap(RsContext con, RsType vtype, } } + texAlloc->deferedUploadToTexture(rsc, false, 0); return texAlloc; } diff --git a/libs/rs/rsAllocation.h b/libs/rs/rsAllocation.h index e63c7ab..d1dcb73 100644 --- a/libs/rs/rsAllocation.h +++ b/libs/rs/rsAllocation.h @@ -30,7 +30,6 @@ class Allocation : public ObjectBase { public: Allocation(Context *rsc, const Type *, uint32_t usages); - Allocation(Context *rsc, const Type *, void *bmp, void *callbackData, RsBitmapCallback_t callback); virtual ~Allocation(); @@ -88,8 +87,12 @@ public: virtual void uploadCheck(Context *rsc); - bool getIsTexture() const {return mIsTexture;} - bool getIsBufferObject() const {return mIsVertexBuffer;} + bool getIsTexture() const { + return (mUsageFlags & RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE) != 0; + } + bool getIsBufferObject() const { + return (mUsageFlags & RS_ALLOCATION_USAGE_GRAPHICS_VERTEX) != 0; + } void incRefs(const void *ptr, size_t ct, size_t startOff = 0) const; void decRefs(const void *ptr, size_t ct, size_t startOff = 0) const; @@ -115,6 +118,7 @@ protected: bool mGpuRead; uint32_t mUsageFlags; + RsAllocationMipmapControl mMipmapControl; // more usage hint data from the application // which can be used by a driver to pick the best memory type. @@ -125,7 +129,6 @@ protected: // Is this a legal structure to be used as a texture source. // Initially this will require 1D or 2D and color data - bool mIsTexture; bool mTextureGenMipmap; uint32_t mTextureLOD; uint32_t mTextureID; @@ -133,7 +136,6 @@ protected: // Is this a legal structure to be used as a vertex source. // Initially this will require 1D and x(yzw). Additional per element data // is allowed. - bool mIsVertexBuffer; uint32_t mBufferID; bool mUploadDefered; |