Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
bindings.cpp File Reference
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkColorSpace.h"
#include "include/core/SkColorType.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkSurface.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/gpu/GrBackendSurface.h"
#include "include/gpu/GrDirectContext.h"
#include "include/gpu/ganesh/SkSurfaceGanesh.h"
#include <emscripten/bind.h>
#include <emscripten/emscripten.h>
#include <emscripten/html5.h>
#include <emscripten/html5_webgpu.h>
#include <webgpu/webgpu.h>
#include <webgpu/webgpu_cpp.h>

Go to the source code of this file.

Classes

struct  DemoUniforms
 
class  Demo
 

Enumerations

enum class  DemoKind { SOLID_COLOR , GRADIENT , RUNTIME_EFFECT }
 

Functions

static wgpu::SwapChain getSwapChainForCanvas (wgpu::Device device, std::string canvasSelector, int width, int height)
 
 EMSCRIPTEN_BINDINGS (Skia)
 

Enumeration Type Documentation

◆ DemoKind

enum class DemoKind
strong
Enumerator
SOLID_COLOR 
GRADIENT 
RUNTIME_EFFECT 

Definition at line 60 of file bindings.cpp.

60 {
64};
@ RUNTIME_EFFECT

Function Documentation

◆ EMSCRIPTEN_BINDINGS()

EMSCRIPTEN_BINDINGS ( Skia  )

Definition at line 194 of file bindings.cpp.

194 {
195 emscripten::enum_<DemoKind>("DemoKind")
196 .value("SOLID_COLOR", DemoKind::SOLID_COLOR)
197 .value("GRADIENT", DemoKind::GRADIENT)
198 .value("RUNTIME_EFFECT", DemoKind::RUNTIME_EFFECT);
199 emscripten::class_<Demo>("Demo")
200 .constructor()
201 .function("init", &Demo::init)
202 .function("setKind", &Demo::setKind)
203 .function("draw", &Demo::draw);
204}
void draw(int timestamp)
Definition bindings.cpp:123
bool init(std::string canvasSelector, int width, int height)
Definition bindings.cpp:74
void setKind(DemoKind kind)
Definition bindings.cpp:121

◆ getSwapChainForCanvas()

static wgpu::SwapChain getSwapChainForCanvas ( wgpu::Device  device,
std::string  canvasSelector,
int  width,
int  height 
)
static

Definition at line 39 of file bindings.cpp.

42 {
43 wgpu::SurfaceDescriptorFromCanvasHTMLSelector surfaceSelector;
44 surfaceSelector.selector = canvasSelector.c_str();
45
46 wgpu::SurfaceDescriptor surface_desc;
47 surface_desc.nextInChain = &surfaceSelector;
48 wgpu::Instance instance;
49 wgpu::Surface surface = instance.CreateSurface(&surface_desc);
50
51 wgpu::SwapChainDescriptor swap_chain_desc;
52 swap_chain_desc.format = wgpu::TextureFormat::BGRA8Unorm;
53 swap_chain_desc.usage = wgpu::TextureUsage::RenderAttachment;
54 swap_chain_desc.presentMode = wgpu::PresentMode::Fifo;
55 swap_chain_desc.width = width;
56 swap_chain_desc.height = height;
57 return device.CreateSwapChain(surface, &swap_chain_desc);
58}
VkDevice device
Definition main.cc:53
VkInstance instance
Definition main.cc:48
VkSurfaceKHR surface
Definition main.cc:49
int32_t height
int32_t width