Skip to content

Commit

Permalink
Export CanvasWrapper, OffscreenCanvasWrapper in web_rwh feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Jan 2, 2025
1 parent 5626a80 commit dca7db1
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 149 deletions.
38 changes: 19 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ android_logger = "0.14"
jni = "0.21"
jni_fn = "0.1"
ndk-sys = "0.6"
ash = "0.38"

# wasm target
web-sys = "0.3.72"
wasm-bindgen = "0.2.95"
js-sys = "0.3.72"
wasm-bindgen-futures = "0.4.45"
web-sys = "0.3.76"
wasm-bindgen = "0.2.99"
js-sys = "0.3.76"
wasm-bindgen-futures = "0.4.49"
3 changes: 1 addition & 2 deletions app-surface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "app-surface"
authors = ["jinleili"]
description = "Integrate wgpu into your existing iOS, Android and Web apps without relying on winit."
edition = "2021"
version = "1.3.2"
version = "1.3.3"
rust-version = "1.76"
repository = "https://github.com/jinleili/wgpu-in-app"
keywords = ["android", "SurfaceView", "CAMetalLayer", "Canvas", "wgpu"]
Expand Down Expand Up @@ -49,7 +49,6 @@ android_logger.workspace = true
jni.workspace = true
ndk-sys.workspace = true
raw-window-handle.workspace = true
ash.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
winit.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion app-surface/src/app_surface_use_winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl AppSurface {
}

pub fn get_view(&self) -> &Window {
return self.view.as_ref().unwrap();
self.view.as_ref().unwrap()
}

#[allow(unused_variables)]
Expand Down
4 changes: 2 additions & 2 deletions app-surface/src/web_rwh/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Deref for Canvas {
}
}

impl HasWindowHandle for Canvas {
impl HasWindowHandle for CanvasWrapper {
fn window_handle(
&self,
) -> Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
Expand All @@ -101,7 +101,7 @@ impl HasWindowHandle for Canvas {
}
}

impl HasDisplayHandle for Canvas {
impl HasDisplayHandle for CanvasWrapper {
fn display_handle(
&self,
) -> Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
Expand Down
2 changes: 1 addition & 1 deletion app-surface/src/web_rwh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl ViewObj {
}

#[derive(Clone, Debug)]
pub(crate) struct SendSyncWrapper<T>(pub(crate) T);
pub struct SendSyncWrapper<T>(pub T);

unsafe impl<T> Send for SendSyncWrapper<T> {}
unsafe impl<T> Sync for SendSyncWrapper<T> {}
4 changes: 2 additions & 2 deletions app-surface/src/web_rwh/offscreen_canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl From<&Canvas> for OffscreenCanvas {
}
}

impl HasWindowHandle for OffscreenCanvas {
impl HasWindowHandle for OffscreenCanvasWrapper {
fn window_handle(
&self,
) -> Result<raw_window_handle::WindowHandle<'_>, raw_window_handle::HandleError> {
Expand All @@ -78,7 +78,7 @@ impl HasWindowHandle for OffscreenCanvas {
}
}

impl HasDisplayHandle for OffscreenCanvas {
impl HasDisplayHandle for OffscreenCanvasWrapper {
fn display_handle(
&self,
) -> Result<raw_window_handle::DisplayHandle<'_>, raw_window_handle::HandleError> {
Expand Down
118 changes: 1 addition & 117 deletions wgpu-in-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,126 +45,10 @@ log-panics = "*"
web-sys = { workspace = true, features = [
"Document",
"Navigator",
"Node",
"NodeList",
"Gpu",
"GpuAdapter",
"GpuAddressMode",
"GpuAutoLayoutMode",
"GpuBindGroup",
"GpuBindGroupDescriptor",
"GpuBindGroupEntry",
"GpuBindGroupLayout",
"GpuBindGroupLayoutDescriptor",
"GpuBindGroupLayoutEntry",
"GpuBlendComponent",
"GpuBlendFactor",
"GpuBlendOperation",
"GpuBlendState",
"GpuBuffer",
"GpuBufferBinding",
"GpuBufferBindingLayout",
"GpuBufferBindingType",
"GpuBufferDescriptor",
"GpuCanvasAlphaMode",
"GpuCanvasContext",
"GpuCanvasConfiguration",
"GpuColorDict",
"GpuColorTargetState",
"GpuCommandBuffer",
"GpuCommandBufferDescriptor",
"GpuCommandEncoder",
"GpuCommandEncoderDescriptor",
"GpuCompareFunction",
"GpuCompilationInfo",
"GpuCompilationMessage",
"GpuCompilationMessageType",
"GpuComputePassDescriptor",
"GpuComputePassEncoder",
"GpuComputePipeline",
"GpuComputePipelineDescriptor",
"GpuCullMode",
"GpuDepthStencilState",
"GpuDevice",
"GpuDeviceDescriptor",
"GpuDeviceLostInfo",
"GpuDeviceLostReason",
"GpuError",
"GpuErrorFilter",
"GpuExtent3dDict",
"GpuFeatureName",
"GpuFilterMode",
"GpuFragmentState",
"GpuFrontFace",
"GpuImageCopyBuffer",
"GpuImageCopyTexture",
"GpuImageDataLayout",
"GpuIndexFormat",
"GpuLoadOp",
"gpu_map_mode",
"GpuMipmapFilterMode",
"GpuMultisampleState",
"GpuObjectDescriptorBase",
"GpuOrigin2dDict",
"GpuOrigin3dDict",
"GpuOutOfMemoryError",
"GpuPipelineDescriptorBase",
"GpuPipelineLayout",
"GpuPipelineLayoutDescriptor",
"GpuPowerPreference",
"GpuPrimitiveState",
"GpuPrimitiveTopology",
"GpuProgrammableStage",
"GpuQuerySet",
"GpuQuerySetDescriptor",
"GpuQueryType",
"GpuQueue",
"GpuRenderBundle",
"GpuRenderBundleDescriptor",
"GpuRenderBundleEncoder",
"GpuRenderBundleEncoderDescriptor",
"GpuRenderPassColorAttachment",
"GpuRenderPassDepthStencilAttachment",
"GpuRenderPassDescriptor",
"GpuRenderPassEncoder",
"GpuRenderPipeline",
"GpuRenderPipelineDescriptor",
"GpuRequestAdapterOptions",
"GpuSampler",
"GpuSamplerBindingLayout",
"GpuSamplerBindingType",
"GpuSamplerDescriptor",
"GpuShaderModule",
"GpuShaderModuleDescriptor",
"GpuStencilFaceState",
"GpuStencilOperation",
"GpuStorageTextureAccess",
"GpuStorageTextureBindingLayout",
"GpuStoreOp",
"GpuSupportedFeatures",
"GpuSupportedLimits",
"GpuTexture",
"GpuTextureAspect",
"GpuTextureBindingLayout",
"GpuTextureDescriptor",
"GpuTextureDimension",
"GpuTextureFormat",
"GpuTextureSampleType",
"GpuTextureView",
"GpuTextureViewDescriptor",
"GpuTextureViewDimension",
"GpuUncapturedErrorEvent",
"GpuUncapturedErrorEventInit",
"GpuValidationError",
"GpuVertexAttribute",
"GpuVertexBufferLayout",
"GpuVertexFormat",
"GpuVertexState",
"GpuVertexStepMode",
"GpuAdapter",
"HtmlCanvasElement",
"OffscreenCanvas",
"ImageBitmap",
"ImageBitmapRenderingContext",
"Window",
] }
wasm-bindgen.workspace = true
Expand Down

0 comments on commit dca7db1

Please sign in to comment.