@elurjs/android 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/index.mjs +11 -0
- package/package.json +29 -4
- package/template/.gitkeep +0 -0
- package/template/app/build.gradle.kts +192 -0
- package/template/app/proguard-rules-elur.pro +12 -0
- package/template/app/proguard-rules.pro +3 -0
- package/template/app/src/main/AndroidManifest.xml +81 -0
- package/template/app/src/main/assets/oss-notices.txt +153 -0
- package/template/app/src/main/assets/tck_pixel.png +0 -0
- package/template/app/src/main/cpp/CMakeLists.txt +117 -0
- package/template/app/src/main/cpp/dlEncoder.h +117 -0
- package/template/app/src/main/cpp/dlEncoderJsi.cpp +315 -0
- package/template/app/src/main/cpp/dlEncoderQjs.cpp +394 -0
- package/template/app/src/main/cpp/dlOps.inc +145 -0
- package/template/app/src/main/cpp/elurBridge.cpp +1350 -0
- package/template/app/src/main/cpp/elurBridgeHermes.cpp +1294 -0
- package/template/app/src/main/cpp/elurSkia.cpp +287 -0
- package/template/app/src/main/cpp/elurSkiaTree.cpp +448 -0
- package/template/app/src/main/cpp/elurUiWorklet.cpp +1233 -0
- package/template/app/src/main/cpp/elurYoga.cpp +1060 -0
- package/template/app/src/main/cpp/elurYoga.h +82 -0
- package/template/app/src/main/cpp/hermes-libs/LICENSE +21 -0
- package/template/app/src/main/cpp/hermes-libs/arm64-v8a/libhermesvm.so +0 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/AsyncDebuggerAPI.h +276 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/CompileJS.h +97 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/DebuggerAPI.h +502 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/CrashManager.h +107 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/CtorConfig.h +145 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/DebuggerTypes.h +193 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/GCConfig.h +211 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/GCTripwireContext.h +40 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/HermesExport.h +14 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/JSOutOfMemoryError.h +27 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/RuntimeConfig.h +141 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/SamplingProfiler.h +270 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/RuntimeTaskRunner.h +64 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/SynthTrace.h +1566 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/SynthTraceParser.h +37 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/ThreadSafetyAnalysis.h +75 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/TimerStats.h +23 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/TraceInterpreter.h +334 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/TracingRuntime.h +328 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPAgent.h +131 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPDebugAPI.h +73 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/CallbackOStream.h +89 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/ConsoleMessage.h +135 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainAgent.h +280 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainCoordinator.h +137 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainAgent.h +107 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainState.h +140 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/HeapProfilerDomainAgent.h +71 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/JSONValueInterfaces.h +40 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageConverters.h +82 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageInterfaces.h +72 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypes.h +1279 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypesInlines.h +313 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/ProfilerDomainAgent.h +38 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectConverters.h +77 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectsTable.h +127 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/RuntimeDomainAgent.h +138 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/Dummy.h +24 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/Extensions.h +20 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/ExtensionsBytecode.h +23 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/Intrinsics.h +44 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/JSIUtils.h +123 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/TextEncoder.h +29 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribDummy.h +24 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribExtensions.h +23 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoder.h +30 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoderUtils.h +113 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/hermes.h +242 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/hermes_tracing.h +52 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIHelpers.h +295 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIRuntimeWrapper.h +25 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_abi.h +642 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_vtable.h +29 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/HermesSandboxRuntime.h +41 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_compiled.h +12 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled-impl.h +8516 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.h +137 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled-impl.h +3945 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.h +119 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-fb.h +124 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-impl.h +66 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt.h +456 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/JSIDynamic.h +26 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/decorator.h +1157 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/hermes-interfaces.h +242 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/instrumentation.h +132 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/jsi-inl.h +434 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/jsi.h +2266 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/jsilib.h +59 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/threadsafe.h +79 -0
- package/template/app/src/main/cpp/hermes-libs/jsi-impl/jsi.cpp +1111 -0
- package/template/app/src/main/cpp/hermes-libs/x86_64/libhermesvm.so +0 -0
- package/template/app/src/main/java/com/elur/universal/BinaryCodec.kt +121 -0
- package/template/app/src/main/java/com/elur/universal/DlDecoder.kt +260 -0
- package/template/app/src/main/java/com/elur/universal/DlOpsDecode.kt +158 -0
- package/template/app/src/main/java/com/elur/universal/ElurBoxDrawable.kt +161 -0
- package/template/app/src/main/java/com/elur/universal/ElurBridge.kt +238 -0
- package/template/app/src/main/java/com/elur/universal/ElurBridgeHermes.kt +223 -0
- package/template/app/src/main/java/com/elur/universal/ElurCanvasView.kt +202 -0
- package/template/app/src/main/java/com/elur/universal/ElurCryptoModule.kt +206 -0
- package/template/app/src/main/java/com/elur/universal/ElurCustomLayout.kt +185 -0
- package/template/app/src/main/java/com/elur/universal/ElurEditText.kt +17 -0
- package/template/app/src/main/java/com/elur/universal/ElurFontRegistry.kt +190 -0
- package/template/app/src/main/java/com/elur/universal/ElurHttpModule.kt +306 -0
- package/template/app/src/main/java/com/elur/universal/ElurImageService.kt +348 -0
- package/template/app/src/main/java/com/elur/universal/ElurLicensesActivity.kt +84 -0
- package/template/app/src/main/java/com/elur/universal/ElurListView.kt +954 -0
- package/template/app/src/main/java/com/elur/universal/ElurManifest.kt +117 -0
- package/template/app/src/main/java/com/elur/universal/ElurMetrics.kt +325 -0
- package/template/app/src/main/java/com/elur/universal/ElurModuleRegistrar.kt +14 -0
- package/template/app/src/main/java/com/elur/universal/ElurPermissionGate.kt +36 -0
- package/template/app/src/main/java/com/elur/universal/ElurRenderer.kt +6164 -0
- package/template/app/src/main/java/com/elur/universal/ElurRowYoga.kt +130 -0
- package/template/app/src/main/java/com/elur/universal/ElurScrollView.kt +240 -0
- package/template/app/src/main/java/com/elur/universal/ElurShellView.kt +117 -0
- package/template/app/src/main/java/com/elur/universal/ElurSkiaCanvasView.kt +162 -0
- package/template/app/src/main/java/com/elur/universal/ElurSkiaTreeRenderer.kt +968 -0
- package/template/app/src/main/java/com/elur/universal/ElurStateModule.kt +69 -0
- package/template/app/src/main/java/com/elur/universal/ElurSwipeDriver.kt +34 -0
- package/template/app/src/main/java/com/elur/universal/ElurTckModule.kt +99 -0
- package/template/app/src/main/java/com/elur/universal/ElurTextMeasure.kt +16 -0
- package/template/app/src/main/java/com/elur/universal/ElurTrace.kt +24 -0
- package/template/app/src/main/java/com/elur/universal/ElurUiModule.kt +48 -0
- package/template/app/src/main/java/com/elur/universal/ElurUiWorklet.kt +305 -0
- package/template/app/src/main/java/com/elur/universal/JsBridge.kt +67 -0
- package/template/app/src/main/java/com/elur/universal/JsThread.kt +189 -0
- package/template/app/src/main/java/com/elur/universal/MainActivity.kt +844 -0
- package/template/app/src/main/java/com/elur/universal/ModuleRegistry.kt +701 -0
- package/template/app/src/main/java/com/elur/universal/YogaRowScope.kt +97 -0
- package/template/app/src/main/res/values/ids.xml +10 -0
- package/template/app/src/main/res/values/strings.xml +8 -0
- package/template/app/src/main/res/values-es/strings.xml +5 -0
- package/template/app/src/main/res/xml/network_security_config.xml +10 -0
- package/template/build.gradle.kts +5 -0
- package/template/gradle/libs.versions.toml +12 -0
- package/template/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/template/gradle.properties +23 -0
- package/template/gradlew +251 -0
- package/template/gradlew.bat +94 -0
- package/template/settings.gradle.kts +32 -0
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
// elurSkiaTree.cpp — glue Android del render-tree compartido
|
|
2
|
+
// (native/skia-tree, propuesta skia-renderer-arbol fase 4). La lib es
|
|
3
|
+
// opt-in (surface:"custom" → carril Skia); sin ella el host cae a
|
|
4
|
+
// Platform Views con warn — misma regla que libelur-skia (ADR-0123).
|
|
5
|
+
//
|
|
6
|
+
// Superficie: ANativeWindow raster (lock→SkSurface::Raster→unlockAndPost).
|
|
7
|
+
// El path GPU (EGL+Ganesh) es fase posterior sobre este mismo glue —
|
|
8
|
+
// la policy de backend se decide aquí, no en Kotlin.
|
|
9
|
+
//
|
|
10
|
+
// Unidades: todo el árbol trabaja en unidades lógicas (dp) — el rect
|
|
11
|
+
// Yoga del stream, el hit-test y la medida comparten el espacio; el
|
|
12
|
+
// canvas se escala por density en nativeRender. Kotlin convierte
|
|
13
|
+
// MotionEvent px→dp antes de cruzar.
|
|
14
|
+
//
|
|
15
|
+
// Medida: el espejo Yoga del bridge (elur-bridge.so) invoca
|
|
16
|
+
// measureNode/baselineNode del objeto renderer — Kotlin los reenvía a
|
|
17
|
+
// nativeMeasure/nativeBaseline sobre este árbol (misma semántica que
|
|
18
|
+
// el hook del espejo en Linux).
|
|
19
|
+
|
|
20
|
+
#include <android/log.h>
|
|
21
|
+
#include <android/native_window.h>
|
|
22
|
+
#include <android/native_window_jni.h>
|
|
23
|
+
#include <jni.h>
|
|
24
|
+
#include <string.h>
|
|
25
|
+
|
|
26
|
+
#include "include/core/SkFontScanner.h"
|
|
27
|
+
#include "include/core/SkSurface.h"
|
|
28
|
+
#include "include/ports/SkFontMgr_android.h"
|
|
29
|
+
#include "include/ports/SkFontMgr_directory.h"
|
|
30
|
+
#include "include/ports/SkFontScanner_FreeType.h"
|
|
31
|
+
#include <skia-tree/elur_skia_tree.h>
|
|
32
|
+
|
|
33
|
+
#define LOGI(...) \
|
|
34
|
+
__android_log_print(ANDROID_LOG_INFO, "ElurSkiaTree", __VA_ARGS__)
|
|
35
|
+
#define LOGW(...) \
|
|
36
|
+
__android_log_print(ANDROID_LOG_WARN, "ElurSkiaTree", __VA_ARGS__)
|
|
37
|
+
|
|
38
|
+
namespace {
|
|
39
|
+
|
|
40
|
+
elur::skia::SkiaTree g_tree;
|
|
41
|
+
ANativeWindow *g_win = nullptr;
|
|
42
|
+
int g_winW = 0, g_winH = 0;
|
|
43
|
+
float g_density = 1.0f;
|
|
44
|
+
bool g_dirty = true;
|
|
45
|
+
|
|
46
|
+
sk_sp<SkFontMgr> makeFontMgr() {
|
|
47
|
+
// Fonts del sistema: resolución por familia + fallback de scripts.
|
|
48
|
+
// La variante NDK (API 29+) queda detrás de SkFontMgr_New_Android —
|
|
49
|
+
// minSdk 24 → la lectura de fonts.xml es la compatible aquí. El
|
|
50
|
+
// scanner no admite nullptr (fScanner se dereferencia al escanear
|
|
51
|
+
// las familias) — FreeType es el único enlazado en este build.
|
|
52
|
+
if (auto mgr = SkFontMgr_New_Android(nullptr, SkFontScanner_Make_FreeType()))
|
|
53
|
+
return mgr;
|
|
54
|
+
if (auto mgr = SkFontMgr_New_Custom_Directory("/system/fonts/"))
|
|
55
|
+
return mgr;
|
|
56
|
+
LOGW("fontmgr: sin fuentes de sistema — texto degradado");
|
|
57
|
+
return SkFontMgr::RefEmpty();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
} // namespace
|
|
61
|
+
|
|
62
|
+
extern "C" {
|
|
63
|
+
|
|
64
|
+
JNIEXPORT void JNICALL Java_com_elur_universal_ElurSkiaTreeRenderer_nativeInit(
|
|
65
|
+
JNIEnv *, jclass, jfloat density) {
|
|
66
|
+
g_density = density > 0 ? density : 1.0f;
|
|
67
|
+
g_tree.setFontMgr(makeFontMgr());
|
|
68
|
+
g_dirty = true;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
JNIEXPORT void JNICALL
|
|
72
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSetSurface(JNIEnv *env,
|
|
73
|
+
jclass,
|
|
74
|
+
jobject surface,
|
|
75
|
+
jint w, jint h) {
|
|
76
|
+
if (g_win)
|
|
77
|
+
ANativeWindow_release(g_win);
|
|
78
|
+
g_win = surface ? ANativeWindow_fromSurface(env, surface) : nullptr;
|
|
79
|
+
g_winW = w;
|
|
80
|
+
g_winH = h;
|
|
81
|
+
g_dirty = true;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
JNIEXPORT void JNICALL
|
|
85
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeReleaseSurface(JNIEnv *,
|
|
86
|
+
jclass) {
|
|
87
|
+
if (g_win) {
|
|
88
|
+
ANativeWindow_release(g_win);
|
|
89
|
+
g_win = nullptr;
|
|
90
|
+
}
|
|
91
|
+
g_winW = g_winH = 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── ops del DL (ya decodificadas en Kotlin — mismo vocabulario) ────
|
|
95
|
+
|
|
96
|
+
JNIEXPORT void JNICALL
|
|
97
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeCreateNode(JNIEnv *env,
|
|
98
|
+
jclass, jint id,
|
|
99
|
+
jstring type) {
|
|
100
|
+
const char *t = env->GetStringUTFChars(type, nullptr);
|
|
101
|
+
g_tree.createNode(id, t ? t : "");
|
|
102
|
+
if (t)
|
|
103
|
+
env->ReleaseStringUTFChars(type, t);
|
|
104
|
+
g_dirty = true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
JNIEXPORT void JNICALL
|
|
108
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeUpdateText(JNIEnv *env,
|
|
109
|
+
jclass, jint id,
|
|
110
|
+
jstring value) {
|
|
111
|
+
const char *v = env->GetStringUTFChars(value, nullptr);
|
|
112
|
+
g_tree.updateText(id, v ? v : "");
|
|
113
|
+
if (v)
|
|
114
|
+
env->ReleaseStringUTFChars(value, v);
|
|
115
|
+
g_dirty = true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
JNIEXPORT void JNICALL
|
|
119
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeUpdateStyle(
|
|
120
|
+
JNIEnv *env, jclass, jint id, jobjectArray keys, jbooleanArray isNum,
|
|
121
|
+
jdoubleArray nums, jobjectArray strs) {
|
|
122
|
+
jsize n = env->GetArrayLength(keys);
|
|
123
|
+
jboolean *numFlags = env->GetBooleanArrayElements(isNum, nullptr);
|
|
124
|
+
jdouble *numVals = env->GetDoubleArrayElements(nums, nullptr);
|
|
125
|
+
for (jsize i = 0; i < n; i++) {
|
|
126
|
+
auto key = (jstring)env->GetObjectArrayElement(keys, i);
|
|
127
|
+
auto str = (jstring)env->GetObjectArrayElement(strs, i);
|
|
128
|
+
const char *k = key ? env->GetStringUTFChars(key, nullptr) : nullptr;
|
|
129
|
+
const char *s = str ? env->GetStringUTFChars(str, nullptr) : nullptr;
|
|
130
|
+
g_tree.setStyle(id, k ? k : "", numFlags[i] ? true : false, numVals[i],
|
|
131
|
+
s ? s : "");
|
|
132
|
+
if (k)
|
|
133
|
+
env->ReleaseStringUTFChars(key, k);
|
|
134
|
+
if (s)
|
|
135
|
+
env->ReleaseStringUTFChars(str, s);
|
|
136
|
+
if (key)
|
|
137
|
+
env->DeleteLocalRef(key);
|
|
138
|
+
if (str)
|
|
139
|
+
env->DeleteLocalRef(str);
|
|
140
|
+
}
|
|
141
|
+
env->ReleaseDoubleArrayElements(nums, numVals, JNI_ABORT);
|
|
142
|
+
env->ReleaseBooleanArrayElements(isNum, numFlags, JNI_ABORT);
|
|
143
|
+
g_dirty = true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
JNIEXPORT void JNICALL
|
|
147
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSetProp(JNIEnv *env, jclass,
|
|
148
|
+
jint id, jstring key,
|
|
149
|
+
jstring flat) {
|
|
150
|
+
const char *k = env->GetStringUTFChars(key, nullptr);
|
|
151
|
+
const char *v = flat ? env->GetStringUTFChars(flat, nullptr) : nullptr;
|
|
152
|
+
g_tree.setProp(id, k ? k : "", v ? v : "");
|
|
153
|
+
if (k)
|
|
154
|
+
env->ReleaseStringUTFChars(key, k);
|
|
155
|
+
if (v)
|
|
156
|
+
env->ReleaseStringUTFChars(flat, v);
|
|
157
|
+
g_dirty = true;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
JNIEXPORT void JNICALL
|
|
161
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeInsertChild(JNIEnv *, jclass,
|
|
162
|
+
jint parent,
|
|
163
|
+
jint child,
|
|
164
|
+
jint index) {
|
|
165
|
+
g_tree.insertChild(parent, child, index);
|
|
166
|
+
g_dirty = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
JNIEXPORT void JNICALL
|
|
170
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeRemoveChild(JNIEnv *, jclass,
|
|
171
|
+
jint parent,
|
|
172
|
+
jint child) {
|
|
173
|
+
g_tree.removeChild(parent, child);
|
|
174
|
+
g_dirty = true;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
JNIEXPORT void JNICALL
|
|
178
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeMoveChild(JNIEnv *, jclass,
|
|
179
|
+
jint parent,
|
|
180
|
+
jint child,
|
|
181
|
+
jint index) {
|
|
182
|
+
g_tree.moveChild(parent, child, index);
|
|
183
|
+
g_dirty = true;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
JNIEXPORT void JNICALL
|
|
187
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeDeleteNode(JNIEnv *, jclass,
|
|
188
|
+
jint id) {
|
|
189
|
+
g_tree.deleteNode(id);
|
|
190
|
+
g_dirty = true;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
JNIEXPORT void JNICALL
|
|
194
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeAttachEvent(
|
|
195
|
+
JNIEnv *env, jclass, jint id, jstring event, jstring handler,
|
|
196
|
+
jboolean continuous, jstring payload) {
|
|
197
|
+
const char *e = env->GetStringUTFChars(event, nullptr);
|
|
198
|
+
const char *h = env->GetStringUTFChars(handler, nullptr);
|
|
199
|
+
const char *p = payload ? env->GetStringUTFChars(payload, nullptr) : nullptr;
|
|
200
|
+
g_tree.attachEvent(id, e ? e : "", h ? h : "", continuous, p ? p : "");
|
|
201
|
+
if (e)
|
|
202
|
+
env->ReleaseStringUTFChars(event, e);
|
|
203
|
+
if (h)
|
|
204
|
+
env->ReleaseStringUTFChars(handler, h);
|
|
205
|
+
if (p)
|
|
206
|
+
env->ReleaseStringUTFChars(payload, p);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
JNIEXPORT void JNICALL
|
|
210
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeDetachEvent(JNIEnv *env,
|
|
211
|
+
jclass, jint id,
|
|
212
|
+
jstring event) {
|
|
213
|
+
const char *e = env->GetStringUTFChars(event, nullptr);
|
|
214
|
+
g_tree.detachEvent(id, e ? e : "");
|
|
215
|
+
if (e)
|
|
216
|
+
env->ReleaseStringUTFChars(event, e);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
JNIEXPORT void JNICALL
|
|
220
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeResetNode(JNIEnv *, jclass,
|
|
221
|
+
jint id) {
|
|
222
|
+
g_tree.resetNode(id);
|
|
223
|
+
g_dirty = true;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
JNIEXPORT void JNICALL
|
|
227
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeLayout(JNIEnv *, jclass,
|
|
228
|
+
jint id, jfloat x,
|
|
229
|
+
jfloat y, jfloat w,
|
|
230
|
+
jfloat h) {
|
|
231
|
+
g_tree.setRect(id, x, y, w, h);
|
|
232
|
+
g_dirty = true;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ── medida (vtable del espejo Yoga — misma semántica Linux) ────────
|
|
236
|
+
// Contrato del carril views: el espejo llama measureNode con w/h en PX
|
|
237
|
+
// (multiplicadas por g_density del lado C++ del bridge) y desempaqueta
|
|
238
|
+
// (px<<32 | px) dividiendo por density. El árbol trabaja en dp — se
|
|
239
|
+
// convierte en la frontera.
|
|
240
|
+
JNIEXPORT jlong JNICALL
|
|
241
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeMeasure(
|
|
242
|
+
JNIEnv *, jclass, jint id, jfloat wPx, jint wMode, jfloat hPx, jint hMode) {
|
|
243
|
+
float ow = 0, oh = 0;
|
|
244
|
+
g_tree.measure(id, wPx / g_density, wMode, hPx / g_density, hMode, ow, oh);
|
|
245
|
+
int32_t wi = (int32_t)lroundf(ow * g_density);
|
|
246
|
+
int32_t hi = (int32_t)lroundf(oh * g_density);
|
|
247
|
+
return ((jlong)(uint32_t)wi << 32) | (uint32_t)hi;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
JNIEXPORT jfloat JNICALL
|
|
251
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeBaseline(JNIEnv *, jclass,
|
|
252
|
+
jint id, jfloat wPx,
|
|
253
|
+
jfloat hPx) {
|
|
254
|
+
return g_tree.baseline(id, wPx / g_density, hPx / g_density) * g_density;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
JNIEXPORT void JNICALL
|
|
258
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSetFontScale(JNIEnv *,
|
|
259
|
+
jclass,
|
|
260
|
+
jfloat s) {
|
|
261
|
+
g_tree.setFontScale(s);
|
|
262
|
+
g_dirty = true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
JNIEXPORT void JNICALL
|
|
266
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSetRtl(JNIEnv *, jclass,
|
|
267
|
+
jboolean rtl) {
|
|
268
|
+
g_tree.setRtl(rtl);
|
|
269
|
+
g_dirty = true;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ── input (coordenadas en unidades lógicas — Kotlin divide por density) ─
|
|
273
|
+
|
|
274
|
+
JNIEXPORT jint JNICALL
|
|
275
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeHitTest(JNIEnv *env, jclass,
|
|
276
|
+
jfloat x, jfloat y,
|
|
277
|
+
jstring event) {
|
|
278
|
+
const char *e = env->GetStringUTFChars(event, nullptr);
|
|
279
|
+
int r = g_tree.hitTest(x, y, e ? e : "");
|
|
280
|
+
if (e)
|
|
281
|
+
env->ReleaseStringUTFChars(event, e);
|
|
282
|
+
return r;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
JNIEXPORT jint JNICALL
|
|
286
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeNodeAt(JNIEnv *, jclass,
|
|
287
|
+
jfloat x, jfloat y) {
|
|
288
|
+
return g_tree.nodeAt(x, y);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
JNIEXPORT jint JNICALL
|
|
292
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeScrollableAt(JNIEnv *,
|
|
293
|
+
jclass,
|
|
294
|
+
jfloat x,
|
|
295
|
+
jfloat y) {
|
|
296
|
+
return g_tree.scrollableAt(x, y);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
JNIEXPORT jboolean JNICALL
|
|
300
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeScrollBy(JNIEnv *, jclass,
|
|
301
|
+
jint id, jfloat dx,
|
|
302
|
+
jfloat dy) {
|
|
303
|
+
bool moved = g_tree.scrollBy(id, dx, dy);
|
|
304
|
+
if (moved)
|
|
305
|
+
g_dirty = true;
|
|
306
|
+
return moved;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
JNIEXPORT jfloat JNICALL
|
|
310
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeMaxScrollY(JNIEnv *, jclass,
|
|
311
|
+
jint id) {
|
|
312
|
+
return g_tree.maxScrollY(id);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
JNIEXPORT jfloat JNICALL
|
|
316
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeScrollY(JNIEnv *, jclass,
|
|
317
|
+
jint id) {
|
|
318
|
+
auto it = g_tree.nodes.find(id);
|
|
319
|
+
return it != g_tree.nodes.end() ? it->second.scrollY : 0.f;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
JNIEXPORT jfloat JNICALL
|
|
323
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeNodeH(JNIEnv *, jclass,
|
|
324
|
+
jint id) {
|
|
325
|
+
auto it = g_tree.nodes.find(id);
|
|
326
|
+
return it != g_tree.nodes.end() ? it->second.rh : 0.f;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
JNIEXPORT jfloat JNICALL
|
|
330
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeLocalX(JNIEnv *, jclass,
|
|
331
|
+
jint id,
|
|
332
|
+
jfloat absX) {
|
|
333
|
+
float lx = 0, ly = 0;
|
|
334
|
+
g_tree.pointInNode(id, absX, 0.f, lx, ly);
|
|
335
|
+
return lx;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
JNIEXPORT void JNICALL
|
|
339
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSetFocused(JNIEnv *, jclass,
|
|
340
|
+
jint id) {
|
|
341
|
+
g_tree.focusedId = id;
|
|
342
|
+
g_dirty = true;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
JNIEXPORT jboolean JNICALL
|
|
346
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSwitchToggle(JNIEnv *,
|
|
347
|
+
jclass,
|
|
348
|
+
jint id) {
|
|
349
|
+
bool v = g_tree.switchToggle(id);
|
|
350
|
+
g_dirty = true;
|
|
351
|
+
return v;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
JNIEXPORT jfloat JNICALL
|
|
355
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeSliderSetAt(JNIEnv *, jclass,
|
|
356
|
+
jint id,
|
|
357
|
+
jfloat localX) {
|
|
358
|
+
float v = g_tree.sliderSetAt(id, localX);
|
|
359
|
+
g_dirty = true;
|
|
360
|
+
return v;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// Datos del nodo para el envelope de eventos (handler + payload +
|
|
364
|
+
// tipo — el glue arma el envelope, el árbol guarda lo mínimo).
|
|
365
|
+
JNIEXPORT jstring JNICALL
|
|
366
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeEventInfo(JNIEnv *env,
|
|
367
|
+
jclass, jint id,
|
|
368
|
+
jstring event) {
|
|
369
|
+
const char *e = env->GetStringUTFChars(event, nullptr);
|
|
370
|
+
std::string out;
|
|
371
|
+
auto it = g_tree.nodes.find(id);
|
|
372
|
+
if (it != g_tree.nodes.end()) {
|
|
373
|
+
auto b = it->second.events.find(e ? e : "");
|
|
374
|
+
if (b != it->second.events.end()) {
|
|
375
|
+
// handler\tpayload — el tabulador no existe en los valores.
|
|
376
|
+
out = b->second.handler + "\t" + b->second.payload;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
if (e)
|
|
380
|
+
env->ReleaseStringUTFChars(event, e);
|
|
381
|
+
return env->NewStringUTF(out.c_str());
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
JNIEXPORT jstring JNICALL
|
|
385
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeNodeType(JNIEnv *env, jclass,
|
|
386
|
+
jint id) {
|
|
387
|
+
auto it = g_tree.nodes.find(id);
|
|
388
|
+
return env->NewStringUTF(it != g_tree.nodes.end() ? it->second.type.c_str()
|
|
389
|
+
: "");
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// ── render ────────────────────────────────────────────────────────
|
|
393
|
+
|
|
394
|
+
JNIEXPORT jboolean JNICALL
|
|
395
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeRender(JNIEnv *, jclass) {
|
|
396
|
+
if (!g_win || g_winW <= 0 || g_winH <= 0)
|
|
397
|
+
return JNI_FALSE;
|
|
398
|
+
if (!g_dirty)
|
|
399
|
+
return JNI_FALSE;
|
|
400
|
+
|
|
401
|
+
ANativeWindow_Buffer buf;
|
|
402
|
+
if (ANativeWindow_lock(g_win, &buf, nullptr) != 0) {
|
|
403
|
+
LOGW("render: ANativeWindow_lock falló");
|
|
404
|
+
return JNI_FALSE;
|
|
405
|
+
}
|
|
406
|
+
// ARGB_8888/RGBA_8888 según el format del buffer — stride en
|
|
407
|
+
// PÍXELES (contrato ANativeWindow_Buffer), rowBytes = stride*bpp.
|
|
408
|
+
SkImageInfo info;
|
|
409
|
+
int bpp;
|
|
410
|
+
if (buf.format == WINDOW_FORMAT_RGB_565) {
|
|
411
|
+
info = SkImageInfo::Make(buf.width, buf.height, kRGB_565_SkColorType,
|
|
412
|
+
kOpaque_SkAlphaType);
|
|
413
|
+
bpp = 2;
|
|
414
|
+
} else {
|
|
415
|
+
info = SkImageInfo::MakeN32Premul(buf.width, buf.height);
|
|
416
|
+
bpp = 4;
|
|
417
|
+
}
|
|
418
|
+
auto surface =
|
|
419
|
+
SkSurfaces::WrapPixels(info, buf.bits, (size_t)buf.stride * bpp);
|
|
420
|
+
if (surface) {
|
|
421
|
+
SkCanvas &canvas = *surface->getCanvas();
|
|
422
|
+
canvas.save();
|
|
423
|
+
canvas.scale(g_density, g_density);
|
|
424
|
+
canvas.clear(SK_ColorWHITE);
|
|
425
|
+
g_tree.paint(canvas);
|
|
426
|
+
canvas.restore();
|
|
427
|
+
}
|
|
428
|
+
ANativeWindow_unlockAndPost(g_win);
|
|
429
|
+
g_dirty = false;
|
|
430
|
+
return JNI_TRUE;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
JNIEXPORT void JNICALL
|
|
434
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeInvalidate(JNIEnv *,
|
|
435
|
+
jclass) {
|
|
436
|
+
g_dirty = true;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
JNIEXPORT void JNICALL
|
|
440
|
+
Java_com_elur_universal_ElurSkiaTreeRenderer_nativeShutdown(JNIEnv *, jclass) {
|
|
441
|
+
g_tree = elur::skia::SkiaTree();
|
|
442
|
+
if (g_win) {
|
|
443
|
+
ANativeWindow_release(g_win);
|
|
444
|
+
g_win = nullptr;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
} // extern "C"
|