mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
ca9f7b7dd6
The build is based on CMake. There is a demo HTML page under webp_js/index.html See README.webp_js file. BUG=webp:261 Change-Id: I6612378b89907efd7b863720c6becf98385fc406
64 lines
2.1 KiB
Plaintext
64 lines
2.1 KiB
Plaintext
__ __ ____ ____ ____ __ ____
|
|
/ \\/ \ _ \ _ \ _ \ (__)/ __\
|
|
\ / __/ _ \ __/ _) \_ \
|
|
\__\__/_____/____/_/ /____/____/
|
|
|
|
Description:
|
|
============
|
|
|
|
This file describes the compilation of libwebp into a JavaScript decoder
|
|
using Emscripten and CMake.
|
|
|
|
- install the Emscripten SDK following the procedure described at:
|
|
https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html
|
|
After installation, you should have some global variable positioned to the
|
|
location of the SDK. In particular, $EMSCRIPTEN should point to the
|
|
top-level directory containing Emscripten tools.
|
|
|
|
- make sure the file $EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake is
|
|
accessible. This is the toolchain file used by CMake to invoke Emscripten.
|
|
|
|
- configure the project 'WEBP_JS' with CMake using:
|
|
|
|
cd webp_js && \
|
|
cmake -DWEBP_BUILD_WEBP_JS=ON \
|
|
-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1 \
|
|
-DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake \
|
|
../
|
|
|
|
- compile webp.js using 'make'.
|
|
|
|
- that's it! Upon completion, you should have the webp.js and
|
|
webp.js.mem files generated.
|
|
|
|
The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
|
|
bitstream into a canvas. See webp_js/index.html for a simple usage sample.
|
|
|
|
Demo HTML page:
|
|
===============
|
|
|
|
The HTML page webp_js/index.html requires an HTTP server to serve the WebP
|
|
image example. It's easy to just use Python for that.
|
|
|
|
cd webp_js && python -m SimpleHTTPServer 8080
|
|
|
|
and then navigate to http://localhost:8080 in your favorite browser.
|
|
|
|
|
|
Caveat:
|
|
=======
|
|
|
|
- First decoding using the library is usually slower, due to just-in-time
|
|
compilation.
|
|
|
|
- Some versions of llvm produce the following compile error when SSE2 is
|
|
enabled.
|
|
|
|
"Unsupported: %516 = bitcast <8 x i16> %481 to i128
|
|
LLVM ERROR: BitCast Instruction not yet supported for integer types larger than 64 bits"
|
|
|
|
The corresponding Emscripten bug is at:
|
|
https://github.com/kripken/emscripten/issues/3788
|
|
|
|
Therefore, SSE2 optimization is currently disabled in CMakeLists.txt.
|