Skip to content

Commit

Permalink
[app-surface] fix view_formats on Android platform
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed Nov 6, 2024
1 parent c5e6ef4 commit 3289571
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion 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 and Android apps."
edition = "2021"
version = "1.2.3"
version = "1.2.4"
rust-version = "1.76"
repository = "https://github.com/jinleili/wgpu-in-app"
keywords = ["android", "SurfaceView", "ios", "macos", "wgpu"]
Expand Down
11 changes: 10 additions & 1 deletion app-surface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,18 @@ async fn create_iasdq_context(
// Caused by:
// Downlevel flags DownlevelFlags(SURFACE_VIEW_FORMATS) are required but not supported on the device.
vec![]
} else if format.is_srgb() {
} else if cfg!(target_os = "android") {
// TODO:HarmonyOS 不支持 view_formats 格式
// format 的值与 view_formats 的值一致时,configure 内部会自动忽略 view_formats 的值
//
// Android 不支持 view_formats:
// Downlevel flags DownlevelFlags(SURFACE_VIEW_FORMATS) are required but not supported on the device.
// This is not an invalid use of WebGPU: the underlying API or device does not support enough features
// to be a fully compliant implementation. A subset of the features can still be used.
// If you are running this program on native and not in a browser and wish to work around this issue,
// call Adapter::downlevel_properties or Device::downlevel_properties to get a listing of the features the current platform supports.
vec![format]
} else if format.is_srgb() {
vec![format, format.remove_srgb_suffix()]
} else {
vec![format.add_srgb_suffix(), format.remove_srgb_suffix()]
Expand Down
2 changes: 1 addition & 1 deletion wgpu-in-app/src/ffi/android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use log::info;
pub fn createWgpuCanvas(env: *mut JNIEnv, _: JClass, surface: jobject, idx: jint) -> jlong {
crate::init_logger();

let mut canvas = WgpuCanvas::new(AppSurface::new(env as *mut _, surface), idx);
let canvas = WgpuCanvas::new(AppSurface::new(env as *mut _, surface), idx);
info!("WgpuCanvas created!");

Box::into_raw(Box::new(canvas)) as jlong
Expand Down

0 comments on commit 3289571

Please sign in to comment.