Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
WasmCommon.h File Reference
#include <emscripten.h>
#include <emscripten/bind.h>
#include "include/core/SkColor.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkSpan.h"
#include "include/private/base/SkMalloc.h"
#include <memory>

Go to the source code of this file.

Classes

struct  JSArrayType< T >
 
class  JSSpan< T >
 

Macros

#define SPECIALIZE_JSARRAYTYPE(type, name)
 

Typedefs

using JSColor = int32_t
 
using JSArray = emscripten::val
 
using JSObject = emscripten::val
 
using JSString = emscripten::val
 
using SkPathOrNull = emscripten::val
 
using TypedArray = emscripten::val
 
using Uint8Array = emscripten::val
 
using Uint16Array = emscripten::val
 
using Uint32Array = emscripten::val
 
using Float32Array = emscripten::val
 
using WASMPointerF32 = uintptr_t
 
using WASMPointerI32 = uintptr_t
 
using WASMPointerU8 = uintptr_t
 
using WASMPointerU16 = uintptr_t
 
using WASMPointerU32 = uintptr_t
 
using WASMPointer = uintptr_t
 

Functions

 SPECIALIZE_JSARRAYTYPE (int8_t, "Int8Array")
 
 SPECIALIZE_JSARRAYTYPE (uint8_t, "Uint8Array")
 
 SPECIALIZE_JSARRAYTYPE (int16_t, "Int16Array")
 
 SPECIALIZE_JSARRAYTYPE (uint16_t, "Uint16Array")
 
 SPECIALIZE_JSARRAYTYPE (int32_t, "Int32Array")
 
 SPECIALIZE_JSARRAYTYPE (uint32_t, "Uint32Array")
 
 SPECIALIZE_JSARRAYTYPE (float, "Float32Array")
 
template<typename T >
TypedArray MakeTypedArray (int count, const T src[])
 
SkColor4f ptrToSkColor4f (WASMPointerF32)
 
std::unique_ptr< SkCodecDecodeImageData (sk_sp< SkData >)
 

Macro Definition Documentation

◆ SPECIALIZE_JSARRAYTYPE

#define SPECIALIZE_JSARRAYTYPE (   type,
  name 
)
Value:
template <> struct JSArrayType<type> { \
static constexpr const char* const gName = name; \
}
const char * name
Definition fuchsia.cc:50

Definition at line 51 of file WasmCommon.h.

52 { \
53 static constexpr const char* const gName = name; \
54 }

Typedef Documentation

◆ Float32Array

using Float32Array = emscripten::val

Definition at line 35 of file WasmCommon.h.

◆ JSArray

using JSArray = emscripten::val

Definition at line 27 of file WasmCommon.h.

◆ JSColor

using JSColor = int32_t

Definition at line 26 of file WasmCommon.h.

◆ JSObject

using JSObject = emscripten::val

Definition at line 28 of file WasmCommon.h.

◆ JSString

using JSString = emscripten::val

Definition at line 29 of file WasmCommon.h.

◆ SkPathOrNull

using SkPathOrNull = emscripten::val

Definition at line 30 of file WasmCommon.h.

◆ TypedArray

using TypedArray = emscripten::val

Definition at line 31 of file WasmCommon.h.

◆ Uint16Array

using Uint16Array = emscripten::val

Definition at line 33 of file WasmCommon.h.

◆ Uint32Array

using Uint32Array = emscripten::val

Definition at line 34 of file WasmCommon.h.

◆ Uint8Array

using Uint8Array = emscripten::val

Definition at line 32 of file WasmCommon.h.

◆ WASMPointer

using WASMPointer = uintptr_t

Definition at line 49 of file WasmCommon.h.

◆ WASMPointerF32

using WASMPointerF32 = uintptr_t

Definition at line 44 of file WasmCommon.h.

◆ WASMPointerI32

using WASMPointerI32 = uintptr_t

Definition at line 45 of file WasmCommon.h.

◆ WASMPointerU16

using WASMPointerU16 = uintptr_t

Definition at line 47 of file WasmCommon.h.

◆ WASMPointerU32

using WASMPointerU32 = uintptr_t

Definition at line 48 of file WasmCommon.h.

◆ WASMPointerU8

using WASMPointerU8 = uintptr_t

Definition at line 46 of file WasmCommon.h.

Function Documentation

◆ DecodeImageData()

std::unique_ptr< SkCodec > DecodeImageData ( sk_sp< SkData data)

