summaryrefslogtreecommitdiff
path: root/rs/jni/android_renderscript_RenderScript.cpp
diff options
context:
space:
mode:
authorMiao Wang <miaowang@google.com>2017-03-06 09:31:32 -0800
committerMiao Wang <miaowang@google.com>2017-03-06 09:59:06 -0800
commit33287e8a893821be86b395ce9d5d639cc8a535f3 (patch)
tree06db8ebec71e90827c21741aa02d2b6289c61835 /rs/jni/android_renderscript_RenderScript.cpp
parent3e64003641c376573f4809aae79febd0187be81e (diff)
[RenderScript] Use ANativeWindow_fromSurface to get ANativeWindow
from Java Surface. - ANativeWindow_fromSurface and ANativeWindow_release has to be used in pairs to avoid leaks. Bug: 34396220 Test: mm, CTS tests pass. Change-Id: Id67fd005a056df4d496a48f705d445a2d8c45232
Diffstat (limited to 'rs/jni/android_renderscript_RenderScript.cpp')
-rw-r--r--rs/jni/android_renderscript_RenderScript.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index 2300da32d355..c663255d3315 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -34,6 +34,8 @@
#include "android_runtime/android_view_Surface.h"
#include "android_runtime/android_util_AssetManager.h"
#include "android/graphics/GraphicsJNI.h"
+#include "android/native_window.h"
+#include "android/native_window_jni.h"
#include <rsEnv.h>
#include <rsApiStubs.h>
@@ -1281,13 +1283,12 @@ nAllocationSetSurface(JNIEnv *_env, jobject _this, jlong con, jlong alloc, jobje
(RsAllocation)alloc, (Surface *)sur);
}
- sp<Surface> s;
+ ANativeWindow *anw = nullptr;
if (sur != 0) {
- s = android_view_Surface_getSurface(_env, sur);
+ anw = ANativeWindow_fromSurface(_env, sur);
}
- rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc,
- static_cast<ANativeWindow *>(s.get()));
+ rsAllocationSetSurface((RsContext)con, (RsAllocation)alloc, anw);
}
static void