|
|
|
|
|
|
#include "uiwidgets_panel.h"
|
|
|
|
|
|
|
|
// #include <Windows.h>
|
|
|
|
// #include <include\utils\SkBase64.h>
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
#include "shell/common/switches.h"
|
|
|
|
#include "shell/platform/embedder/embedder_engine.h"
|
|
|
|
#include "uiwidgets_system.h"
|
|
|
|
// #include "unity_external_texture_gl.h"
|
|
|
|
namespace uiwidgets { |
|
|
|
namespace uiwidgets |
|
|
|
{ |
|
|
|
fml::RefPtr<UIWidgetsPanel> UIWidgetsPanel::Create( |
|
|
|
Mono_Handle handle, EntrypointCallback entrypoint_callback) { |
|
|
|
return fml::MakeRefCounted<UIWidgetsPanel>(handle, entrypoint_callback); |
|
|
|
} |
|
|
|
fml::RefPtr<UIWidgetsPanel> UIWidgetsPanel::Create( |
|
|
|
Mono_Handle handle, UIWidgetsWindowType window_type, EntrypointCallback entrypoint_callback) |
|
|
|
{ |
|
|
|
return fml::MakeRefCounted<UIWidgetsPanel>(handle, window_type, entrypoint_callback); |
|
|
|
} |
|
|
|
UIWidgetsPanel::UIWidgetsPanel(Mono_Handle handle, |
|
|
|
EntrypointCallback entrypoint_callback) |
|
|
|
: handle_(handle), entrypoint_callback_(entrypoint_callback) {} |
|
|
|
UIWidgetsPanel::UIWidgetsPanel(Mono_Handle handle, |
|
|
|
UIWidgetsWindowType window_type, |
|
|
|
EntrypointCallback entrypoint_callback) |
|
|
|
: handle_(handle), window_type_(window_type), entrypoint_callback_(entrypoint_callback) {} |
|
|
|
UIWidgetsPanel::~UIWidgetsPanel() = default; |
|
|
|
UIWidgetsPanel::~UIWidgetsPanel() = default; |
|
|
|
void UIWidgetsPanel::OnEnable(void* native_texture_ptr, size_t width, |
|
|
|
size_t height, float device_pixel_ratio, |
|
|
|
const char* streaming_assets_path, |
|
|
|
const char* settings) { |
|
|
|
UnityConsole::WriteLine("test ggg ++"); |
|
|
|
|
|
|
|
surface_manager_ = std::make_unique<UnitySurfaceManager>( |
|
|
|
UIWidgetsSystem::GetInstancePtr()->GetUnityInterfaces()); |
|
|
|
bool UIWidgetsPanel::NeedUpdateByPlayerLoop() |
|
|
|
{ |
|
|
|
return window_type_ == GameObjectPanel; |
|
|
|
} |
|
|
|
FML_DCHECK(fbo_ == 0); |
|
|
|
surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
fbo_ = surface_manager_->CreateRenderSurface(native_texture_ptr); |
|
|
|
surface_manager_->ClearCurrent(); |
|
|
|
bool UIWidgetsPanel::NeedUpdateByEditorLoop() |
|
|
|
{ |
|
|
|
return window_type_ == EditorWindowPanel; |
|
|
|
} |
|
|
|
fml::AutoResetWaitableEvent latch; |
|
|
|
std::thread::id gfx_worker_thread_id; |
|
|
|
UIWidgetsSystem::GetInstancePtr()->PostTaskToGfxWorker( |
|
|
|
[&latch, &gfx_worker_thread_id]() -> void { |
|
|
|
gfx_worker_thread_id = std::this_thread::get_id(); |
|
|
|
latch.Signal(); |
|
|
|
}); |
|
|
|
latch.Wait(); |
|
|
|
void UIWidgetsPanel::OnEnable(void *native_texture_ptr, size_t width, |
|
|
|
size_t height, float device_pixel_ratio, |
|
|
|
const char *streaming_assets_path, |
|
|
|
const char *settings) |
|
|
|
{ |
|
|
|
surface_manager_ = std::make_unique<UnitySurfaceManager>( |
|
|
|
UIWidgetsSystem::GetInstancePtr()->GetUnityInterfaces()); |
|
|
|
gfx_worker_task_runner_ = std::make_unique<GfxWorkerTaskRunner>( |
|
|
|
gfx_worker_thread_id, [this](const auto* task) { |
|
|
|
if (UIWidgetsEngineRunTask(engine_, task) != kSuccess) { |
|
|
|
std::cerr << "Could not post an gfx worker task." << std::endl; |
|
|
|
} |
|
|
|
}); |
|
|
|
FML_DCHECK(fbo_ == 0); |
|
|
|
surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
fbo_ = surface_manager_->CreateRenderSurface(native_texture_ptr); |
|
|
|
surface_manager_->ClearCurrent(); |
|
|
|
UIWidgetsTaskRunnerDescription render_task_runner = {}; |
|
|
|
render_task_runner.struct_size = sizeof(UIWidgetsTaskRunnerDescription); |
|
|
|
render_task_runner.identifier = 1; |
|
|
|
render_task_runner.user_data = gfx_worker_task_runner_.get(); |
|
|
|
render_task_runner.runs_task_on_current_thread_callback = |
|
|
|
[](void* user_data) -> bool { |
|
|
|
return static_cast<GfxWorkerTaskRunner*>(user_data) |
|
|
|
->RunsTasksOnCurrentThread(); |
|
|
|
}; |
|
|
|
render_task_runner.post_task_callback = [](UIWidgetsTask task, |
|
|
|
uint64_t target_time_nanos, |
|
|
|
void* user_data) -> void { |
|
|
|
static_cast<GfxWorkerTaskRunner*>(user_data)->PostTask(task, |
|
|
|
target_time_nanos); |
|
|
|
}; |
|
|
|
fml::AutoResetWaitableEvent latch; |
|
|
|
std::thread::id gfx_worker_thread_id; |
|
|
|
UIWidgetsSystem::GetInstancePtr()->PostTaskToGfxWorker( |
|
|
|
[&latch, &gfx_worker_thread_id]() -> void { |
|
|
|
gfx_worker_thread_id = std::this_thread::get_id(); |
|
|
|
latch.Signal(); |
|
|
|
}); |
|
|
|
latch.Wait(); |
|
|
|
UIWidgetsRendererConfig config = {}; |
|
|
|
config.type = kOpenGL; |
|
|
|
config.open_gl.struct_size = sizeof(config.open_gl); |
|
|
|
config.open_gl.clear_current = [](void* user_data) -> bool { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
return panel->surface_manager_->ClearCurrent(); |
|
|
|
}; |
|
|
|
config.open_gl.make_current = [](void* user_data) -> bool { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
return panel->surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
}; |
|
|
|
config.open_gl.make_resource_current = [](void* user_data) -> bool { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
return panel->surface_manager_->MakeResourceCurrent(); |
|
|
|
}; |
|
|
|
config.open_gl.fbo_callback = [](void* user_data) -> uint32_t { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
return panel->fbo_; |
|
|
|
}; |
|
|
|
config.open_gl.present = [](void* user_data) -> bool { return true; }; |
|
|
|
config.open_gl.gl_proc_resolver = [](void* user_data, |
|
|
|
const char* what) -> void* { |
|
|
|
return reinterpret_cast<void*>(eglGetProcAddress(what)); |
|
|
|
}; |
|
|
|
config.open_gl.fbo_reset_after_present = true; |
|
|
|
gfx_worker_task_runner_ = std::make_unique<GfxWorkerTaskRunner>( |
|
|
|
gfx_worker_thread_id, [this](const auto *task) { |
|
|
|
if (UIWidgetsEngineRunTask(engine_, task) != kSuccess) |
|
|
|
{ |
|
|
|
std::cerr << "Could not post an gfx worker task." << std::endl; |
|
|
|
} |
|
|
|
}); |
|
|
|
task_runner_ = std::make_unique<CocoaTaskRunner>( |
|
|
|
gettid(), [this](const auto* task) { |
|
|
|
if (UIWidgetsEngineRunTask(engine_, task) != kSuccess) { |
|
|
|
std::cerr << "Could not post an engine task." << std::endl; |
|
|
|
} |
|
|
|
}); |
|
|
|
UIWidgetsTaskRunnerDescription render_task_runner = {}; |
|
|
|
render_task_runner.struct_size = sizeof(UIWidgetsTaskRunnerDescription); |
|
|
|
render_task_runner.identifier = 1; |
|
|
|
render_task_runner.user_data = gfx_worker_task_runner_.get(); |
|
|
|
render_task_runner.runs_task_on_current_thread_callback = |
|
|
|
[](void *user_data) -> bool { |
|
|
|
return static_cast<GfxWorkerTaskRunner *>(user_data) |
|
|
|
->RunsTasksOnCurrentThread(); |
|
|
|
}; |
|
|
|
render_task_runner.post_task_callback = [](UIWidgetsTask task, |
|
|
|
uint64_t target_time_nanos, |
|
|
|
void *user_data) -> void { |
|
|
|
static_cast<GfxWorkerTaskRunner *>(user_data)->PostTask(task, |
|
|
|
target_time_nanos); |
|
|
|
}; |
|
|
|
UIWidgetsTaskRunnerDescription ui_task_runner = {}; |
|
|
|
ui_task_runner.struct_size = sizeof(UIWidgetsTaskRunnerDescription); |
|
|
|
ui_task_runner.identifier = 2; |
|
|
|
ui_task_runner.user_data = task_runner_.get(); |
|
|
|
UIWidgetsRendererConfig config = {}; |
|
|
|
config.type = kOpenGL; |
|
|
|
config.open_gl.struct_size = sizeof(config.open_gl); |
|
|
|
config.open_gl.clear_current = [](void *user_data) -> bool { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
return panel->surface_manager_->ClearCurrent(); |
|
|
|
}; |
|
|
|
config.open_gl.make_current = [](void *user_data) -> bool { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
return panel->surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
}; |
|
|
|
config.open_gl.make_resource_current = [](void *user_data) -> bool { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
return panel->surface_manager_->MakeResourceCurrent(); |
|
|
|
}; |
|
|
|
config.open_gl.fbo_callback = [](void *user_data) -> uint32_t { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
return panel->fbo_; |
|
|
|
}; |
|
|
|
config.open_gl.present = [](void *user_data) -> bool { return true; }; |
|
|
|
config.open_gl.gl_proc_resolver = [](void *user_data, |
|
|
|
const char *what) -> void * { |
|
|
|
return reinterpret_cast<void *>(eglGetProcAddress(what)); |
|
|
|
}; |
|
|
|
config.open_gl.fbo_reset_after_present = true; |
|
|
|
// TODO: waht is this
|
|
|
|
ui_task_runner.runs_task_on_current_thread_callback = |
|
|
|
[](void* user_data) -> bool { |
|
|
|
return static_cast<CocoaTaskRunner*>(user_data)->RunsTasksOnCurrentThread(); |
|
|
|
}; |
|
|
|
ui_task_runner.post_task_callback = [](UIWidgetsTask task, |
|
|
|
uint64_t target_time_nanos, |
|
|
|
void* user_data) -> void { |
|
|
|
static_cast<CocoaTaskRunner*>(user_data)->PostTask(task, target_time_nanos); |
|
|
|
}; |
|
|
|
task_runner_ = std::make_unique<CocoaTaskRunner>( |
|
|
|
gettid(), [this](const auto *task) { |
|
|
|
if (UIWidgetsEngineRunTask(engine_, task) != kSuccess) |
|
|
|
{ |
|
|
|
std::cerr << "Could not post an engine task." << std::endl; |
|
|
|
} |
|
|
|
}); |
|
|
|
UIWidgetsCustomTaskRunners custom_task_runners = {}; |
|
|
|
custom_task_runners.struct_size = sizeof(UIWidgetsCustomTaskRunners); |
|
|
|
custom_task_runners.platform_task_runner = &ui_task_runner; |
|
|
|
custom_task_runners.ui_task_runner = &ui_task_runner; |
|
|
|
custom_task_runners.render_task_runner = &render_task_runner; |
|
|
|
UIWidgetsTaskRunnerDescription ui_task_runner = {}; |
|
|
|
ui_task_runner.struct_size = sizeof(UIWidgetsTaskRunnerDescription); |
|
|
|
ui_task_runner.identifier = 2; |
|
|
|
ui_task_runner.user_data = task_runner_.get(); |
|
|
|
UIWidgetsProjectArgs args = {}; |
|
|
|
args.struct_size = sizeof(UIWidgetsProjectArgs); |
|
|
|
// TODO: waht is this
|
|
|
|
ui_task_runner.runs_task_on_current_thread_callback = |
|
|
|
[](void *user_data) -> bool { |
|
|
|
return static_cast<CocoaTaskRunner *>(user_data)->RunsTasksOnCurrentThread(); |
|
|
|
}; |
|
|
|
ui_task_runner.post_task_callback = [](UIWidgetsTask task, |
|
|
|
uint64_t target_time_nanos, |
|
|
|
void *user_data) -> void { |
|
|
|
static_cast<CocoaTaskRunner *>(user_data)->PostTask(task, target_time_nanos); |
|
|
|
}; |
|
|
|
args.assets_path = streaming_assets_path; |
|
|
|
args.font_asset = settings; |
|
|
|
UIWidgetsCustomTaskRunners custom_task_runners = {}; |
|
|
|
custom_task_runners.struct_size = sizeof(UIWidgetsCustomTaskRunners); |
|
|
|
custom_task_runners.platform_task_runner = &ui_task_runner; |
|
|
|
custom_task_runners.ui_task_runner = &ui_task_runner; |
|
|
|
custom_task_runners.render_task_runner = &render_task_runner; |
|
|
|
// // std::string icu_path = std::string(streaming_assets_path) + "/icudtl.dat";
|
|
|
|
// // args.icu_data_path = icu_path.c_str();
|
|
|
|
UIWidgetsProjectArgs args = {}; |
|
|
|
args.struct_size = sizeof(UIWidgetsProjectArgs); |
|
|
|
args.icu_mapper = GetICUStaticMapping; |
|
|
|
args.assets_path = streaming_assets_path; |
|
|
|
args.font_asset = settings; |
|
|
|
// // Used for IOS build
|
|
|
|
// // std::string icu_symbol_prefix = "_binary_icudtl_dat_start";
|
|
|
|
// // std::string native_lib_path =
|
|
|
|
// // "pathtodll/Plugins/x86_64/libUIWidgets_d.dll"; args.icu_mapper =
|
|
|
|
// // [icu_symbol_prefix, native_lib_path] {
|
|
|
|
// // return GetSymbolMapping(icu_symbol_prefix, native_lib_path);
|
|
|
|
// // };
|
|
|
|
args.command_line_argc = 0; |
|
|
|
args.command_line_argv = nullptr; |
|
|
|
// // std::string icu_path = std::string(streaming_assets_path) + "/icudtl.dat";
|
|
|
|
// // args.icu_data_path = icu_path.c_str();
|
|
|
|
args.platform_message_callback = |
|
|
|
[](const UIWidgetsPlatformMessage* engine_message, |
|
|
|
void* user_data) -> void {}; |
|
|
|
args.icu_mapper = GetICUStaticMapping; |
|
|
|
args.custom_task_runners = &custom_task_runners; |
|
|
|
args.task_observer_add = [](intptr_t key, void* callback, |
|
|
|
void* user_data) -> void { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
panel->task_runner_->AddTaskObserver(key, |
|
|
|
*static_cast<fml::closure*>(callback)); |
|
|
|
}; |
|
|
|
args.task_observer_remove = [](intptr_t key, void* user_data) -> void { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
panel->task_runner_->RemoveTaskObserver(key); |
|
|
|
}; |
|
|
|
// // Used for IOS build
|
|
|
|
// // std::string icu_symbol_prefix = "_binary_icudtl_dat_start";
|
|
|
|
// // std::string native_lib_path =
|
|
|
|
// // "pathtodll/Plugins/x86_64/libUIWidgets_d.dll"; args.icu_mapper =
|
|
|
|
// // [icu_symbol_prefix, native_lib_path] {
|
|
|
|
// // return GetSymbolMapping(icu_symbol_prefix, native_lib_path);
|
|
|
|
// // };
|
|
|
|
args.command_line_argc = 0; |
|
|
|
args.command_line_argv = nullptr; |
|
|
|
args.custom_mono_entrypoint = [](void* user_data) -> void { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
panel->MonoEntrypoint(); |
|
|
|
}; |
|
|
|
args.platform_message_callback = |
|
|
|
[](const UIWidgetsPlatformMessage *engine_message, |
|
|
|
void *user_data) -> void {}; |
|
|
|
args.vsync_callback = [](void* user_data, intptr_t baton) -> void { |
|
|
|
auto* panel = static_cast<UIWidgetsPanel*>(user_data); |
|
|
|
panel->VSyncCallback(baton); |
|
|
|
}; |
|
|
|
args.custom_task_runners = &custom_task_runners; |
|
|
|
args.task_observer_add = [](intptr_t key, void *callback, |
|
|
|
void *user_data) -> void { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
panel->task_runner_->AddTaskObserver(key, |
|
|
|
*static_cast<fml::closure *>(callback)); |
|
|
|
}; |
|
|
|
args.task_observer_remove = [](intptr_t key, void *user_data) -> void { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
panel->task_runner_->RemoveTaskObserver(key); |
|
|
|
}; |
|
|
|
args.initial_window_metrics.width = width; |
|
|
|
args.initial_window_metrics.height = height; |
|
|
|
args.initial_window_metrics.pixel_ratio = device_pixel_ratio; |
|
|
|
args.custom_mono_entrypoint = [](void *user_data) -> void { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
panel->MonoEntrypoint(); |
|
|
|
}; |
|
|
|
UIWidgetsEngine engine = nullptr; |
|
|
|
auto result = UIWidgetsEngineInitialize(&config, &args, this, &engine); |
|
|
|
args.vsync_callback = [](void *user_data, intptr_t baton) -> void { |
|
|
|
auto *panel = static_cast<UIWidgetsPanel *>(user_data); |
|
|
|
panel->VSyncCallback(baton); |
|
|
|
}; |
|
|
|
if (result != kSuccess || engine == nullptr) { |
|
|
|
std::cerr << "Failed to start UIWidgets engine: error " << result |
|
|
|
<< std::endl; |
|
|
|
return; |
|
|
|
} |
|
|
|
args.initial_window_metrics.width = width; |
|
|
|
args.initial_window_metrics.height = height; |
|
|
|
args.initial_window_metrics.pixel_ratio = device_pixel_ratio; |
|
|
|
engine_ = engine; |
|
|
|
UIWidgetsEngineRunInitialized(engine); |
|
|
|
UIWidgetsEngine engine = nullptr; |
|
|
|
auto result = UIWidgetsEngineInitialize(&config, &args, this, &engine); |
|
|
|
UIWidgetsSystem::GetInstancePtr()->RegisterPanel(this); |
|
|
|
if (result != kSuccess || engine == nullptr) |
|
|
|
{ |
|
|
|
std::cerr << "Failed to start UIWidgets engine: error " << result |
|
|
|
<< std::endl; |
|
|
|
return; |
|
|
|
} |
|
|
|
process_events_ = true; |
|
|
|
} |
|
|
|
engine_ = engine; |
|
|
|
UIWidgetsEngineRunInitialized(engine); |
|
|
|
void UIWidgetsPanel::MonoEntrypoint() { entrypoint_callback_(handle_); } |
|
|
|
UIWidgetsSystem::GetInstancePtr()->RegisterPanel(this); |
|
|
|
void UIWidgetsPanel::OnDisable() { |
|
|
|
// drain pending messages
|
|
|
|
ProcessMessages(); |
|
|
|
process_events_ = true; |
|
|
|
} |
|
|
|
// drain pending vsync batons
|
|
|
|
ProcessVSync(); |
|
|
|
void UIWidgetsPanel::MonoEntrypoint() { entrypoint_callback_(handle_); } |
|
|
|
process_events_ = false; |
|
|
|
void UIWidgetsPanel::OnDisable() |
|
|
|
{ |
|
|
|
// drain pending messages
|
|
|
|
ProcessMessages(); |
|
|
|
UIWidgetsSystem::GetInstancePtr()->UnregisterPanel(this); |
|
|
|
// drain pending vsync batons
|
|
|
|
ProcessVSync(); |
|
|
|
if (engine_) { |
|
|
|
UIWidgetsEngineShutdown(engine_); |
|
|
|
engine_ = nullptr; |
|
|
|
} |
|
|
|
process_events_ = false; |
|
|
|
gfx_worker_task_runner_ = nullptr; |
|
|
|
task_runner_ = nullptr; |
|
|
|
UIWidgetsSystem::GetInstancePtr()->UnregisterPanel(this); |
|
|
|
if (fbo_) { |
|
|
|
surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
if (engine_) |
|
|
|
{ |
|
|
|
UIWidgetsEngineShutdown(engine_); |
|
|
|
engine_ = nullptr; |
|
|
|
} |
|
|
|
surface_manager_->DestroyRenderSurface(); |
|
|
|
fbo_ = 0; |
|
|
|
gfx_worker_task_runner_ = nullptr; |
|
|
|
task_runner_ = nullptr; |
|
|
|
surface_manager_->ClearCurrent(); |
|
|
|
} |
|
|
|
if (fbo_) |
|
|
|
{ |
|
|
|
surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
surface_manager_ = nullptr; |
|
|
|
} |
|
|
|
surface_manager_->DestroyRenderSurface(); |
|
|
|
fbo_ = 0; |
|
|
|
void UIWidgetsPanel::OnRenderTexture(void* native_texture_ptr, size_t width, |
|
|
|
size_t height, float device_pixel_ratio) { |
|
|
|
reinterpret_cast<EmbedderEngine*>(engine_)->PostRenderThreadTask( |
|
|
|
[this, native_texture_ptr]() -> void { |
|
|
|
surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
surface_manager_->ClearCurrent(); |
|
|
|
} |
|
|
|
if (fbo_) { |
|
|
|
surface_manager_->DestroyRenderSurface(); |
|
|
|
fbo_ = 0; |
|
|
|
} |
|
|
|
fbo_ = surface_manager_->CreateRenderSurface(native_texture_ptr); |
|
|
|
surface_manager_ = nullptr; |
|
|
|
} |
|
|
|
surface_manager_->ClearCurrent(); |
|
|
|
}); |
|
|
|
void UIWidgetsPanel::OnRenderTexture(void *native_texture_ptr, size_t width, |
|
|
|
size_t height, float device_pixel_ratio) |
|
|
|
{ |
|
|
|
reinterpret_cast<EmbedderEngine *>(engine_)->PostRenderThreadTask( |
|
|
|
[this, native_texture_ptr]() -> void { |
|
|
|
surface_manager_->MakeCurrent(EGL_NO_DISPLAY); |
|
|
|
ViewportMetrics metrics; |
|
|
|
metrics.physical_width = static_cast<float>(width); |
|
|
|
metrics.physical_height = static_cast<float>(height); |
|
|
|
metrics.device_pixel_ratio = device_pixel_ratio; |
|
|
|
reinterpret_cast<EmbedderEngine*>(engine_)->SetViewportMetrics(metrics); |
|
|
|
} |
|
|
|
if (fbo_) |
|
|
|
{ |
|
|
|
surface_manager_->DestroyRenderSurface(); |
|
|
|
fbo_ = 0; |
|
|
|
} |
|
|
|
fbo_ = surface_manager_->CreateRenderSurface(native_texture_ptr); |
|
|
|
int UIWidgetsPanel::RegisterTexture(void* native_texture_ptr) { |
|
|
|
int texture_identifier = 0; |
|
|
|
// texture_identifier++;
|
|
|
|
surface_manager_->ClearCurrent(); |
|
|
|
}); |
|
|
|
// auto* engine = reinterpret_cast<EmbedderEngine*>(engine_);
|
|
|
|
ViewportMetrics metrics; |
|
|
|
metrics.physical_width = static_cast<float>(width); |
|
|
|
metrics.physical_height = static_cast<float>(height); |
|
|
|
metrics.device_pixel_ratio = device_pixel_ratio; |
|
|
|
reinterpret_cast<EmbedderEngine *>(engine_)->SetViewportMetrics(metrics); |
|
|
|
} |
|
|
|
// engine->GetShell().GetPlatformView()->RegisterTexture(
|
|
|
|
// std::make_unique<UnityExternalTextureGL>(
|
|
|
|
// texture_identifier, native_texture_ptr, surface_manager_.get()));
|
|
|
|
return texture_identifier; |
|
|
|
} |
|
|
|
int UIWidgetsPanel::RegisterTexture(void *native_texture_ptr) |
|
|
|
{ |
|
|
|
int texture_identifier = 0; |
|
|
|
// texture_identifier++;
|
|
|
|
void UIWidgetsPanel::UnregisterTexture(int texture_id) { |
|
|
|
auto* engine = reinterpret_cast<EmbedderEngine*>(engine_); |
|
|
|
engine->GetShell().GetPlatformView()->UnregisterTexture(texture_id); |
|
|
|
} |
|
|
|
// auto* engine = reinterpret_cast<EmbedderEngine*>(engine_);
|
|
|
|
std::chrono::nanoseconds UIWidgetsPanel::ProcessMessages() { |
|
|
|
return std::chrono::nanoseconds(task_runner_->ProcessTasks().count()); |
|
|
|
} |
|
|
|
// engine->GetShell().GetPlatformView()->RegisterTexture(
|
|
|
|
// std::make_unique<UnityExternalTextureGL>(
|
|
|
|
// texture_identifier, native_texture_ptr, surface_manager_.get()));
|
|
|
|
return texture_identifier; |
|
|
|
} |
|
|
|
void UIWidgetsPanel::ProcessVSync() { |
|
|
|
std::vector<intptr_t> batons; |
|
|
|
vsync_batons_.swap(batons); |
|
|
|
void UIWidgetsPanel::UnregisterTexture(int texture_id) |
|
|
|
{ |
|
|
|
auto *engine = reinterpret_cast<EmbedderEngine *>(engine_); |
|
|
|
engine->GetShell().GetPlatformView()->UnregisterTexture(texture_id); |
|
|
|
} |
|
|
|
for (intptr_t baton : batons) { |
|
|
|
reinterpret_cast<EmbedderEngine*>(engine_)->OnVsyncEvent( |
|
|
|
baton, fml::TimePoint::Now(), |
|
|
|
fml::TimePoint::Now() + |
|
|
|
fml::TimeDelta::FromNanoseconds(1000000000 / 60)); |
|
|
|
std::chrono::nanoseconds UIWidgetsPanel::ProcessMessages() |
|
|
|
{ |
|
|
|
return std::chrono::nanoseconds(task_runner_->ProcessTasks().count()); |
|
|
|
} |
|
|
|
void UIWidgetsPanel::VSyncCallback(intptr_t baton) { |
|
|
|
vsync_batons_.push_back(baton); |
|
|
|
} |
|
|
|
void UIWidgetsPanel::ProcessVSync() |
|
|
|
{ |
|
|
|
std::vector<intptr_t> batons; |
|
|
|
vsync_batons_.swap(batons); |
|
|
|
void UIWidgetsPanel::SetEventPhaseFromCursorButtonState( |
|
|
|
UIWidgetsPointerEvent* event_data) { |
|
|
|
MouseState state = GetMouseState(); |
|
|
|
event_data->phase = state.buttons == 0 |
|
|
|
? state.state_is_down ? UIWidgetsPointerPhase::kUp |
|
|
|
: UIWidgetsPointerPhase::kHover |
|
|
|
: state.state_is_down ? UIWidgetsPointerPhase::kMove |
|
|
|
: UIWidgetsPointerPhase::kDown; |
|
|
|
} |
|
|
|
for (intptr_t baton : batons) |
|
|
|
{ |
|
|
|
reinterpret_cast<EmbedderEngine *>(engine_)->OnVsyncEvent( |
|
|
|
baton, fml::TimePoint::Now(), |
|
|
|
fml::TimePoint::Now() + |
|
|
|
fml::TimeDelta::FromNanoseconds(1000000000 / 60)); |
|
|
|
} |
|
|
|
} |
|
|
|
void UIWidgetsPanel::SendMouseMove(float x, float y) { |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.x = x; |
|
|
|
event.y = y; |
|
|
|
SetEventPhaseFromCursorButtonState(&event); |
|
|
|
SendPointerEventWithData(event); |
|
|
|
} |
|
|
|
void UIWidgetsPanel::VSyncCallback(intptr_t baton) |
|
|
|
{ |
|
|
|
vsync_batons_.push_back(baton); |
|
|
|
} |
|
|
|
void UIWidgetsPanel::SendMouseDown(float x, float y) { |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
SetEventPhaseFromCursorButtonState(&event); |
|
|
|
event.x = x; |
|
|
|
event.y = y; |
|
|
|
SendPointerEventWithData(event); |
|
|
|
SetMouseStateDown(true); |
|
|
|
} |
|
|
|
void UIWidgetsPanel::SetEventPhaseFromCursorButtonState( |
|
|
|
UIWidgetsPointerEvent *event_data) |
|
|
|
{ |
|
|
|
MouseState state = GetMouseState(); |
|
|
|
event_data->phase = state.buttons == 0 |
|
|
|
? state.state_is_down ? UIWidgetsPointerPhase::kUp |
|
|
|
: UIWidgetsPointerPhase::kHover |
|
|
|
: state.state_is_down ? UIWidgetsPointerPhase::kMove |
|
|
|
: UIWidgetsPointerPhase::kDown; |
|
|
|
} |
|
|
|
void UIWidgetsPanel::SendMouseUp(float x, float y) { |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
SetEventPhaseFromCursorButtonState(&event); |
|
|
|
event.x = x; |
|
|
|
event.y = y; |
|
|
|
SendPointerEventWithData(event); |
|
|
|
if (event.phase == UIWidgetsPointerPhase::kUp) { |
|
|
|
SetMouseStateDown(false); |
|
|
|
void UIWidgetsPanel::SendMouseMove(float x, float y) |
|
|
|
{ |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.x = x; |
|
|
|
event.y = y; |
|
|
|
SetEventPhaseFromCursorButtonState(&event); |
|
|
|
SendPointerEventWithData(event); |
|
|
|
} |
|
|
|
void UIWidgetsPanel::SendMouseLeave() { |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.phase = UIWidgetsPointerPhase::kRemove; |
|
|
|
SendPointerEventWithData(event); |
|
|
|
} |
|
|
|
|
|
|
|
void UIWidgetsPanel::SendPointerEventWithData( |
|
|
|
const UIWidgetsPointerEvent& event_data) { |
|
|
|
MouseState mouse_state = GetMouseState(); |
|
|
|
// If sending anything other than an add, and the pointer isn't already added,
|
|
|
|
// synthesize an add to satisfy Flutter's expectations about events.
|
|
|
|
if (!mouse_state.state_is_added && |
|
|
|
event_data.phase != UIWidgetsPointerPhase::kAdd) { |
|
|
|
void UIWidgetsPanel::SendMouseDown(float x, float y) |
|
|
|
{ |
|
|
|
event.phase = UIWidgetsPointerPhase::kAdd; |
|
|
|
event.x = event_data.x; |
|
|
|
event.y = event_data.y; |
|
|
|
event.buttons = 0; |
|
|
|
SetEventPhaseFromCursorButtonState(&event); |
|
|
|
event.x = x; |
|
|
|
event.y = y; |
|
|
|
} |
|
|
|
// Don't double-add (e.g., if events are delivered out of order, so an add has
|
|
|
|
// already been synthesized).
|
|
|
|
if (mouse_state.state_is_added && |
|
|
|
event_data.phase == UIWidgetsPointerPhase::kAdd) { |
|
|
|
return; |
|
|
|
SetMouseStateDown(true); |
|
|
|
UIWidgetsPointerEvent event = event_data; |
|
|
|
event.device_kind = kUIWidgetsPointerDeviceKindMouse; |
|
|
|
event.buttons = mouse_state.buttons; |
|
|
|
void UIWidgetsPanel::SendMouseUp(float x, float y) |
|
|
|
{ |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
SetEventPhaseFromCursorButtonState(&event); |
|
|
|
event.x = x; |
|
|
|
event.y = y; |
|
|
|
SendPointerEventWithData(event); |
|
|
|
if (event.phase == UIWidgetsPointerPhase::kUp) |
|
|
|
{ |
|
|
|
SetMouseStateDown(false); |
|
|
|
} |
|
|
|
} |
|
|
|
// Set metadata that's always the same regardless of the event.
|
|
|
|
event.struct_size = sizeof(event); |
|
|
|
event.timestamp = |
|
|
|
std::chrono::duration_cast<std::chrono::microseconds>( |
|
|
|
std::chrono::high_resolution_clock::now().time_since_epoch()) |
|
|
|
.count(); |
|
|
|
void UIWidgetsPanel::SendMouseLeave() |
|
|
|
{ |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.phase = UIWidgetsPointerPhase::kRemove; |
|
|
|
SendPointerEventWithData(event); |
|
|
|
} |
|
|
|
UIWidgetsEngineSendPointerEvent(engine_, &event, 1); |
|
|
|
void UIWidgetsPanel::SendPointerEventWithData( |
|
|
|
const UIWidgetsPointerEvent &event_data) |
|
|
|
{ |
|
|
|
MouseState mouse_state = GetMouseState(); |
|
|
|
// If sending anything other than an add, and the pointer isn't already added,
|
|
|
|
// synthesize an add to satisfy Flutter's expectations about events.
|
|
|
|
if (!mouse_state.state_is_added && |
|
|
|
event_data.phase != UIWidgetsPointerPhase::kAdd) |
|
|
|
{ |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.phase = UIWidgetsPointerPhase::kAdd; |
|
|
|
event.x = event_data.x; |
|
|
|
event.y = event_data.y; |
|
|
|
event.buttons = 0; |
|
|
|
SendPointerEventWithData(event); |
|
|
|
} |
|
|
|
// Don't double-add (e.g., if events are delivered out of order, so an add has
|
|
|
|
// already been synthesized).
|
|
|
|
if (mouse_state.state_is_added && |
|
|
|
event_data.phase == UIWidgetsPointerPhase::kAdd) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
if (event_data.phase == UIWidgetsPointerPhase::kAdd) { |
|
|
|
SetMouseStateAdded(true); |
|
|
|
} else if (event_data.phase == UIWidgetsPointerPhase::kRemove) { |
|
|
|
SetMouseStateAdded(false); |
|
|
|
ResetMouseState(); |
|
|
|
} |
|
|
|
} |
|
|
|
UIWidgetsPointerEvent event = event_data; |
|
|
|
event.device_kind = kUIWidgetsPointerDeviceKindMouse; |
|
|
|
event.buttons = mouse_state.buttons; |
|
|
|
void UIWidgetsPanel::OnKeyDown(int keyCode, bool isKeyDown) { |
|
|
|
if (process_events_) { |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.phase = isKeyDown ? UIWidgetsPointerPhase::kMouseDown : UIWidgetsPointerPhase::kMouseUp; |
|
|
|
event.device_kind = |
|
|
|
UIWidgetsPointerDeviceKind::kUIWidgetsPointerDeviceKindKeyboard; |
|
|
|
event.buttons = keyCode; |
|
|
|
// Set metadata that's always the same regardless of the event.
|
|
|
|
event.struct_size = sizeof(event); |
|
|
|
event.timestamp = |
|
|
|
std::chrono::duration_cast<std::chrono::microseconds>( |
|
|
|
|
|
|
UIWidgetsEngineSendPointerEvent(engine_, &event, 1); |
|
|
|
|
|
|
|
if (event_data.phase == UIWidgetsPointerPhase::kAdd) |
|
|
|
{ |
|
|
|
SetMouseStateAdded(true); |
|
|
|
} |
|
|
|
else if (event_data.phase == UIWidgetsPointerPhase::kRemove) |
|
|
|
{ |
|
|
|
SetMouseStateAdded(false); |
|
|
|
ResetMouseState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UIWidgetsPanel::OnKeyDown(int keyCode, bool isKeyDown) |
|
|
|
{ |
|
|
|
if (process_events_) |
|
|
|
{ |
|
|
|
UIWidgetsPointerEvent event = {}; |
|
|
|
event.phase = isKeyDown ? UIWidgetsPointerPhase::kMouseDown : UIWidgetsPointerPhase::kMouseUp; |
|
|
|
event.device_kind = |
|
|
|
UIWidgetsPointerDeviceKind::kUIWidgetsPointerDeviceKindKeyboard; |
|
|
|
event.buttons = keyCode; |
|
|
|
event.struct_size = sizeof(event); |
|
|
|
event.timestamp = |
|
|
|
std::chrono::duration_cast<std::chrono::microseconds>( |
|
|
|
std::chrono::high_resolution_clock::now().time_since_epoch()) |
|
|
|
.count(); |
|
|
|
void UIWidgetsPanel::OnMouseMove(float x, float y) { |
|
|
|
if (process_events_) { |
|
|
|
SendMouseMove(x, y); |
|
|
|
UIWidgetsEngineSendPointerEvent(engine_, &event, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void UIWidgetsPanel::OnMouseMove(float x, float y) |
|
|
|
{ |
|
|
|
if (process_events_) |
|
|
|
{ |
|
|
|
SendMouseMove(x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
static uint64_t ConvertToUIWidgetsButton(int button) { |
|
|
|
switch (button) { |
|
|
|
static uint64_t ConvertToUIWidgetsButton(int button) |
|
|
|
{ |
|
|
|
switch (button) |
|
|
|
{ |
|
|
|
case -1: |
|
|
|
return kUIWidgetsPointerButtonMousePrimary; |
|
|
|
case -2: |
|
|
|
|
|
|
} |
|
|
|
std::cerr << "Mouse button not recognized: " << button << std::endl; |
|
|
|
return 0; |
|
|
|
std::cerr << "Mouse button not recognized: " << button << std::endl; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
void UIWidgetsPanel::OnMouseDown(float x, float y, int button) { |
|
|
|
if (process_events_) { |
|
|
|
uint64_t uiwidgets_button = ConvertToUIWidgetsButton(button); |
|
|
|
if (uiwidgets_button != 0) { |
|
|
|
uint64_t mouse_buttons = GetMouseState().buttons | uiwidgets_button; |
|
|
|
SetMouseButtons(mouse_buttons); |
|
|
|
SendMouseDown(x, y); |
|
|
|
void UIWidgetsPanel::OnMouseDown(float x, float y, int button) |
|
|
|
{ |
|
|
|
if (process_events_) |
|
|
|
{ |
|
|
|
uint64_t uiwidgets_button = ConvertToUIWidgetsButton(button); |
|
|
|
if (uiwidgets_button != 0) |
|
|
|
{ |
|
|
|
uint64_t mouse_buttons = GetMouseState().buttons | uiwidgets_button; |
|
|
|
SetMouseButtons(mouse_buttons); |
|
|
|
SendMouseDown(x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
void UIWidgetsPanel::OnMouseUp(float x, float y, int button) { |
|
|
|
if (process_events_) { |
|
|
|
uint64_t uiwidgets_button = ConvertToUIWidgetsButton(button); |
|
|
|
if (uiwidgets_button != 0) { |
|
|
|
uint64_t mouse_buttons = GetMouseState().buttons & ~uiwidgets_button; |
|
|
|
SetMouseButtons(mouse_buttons); |
|
|
|
SendMouseUp(x, y); |
|
|
|
void UIWidgetsPanel::OnMouseUp(float x, float y, int button) |
|
|
|
{ |
|
|
|
if (process_events_) |
|
|
|
{ |
|
|
|
uint64_t uiwidgets_button = ConvertToUIWidgetsButton(button); |
|
|
|
if (uiwidgets_button != 0) |
|
|
|
{ |
|
|
|
uint64_t mouse_buttons = GetMouseState().buttons & ~uiwidgets_button; |
|
|
|
SetMouseButtons(mouse_buttons); |
|
|
|
SendMouseUp(x, y); |
|
|
|
} |
|
|
|
} |
|
|
|
void UIWidgetsPanel::OnMouseLeave() { |
|
|
|
if (process_events_) { |
|
|
|
SendMouseLeave(); |
|
|
|
void UIWidgetsPanel::OnMouseLeave() |
|
|
|
{ |
|
|
|
if (process_events_) |
|
|
|
{ |
|
|
|
SendMouseLeave(); |
|
|
|
} |
|
|
|
} |
|
|
|
UIWIDGETS_API(UIWidgetsPanel*) |
|
|
|
UIWidgetsPanel_constructor( |
|
|
|
Mono_Handle handle, |
|
|
|
UIWidgetsPanel::EntrypointCallback entrypoint_callback) { |
|
|
|
UnityConsole::WriteLine("??? constructor ggg ++"); |
|
|
|
UIWIDGETS_API(UIWidgetsPanel *) |
|
|
|
UIWidgetsPanel_constructor( |
|
|
|
Mono_Handle handle, int windowType, |
|
|
|
UIWidgetsPanel::EntrypointCallback entrypoint_callback) |
|
|
|
{ |
|
|
|
UIWidgetsWindowType window_type = static_cast<UIWidgetsWindowType>(windowType); |
|
|
|
const auto panel = UIWidgetsPanel::Create(handle, window_type, entrypoint_callback); |
|
|
|
panel->AddRef(); |
|
|
|
// entrypoint_callback(handle);
|
|
|
|
return panel.get(); |
|
|
|
} |
|
|
|
const auto panel = UIWidgetsPanel::Create(handle, entrypoint_callback); |
|
|
|
panel->AddRef(); |
|
|
|
return panel.get(); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_dispose(UIWidgetsPanel *panel) |
|
|
|
{ |
|
|
|
panel->Release(); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) UIWidgetsPanel_dispose(UIWidgetsPanel* panel) { |
|
|
|
panel->Release(); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onEnable(UIWidgetsPanel *panel, void *native_texture_ptr, |
|
|
|
size_t width, size_t height, float device_pixel_ratio, |
|
|
|
const char *streaming_assets_path, |
|
|
|
const char *settings) |
|
|
|
{ |
|
|
|
panel->OnEnable(native_texture_ptr, width, height, device_pixel_ratio, |
|
|
|
streaming_assets_path, settings); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onEnable(UIWidgetsPanel* panel, void* native_texture_ptr, |
|
|
|
size_t width, size_t height, float device_pixel_ratio, |
|
|
|
const char* streaming_assets_path, |
|
|
|
const char* settings) { |
|
|
|
panel->OnEnable(native_texture_ptr, width, height, device_pixel_ratio, |
|
|
|
streaming_assets_path, settings); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onDisable(UIWidgetsPanel *panel) |
|
|
|
{ |
|
|
|
panel->OnDisable(); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) UIWidgetsPanel_onDisable(UIWidgetsPanel* panel) { |
|
|
|
panel->OnDisable(); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onRenderTexture(UIWidgetsPanel *panel, void *native_texture_ptr, |
|
|
|
int width, int height, float dpi) |
|
|
|
{ |
|
|
|
panel->OnRenderTexture(native_texture_ptr, width, height, dpi); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onRenderTexture(UIWidgetsPanel* panel, void* native_texture_ptr, |
|
|
|
int width, int height, float dpi) { |
|
|
|
panel->OnRenderTexture(native_texture_ptr, width, height, dpi); |
|
|
|
} |
|
|
|
UIWIDGETS_API(int) |
|
|
|
UIWidgetsPanel_registerTexture(UIWidgetsPanel *panel, |
|
|
|
void *native_texture_ptr) |
|
|
|
{ |
|
|
|
return panel->RegisterTexture(native_texture_ptr); |
|
|
|
} |
|
|
|
UIWIDGETS_API(int) |
|
|
|
UIWidgetsPanel_registerTexture(UIWidgetsPanel* panel, |
|
|
|
void* native_texture_ptr) { |
|
|
|
return panel->RegisterTexture(native_texture_ptr); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_unregisterTexture(UIWidgetsPanel *panel, int texture_id) |
|
|
|
{ |
|
|
|
panel->UnregisterTexture(texture_id); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_unregisterTexture(UIWidgetsPanel* panel, int texture_id) { |
|
|
|
panel->UnregisterTexture(texture_id); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onKey(UIWidgetsPanel* panel, int keyCode, bool isKeyDown) { |
|
|
|
panel->OnKeyDown(keyCode, isKeyDown); |
|
|
|
} |
|
|
|
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseDown(UIWidgetsPanel* panel, float x, float y, |
|
|
|
int button) { |
|
|
|
panel->OnMouseDown(x, y, button); |
|
|
|
} |
|
|
|
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseUp(UIWidgetsPanel* panel, float x, float y, int button) { |
|
|
|
panel->OnMouseUp(x, y, button); |
|
|
|
} |
|
|
|
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseMove(UIWidgetsPanel* panel, float x, float y) { |
|
|
|
panel->OnMouseMove(x, y); |
|
|
|
} |
|
|
|
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseLeave(UIWidgetsPanel* panel) { panel->OnMouseLeave(); } |
|
|
|
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onKey(UIWidgetsPanel *panel, int keyCode, bool isKeyDown) |
|
|
|
{ |
|
|
|
panel->OnKeyDown(keyCode, isKeyDown); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void*) |
|
|
|
SetTextureFromUnity2(void* tex, int w, int h) { return UnitySurfaceManager::SetTextureFromUnity(tex, w, h); } |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseDown(UIWidgetsPanel *panel, float x, float y, |
|
|
|
int button) |
|
|
|
{ |
|
|
|
panel->OnMouseDown(x, y, button); |
|
|
|
} |
|
|
|
static void UNITY_INTERFACE_API OnGetUnityContextEvent(int eventID) |
|
|
|
{ |
|
|
|
UnitySurfaceManager::GetUnityContext(); |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseUp(UIWidgetsPanel *panel, float x, float y, int button) |
|
|
|
{ |
|
|
|
panel->OnMouseUp(x, y, button); |
|
|
|
} |
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// GetRenderEventFunc, an example function we export which is used to get a rendering event callback function.
|
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseMove(UIWidgetsPanel *panel, float x, float y) |
|
|
|
{ |
|
|
|
panel->OnMouseMove(x, y); |
|
|
|
} |
|
|
|
UIWIDGETS_API(UnityRenderingEvent) GetUnityContextEventFunc() |
|
|
|
{ |
|
|
|
return OnGetUnityContextEvent; |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
UIWidgetsPanel_onMouseLeave(UIWidgetsPanel *panel) { panel->OnMouseLeave(); } |
|
|
|
static void UNITY_INTERFACE_API OnRenderEvent(int eventID) |
|
|
|
{ |
|
|
|
UnitySurfaceManager::SetUp(); |
|
|
|
} |
|
|
|
static void UNITY_INTERFACE_API OnGetUnityContextEvent(int eventID) |
|
|
|
{ |
|
|
|
UnitySurfaceManager::GetUnityContext(); |
|
|
|
} |
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// GetRenderEventFunc, an example function we export which is used to get a rendering event callback function.
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// GetRenderEventFunc, an example function we export which is used to get a rendering event callback function.
|
|
|
|
UIWIDGETS_API(UnityRenderingEvent) GetRenderEventFunc() |
|
|
|
{ |
|
|
|
return OnRenderEvent; |
|
|
|
} |
|
|
|
UIWIDGETS_API(UnityRenderingEvent) |
|
|
|
GetUnityContextEventFunc() |
|
|
|
{ |
|
|
|
return OnGetUnityContextEvent; |
|
|
|
} |
|
|
|
UIWIDGETS_API(void) |
|
|
|
draw_xxx() { UnitySurfaceManager::drawxxx(); } |
|
|
|
} // namespace uiwidgets
|
|
|
|
} // namespace uiwidgets
|