Merge changes from topic 'USAGE_IO_INPUT'

* changes:
  [RenderScript] Update RenderScript JNI with the corresponding AllocationGetSurface driver implementation change.
  [RenderScript] Use ANativeWindow_fromSurface to get ANativeWindow from Java Surface.
This commit is contained in:
Miao Wang
2017-03-09 20:38:48 +00:00
committed by Gerrit Code Review
2 changed files with 10 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ LOCAL_SRC_FILES:= \
android_renderscript_RenderScript.cpp android_renderscript_RenderScript.cpp
LOCAL_SHARED_LIBRARIES := \ LOCAL_SHARED_LIBRARIES := \
libandroid \
libandroid_runtime \ libandroid_runtime \
libandroidfw \ libandroidfw \
libnativehelper \ libnativehelper \

View File

@@ -34,6 +34,8 @@
#include "android_runtime/android_view_Surface.h" #include "android_runtime/android_view_Surface.h"
#include "android_runtime/android_util_AssetManager.h" #include "android_runtime/android_util_AssetManager.h"
#include "android/graphics/GraphicsJNI.h" #include "android/graphics/GraphicsJNI.h"
#include "android/native_window.h"
#include "android/native_window_jni.h"
#include <rsEnv.h> #include <rsEnv.h>
#include <rsApiStubs.h> #include <rsApiStubs.h>
@@ -1264,10 +1266,10 @@ nAllocationGetSurface(JNIEnv *_env, jobject _this, jlong con, jlong a)
ALOGD("nAllocationGetSurface, con(%p), a(%p)", (RsContext)con, (RsAllocation)a); ALOGD("nAllocationGetSurface, con(%p), a(%p)", (RsContext)con, (RsAllocation)a);
} }
IGraphicBufferProducer *v = (IGraphicBufferProducer *)rsAllocationGetSurface((RsContext)con, ANativeWindow *anw = (ANativeWindow *)rsAllocationGetSurface((RsContext)con, (RsAllocation)a);
(RsAllocation)a);
sp<IGraphicBufferProducer> bp = v; sp<Surface> surface(static_cast<Surface*>(anw));
v->decStrong(nullptr); sp<IGraphicBufferProducer> bp = surface->getIGraphicBufferProducer();
jobject o = android_view_Surface_createFromIGraphicBufferProducer(_env, bp); jobject o = android_view_Surface_createFromIGraphicBufferProducer(_env, bp);
return o; return o;
@@ -1281,13 +1283,12 @@ nAllocationSetSurface(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobje
(RsAllocation)alloc, (Surface *)sur); (RsAllocation)alloc, (Surface *)sur);
} }
sp<Surface> s; ANativeWindow *anw = nullptr;
if (sur != 0) { if (sur != 0) {
s = android_view_Surface_getSurface(_env, sur); anw = ANativeWindow_fromSurface(_env, sur);
} }
rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, anw);
static_cast<ANativeWindow *>(s.get()));
} }
static void static void