Add Chromium-only Blender WebEngine parity work
This commit is contained in:
27
web/engine/CMakeLists.txt
Normal file
27
web/engine/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(blender_web_engine LANGUAGES C CXX)
|
||||
|
||||
set(WITH_WEB ON CACHE BOOL "Build the browser Blender engine")
|
||||
option(WEB_ENGINE_THREADS "Build the pthread variant" OFF)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/../../blender-5.2.0/build_files/cmake/platform/web.cmake")
|
||||
|
||||
if(WEB_ENGINE_THREADS)
|
||||
add_compile_options(-pthread)
|
||||
add_link_options(-pthread -sPTHREAD_POOL_SIZE=1)
|
||||
endif()
|
||||
|
||||
add_library(blender_web_engine_core STATIC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../../blender-5.2.0/source/blender/web_engine/web_engine_api.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/web_engine_native_reader_stub.cpp"
|
||||
)
|
||||
target_include_directories(blender_web_engine_core PUBLIC
|
||||
"${CMAKE_CURRENT_LIST_DIR}/../../blender-5.2.0/source/blender/web_engine"
|
||||
)
|
||||
|
||||
add_executable(web_engine web_engine_smoke.cpp)
|
||||
target_link_libraries(web_engine PRIVATE blender_web_engine_core)
|
||||
target_link_options(web_engine PRIVATE
|
||||
"-sEXPORTED_FUNCTIONS=['_malloc','_free','_web_engine_create','_web_engine_destroy','_web_engine_get_memory_stats','_web_engine_get_live_handles','_web_engine_get_allocated_bytes','_web_engine_open_blend','_web_engine_apply_command','_web_engine_get_scene_snapshot','_web_engine_save_blend','_web_engine_free_buffer','_web_engine_last_error_code','_web_engine_last_error_message']"
|
||||
"-sEXPORTED_RUNTIME_METHODS=['ccall','cwrap']"
|
||||
)
|
||||
set_target_properties(web_engine PROPERTIES OUTPUT_NAME "web_engine")
|
||||
6
web/engine/emscripten_smoke.c
Normal file
6
web/engine/emscripten_smoke.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <stdint.h>
|
||||
|
||||
int web_engine_smoke_value(void) {
|
||||
const uint32_t value = 0x424c454e;
|
||||
return (int)(value & 0xffffu);
|
||||
}
|
||||
158
web/engine/web_engine_native_reader_stub.cpp
Normal file
158
web/engine/web_engine_native_reader_stub.cpp
Normal file
@@ -0,0 +1,158 @@
|
||||
#include "web_engine_blend_reader.h"
|
||||
#include "web_engine_decimate.h"
|
||||
#include "web_engine_depsgraph.h"
|
||||
#include "web_engine_main_state.h"
|
||||
|
||||
struct WebBlendMainState {};
|
||||
|
||||
void web_engine_blender_runtime_initialize() {}
|
||||
|
||||
WebBlendMainState *web_engine_blend_main_open(const uint8_t *, uint32_t, std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void web_engine_blend_main_free(WebBlendMainState *) {}
|
||||
|
||||
bool web_engine_blend_main_set_frame(WebBlendMainState *, int, std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_visibility(WebBlendMainState *, const char *, bool, std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_modifier_enabled(WebBlendMainState *,
|
||||
const char *,
|
||||
const char *,
|
||||
bool,
|
||||
std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_replace_mesh(WebBlendMainState *,
|
||||
const char *,
|
||||
const std::vector<float> &,
|
||||
const std::vector<uint32_t> &,
|
||||
const std::vector<float> &,
|
||||
const std::vector<float> &,
|
||||
const std::vector<uint32_t> &,
|
||||
std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_create_primitive(WebBlendMainState *,
|
||||
const char *,
|
||||
const char *,
|
||||
const std::vector<float> &,
|
||||
std::string &,
|
||||
std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_duplicate_object(WebBlendMainState *,
|
||||
const char *,
|
||||
const std::vector<float> &,
|
||||
std::string &,
|
||||
std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_delete_object(WebBlendMainState *, const char *, std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_set_transform(WebBlendMainState *,
|
||||
const char *,
|
||||
const std::vector<float> &,
|
||||
const std::vector<float> &,
|
||||
const std::vector<float> &,
|
||||
std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_translate_vertices(WebBlendMainState *,
|
||||
const char *,
|
||||
const std::vector<uint32_t> &,
|
||||
const std::vector<float> &,
|
||||
std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool web_engine_blend_main_write(WebBlendMainState *, std::vector<uint8_t> &, std::string &error)
|
||||
{
|
||||
error = "native smoke Main stub";
|
||||
return false;
|
||||
}
|
||||
|
||||
WebBlendReadResult web_engine_read_blend_scene_ir(const uint8_t *, uint32_t, uint64_t)
|
||||
{
|
||||
// The native ABI smoke test exercises handle/error ownership. The real reader is linked
|
||||
// by the Blender/Emscripten target and covered by the WASM fixture smoke test.
|
||||
return {false, "native smoke reader stub", {}, {}, 0};
|
||||
}
|
||||
|
||||
WebDepsgraphEvaluationResult web_engine_evaluate_blender_depsgraph(const uint8_t *,
|
||||
uint32_t,
|
||||
int)
|
||||
{
|
||||
return {false, "native smoke depsgraph stub", {}};
|
||||
}
|
||||
|
||||
extern "C" int web_engine_decimate_apply(const float *,
|
||||
uint32_t,
|
||||
const uint32_t *,
|
||||
uint32_t,
|
||||
uint32_t,
|
||||
float,
|
||||
uint32_t,
|
||||
float,
|
||||
uint32_t,
|
||||
uint32_t,
|
||||
uint32_t,
|
||||
int32_t,
|
||||
float,
|
||||
const float *,
|
||||
float,
|
||||
uint32_t,
|
||||
const float *,
|
||||
const float *,
|
||||
const uint32_t *,
|
||||
float *,
|
||||
uint32_t,
|
||||
uint32_t *,
|
||||
uint32_t *,
|
||||
uint32_t,
|
||||
uint32_t *,
|
||||
float *,
|
||||
uint32_t,
|
||||
uint32_t *,
|
||||
float *,
|
||||
uint32_t,
|
||||
uint32_t *,
|
||||
uint32_t *,
|
||||
uint32_t,
|
||||
uint32_t *,
|
||||
uint32_t *)
|
||||
{
|
||||
return WEB_ENGINE_DECIMATE_NOT_IMPLEMENTED;
|
||||
}
|
||||
24
web/engine/web_engine_native_smoke.cpp
Normal file
24
web/engine/web_engine_native_smoke.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "web_engine_api.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
const int handle = web_engine_create();
|
||||
const int open_result = web_engine_open_blend(handle, nullptr, 0);
|
||||
const int command_result = web_engine_apply_command(handle, nullptr, 0);
|
||||
const uint32_t live_before_destroy = web_engine_get_live_handles();
|
||||
web_engine_destroy(handle);
|
||||
const uint32_t live_after_destroy = web_engine_get_live_handles();
|
||||
|
||||
std::printf("{\"handle\":%d,\"open\":%d,\"command\":%d,\"liveBeforeDestroy\":%u,\"liveAfterDestroy\":%u}\n",
|
||||
handle,
|
||||
open_result,
|
||||
command_result,
|
||||
live_before_destroy,
|
||||
live_after_destroy);
|
||||
return handle == 1 && open_result == -2 && command_result == -2 && live_before_destroy == 1 &&
|
||||
live_after_destroy == 0 ?
|
||||
0 :
|
||||
1;
|
||||
}
|
||||
14
web/engine/web_engine_smoke.cpp
Normal file
14
web/engine/web_engine_smoke.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "web_engine_api.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
int web_engine_smoke_value(void) {
|
||||
const int handle = web_engine_create();
|
||||
const WebEngineMemoryStats stats = web_engine_get_memory_stats();
|
||||
web_engine_destroy(handle);
|
||||
return static_cast<int>((UINT32_C(0x574542) & UINT32_C(0xffff)) + stats.live_handles);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user