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

Commit cbb0206c authored by Miao Wang's avatar Miao Wang
Browse files

Update RenderScript JNI code for Treble

  - Include rsApiStubs.h instead of rs.h, and remove unused
  dependencies for rs.h in Android.mk.
  - Remove libRSDriver.so from LOCAL_REQUIRED_MODULE, since it is not
  required nor directly used by librs_jni.so.
  - Fix the discrepancy in ElementGetNativeData and
  ElementGetSubElements, respective to NDK APIs exposed in libRS.so.

  rsApiStubs.h contains all public RenderScript APIs exposed in libRS.so.
  It fixes the mismatch of the declarations and definitions of the two
  functions mentioned above. And it does not rely on the auto generated
  header (rsgApiFuncDecl.h) anymore.

Bug: 34396220
Test: mm
Merged-In: Iedb1b976cfa9033dccefe78cbe80c8022f990e53
Change-Id: Iedb1b976cfa9033dccefe78cbe80c8022f990e53
parent 6d198966
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -19,22 +19,17 @@ LOCAL_SHARED_LIBRARIES := \

LOCAL_STATIC_LIBRARIES :=

rs_generated_include_dir := $(call intermediates-dir-for,SHARED_LIBRARIES,libRS,,)

LOCAL_C_INCLUDES += \
    $(JNI_H_INCLUDE) \
    frameworks/rs \
    frameworks/base/core/jni \
    frameworks/base/libs/hwui \
    $(rs_generated_include_dir)
    frameworks/base/libs/hwui

LOCAL_CFLAGS += -Wno-unused-parameter
LOCAL_CFLAGS += -Wall -Werror -Wunused -Wunreachable-code

LOCAL_ADDITIONAL_DEPENDENCIES := $(addprefix $(rs_generated_include_dir)/,rsgApiFuncDecl.h)
LOCAL_MODULE:= librs_jni
LOCAL_ADDITIONAL_DEPENDENCIES += $(rs_generated_source)
LOCAL_MODULE_TAGS := optional
LOCAL_REQUIRED_MODULES := libRS libRSDriver
LOCAL_REQUIRED_MODULES := libRS

include $(BUILD_SHARED_LIBRARY)
+3 −3
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@
#include "android_runtime/android_util_AssetManager.h"
#include "android/graphics/GraphicsJNI.h"

#include <rs.h>
#include <rsEnv.h>
#include <rsApiStubs.h>
#include <gui/Surface.h>
#include <gui/GLConsumer.h>
#include <android_runtime/android_graphics_SurfaceTexture.h>
@@ -1134,7 +1134,7 @@ nElementGetNativeData(JNIEnv *_env, jobject _this, jlong con, jlong id, jintArra
    // we will pack mType; mKind; mNormalized; mVectorSize; NumSubElements
    assert(dataSize == 5);

    uintptr_t elementData[5];
    uint32_t elementData[5];
    rsaElementGetNativeData((RsContext)con, (RsElement)id, elementData, dataSize);

    for(jint i = 0; i < dataSize; i ++) {
@@ -1157,7 +1157,7 @@ nElementGetSubElements(JNIEnv *_env, jobject _this, jlong con, jlong id,

    uintptr_t *ids = (uintptr_t*)malloc(dataSize * sizeof(uintptr_t));
    const char **names = (const char **)malloc(dataSize * sizeof(const char *));
    uint32_t *arraySizes = (uint32_t *)malloc(dataSize * sizeof(uint32_t));
    size_t *arraySizes = (size_t *)malloc(dataSize * sizeof(size_t));

    rsaElementGetSubElements((RsContext)con, (RsElement)id, ids, names, arraySizes,
                             (uint32_t)dataSize);