Skip to content

Commit

Permalink
Fix config size
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Jan 21, 2024
1 parent e11113d commit ab15b1b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
CARGO_INCREMENTAL: false
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
MSRV: 1.70
MSRV: 1.71

jobs:
check-msrv:
Expand Down
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# wgpu in App

![Minimum Rust Version](https://img.shields.io/badge/min%20rust-1.70-green.svg)
![Minimum Rust Version](https://img.shields.io/badge/min%20rust-1.71-green.svg)
[![Build Status](https://github.com/jinleili/wgpu-in-app/workflows/CI/badge.svg?branch=master)](https://github.com/jinleili/wgpu-in-app/actions)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jinleili/wgpu-in-app/blob/master/LICENSE.MIT)

Expand Down
2 changes: 1 addition & 1 deletion app-surface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ authors = ["jinleili"]
description = "Integrate wgpu into your existing iOS and Android apps."
edition = "2021"
version = "0.4.0"
rust-version = "1.70"
rust-version = "1.71"
repository = "https://github.com/jinleili/wgpu-in-app"
keywords = ["android", "SurfaceView", "ios", "app", "wgpu"]
license = "MIT"
Expand Down
1 change: 0 additions & 1 deletion app-surface/src/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl AppSurface {

let caps = surface.get_capabilities(&adapter);

log::info!("adapter.limits(): {:?}", adapter.limits());
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
Expand Down
21 changes: 14 additions & 7 deletions app-surface/src/app_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ impl AppSurface {
#[allow(clippy::needless_update)]
pub async fn new(view: Window) -> Self {
let scale_factor = view.scale_factor() as f32;
let physical_size = view.inner_size();
let mut physical_size = view.inner_size();
physical_size.width = physical_size.width.max(1);
physical_size.height = physical_size.height.max(1);
let view_setting = ViewSetting {
scale_factor,
physical_size: (physical_size.width, physical_size.height),
Expand All @@ -36,6 +38,10 @@ impl AppSurface {
Self::create(view_setting).await
}

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

#[cfg(target_arch = "wasm32")]
pub async fn from_offscreen_canvas(
offscreen_canvas: web_sys::OffscreenCanvas,
Expand Down Expand Up @@ -81,10 +87,11 @@ impl AppSurface {
wgpu::SurfaceTarget::OffscreenCanvas(view_setting.offscreen_canvas.unwrap())
)
} else {
use winit::platform::web::WindowExtWebSys;
let canvas: web_sys::HtmlCanvasElement =
view.as_ref().canvas().unwrap();
instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas))
// use winit::platform::web::WindowExtWebSys;
// let canvas: web_sys::HtmlCanvasElement =
// view.as_ref().canvas().unwrap();
// instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas))
instance.create_surface(view.clone())
};
} else {
let surface = instance.create_surface(view.clone());
Expand Down Expand Up @@ -165,8 +172,8 @@ impl AppSurface {
if self.is_offscreen_canvas {
panic!("Offscreen canvas cannot provide any DOM interfaces.");
} else {
let physical = self.view.as_ref().unwrap().inner_size();
(physical.width, physical.height)
let physical = self.get_view().inner_size();
(physical.width.max(1), physical.height.max(1))
}
}
}
2 changes: 1 addition & 1 deletion wgpu-in-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "wgpu-in-app"
authors = ["jinleili"]
version = "0.3.0"
edition = "2021"
rust-version = "1.70"
rust-version = "1.71"

[lib]
crate-type = ["rlib", "staticlib", "cdylib"]
Expand Down
1 change: 0 additions & 1 deletion wgpu-in-app/src/examples/msaa_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ impl MSAALine {
vertex_buffer_list: &Vec<wgpu::Buffer>,
vertex_count: u32,
) -> wgpu::RenderBundle {
log::info!("sample_count: {}", sample_count);
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
label: None,
layout: Some(pipeline_layout),
Expand Down

0 comments on commit ab15b1b

Please sign in to comment.