Adds option to use tensor_ahwb in Android vendor processes
PiperOrigin-RevId: 558086646
This commit is contained in:
parent
a04a3a1c81
commit
fda0d19337
|
@ -427,6 +427,17 @@ cc_test(
|
|||
],
|
||||
)
|
||||
|
||||
# Used by vendor processes that don't have access to libandroid.so, but want to use AHardwareBuffer.
|
||||
config_setting(
|
||||
name = "android_link_native_window",
|
||||
define_values = {
|
||||
"MEDIAPIPE_ANDROID_LINK_NATIVE_WINDOW": "1",
|
||||
"MEDIAPIPE_NO_JNI": "1",
|
||||
},
|
||||
values = {"crosstool_top": "//external:android/crosstool"},
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tensor",
|
||||
srcs =
|
||||
|
@ -449,7 +460,13 @@ cc_library(
|
|||
"//conditions:default": [],
|
||||
}),
|
||||
defines = select({
|
||||
# Excludes AHardwareBuffer features from vendor processes
|
||||
"//mediapipe/framework:android_no_jni": ["MEDIAPIPE_NO_JNI"],
|
||||
# unless they're linked against nativewindow.
|
||||
":android_link_native_window": [
|
||||
"MEDIAPIPE_ANDROID_LINK_NATIVE_WINDOW",
|
||||
"MEDIAPIPE_NO_JNI",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
linkopts = select({
|
||||
|
@ -462,6 +479,9 @@ cc_library(
|
|||
"//mediapipe:android": [
|
||||
"-landroid",
|
||||
],
|
||||
":android_link_native_window": [
|
||||
"-lnativewindow", # Provides <android/hardware_buffer.h> to vendor processes on Android API >= 26.
|
||||
],
|
||||
}),
|
||||
deps = [
|
||||
"//mediapipe/framework:port",
|
||||
|
|
|
@ -29,12 +29,16 @@
|
|||
#include "mediapipe/framework/formats/tensor/internal.h"
|
||||
#include "mediapipe/framework/port.h"
|
||||
|
||||
#ifndef MEDIAPIPE_NO_JNI
|
||||
// Supported use cases for tensor_ahwb:
|
||||
// 1. Native code running in Android apps.
|
||||
// 2. Android vendor processes linked against nativewindow.
|
||||
#if !defined(MEDIAPIPE_NO_JNI) || defined(MEDIAPIPE_ANDROID_LINK_NATIVE_WINDOW)
|
||||
#if __ANDROID_API__ >= 26 || defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
|
||||
#define MEDIAPIPE_TENSOR_USE_AHWB 1
|
||||
#endif // __ANDROID_API__ >= 26 ||
|
||||
// defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
|
||||
#endif // MEDIAPIPE_NO_JNI
|
||||
#endif // !defined(MEDIAPIPE_NO_JNI) ||
|
||||
// defined(MEDIAPIPE_ANDROID_LINK_NATIVE_WINDOW)
|
||||
|
||||
#ifdef MEDIAPIPE_TENSOR_USE_AHWB
|
||||
#include <EGL/egl.h>
|
||||
|
|
Loading…
Reference in New Issue
Block a user