8#ifndef WasmCommon_DEFINED
9#define WasmCommon_DEFINED
11#include <emscripten.h>
12#include <emscripten/bind.h>
51#define SPECIALIZE_JSARRAYTYPE(type, name) \
52 template <> struct JSArrayType<type> { \
53 static constexpr const char* const gName = name; \
66#undef SPECIALIZE_JSARRAYTYPE
75 jarray.call<
void>(
"set", val(typed_memory_view(
count,
src)));
94 const size_t len =
src[
"length"].as<
size_t>();
98 if (
src[
"_ck"].isTrue()) {
100 data =
reinterpret_cast<T*
>(
src[
"byteOffset"].as<
size_t>());
107 auto dst_view = emscripten::val(typed_memory_view(
len,
data));
108 dst_view.call<
void>(
"set",
src);
110 for (
size_t i = 0;
i <
len; ++
i) {
119 fSpan =
SkSpan(
reinterpret_cast<T*
>(ptr),
len);
128 const T*
data()
const {
return fSpan.data(); }
129 size_t size()
const {
return fSpan.size(); }
SK_API void sk_free(void *)
static void * sk_malloc_throw(size_t size)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
std::unique_ptr< SkCodec > DecodeImageData(sk_sp< SkData >)
#define SPECIALIZE_JSARRAYTYPE(type, name)
emscripten::val Uint32Array
emscripten::val SkPathOrNull
emscripten::val Uint16Array
TypedArray MakeTypedArray(int count, const T src[])
SkColor4f ptrToSkColor4f(WASMPointerF32)
emscripten::val TypedArray
emscripten::val Float32Array
emscripten::val Uint8Array
JSSpan(WASMPointer ptr, size_t len, bool takeOwnership)