Loading graphics/java/android/renderscript/Allocation.java +29 −38 Original line number Diff line number Diff line Loading @@ -55,13 +55,13 @@ public class Allocation extends BaseObj { } } public enum MipmapGenerationControl { public enum MipmapControl { MIPMAP_NONE(0), MIPMAP_FULL(1), MIPMAP_ON_SYNC_TO_TEXTURE(2); int mID; MipmapGenerationControl(int id) { MipmapControl(int id) { mID = id; } } Loading Loading @@ -131,6 +131,14 @@ public class Allocation extends BaseObj { subData1D(0, mType.getCount(), i); } private void validateBitmap(Bitmap b) { mRS.validate(); if(mType.getX() != b.getWidth() || mType.getY() != b.getHeight()) { throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); } } public void copyFrom(int[] d) { mRS.validate(); subData1D(0, mType.getCount(), d); Loading @@ -147,18 +155,17 @@ public class Allocation extends BaseObj { mRS.validate(); subData1D(0, mType.getCount(), d); } public void copyFrom(Bitmap b) { mRS.validate(); if(mType.getX() != b.getWidth() || mType.getY() != b.getHeight()) { throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); validateBitmap(b); mRS.nAllocationCopyFromBitmap(getID(), b); } mRS.nAllocationUpdateFromBitmap(getID(), b); public void copyTo(Bitmap b) { validateBitmap(b); mRS.nAllocationCopyToBitmap(getID(), b); } public void subData(int xoff, FieldPacker fp) { int eSize = mType.mElement.getSizeBytes(); final byte[] data = fp.getData(); Loading Loading @@ -423,17 +430,17 @@ public class Allocation extends BaseObj { } static private Type typeFromBitmap(RenderScript rs, Bitmap b, MipmapGenerationControl mip) { MipmapControl mip) { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); tb.setX(b.getWidth()); tb.setY(b.getHeight()); tb.setMipmaps(mip == MipmapGenerationControl.MIPMAP_FULL); tb.setMipmaps(mip == MipmapControl.MIPMAP_FULL); return tb.create(); } static public Allocation createFromBitmap(RenderScript rs, Bitmap b, MipmapGenerationControl mips, MipmapControl mips, int usage) { rs.validate(); Type t = typeFromBitmap(rs, b, mips); Loading @@ -447,15 +454,15 @@ public class Allocation extends BaseObj { static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips) { MipmapGenerationControl mc = MipmapGenerationControl.MIPMAP_NONE; MipmapControl mc = MipmapControl.MIPMAP_NONE; if (genMips) { mc = MipmapGenerationControl.MIPMAP_ON_SYNC_TO_TEXTURE; mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } return createFromBitmap(rs, b, mc, USAGE_ALL); } static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b, MipmapGenerationControl mips, MipmapControl mips, CubemapLayout layout, int usage) { rs.validate(); Loading @@ -482,7 +489,7 @@ public class Allocation extends BaseObj { tb.setX(width); tb.setY(width); tb.setFaces(true); tb.setMipmaps(mips == MipmapGenerationControl.MIPMAP_FULL); tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); int id = rs.nAllocationCubeCreateFromBitmap(t.getID(), mips.mID, b, usage); Loading @@ -496,33 +503,17 @@ public class Allocation extends BaseObj { Element dstFmt, boolean genMips, CubemapLayout layout) { MipmapGenerationControl mc = MipmapGenerationControl.MIPMAP_NONE; MipmapControl mc = MipmapControl.MIPMAP_NONE; if (genMips) { mc = MipmapGenerationControl.MIPMAP_ON_SYNC_TO_TEXTURE; mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } return createCubemapFromBitmap(rs, b, mc, layout, USAGE_ALL); } static public Allocation createBitmapRef(RenderScript rs, Bitmap b) { rs.validate(); Type t = typeFromBitmap(rs, b, MipmapGenerationControl.MIPMAP_NONE); int id = rs.nAllocationCreateBitmapRef(t.getID(), b); if(id == 0) { throw new RSRuntimeException("Load failed."); } Allocation a = new Allocation(id, rs, t, USAGE_SCRIPT); a.mBitmap = b; return a; } static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, MipmapGenerationControl mips, MipmapControl mips, int usage) { rs.validate(); Loading @@ -537,9 +528,9 @@ public class Allocation extends BaseObj { int id, Element dstFmt, boolean genMips) { MipmapGenerationControl mc = MipmapGenerationControl.MIPMAP_NONE; MipmapControl mc = MipmapControl.MIPMAP_NONE; if (genMips) { mc = MipmapGenerationControl.MIPMAP_ON_SYNC_TO_TEXTURE; mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } return createFromBitmapResource(rs, res, id, mc, USAGE_ALL); } Loading graphics/java/android/renderscript/Element.java +0 −12 Original line number Diff line number Diff line Loading @@ -654,17 +654,5 @@ public class Element extends BaseObj { return new Element(id, mRS, ein, sin, asin); } } static void initPredefined(RenderScript rs) { int a8 = rs.nElementCreate(DataType.UNSIGNED_8.mID, DataKind.PIXEL_A.mID, true, 1); int rgba4444 = rs.nElementCreate(DataType.UNSIGNED_4_4_4_4.mID, DataKind.PIXEL_RGBA.mID, true, 4); int rgba8888 = rs.nElementCreate(DataType.UNSIGNED_8.mID, DataKind.PIXEL_RGBA.mID, true, 4); int rgb565 = rs.nElementCreate(DataType.UNSIGNED_5_6_5.mID, DataKind.PIXEL_RGB.mID, true, 3); rs.nInitElements(a8, rgba4444, rgba8888, rgb565); } } graphics/java/android/renderscript/RenderScript.java +9 −5 Original line number Diff line number Diff line Loading @@ -65,7 +65,6 @@ public class RenderScript { } // Non-threadsafe functions. native void nInitElements(int a8, int rgba4444, int rgba8888, int rgb565); native int nDeviceCreate(); native void nDeviceDestroy(int dev); native void nDeviceSetConfig(int dev, int param, int value); Loading Loading @@ -213,13 +212,19 @@ public class RenderScript { return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage); } native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) { rsnAllocationCopyToBitmap(mContext, alloc, bmp); } native void rsnAllocationSyncAll(int con, int alloc, int src); synchronized void nAllocationSyncAll(int alloc, int src) { rsnAllocationSyncAll(mContext, alloc, src); } native void rsnAllocationUpdateFromBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationUpdateFromBitmap(int alloc, Bitmap bmp) { rsnAllocationUpdateFromBitmap(mContext, alloc, bmp); native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { rsnAllocationCopyFromBitmap(mContext, alloc, bmp); } native void rsnAllocationUploadToTexture(int con, int alloc, boolean genMips, int baseMioLevel); Loading Loading @@ -787,7 +792,6 @@ public class RenderScript { rs.mContext = rs.nContextCreate(rs.mDev, 0); rs.mMessageThread = new MessageThread(rs); rs.mMessageThread.start(); Element.initPredefined(rs); return rs; } Loading graphics/java/android/renderscript/RenderScriptGL.java +0 −1 Original line number Diff line number Diff line Loading @@ -190,7 +190,6 @@ public class RenderScriptGL extends RenderScript { } mMessageThread = new MessageThread(this); mMessageThread.start(); Element.initPredefined(this); } /** Loading graphics/jni/android_renderscript_RenderScript.cpp +21 −84 Original line number Diff line number Diff line Loading @@ -59,11 +59,6 @@ static jfieldID gContextId = 0; static jfieldID gNativeBitmapID = 0; static jfieldID gTypeNativeCache = 0; static RsElement g_A_8 = NULL; static RsElement g_RGBA_4444 = NULL; static RsElement g_RGBA_8888 = NULL; static RsElement g_RGB_565 = NULL; static void _nInit(JNIEnv *_env, jclass _this) { gContextId = _env->GetFieldID(_this, "mContext", "I"); Loading @@ -72,14 +67,6 @@ static void _nInit(JNIEnv *_env, jclass _this) gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); } static void nInitElements(JNIEnv *_env, jobject _this, jint a8, jint rgba4444, jint rgba8888, jint rgb565) { g_A_8 = reinterpret_cast<RsElement>(a8); g_RGBA_4444 = reinterpret_cast<RsElement>(rgba4444); g_RGBA_8888 = reinterpret_cast<RsElement>(rgba8888); g_RGB_565 = reinterpret_cast<RsElement>(rgb565); } // --------------------------------------------------------------------------- static void Loading Loading @@ -415,26 +402,6 @@ nAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); } static RsElement SkBitmapToPredefined(SkBitmap::Config cfg) { switch (cfg) { case SkBitmap::kA8_Config: return g_A_8; case SkBitmap::kARGB_4444_Config: return g_RGBA_4444; case SkBitmap::kARGB_8888_Config: return g_RGBA_8888; case SkBitmap::kRGB_565_Config: return g_RGB_565; default: break; } // If we don't have a conversion mark it as a user type. LOGE("Unsupported bitmap type"); return NULL; } static int nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { Loading Loading @@ -464,20 +431,29 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint } static void nAllocationUpdateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); RsElement e = SkBitmapToPredefined(config); if (e) { bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); rsAllocationUpdateFromBitmap(con, (RsAllocation)alloc, e, ptr); rsAllocationCopyFromBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize()); bitmap.unlockPixels(); } static void nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); bitmap.lockPixels(); void* ptr = bitmap.getPixels(); rsAllocationCopyToBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize()); bitmap.unlockPixels(); } static void ReleaseBitmapCallback(void *bmp) Loading @@ -486,44 +462,6 @@ static void ReleaseBitmapCallback(void *bmp) nativeBitmap->unlockPixels(); } static int nAllocationCreateBitmapRef(JNIEnv *_env, jobject _this, RsContext con, jint type, jobject jbitmap) { SkBitmap * nativeBitmap = (SkBitmap *)_env->GetIntField(jbitmap, gNativeBitmapID); nativeBitmap->lockPixels(); void* ptr = nativeBitmap->getPixels(); jint id = (jint)rsAllocationCreateBitmapRef(con, (RsType)type, ptr, nativeBitmap, ReleaseBitmapCallback); return id; } static int nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con, jint dstFmt, jboolean genMips, jint native_asset, jint usage) { /* Asset* asset = reinterpret_cast<Asset*>(native_asset); SkBitmap bitmap; SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(), &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode); SkBitmap::Config config = bitmap.getConfig(); RsElement e = SkBitmapToPredefined(config); if (e) { bitmap.lockPixels(); const int w = bitmap.width(); const int h = bitmap.height(); const void* ptr = bitmap.getPixels(); jint id = (jint)rsaAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr, usage); bitmap.unlockPixels(); return id; } */ return 0; } static void nAllocationSubData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jintArray data, int sizeBytes) Loading Loading @@ -1266,7 +1204,6 @@ static const char *classPathName = "android/renderscript/RenderScript"; static JNINativeMethod methods[] = { {"_nInit", "()V", (void*)_nInit }, {"nInitElements", "(IIII)V", (void*)nInitElements }, {"nDeviceCreate", "()I", (void*)nDeviceCreate }, {"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, Loading Loading @@ -1311,10 +1248,10 @@ static JNINativeMethod methods[] = { {"rsnAllocationCreateTyped", "(III)I", (void*)nAllocationCreateTyped }, {"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, {"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, {"rsnAllocationCreateBitmapRef", "(IILandroid/graphics/Bitmap;)I", (void*)nAllocationCreateBitmapRef }, {"rsnAllocationCreateFromAssetStream","(IIII)I", (void*)nAllocationCreateFromAssetStream }, {"rsnAllocationUpdateFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationUpdateFromBitmap }, {"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, {"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, {"rsnAllocationUploadToTexture", "(IIZI)V", (void*)nAllocationUploadToTexture }, {"rsnAllocationUploadToBufferObject","(II)V", (void*)nAllocationUploadToBufferObject }, {"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, Loading Loading
graphics/java/android/renderscript/Allocation.java +29 −38 Original line number Diff line number Diff line Loading @@ -55,13 +55,13 @@ public class Allocation extends BaseObj { } } public enum MipmapGenerationControl { public enum MipmapControl { MIPMAP_NONE(0), MIPMAP_FULL(1), MIPMAP_ON_SYNC_TO_TEXTURE(2); int mID; MipmapGenerationControl(int id) { MipmapControl(int id) { mID = id; } } Loading Loading @@ -131,6 +131,14 @@ public class Allocation extends BaseObj { subData1D(0, mType.getCount(), i); } private void validateBitmap(Bitmap b) { mRS.validate(); if(mType.getX() != b.getWidth() || mType.getY() != b.getHeight()) { throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); } } public void copyFrom(int[] d) { mRS.validate(); subData1D(0, mType.getCount(), d); Loading @@ -147,18 +155,17 @@ public class Allocation extends BaseObj { mRS.validate(); subData1D(0, mType.getCount(), d); } public void copyFrom(Bitmap b) { mRS.validate(); if(mType.getX() != b.getWidth() || mType.getY() != b.getHeight()) { throw new RSIllegalArgumentException("Cannot update allocation from bitmap, sizes mismatch"); validateBitmap(b); mRS.nAllocationCopyFromBitmap(getID(), b); } mRS.nAllocationUpdateFromBitmap(getID(), b); public void copyTo(Bitmap b) { validateBitmap(b); mRS.nAllocationCopyToBitmap(getID(), b); } public void subData(int xoff, FieldPacker fp) { int eSize = mType.mElement.getSizeBytes(); final byte[] data = fp.getData(); Loading Loading @@ -423,17 +430,17 @@ public class Allocation extends BaseObj { } static private Type typeFromBitmap(RenderScript rs, Bitmap b, MipmapGenerationControl mip) { MipmapControl mip) { Element e = elementFromBitmap(rs, b); Type.Builder tb = new Type.Builder(rs, e); tb.setX(b.getWidth()); tb.setY(b.getHeight()); tb.setMipmaps(mip == MipmapGenerationControl.MIPMAP_FULL); tb.setMipmaps(mip == MipmapControl.MIPMAP_FULL); return tb.create(); } static public Allocation createFromBitmap(RenderScript rs, Bitmap b, MipmapGenerationControl mips, MipmapControl mips, int usage) { rs.validate(); Type t = typeFromBitmap(rs, b, mips); Loading @@ -447,15 +454,15 @@ public class Allocation extends BaseObj { static public Allocation createFromBitmap(RenderScript rs, Bitmap b, Element dstFmt, boolean genMips) { MipmapGenerationControl mc = MipmapGenerationControl.MIPMAP_NONE; MipmapControl mc = MipmapControl.MIPMAP_NONE; if (genMips) { mc = MipmapGenerationControl.MIPMAP_ON_SYNC_TO_TEXTURE; mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } return createFromBitmap(rs, b, mc, USAGE_ALL); } static public Allocation createCubemapFromBitmap(RenderScript rs, Bitmap b, MipmapGenerationControl mips, MipmapControl mips, CubemapLayout layout, int usage) { rs.validate(); Loading @@ -482,7 +489,7 @@ public class Allocation extends BaseObj { tb.setX(width); tb.setY(width); tb.setFaces(true); tb.setMipmaps(mips == MipmapGenerationControl.MIPMAP_FULL); tb.setMipmaps(mips == MipmapControl.MIPMAP_FULL); Type t = tb.create(); int id = rs.nAllocationCubeCreateFromBitmap(t.getID(), mips.mID, b, usage); Loading @@ -496,33 +503,17 @@ public class Allocation extends BaseObj { Element dstFmt, boolean genMips, CubemapLayout layout) { MipmapGenerationControl mc = MipmapGenerationControl.MIPMAP_NONE; MipmapControl mc = MipmapControl.MIPMAP_NONE; if (genMips) { mc = MipmapGenerationControl.MIPMAP_ON_SYNC_TO_TEXTURE; mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } return createCubemapFromBitmap(rs, b, mc, layout, USAGE_ALL); } static public Allocation createBitmapRef(RenderScript rs, Bitmap b) { rs.validate(); Type t = typeFromBitmap(rs, b, MipmapGenerationControl.MIPMAP_NONE); int id = rs.nAllocationCreateBitmapRef(t.getID(), b); if(id == 0) { throw new RSRuntimeException("Load failed."); } Allocation a = new Allocation(id, rs, t, USAGE_SCRIPT); a.mBitmap = b; return a; } static public Allocation createFromBitmapResource(RenderScript rs, Resources res, int id, MipmapGenerationControl mips, MipmapControl mips, int usage) { rs.validate(); Loading @@ -537,9 +528,9 @@ public class Allocation extends BaseObj { int id, Element dstFmt, boolean genMips) { MipmapGenerationControl mc = MipmapGenerationControl.MIPMAP_NONE; MipmapControl mc = MipmapControl.MIPMAP_NONE; if (genMips) { mc = MipmapGenerationControl.MIPMAP_ON_SYNC_TO_TEXTURE; mc = MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE; } return createFromBitmapResource(rs, res, id, mc, USAGE_ALL); } Loading
graphics/java/android/renderscript/Element.java +0 −12 Original line number Diff line number Diff line Loading @@ -654,17 +654,5 @@ public class Element extends BaseObj { return new Element(id, mRS, ein, sin, asin); } } static void initPredefined(RenderScript rs) { int a8 = rs.nElementCreate(DataType.UNSIGNED_8.mID, DataKind.PIXEL_A.mID, true, 1); int rgba4444 = rs.nElementCreate(DataType.UNSIGNED_4_4_4_4.mID, DataKind.PIXEL_RGBA.mID, true, 4); int rgba8888 = rs.nElementCreate(DataType.UNSIGNED_8.mID, DataKind.PIXEL_RGBA.mID, true, 4); int rgb565 = rs.nElementCreate(DataType.UNSIGNED_5_6_5.mID, DataKind.PIXEL_RGB.mID, true, 3); rs.nInitElements(a8, rgba4444, rgba8888, rgb565); } }
graphics/java/android/renderscript/RenderScript.java +9 −5 Original line number Diff line number Diff line Loading @@ -65,7 +65,6 @@ public class RenderScript { } // Non-threadsafe functions. native void nInitElements(int a8, int rgba4444, int rgba8888, int rgb565); native int nDeviceCreate(); native void nDeviceDestroy(int dev); native void nDeviceSetConfig(int dev, int param, int value); Loading Loading @@ -213,13 +212,19 @@ public class RenderScript { return rsnAllocationCreateFromAssetStream(mContext, mips, assetStream, usage); } native void rsnAllocationCopyToBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationCopyToBitmap(int alloc, Bitmap bmp) { rsnAllocationCopyToBitmap(mContext, alloc, bmp); } native void rsnAllocationSyncAll(int con, int alloc, int src); synchronized void nAllocationSyncAll(int alloc, int src) { rsnAllocationSyncAll(mContext, alloc, src); } native void rsnAllocationUpdateFromBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationUpdateFromBitmap(int alloc, Bitmap bmp) { rsnAllocationUpdateFromBitmap(mContext, alloc, bmp); native void rsnAllocationCopyFromBitmap(int con, int alloc, Bitmap bmp); synchronized void nAllocationCopyFromBitmap(int alloc, Bitmap bmp) { rsnAllocationCopyFromBitmap(mContext, alloc, bmp); } native void rsnAllocationUploadToTexture(int con, int alloc, boolean genMips, int baseMioLevel); Loading Loading @@ -787,7 +792,6 @@ public class RenderScript { rs.mContext = rs.nContextCreate(rs.mDev, 0); rs.mMessageThread = new MessageThread(rs); rs.mMessageThread.start(); Element.initPredefined(rs); return rs; } Loading
graphics/java/android/renderscript/RenderScriptGL.java +0 −1 Original line number Diff line number Diff line Loading @@ -190,7 +190,6 @@ public class RenderScriptGL extends RenderScript { } mMessageThread = new MessageThread(this); mMessageThread.start(); Element.initPredefined(this); } /** Loading
graphics/jni/android_renderscript_RenderScript.cpp +21 −84 Original line number Diff line number Diff line Loading @@ -59,11 +59,6 @@ static jfieldID gContextId = 0; static jfieldID gNativeBitmapID = 0; static jfieldID gTypeNativeCache = 0; static RsElement g_A_8 = NULL; static RsElement g_RGBA_4444 = NULL; static RsElement g_RGBA_8888 = NULL; static RsElement g_RGB_565 = NULL; static void _nInit(JNIEnv *_env, jclass _this) { gContextId = _env->GetFieldID(_this, "mContext", "I"); Loading @@ -72,14 +67,6 @@ static void _nInit(JNIEnv *_env, jclass _this) gNativeBitmapID = _env->GetFieldID(bitmapClass, "mNativeBitmap", "I"); } static void nInitElements(JNIEnv *_env, jobject _this, jint a8, jint rgba4444, jint rgba8888, jint rgb565) { g_A_8 = reinterpret_cast<RsElement>(a8); g_RGBA_4444 = reinterpret_cast<RsElement>(rgba4444); g_RGBA_8888 = reinterpret_cast<RsElement>(rgba8888); g_RGB_565 = reinterpret_cast<RsElement>(rgb565); } // --------------------------------------------------------------------------- static void Loading Loading @@ -415,26 +402,6 @@ nAllocationSyncAll(JNIEnv *_env, jobject _this, RsContext con, jint a, jint bits rsAllocationSyncAll(con, (RsAllocation)a, (RsAllocationUsageType)bits); } static RsElement SkBitmapToPredefined(SkBitmap::Config cfg) { switch (cfg) { case SkBitmap::kA8_Config: return g_A_8; case SkBitmap::kARGB_4444_Config: return g_RGBA_4444; case SkBitmap::kARGB_8888_Config: return g_RGBA_8888; case SkBitmap::kRGB_565_Config: return g_RGB_565; default: break; } // If we don't have a conversion mark it as a user type. LOGE("Unsupported bitmap type"); return NULL; } static int nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint type, jint mip, jobject jbitmap, jint usage) { Loading Loading @@ -464,20 +431,29 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint } static void nAllocationUpdateFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); RsElement e = SkBitmapToPredefined(config); if (e) { bitmap.lockPixels(); const void* ptr = bitmap.getPixels(); rsAllocationUpdateFromBitmap(con, (RsAllocation)alloc, e, ptr); rsAllocationCopyFromBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize()); bitmap.unlockPixels(); } static void nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jobject jbitmap) { SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); bitmap.lockPixels(); void* ptr = bitmap.getPixels(); rsAllocationCopyToBitmap(con, (RsAllocation)alloc, ptr, bitmap.getSize()); bitmap.unlockPixels(); } static void ReleaseBitmapCallback(void *bmp) Loading @@ -486,44 +462,6 @@ static void ReleaseBitmapCallback(void *bmp) nativeBitmap->unlockPixels(); } static int nAllocationCreateBitmapRef(JNIEnv *_env, jobject _this, RsContext con, jint type, jobject jbitmap) { SkBitmap * nativeBitmap = (SkBitmap *)_env->GetIntField(jbitmap, gNativeBitmapID); nativeBitmap->lockPixels(); void* ptr = nativeBitmap->getPixels(); jint id = (jint)rsAllocationCreateBitmapRef(con, (RsType)type, ptr, nativeBitmap, ReleaseBitmapCallback); return id; } static int nAllocationCreateFromAssetStream(JNIEnv *_env, jobject _this, RsContext con, jint dstFmt, jboolean genMips, jint native_asset, jint usage) { /* Asset* asset = reinterpret_cast<Asset*>(native_asset); SkBitmap bitmap; SkImageDecoder::DecodeMemory(asset->getBuffer(false), asset->getLength(), &bitmap, SkBitmap::kNo_Config, SkImageDecoder::kDecodePixels_Mode); SkBitmap::Config config = bitmap.getConfig(); RsElement e = SkBitmapToPredefined(config); if (e) { bitmap.lockPixels(); const int w = bitmap.width(); const int h = bitmap.height(); const void* ptr = bitmap.getPixels(); jint id = (jint)rsaAllocationCreateFromBitmap(con, w, h, (RsElement)dstFmt, e, genMips, ptr, usage); bitmap.unlockPixels(); return id; } */ return 0; } static void nAllocationSubData1D_i(JNIEnv *_env, jobject _this, RsContext con, jint alloc, jint offset, jint count, jintArray data, int sizeBytes) Loading Loading @@ -1266,7 +1204,6 @@ static const char *classPathName = "android/renderscript/RenderScript"; static JNINativeMethod methods[] = { {"_nInit", "()V", (void*)_nInit }, {"nInitElements", "(IIII)V", (void*)nInitElements }, {"nDeviceCreate", "()I", (void*)nDeviceCreate }, {"nDeviceDestroy", "(I)V", (void*)nDeviceDestroy }, Loading Loading @@ -1311,10 +1248,10 @@ static JNINativeMethod methods[] = { {"rsnAllocationCreateTyped", "(III)I", (void*)nAllocationCreateTyped }, {"rsnAllocationCreateFromBitmap", "(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCreateFromBitmap }, {"rsnAllocationCubeCreateFromBitmap","(IIILandroid/graphics/Bitmap;I)I", (void*)nAllocationCubeCreateFromBitmap }, {"rsnAllocationCreateBitmapRef", "(IILandroid/graphics/Bitmap;)I", (void*)nAllocationCreateBitmapRef }, {"rsnAllocationCreateFromAssetStream","(IIII)I", (void*)nAllocationCreateFromAssetStream }, {"rsnAllocationUpdateFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationUpdateFromBitmap }, {"rsnAllocationCopyFromBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyFromBitmap }, {"rsnAllocationCopyToBitmap", "(IILandroid/graphics/Bitmap;)V", (void*)nAllocationCopyToBitmap }, {"rsnAllocationUploadToTexture", "(IIZI)V", (void*)nAllocationUploadToTexture }, {"rsnAllocationUploadToBufferObject","(II)V", (void*)nAllocationUploadToBufferObject }, {"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, Loading