2023-01-30 11:38:52 -07:00
|
|
|
project(VisionCamera)
|
2023-02-13 07:22:45 -07:00
|
|
|
cmake_minimum_required(VERSION 3.9.0)
|
2021-06-27 04:37:54 -06:00
|
|
|
|
2023-02-13 07:22:45 -07:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
set(PACKAGE_NAME "VisionCamera")
|
|
|
|
set(BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
|
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2023-01-30 11:38:52 -07:00
|
|
|
|
2023-02-13 07:22:45 -07:00
|
|
|
# Third party libraries (Prefabs)
|
2023-02-08 09:48:22 -07:00
|
|
|
find_package(ReactAndroid REQUIRED CONFIG)
|
2023-02-13 07:22:45 -07:00
|
|
|
find_package(fbjni REQUIRED CONFIG)
|
|
|
|
find_library(LOG_LIB log)
|
2021-06-27 04:37:54 -06:00
|
|
|
|
2023-09-01 02:43:19 -06:00
|
|
|
add_definitions(-DVISION_CAMERA_ENABLE_FRAME_PROCESSORS=${ENABLE_FRAME_PROCESSORS} -DVISION_CAMERA_ENABLE_SKIA=${ENABLE_SKIA} -DEGL_EGLEXT_PROTOTYPES=1)
|
2023-05-04 04:30:24 -06:00
|
|
|
|
2023-08-21 04:50:14 -06:00
|
|
|
|
2023-02-13 07:22:45 -07:00
|
|
|
# Add react-native-vision-camera sources
|
2021-06-27 04:37:54 -06:00
|
|
|
add_library(
|
|
|
|
${PACKAGE_NAME}
|
|
|
|
SHARED
|
2023-02-21 07:00:48 -07:00
|
|
|
../cpp/JSITypedArray.cpp
|
2023-07-21 16:15:11 -06:00
|
|
|
src/main/cpp/VisionCamera.cpp
|
2023-08-29 09:52:03 -06:00
|
|
|
src/main/cpp/VideoPipeline.cpp
|
|
|
|
src/main/cpp/PassThroughShader.cpp
|
|
|
|
src/main/cpp/OpenGLContext.cpp
|
|
|
|
src/main/cpp/OpenGLRenderer.cpp
|
2023-08-25 04:22:44 -06:00
|
|
|
# Frame Processor
|
|
|
|
src/main/cpp/frameprocessor/FrameHostObject.cpp
|
|
|
|
src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp
|
|
|
|
src/main/cpp/frameprocessor/JSIJNIConversion.cpp
|
|
|
|
src/main/cpp/frameprocessor/VisionCameraProxy.cpp
|
|
|
|
src/main/cpp/frameprocessor/java-bindings/JFrame.cpp
|
|
|
|
src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp
|
|
|
|
src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp
|
|
|
|
src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp
|
|
|
|
src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.cpp
|
|
|
|
# Skia Frame Processor
|
2023-08-21 04:50:14 -06:00
|
|
|
src/main/cpp/skia/SkiaRenderer.cpp
|
2023-09-01 02:43:19 -06:00
|
|
|
src/main/cpp/skia/JSkiaFrameProcessor.cpp
|
|
|
|
src/main/cpp/skia/DrawableFrameHostObject.cpp
|
|
|
|
src/main/cpp/skia/VisionCameraSkiaContext.cpp
|
2021-06-27 04:37:54 -06:00
|
|
|
)
|
|
|
|
|
2023-02-13 07:22:45 -07:00
|
|
|
# Header Search Paths (includes)
|
2023-02-08 09:48:22 -07:00
|
|
|
target_include_directories(
|
|
|
|
${PACKAGE_NAME}
|
|
|
|
PRIVATE
|
2023-02-21 07:00:48 -07:00
|
|
|
"../cpp"
|
2023-02-13 07:22:45 -07:00
|
|
|
"src/main/cpp"
|
2023-08-25 04:22:44 -06:00
|
|
|
"src/main/cpp/frameprocessor"
|
|
|
|
"src/main/cpp/frameprocessor/java-bindings"
|
|
|
|
"src/main/cpp/skia"
|
2023-09-01 02:43:19 -06:00
|
|
|
"src/main/cpp/skia/java-bindings"
|
2023-02-08 09:48:22 -07:00
|
|
|
"${NODE_MODULES_DIR}/react-native/ReactCommon"
|
|
|
|
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
|
2023-02-13 07:22:45 -07:00
|
|
|
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/react/turbomodule" # <-- CallInvokerHolder JNI wrapper
|
2021-10-07 03:16:19 -06:00
|
|
|
)
|
|
|
|
|
2023-02-13 07:22:45 -07:00
|
|
|
# Link everything together
|
2021-07-23 06:28:38 -06:00
|
|
|
target_link_libraries(
|
|
|
|
${PACKAGE_NAME}
|
2023-02-13 07:22:45 -07:00
|
|
|
${LOG_LIB} # <-- Logcat logger
|
|
|
|
android # <-- Android JNI core
|
|
|
|
ReactAndroid::jsi # <-- RN: JSI
|
|
|
|
ReactAndroid::reactnativejni # <-- RN: React Native JNI bindings
|
|
|
|
fbjni::fbjni # <-- fbjni
|
2021-07-30 01:50:09 -06:00
|
|
|
)
|
2023-08-23 04:42:38 -06:00
|
|
|
|
|
|
|
# Optionally also add Frame Processors here
|
|
|
|
if(ENABLE_FRAME_PROCESSORS)
|
|
|
|
find_package(react-native-worklets-core REQUIRED CONFIG)
|
|
|
|
target_link_libraries(
|
|
|
|
${PACKAGE_NAME}
|
|
|
|
react-native-worklets-core::rnworklets
|
|
|
|
)
|
|
|
|
message("VisionCamera: Frame Processors enabled!")
|
|
|
|
|
|
|
|
# Optionally also add Skia Integration here
|
|
|
|
if(ENABLE_SKIA)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSK_GL -DSK_GANESH -DSK_BUILD_FOR_ANDROID")
|
|
|
|
|
|
|
|
find_package(shopify_react-native-skia REQUIRED CONFIG)
|
|
|
|
|
|
|
|
set(SKIA_PACKAGE shopify_react-native-skia::rnskia)
|
|
|
|
set(RNSKIA_PATH ${NODE_MODULES_DIR}/@shopify/react-native-skia)
|
|
|
|
set (SKIA_LIBS_PATH "${RNSKIA_PATH}/libs/android/${ANDROID_ABI}")
|
|
|
|
add_library(skia STATIC IMPORTED)
|
|
|
|
set_property(TARGET skia PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libskia.a")
|
|
|
|
add_library(svg STATIC IMPORTED)
|
|
|
|
set_property(TARGET svg PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libsvg.a")
|
|
|
|
add_library(skshaper STATIC IMPORTED)
|
|
|
|
set_property(TARGET skshaper PROPERTY IMPORTED_LOCATION "${SKIA_LIBS_PATH}/libskshaper.a")
|
|
|
|
|
|
|
|
# We need to include the headers from skia
|
|
|
|
# (Note: rnskia includes all their files without any relative path
|
|
|
|
# so for example "include/core/SkImage.h" becomes #include "SkImage.h".
|
|
|
|
# That's why for the prefab of rnskia, we flatten all cpp files into
|
|
|
|
# just one directory. HOWEVER, skia itself uses relative paths in
|
|
|
|
# their include statements, and so we have to include the path to skia)
|
|
|
|
target_include_directories(
|
|
|
|
${PACKAGE_NAME}
|
|
|
|
PRIVATE
|
2023-09-01 02:43:19 -06:00
|
|
|
"${RNSKIA_PATH}/cpp/api/"
|
|
|
|
"${RNSKIA_PATH}/cpp/jsi/"
|
|
|
|
"${RNSKIA_PATH}/cpp/rnskia/"
|
2023-08-23 04:42:38 -06:00
|
|
|
"${RNSKIA_PATH}/cpp/skia"
|
2023-09-01 02:43:19 -06:00
|
|
|
"${RNSKIA_PATH}/cpp/skia/include/"
|
2023-08-23 04:42:38 -06:00
|
|
|
"${RNSKIA_PATH}/cpp/skia/include/config/"
|
|
|
|
"${RNSKIA_PATH}/cpp/skia/include/core/"
|
|
|
|
"${RNSKIA_PATH}/cpp/skia/include/effects/"
|
|
|
|
"${RNSKIA_PATH}/cpp/skia/include/utils/"
|
|
|
|
"${RNSKIA_PATH}/cpp/skia/include/pathops/"
|
|
|
|
"${RNSKIA_PATH}/cpp/skia/modules/"
|
2023-09-01 02:43:19 -06:00
|
|
|
"${RNSKIA_PATH}/cpp/utils/"
|
2023-08-23 04:42:38 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
${PACKAGE_NAME}
|
|
|
|
GLESv2 # <-- Optional: OpenGL (for Skia)
|
|
|
|
EGL # <-- Optional: OpenGL (EGL) (for Skia)
|
|
|
|
${SKIA_PACKAGE} # <-- Optional: RN Skia
|
|
|
|
jnigraphics
|
|
|
|
skia
|
|
|
|
svg
|
|
|
|
skshaper
|
|
|
|
)
|
|
|
|
|
|
|
|
message("VisionCamera: Skia enabled!")
|
|
|
|
endif()
|
|
|
|
endif()
|