Definition at line 167 of file canvaskit_bindings.cpp.

167 {
168 if (data == nullptr) {
169 return nullptr;
170 }
171 // These codecs are arbitrarily ordered in alphabetical order.
172#if defined(SK_CODEC_DECODES_BMP)
173 if (SkBmpDecoder::IsBmp(data->data(), data->size())) {
174 return SkBmpDecoder::Decode(data, nullptr);
175 }
176#endif
177#if defined(SK_CODEC_DECODES_GIF)
178 if (SkGifDecoder::IsGif(data->data(), data->size())) {
179 return SkGifDecoder::Decode(data, nullptr);
180 }
181#endif
182#if defined(SK_CODEC_DECODES_ICO)
183 if (SkIcoDecoder::IsIco(data->data(), data->size())) {
184 return SkIcoDecoder::Decode(data, nullptr);
185 }
186#endif
187#if defined(SK_CODEC_DECODES_JPEG)
188 if (SkJpegDecoder::IsJpeg(data->data(), data->size())) {
189 return SkJpegDecoder::Decode(data, nullptr);
190 }
191#endif
192#if defined(SK_CODEC_DECODES_PNG)
193 if (SkPngDecoder::IsPng(data->data(), data->size())) {
194 return SkPngDecoder::Decode(data, nullptr);
195 }
196#endif
197#if defined(SK_CODEC_DECODES_WBMP)
198 if (SkWbmpDecoder::IsWbmp(data->data(), data->size())) {
199 return SkWbmpDecoder::Decode(data, nullptr);
200 }
201#endif
202#if defined(SK_CODEC_DECODES_WEBP)
203 if (SkWebpDecoder::IsWebp(data->data(), data->size())) {
204 return SkWebpDecoder::Decode(data, nullptr);
205 }
206#endif
207 return nullptr;
208}
SK_API bool IsBmp(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsGif(const void *, size_t)
SK_API bool IsIco(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsJpeg(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsPng(const void *, size_t)
SK_API bool IsWbmp(const void *, size_t)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API std::unique_ptr< SkCodec > Decode(std::unique_ptr< SkStream >, SkCodec::Result *, SkCodecs::DecodeContext=nullptr)
SK_API bool IsWebp(const void *, size_t)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ MakeTypedArray()

template<typename T >
TypedArray MakeTypedArray ( int  count,
const T  src[] 
)

Create a typed-array (in the JS heap) and initialize it with the provided data (from the wasm heap).

Definition at line 72 of file WasmCommon.h.

72 {
73 emscripten::val length = emscripten::val(count);
74 emscripten::val jarray = emscripten::val::global(JSArrayType<T>::gName).new_(count);
75 jarray.call<void>("set", val(typed_memory_view(count, src)));
76 return jarray;
77}
int count
size_t length

◆ ptrToSkColor4f()

SkColor4f ptrToSkColor4f ( WASMPointerF32  cPtr)

Definition at line 219 of file canvaskit_bindings.cpp.

219 {
220 float* fourFloats = reinterpret_cast<float*>(cPtr);
222 memcpy(&color, fourFloats, 4 * sizeof(float));
223 return color;
224}
SkColor4f color

◆ SPECIALIZE_JSARRAYTYPE() [1/7]

SPECIALIZE_JSARRAYTYPE ( float  ,
"Float32Array"   
)

◆ SPECIALIZE_JSARRAYTYPE() [2/7]

SPECIALIZE_JSARRAYTYPE ( int16_t  ,
"Int16Array"   
)

◆ SPECIALIZE_JSARRAYTYPE() [3/7]

SPECIALIZE_JSARRAYTYPE ( int32_t  ,
"Int32Array"   
)

◆ SPECIALIZE_JSARRAYTYPE() [4/7]

SPECIALIZE_JSARRAYTYPE ( int8_t  ,
"Int8Array"   
)

◆ SPECIALIZE_JSARRAYTYPE() [5/7]

SPECIALIZE_JSARRAYTYPE ( uint16_t  ,
"Uint16Array"   
)

◆ SPECIALIZE_JSARRAYTYPE() [6/7]

SPECIALIZE_JSARRAYTYPE ( uint32_t  ,
"Uint32Array"   
)

◆ SPECIALIZE_JSARRAYTYPE() [7/7]

SPECIALIZE_JSARRAYTYPE ( uint8_t  ,
"Uint8Array"   
)