Loading graphics/java/android/renderscript/Allocation.java +9 −18 Original line number Diff line number Diff line Loading @@ -130,15 +130,6 @@ public class Allocation extends BaseObj { */ public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; /** * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE The allocation * will be used as a SurfaceTexture graphics consumer. This * usage may only be used with USAGE_GRAPHICS_TEXTURE. * * @hide */ public static final int USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020; /** * USAGE_IO_INPUT The allocation will be used as SurfaceTexture * consumer. This usage will cause the allocation to be created Loading @@ -146,7 +137,7 @@ public class Allocation extends BaseObj { * * @hide */ public static final int USAGE_IO_INPUT = 0x0040; public static final int USAGE_IO_INPUT = 0x0020; /** * USAGE_IO_OUTPUT The allocation will be used as a Loading @@ -155,7 +146,7 @@ public class Allocation extends BaseObj { * * @hide */ public static final int USAGE_IO_OUTPUT = 0x0080; public static final int USAGE_IO_OUTPUT = 0x0040; /** * Controls mipmap behavior when using the bitmap creation and Loading Loading @@ -217,17 +208,15 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_VERTEX | USAGE_GRAPHICS_CONSTANTS | USAGE_GRAPHICS_RENDER_TARGET | USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT | USAGE_IO_OUTPUT)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } if ((usage & (USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT)) != 0) { if ((usage & USAGE_IO_INPUT) != 0) { mWriteAllowed = false; if ((usage & ~(USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT | if ((usage & ~(USAGE_IO_INPUT | USAGE_GRAPHICS_TEXTURE | USAGE_SCRIPT)) != 0) { throw new RSIllegalArgumentException("Invalid usage combination."); Loading Loading @@ -348,7 +337,7 @@ public class Allocation extends BaseObj { public void ioGetInput() { if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSIllegalArgumentException( "Can only send buffer if IO_OUTPUT usage specified."); "Can only receive if IO_INPUT usage specified."); } mRS.validate(); mRS.nAllocationIoReceive(getID()); Loading Loading @@ -1134,13 +1123,15 @@ public class Allocation extends BaseObj { * */ public SurfaceTexture getSurfaceTexture() { if ((mUsage & USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) == 0) { if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSInvalidStateException("Allocation is not a surface texture."); } int id = mRS.nAllocationGetSurfaceTextureID(getID()); return new SurfaceTexture(id); SurfaceTexture st = new SurfaceTexture(id); mRS.nAllocationGetSurfaceTextureID2(getID(), st); return st; } /** Loading graphics/java/android/renderscript/RenderScript.java +6 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package android.renderscript; import java.lang.reflect.Field; import java.io.File; import java.lang.reflect.Field; import android.content.Context; import android.content.pm.ApplicationInfo; Loading Loading @@ -294,6 +294,11 @@ public class RenderScript { validate(); return rsnAllocationGetSurfaceTextureID(mContext, alloc); } native void rsnAllocationGetSurfaceTextureID2(int con, int alloc, SurfaceTexture st); synchronized void nAllocationGetSurfaceTextureID2(int alloc, SurfaceTexture st) { validate(); rsnAllocationGetSurfaceTextureID2(mContext, alloc, st); } native void rsnAllocationSetSurfaceTexture(int con, int alloc, SurfaceTexture sur); synchronized void nAllocationSetSurfaceTexture(int alloc, SurfaceTexture sur) { validate(); Loading graphics/jni/android_renderscript_RenderScript.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -476,6 +476,15 @@ nAllocationGetSurfaceTextureID(JNIEnv *_env, jobject _this, RsContext con, jint return rsAllocationGetSurfaceTextureID(con, (RsAllocation)a); } static void nAllocationGetSurfaceTextureID2(JNIEnv *_env, jobject _this, RsContext con, jint a, jobject jst) { LOG_API("nAllocationGetSurfaceTextureID2, con(%p), a(%p)", con, (RsAllocation)a); sp<SurfaceTexture> st = SurfaceTexture_getSurfaceTexture(_env, jst); rsAllocationGetSurfaceTextureID2(con, (RsAllocation)a, st.get(), sizeof(SurfaceTexture *)); } static void nAllocationSetSurfaceTexture(JNIEnv *_env, jobject _this, RsContext con, RsAllocation alloc, jobject sur) Loading Loading @@ -1352,6 +1361,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, {"rsnAllocationGetSurfaceTextureID", "(II)I", (void*)nAllocationGetSurfaceTextureID }, {"rsnAllocationGetSurfaceTextureID2","(IILandroid/graphics/SurfaceTexture;)V",(void*)nAllocationGetSurfaceTextureID2 }, {"rsnAllocationSetSurfaceTexture", "(IILandroid/graphics/SurfaceTexture;)V",(void*)nAllocationSetSurfaceTexture }, {"rsnAllocationIoSend", "(II)V", (void*)nAllocationIoSend }, {"rsnAllocationIoReceive", "(II)V", (void*)nAllocationIoReceive }, Loading libs/rs/Allocation.cpp +3 −6 Original line number Diff line number Diff line /* * Copyright (C) 2008-2012 The Android Open Source Project * Copyright (C) 2012 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. Loading Loading @@ -51,17 +51,14 @@ Allocation::Allocation(void *id, RenderScript *rs, const Type *t, uint32_t usage RS_ALLOCATION_USAGE_GRAPHICS_VERTEX | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS | RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET | RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | RS_ALLOCATION_USAGE_IO_INPUT | RS_ALLOCATION_USAGE_IO_OUTPUT)) != 0) { ALOGE("Unknown usage specified."); } if ((usage & (RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | RS_ALLOCATION_USAGE_IO_INPUT)) != 0) { if ((usage & RS_ALLOCATION_USAGE_IO_INPUT) != 0) { mWriteAllowed = false; if ((usage & ~(RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | RS_ALLOCATION_USAGE_IO_INPUT | if ((usage & ~(RS_ALLOCATION_USAGE_IO_INPUT | RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE | RS_ALLOCATION_USAGE_SCRIPT)) != 0) { ALOGE("Invalid usage combination."); Loading libs/rs/driver/rsdAllocation.cpp +5 −3 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2011-2012 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. Loading Loading @@ -27,6 +27,7 @@ #include "hardware/gralloc.h" #include "ui/Rect.h" #include "ui/GraphicBufferMapper.h" #include "gui/SurfaceTexture.h" #include <GLES/gl.h> #include <GLES2/gl2.h> Loading Loading @@ -139,7 +140,7 @@ static void Upload2DTexture(const Context *rsc, const Allocation *alloc, bool is static void UploadToTexture(const Context *rsc, const Allocation *alloc) { DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv; if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) { if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_INPUT) { if (!drv->textureID) { RSD_CALL_GL(glGenTextures, 1, &drv->textureID); } Loading Loading @@ -475,7 +476,8 @@ void rsdAllocationIoSend(const Context *rsc, Allocation *alloc) { } void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) { ALOGE("not implemented"); DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv; alloc->mHal.state.surfaceTexture->updateTexImage(); } Loading Loading
graphics/java/android/renderscript/Allocation.java +9 −18 Original line number Diff line number Diff line Loading @@ -130,15 +130,6 @@ public class Allocation extends BaseObj { */ public static final int USAGE_GRAPHICS_RENDER_TARGET = 0x0010; /** * USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE The allocation * will be used as a SurfaceTexture graphics consumer. This * usage may only be used with USAGE_GRAPHICS_TEXTURE. * * @hide */ public static final int USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE = 0x0020; /** * USAGE_IO_INPUT The allocation will be used as SurfaceTexture * consumer. This usage will cause the allocation to be created Loading @@ -146,7 +137,7 @@ public class Allocation extends BaseObj { * * @hide */ public static final int USAGE_IO_INPUT = 0x0040; public static final int USAGE_IO_INPUT = 0x0020; /** * USAGE_IO_OUTPUT The allocation will be used as a Loading @@ -155,7 +146,7 @@ public class Allocation extends BaseObj { * * @hide */ public static final int USAGE_IO_OUTPUT = 0x0080; public static final int USAGE_IO_OUTPUT = 0x0040; /** * Controls mipmap behavior when using the bitmap creation and Loading Loading @@ -217,17 +208,15 @@ public class Allocation extends BaseObj { USAGE_GRAPHICS_VERTEX | USAGE_GRAPHICS_CONSTANTS | USAGE_GRAPHICS_RENDER_TARGET | USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT | USAGE_IO_OUTPUT)) != 0) { throw new RSIllegalArgumentException("Unknown usage specified."); } if ((usage & (USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT)) != 0) { if ((usage & USAGE_IO_INPUT) != 0) { mWriteAllowed = false; if ((usage & ~(USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | USAGE_IO_INPUT | if ((usage & ~(USAGE_IO_INPUT | USAGE_GRAPHICS_TEXTURE | USAGE_SCRIPT)) != 0) { throw new RSIllegalArgumentException("Invalid usage combination."); Loading Loading @@ -348,7 +337,7 @@ public class Allocation extends BaseObj { public void ioGetInput() { if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSIllegalArgumentException( "Can only send buffer if IO_OUTPUT usage specified."); "Can only receive if IO_INPUT usage specified."); } mRS.validate(); mRS.nAllocationIoReceive(getID()); Loading Loading @@ -1134,13 +1123,15 @@ public class Allocation extends BaseObj { * */ public SurfaceTexture getSurfaceTexture() { if ((mUsage & USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) == 0) { if ((mUsage & USAGE_IO_INPUT) == 0) { throw new RSInvalidStateException("Allocation is not a surface texture."); } int id = mRS.nAllocationGetSurfaceTextureID(getID()); return new SurfaceTexture(id); SurfaceTexture st = new SurfaceTexture(id); mRS.nAllocationGetSurfaceTextureID2(getID(), st); return st; } /** Loading
graphics/java/android/renderscript/RenderScript.java +6 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ package android.renderscript; import java.lang.reflect.Field; import java.io.File; import java.lang.reflect.Field; import android.content.Context; import android.content.pm.ApplicationInfo; Loading Loading @@ -294,6 +294,11 @@ public class RenderScript { validate(); return rsnAllocationGetSurfaceTextureID(mContext, alloc); } native void rsnAllocationGetSurfaceTextureID2(int con, int alloc, SurfaceTexture st); synchronized void nAllocationGetSurfaceTextureID2(int alloc, SurfaceTexture st) { validate(); rsnAllocationGetSurfaceTextureID2(mContext, alloc, st); } native void rsnAllocationSetSurfaceTexture(int con, int alloc, SurfaceTexture sur); synchronized void nAllocationSetSurfaceTexture(int alloc, SurfaceTexture sur) { validate(); Loading
graphics/jni/android_renderscript_RenderScript.cpp +11 −1 Original line number Diff line number Diff line Loading @@ -476,6 +476,15 @@ nAllocationGetSurfaceTextureID(JNIEnv *_env, jobject _this, RsContext con, jint return rsAllocationGetSurfaceTextureID(con, (RsAllocation)a); } static void nAllocationGetSurfaceTextureID2(JNIEnv *_env, jobject _this, RsContext con, jint a, jobject jst) { LOG_API("nAllocationGetSurfaceTextureID2, con(%p), a(%p)", con, (RsAllocation)a); sp<SurfaceTexture> st = SurfaceTexture_getSurfaceTexture(_env, jst); rsAllocationGetSurfaceTextureID2(con, (RsAllocation)a, st.get(), sizeof(SurfaceTexture *)); } static void nAllocationSetSurfaceTexture(JNIEnv *_env, jobject _this, RsContext con, RsAllocation alloc, jobject sur) Loading Loading @@ -1352,6 +1361,7 @@ static JNINativeMethod methods[] = { {"rsnAllocationSyncAll", "(III)V", (void*)nAllocationSyncAll }, {"rsnAllocationGetSurfaceTextureID", "(II)I", (void*)nAllocationGetSurfaceTextureID }, {"rsnAllocationGetSurfaceTextureID2","(IILandroid/graphics/SurfaceTexture;)V",(void*)nAllocationGetSurfaceTextureID2 }, {"rsnAllocationSetSurfaceTexture", "(IILandroid/graphics/SurfaceTexture;)V",(void*)nAllocationSetSurfaceTexture }, {"rsnAllocationIoSend", "(II)V", (void*)nAllocationIoSend }, {"rsnAllocationIoReceive", "(II)V", (void*)nAllocationIoReceive }, Loading
libs/rs/Allocation.cpp +3 −6 Original line number Diff line number Diff line /* * Copyright (C) 2008-2012 The Android Open Source Project * Copyright (C) 2012 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. Loading Loading @@ -51,17 +51,14 @@ Allocation::Allocation(void *id, RenderScript *rs, const Type *t, uint32_t usage RS_ALLOCATION_USAGE_GRAPHICS_VERTEX | RS_ALLOCATION_USAGE_GRAPHICS_CONSTANTS | RS_ALLOCATION_USAGE_GRAPHICS_RENDER_TARGET | RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | RS_ALLOCATION_USAGE_IO_INPUT | RS_ALLOCATION_USAGE_IO_OUTPUT)) != 0) { ALOGE("Unknown usage specified."); } if ((usage & (RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | RS_ALLOCATION_USAGE_IO_INPUT)) != 0) { if ((usage & RS_ALLOCATION_USAGE_IO_INPUT) != 0) { mWriteAllowed = false; if ((usage & ~(RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE | RS_ALLOCATION_USAGE_IO_INPUT | if ((usage & ~(RS_ALLOCATION_USAGE_IO_INPUT | RS_ALLOCATION_USAGE_GRAPHICS_TEXTURE | RS_ALLOCATION_USAGE_SCRIPT)) != 0) { ALOGE("Invalid usage combination."); Loading
libs/rs/driver/rsdAllocation.cpp +5 −3 Original line number Diff line number Diff line /* * Copyright (C) 2011 The Android Open Source Project * Copyright (C) 2011-2012 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. Loading Loading @@ -27,6 +27,7 @@ #include "hardware/gralloc.h" #include "ui/Rect.h" #include "ui/GraphicBufferMapper.h" #include "gui/SurfaceTexture.h" #include <GLES/gl.h> #include <GLES2/gl2.h> Loading Loading @@ -139,7 +140,7 @@ static void Upload2DTexture(const Context *rsc, const Allocation *alloc, bool is static void UploadToTexture(const Context *rsc, const Allocation *alloc) { DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv; if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_GRAPHICS_SURFACE_TEXTURE_INPUT_OPAQUE) { if (alloc->mHal.state.usageFlags & RS_ALLOCATION_USAGE_IO_INPUT) { if (!drv->textureID) { RSD_CALL_GL(glGenTextures, 1, &drv->textureID); } Loading Loading @@ -475,7 +476,8 @@ void rsdAllocationIoSend(const Context *rsc, Allocation *alloc) { } void rsdAllocationIoReceive(const Context *rsc, Allocation *alloc) { ALOGE("not implemented"); DrvAllocation *drv = (DrvAllocation *)alloc->mHal.drv; alloc->mHal.state.surfaceTexture->updateTexImage(); } Loading