mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +01:00
Merge changes I26f4aa22,I83386b6c,I320ed1a2 into main
* changes: webp_js/*.html: fix canvas mapping cmake,wasm: simplify SDL2 related flags cmake: fix vwebp_sdl compile w/libsdl-org release
This commit is contained in:
commit
b3d1b2cbf7
@ -665,6 +665,21 @@ if(WEBP_BUILD_EXTRAS)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/src ${SDL2_INCLUDE_DIRS})
|
||||
set(WEBP_HAVE_SDL 1)
|
||||
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES "${SDL2_INCLUDE_DIRS}")
|
||||
check_c_source_compiles(
|
||||
"
|
||||
#define SDL_MAIN_HANDLED
|
||||
#include \"SDL.h\"
|
||||
int main(void) {
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
HAVE_JUST_SDL_H)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
if(HAVE_JUST_SDL_H)
|
||||
target_compile_definitions(vwebp_sdl PRIVATE WEBP_HAVE_JUST_SDL_H)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -679,13 +694,10 @@ if(WEBP_BUILD_WEBP_JS)
|
||||
else()
|
||||
set(emscripten_stack_size "-sTOTAL_STACK=5MB")
|
||||
endif()
|
||||
# Set SDL2 flags so that ports are downloaded by emscripten.
|
||||
set(EMSCRIPTEN_SDL2_FLAGS "-sUSE_SDL=2 -sUSE_SDL_IMAGE=2")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EMSCRIPTEN_SDL2_FLAGS}")
|
||||
find_package(SDL2 REQUIRED)
|
||||
# wasm2js does not support SIMD.
|
||||
if(NOT WEBP_ENABLE_SIMD)
|
||||
# JavaScript version
|
||||
find_package(SDL2 QUIET)
|
||||
add_executable(webp_js ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c)
|
||||
target_link_libraries(webp_js webpdecoder SDL2)
|
||||
target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
@ -693,10 +705,13 @@ if(WEBP_BUILD_WEBP_JS)
|
||||
set_target_properties(
|
||||
webp_js
|
||||
PROPERTIES
|
||||
# Emscripten puts -sUSE_SDL2=1 in this variable, though it's needed at
|
||||
# compile time to ensure the headers are downloaded.
|
||||
COMPILE_OPTIONS "${SDL2_LIBRARIES}"
|
||||
LINK_FLAGS
|
||||
"-sWASM=0 ${emscripten_stack_size} \
|
||||
-sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \
|
||||
-sEXPORTED_RUNTIME_METHODS=cwrap ${EMSCRIPTEN_SDL2_FLAGS} \
|
||||
-sEXPORTED_RUNTIME_METHODS=cwrap ${SDL2_LIBRARIES} \
|
||||
-sALLOW_MEMORY_GROWTH")
|
||||
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp)
|
||||
target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
|
||||
@ -709,10 +724,13 @@ if(WEBP_BUILD_WEBP_JS)
|
||||
set_target_properties(
|
||||
webp_wasm
|
||||
PROPERTIES
|
||||
# Emscripten puts -sUSE_SDL2=1 in this variable, though it's needed at
|
||||
# compile time to ensure the headers are downloaded.
|
||||
COMPILE_OPTIONS "${SDL2_LIBRARIES}"
|
||||
LINK_FLAGS
|
||||
"-sWASM=1 ${emscripten_stack_size} \
|
||||
-sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \
|
||||
-sEXPORTED_RUNTIME_METHODS=cwrap ${EMSCRIPTEN_SDL2_FLAGS} \
|
||||
-sEXPORTED_RUNTIME_METHODS=cwrap ${SDL2_LIBRARIES} \
|
||||
-sALLOW_MEMORY_GROWTH")
|
||||
target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
|
||||
|
||||
|
@ -29,6 +29,8 @@ function decode(webp_data, canvas_id) {
|
||||
// clear previous picture (if any)
|
||||
Module.canvas = canvas;
|
||||
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
|
||||
// Map this canvas to the default selector used by emscripten/SDL2.
|
||||
specialHTMLTargets["#canvas"] = Module.canvas;
|
||||
// decode and measure timing
|
||||
var start = new Date();
|
||||
var ret = WebpToCanvas(webp_data, webp_data.length);
|
||||
|
@ -30,6 +30,8 @@ function decode(webp_data, canvas_id) {
|
||||
// clear previous picture (if any)
|
||||
Module.canvas = canvas;
|
||||
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
|
||||
// Map this canvas to the default selector used by emscripten/SDL2.
|
||||
specialHTMLTargets["#canvas"] = Module.canvas;
|
||||
// decode and measure timing
|
||||
var start = new Date();
|
||||
var ret = WebpToCanvas(webp_data, webp_data.length);
|
||||
|
Loading…
Reference in New Issue
Block a user