Loading graphics/java/android/renderscript/RenderScript.java +7 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public class RenderScript { native private int nAllocationCreatePredefSized(int predef, int count); native private int nAllocationCreateSized(int elem, int count); native private int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp); native private int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp); native private void nAllocationUploadToTexture(int alloc, int baseMioLevel); native private void nAllocationDestroy(int alloc); Loading Loading @@ -533,6 +534,11 @@ public class RenderScript { return new Allocation(id); } public Allocation allocationCreateFromBitmapBoxed(Bitmap b, ElementPredefined dstFmt, boolean genMips) { int id = nAllocationCreateFromBitmapBoxed(dstFmt.mID, genMips, b); return new Allocation(id); } ////////////////////////////////////////////////////////////////////////////////// // Adapter1D Loading graphics/jni/android_renderscript_RenderScript.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,29 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jint dstFmt, jboolean g return 0; } static int nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); RsElementPredefined e = SkBitmapToPredefined(config); if (e != RS_ELEMENT_USER_U8) { bitmap.lockPixels(); const int w = bitmap.width(); const int h = bitmap.height(); const void* ptr = bitmap.getPixels(); jint id = (jint)rsAllocationCreateFromBitmapBoxed(w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); bitmap.unlockPixels(); return id; } return 0; } static void nAllocationDestroy(JNIEnv *_env, jobject _this, jint a) Loading Loading @@ -994,6 +1017,7 @@ static JNINativeMethod methods[] = { {"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized }, {"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized }, {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, {"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed }, {"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture }, {"nAllocationDestroy", "(I)V", (void*)nAllocationDestroy }, {"nAllocationData", "(I[I)V", (void*)nAllocationData_i }, Loading libs/rs/RenderScript.h +17 −17 Original line number Diff line number Diff line Loading @@ -146,26 +146,26 @@ enum RsDepthFunc { }; enum RsBlendSrcFunc { RS_BLEND_SRC_ZERO, RS_BLEND_SRC_ONE, RS_BLEND_SRC_DST_COLOR, RS_BLEND_SRC_ONE_MINUS_DST_COLOR, RS_BLEND_SRC_SRC_ALPHA, RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, RS_BLEND_SRC_DST_ALPHA, RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, RS_BLEND_SRC_SRC_ALPHA_SATURATE RS_BLEND_SRC_ZERO, // 0 RS_BLEND_SRC_ONE, // 1 RS_BLEND_SRC_DST_COLOR, // 2 RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3 RS_BLEND_SRC_SRC_ALPHA, // 4 RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5 RS_BLEND_SRC_DST_ALPHA, // 6 RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7 RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8 }; enum RsBlendDstFunc { RS_BLEND_DST_ZERO, RS_BLEND_DST_ONE, RS_BLEND_DST_SRC_COLOR, RS_BLEND_DST_ONE_MINUS_SRC_COLOR, RS_BLEND_DST_SRC_ALPHA, RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, RS_BLEND_DST_DST_ALPHA, RS_BLEND_DST_ONE_MINUS_DST_ALPHA RS_BLEND_DST_ZERO, // 0 RS_BLEND_DST_ONE, // 1 RS_BLEND_DST_SRC_COLOR, // 2 RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3 RS_BLEND_DST_SRC_ALPHA, // 4 RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5 RS_BLEND_DST_DST_ALPHA, // 6 RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7 }; enum RsTexEnvMode { Loading libs/rs/RenderScriptEnv.h +0 −8 Original line number Diff line number Diff line Loading @@ -30,11 +30,3 @@ typedef struct { #define RS_PROGRAM_VERTEX_PROJECTION_OFFSET 16 #define RS_PROGRAM_VERTEX_TEXTURE_OFFSET 32 //typedef int (*rsc_RunScript)(uint32_t launchIndex, const rsc_FunctionTable *); /* EnableCap */ #define GL_LIGHTING 0x0B50 /* LightName */ #define GL_LIGHT0 0x4000 libs/rs/java/Film/res/raw/filmstrip.c +49 −52 Original line number Diff line number Diff line Loading @@ -14,6 +14,14 @@ typedef struct FilmScriptUserEnvRec { } FilmScriptUserEnv; */ #define POS_TRANSLATE 0 #define POS_ROTATE 1 #define POS_FOCUS 2 #define STATE_TRIANGLE_OFFSET_COUNT 0 #define STATE_LAST_FOCUS 1 // The script enviroment has 3 env allocations. // bank0: (r) The enviroment structure // bank1: (r) The position information Loading @@ -23,17 +31,9 @@ int main(int index) { int f1,f2,f3,f4, f5,f6,f7,f8, f9,f10,f11,f12, f13,f14,f15,f16; int g1,g2,g3,g4, g5,g6,g7,g8, g9,g10,g11,g12, g13,g14,g15,g16; float trans; float rot; int x; float focusPos; // float int focusID; int lastFocusID; int imgCount; trans = loadF(1, 0); rot = loadF(1, 1); float trans = loadF(1, POS_TRANSLATE); float rot = loadF(1, POS_ROTATE); matrixLoadScale(&f16, 2.f, 2.f, 2.f); matrixTranslate(&f16, 0.f, 0.f, trans); matrixRotate(&f16, 90.f, 0.f, 0.f, 1.f); Loading @@ -46,24 +46,18 @@ int main(int index) drawTriangleMesh(NAMED_mesh); //int imgId = 0; // Start of images. bindProgramFragmentStore(NAMED_PFImages); bindProgramFragment(NAMED_PFSImages); bindProgramVertex(NAMED_PVImages); //focusPos = loadF(1, 2); //focusID = 0; //lastFocusID = loadI32(2, 0); //imgCount = 13; /* disable(GL_LIGHTING); float focusPos = loadF(1, POS_FOCUS); int focusID = 0; int lastFocusID = loadI32(2, STATE_LAST_FOCUS); int imgCount = 13; if (trans > (-.3)) { focusID = -1.0 - focusPos; if (trans > (-.3f)) { focusID = -1.0f - focusPos; if (focusID >= imgCount) { focusID = -1; } Loading @@ -71,6 +65,7 @@ int main(int index) focusID = -1; } /* if (focusID != lastFocusID) { if (lastFocusID >= 0) { uploadToTexture(con, env->tex[lastFocusID], 1); Loading @@ -79,36 +74,38 @@ int main(int index) uploadToTexture(con, env->tex[focusID], 0); } } storeEnvI32(con, 2, 0, focusID); */ storeI32(2, STATE_LAST_FOCUS, focusID); int triangleOffsetsCount = loadI32(2, STATE_TRIANGLE_OFFSET_COUNT); int imgId = 0; for (imgId=1; imgId <= imgCount; imgId++) { float pos = focusPos + imgId + .4f; int offset = (int)floor(pos*2); pos -= 0.75; float pos = focusPos + imgId + 0.4f; int offset = (int)floorf(pos * 2.f); pos = pos - 0.75f; offset += env->triangleOffsetsCount / 2; if ((offset < 0) || (offset >= env->triangleOffsetsCount)) { continue; } offset = offset + triangleOffsetsCount / 2; if (!((offset < 0) || (offset >= triangleOffsetsCount))) { int start = offset -2; int end = offset + 2; if (start < 0) { start = 0; } if (end > env->triangleOffsetsCount) { end = env->triangleOffsetsCount; if (end > triangleOffsetsCount) { end = triangleOffsetsCount; } programFragmentBindTexture(con, env->fpImages, 0, env->tex[imgId - 1]); bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1)); /* matrixLoadTranslate(con, &m, -pos - env->triangleOffsetsTex[env->triangleOffsetsCount / 2], 0, 0); storeEnvMatrix(con, 3, RS_PROGRAM_VERTEX_TEXTURE_OFFSET, &m); renderTriangleMeshRange(con, env->mesh, env->triangleOffsets[start], env->triangleOffsets[end] - env->triangleOffsets[start]); } */ } } return 0; } Loading
graphics/java/android/renderscript/RenderScript.java +7 −1 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public class RenderScript { native private int nAllocationCreatePredefSized(int predef, int count); native private int nAllocationCreateSized(int elem, int count); native private int nAllocationCreateFromBitmap(int dstFmt, boolean genMips, Bitmap bmp); native private int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp); native private void nAllocationUploadToTexture(int alloc, int baseMioLevel); native private void nAllocationDestroy(int alloc); Loading Loading @@ -533,6 +534,11 @@ public class RenderScript { return new Allocation(id); } public Allocation allocationCreateFromBitmapBoxed(Bitmap b, ElementPredefined dstFmt, boolean genMips) { int id = nAllocationCreateFromBitmapBoxed(dstFmt.mID, genMips, b); return new Allocation(id); } ////////////////////////////////////////////////////////////////////////////////// // Adapter1D Loading
graphics/jni/android_renderscript_RenderScript.cpp +24 −0 Original line number Diff line number Diff line Loading @@ -291,6 +291,29 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jint dstFmt, jboolean g return 0; } static int nAllocationCreateFromBitmapBoxed(JNIEnv *_env, jobject _this, jint dstFmt, jboolean genMips, jobject jbitmap) { RsContext con = (RsContext)(_env->GetIntField(_this, gContextId)); SkBitmap const * nativeBitmap = (SkBitmap const *)_env->GetIntField(jbitmap, gNativeBitmapID); const SkBitmap& bitmap(*nativeBitmap); SkBitmap::Config config = bitmap.getConfig(); RsElementPredefined e = SkBitmapToPredefined(config); if (e != RS_ELEMENT_USER_U8) { bitmap.lockPixels(); const int w = bitmap.width(); const int h = bitmap.height(); const void* ptr = bitmap.getPixels(); jint id = (jint)rsAllocationCreateFromBitmapBoxed(w, h, (RsElementPredefined)dstFmt, e, genMips, ptr); bitmap.unlockPixels(); return id; } return 0; } static void nAllocationDestroy(JNIEnv *_env, jobject _this, jint a) Loading Loading @@ -994,6 +1017,7 @@ static JNINativeMethod methods[] = { {"nAllocationCreatePredefSized", "(II)I", (void*)nAllocationCreatePredefSized }, {"nAllocationCreateSized", "(II)I", (void*)nAllocationCreateSized }, {"nAllocationCreateFromBitmap", "(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmap }, {"nAllocationCreateFromBitmapBoxed","(IZLandroid/graphics/Bitmap;)I", (void*)nAllocationCreateFromBitmapBoxed }, {"nAllocationUploadToTexture", "(II)V", (void*)nAllocationUploadToTexture }, {"nAllocationDestroy", "(I)V", (void*)nAllocationDestroy }, {"nAllocationData", "(I[I)V", (void*)nAllocationData_i }, Loading
libs/rs/RenderScript.h +17 −17 Original line number Diff line number Diff line Loading @@ -146,26 +146,26 @@ enum RsDepthFunc { }; enum RsBlendSrcFunc { RS_BLEND_SRC_ZERO, RS_BLEND_SRC_ONE, RS_BLEND_SRC_DST_COLOR, RS_BLEND_SRC_ONE_MINUS_DST_COLOR, RS_BLEND_SRC_SRC_ALPHA, RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, RS_BLEND_SRC_DST_ALPHA, RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, RS_BLEND_SRC_SRC_ALPHA_SATURATE RS_BLEND_SRC_ZERO, // 0 RS_BLEND_SRC_ONE, // 1 RS_BLEND_SRC_DST_COLOR, // 2 RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3 RS_BLEND_SRC_SRC_ALPHA, // 4 RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5 RS_BLEND_SRC_DST_ALPHA, // 6 RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7 RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8 }; enum RsBlendDstFunc { RS_BLEND_DST_ZERO, RS_BLEND_DST_ONE, RS_BLEND_DST_SRC_COLOR, RS_BLEND_DST_ONE_MINUS_SRC_COLOR, RS_BLEND_DST_SRC_ALPHA, RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, RS_BLEND_DST_DST_ALPHA, RS_BLEND_DST_ONE_MINUS_DST_ALPHA RS_BLEND_DST_ZERO, // 0 RS_BLEND_DST_ONE, // 1 RS_BLEND_DST_SRC_COLOR, // 2 RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3 RS_BLEND_DST_SRC_ALPHA, // 4 RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5 RS_BLEND_DST_DST_ALPHA, // 6 RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7 }; enum RsTexEnvMode { Loading
libs/rs/RenderScriptEnv.h +0 −8 Original line number Diff line number Diff line Loading @@ -30,11 +30,3 @@ typedef struct { #define RS_PROGRAM_VERTEX_PROJECTION_OFFSET 16 #define RS_PROGRAM_VERTEX_TEXTURE_OFFSET 32 //typedef int (*rsc_RunScript)(uint32_t launchIndex, const rsc_FunctionTable *); /* EnableCap */ #define GL_LIGHTING 0x0B50 /* LightName */ #define GL_LIGHT0 0x4000
libs/rs/java/Film/res/raw/filmstrip.c +49 −52 Original line number Diff line number Diff line Loading @@ -14,6 +14,14 @@ typedef struct FilmScriptUserEnvRec { } FilmScriptUserEnv; */ #define POS_TRANSLATE 0 #define POS_ROTATE 1 #define POS_FOCUS 2 #define STATE_TRIANGLE_OFFSET_COUNT 0 #define STATE_LAST_FOCUS 1 // The script enviroment has 3 env allocations. // bank0: (r) The enviroment structure // bank1: (r) The position information Loading @@ -23,17 +31,9 @@ int main(int index) { int f1,f2,f3,f4, f5,f6,f7,f8, f9,f10,f11,f12, f13,f14,f15,f16; int g1,g2,g3,g4, g5,g6,g7,g8, g9,g10,g11,g12, g13,g14,g15,g16; float trans; float rot; int x; float focusPos; // float int focusID; int lastFocusID; int imgCount; trans = loadF(1, 0); rot = loadF(1, 1); float trans = loadF(1, POS_TRANSLATE); float rot = loadF(1, POS_ROTATE); matrixLoadScale(&f16, 2.f, 2.f, 2.f); matrixTranslate(&f16, 0.f, 0.f, trans); matrixRotate(&f16, 90.f, 0.f, 0.f, 1.f); Loading @@ -46,24 +46,18 @@ int main(int index) drawTriangleMesh(NAMED_mesh); //int imgId = 0; // Start of images. bindProgramFragmentStore(NAMED_PFImages); bindProgramFragment(NAMED_PFSImages); bindProgramVertex(NAMED_PVImages); //focusPos = loadF(1, 2); //focusID = 0; //lastFocusID = loadI32(2, 0); //imgCount = 13; /* disable(GL_LIGHTING); float focusPos = loadF(1, POS_FOCUS); int focusID = 0; int lastFocusID = loadI32(2, STATE_LAST_FOCUS); int imgCount = 13; if (trans > (-.3)) { focusID = -1.0 - focusPos; if (trans > (-.3f)) { focusID = -1.0f - focusPos; if (focusID >= imgCount) { focusID = -1; } Loading @@ -71,6 +65,7 @@ int main(int index) focusID = -1; } /* if (focusID != lastFocusID) { if (lastFocusID >= 0) { uploadToTexture(con, env->tex[lastFocusID], 1); Loading @@ -79,36 +74,38 @@ int main(int index) uploadToTexture(con, env->tex[focusID], 0); } } storeEnvI32(con, 2, 0, focusID); */ storeI32(2, STATE_LAST_FOCUS, focusID); int triangleOffsetsCount = loadI32(2, STATE_TRIANGLE_OFFSET_COUNT); int imgId = 0; for (imgId=1; imgId <= imgCount; imgId++) { float pos = focusPos + imgId + .4f; int offset = (int)floor(pos*2); pos -= 0.75; float pos = focusPos + imgId + 0.4f; int offset = (int)floorf(pos * 2.f); pos = pos - 0.75f; offset += env->triangleOffsetsCount / 2; if ((offset < 0) || (offset >= env->triangleOffsetsCount)) { continue; } offset = offset + triangleOffsetsCount / 2; if (!((offset < 0) || (offset >= triangleOffsetsCount))) { int start = offset -2; int end = offset + 2; if (start < 0) { start = 0; } if (end > env->triangleOffsetsCount) { end = env->triangleOffsetsCount; if (end > triangleOffsetsCount) { end = triangleOffsetsCount; } programFragmentBindTexture(con, env->fpImages, 0, env->tex[imgId - 1]); bindTexture(NAMED_PFImages, 0, loadI32(0, imgId - 1)); /* matrixLoadTranslate(con, &m, -pos - env->triangleOffsetsTex[env->triangleOffsetsCount / 2], 0, 0); storeEnvMatrix(con, 3, RS_PROGRAM_VERTEX_TEXTURE_OFFSET, &m); renderTriangleMeshRange(con, env->mesh, env->triangleOffsets[start], env->triangleOffsets[end] - env->triangleOffsets[start]); } */ } } return 0; }