Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33287e8a authored by Miao Wang's avatar Miao Wang
Browse files

[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
parent 3e640036
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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 \
+5 −4
Original line number Original line Diff line number Diff line
@@ -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>
@@ -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