Skip to content

Commit 39b53c7

Browse files
relrelbHerschel
authored andcommitted
ci: Deny warnings on Web
As suggested in #6935 (review).
1 parent 37e1bdb commit 39b53c7

File tree

6 files changed

+8
-15
lines changed

6 files changed

+8
-15
lines changed

.github/workflows/test_web.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878

7979
- name: Build
8080
env:
81+
RUSTFLAGS: -D warnings
8182
# Verify that all features build.
8283
CARGO_FLAGS: --locked --all-features
8384
working-directory: web

exporter/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ fn take_screenshot(
143143
.renderer_mut()
144144
.downcast_mut::<WgpuRenderBackend<TextureTarget>>()
145145
.unwrap();
146-
// Use straight alpha
147-
renderer.capture_frame(false)
146+
renderer.capture_frame()
148147
}) {
149148
Ok(Some(image)) => result.push(image),
150149
Ok(None) => return Err(anyhow!("Unable to capture frame {} of {:?}", i, swf_path)),

render/wgpu/src/backend.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl WgpuRenderBackend<crate::target::TextureTarget> {
131131
Self::new(Arc::new(descriptors), target)
132132
}
133133

134-
pub fn capture_frame(&self, premultiplied_alpha: bool) -> Option<image::RgbaImage> {
134+
pub fn capture_frame(&self) -> Option<image::RgbaImage> {
135135
use crate::utils::buffer_to_image;
136136
if let Some((buffer, dimensions)) = &self.target.buffer {
137137
Some(buffer_to_image(
@@ -140,7 +140,6 @@ impl WgpuRenderBackend<crate::target::TextureTarget> {
140140
dimensions,
141141
None,
142142
self.target.size,
143-
premultiplied_alpha,
144143
))
145144
} else {
146145
None

render/wgpu/src/utils.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use ruffle_render::quality::StageQuality;
2-
use ruffle_render::utils::unmultiply_alpha_rgba;
32
use std::borrow::Cow;
43
use std::mem::size_of;
54
use std::num::NonZeroU32;
@@ -143,13 +142,13 @@ pub fn capture_image<R, F: FnOnce(&[u8], u32) -> R>(
143142
result
144143
}
145144

145+
#[cfg(not(target_family = "wasm"))]
146146
pub fn buffer_to_image(
147147
device: &wgpu::Device,
148148
buffer: &wgpu::Buffer,
149149
dimensions: &BufferDimensions,
150150
index: Option<wgpu::SubmissionIndex>,
151151
size: wgpu::Extent3d,
152-
premultiplied_alpha: bool,
153152
) -> image::RgbaImage {
154153
capture_image(device, buffer, dimensions, index, |rgba, _buffer_width| {
155154
let mut bytes = Vec::with_capacity(dimensions.height * dimensions.unpadded_bytes_per_row);
@@ -160,9 +159,7 @@ pub fn buffer_to_image(
160159

161160
// The image copied from the GPU uses premultiplied alpha, so
162161
// convert to straight alpha if requested by the user.
163-
if !premultiplied_alpha {
164-
unmultiply_alpha_rgba(&mut bytes);
165-
}
162+
ruffle_render::utils::unmultiply_alpha_rgba(&mut bytes);
166163

167164
image::RgbaImage::from_raw(size.width, size.height, bytes)
168165
.expect("Retrieved texture buffer must be a valid RgbaImage")

tests/tests/util/runner.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,7 @@ pub fn run_swf(
178178
.downcast_mut::<WgpuRenderBackend<TextureTarget>>()
179179
.unwrap();
180180

181-
// Use straight alpha, since we want to save this as a PNG
182-
let actual_image = renderer
183-
.capture_frame(false)
184-
.expect("Failed to capture image");
181+
let actual_image = renderer.capture_frame().expect("Failed to capture image");
185182

186183
let expected_image_path = base_path.join("expected.png");
187184
if expected_image_path.is_file() {

web/packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
"//6": "# Enabling `build-std` would also be great, but it's not stable yet.",
2020
"prebuild": "npm run build:wasm-vanilla && npm run build:wasm-extensions",
2121

22-
"build:wasm-vanilla": "cross-env OUT_NAME=ruffle_web CARGO_PROFILE=web-vanilla-wasm RUSTFLAGS=\"--cfg=web_sys_unstable_apis -Aunknown_lints\" npm run build:wasm",
22+
"build:wasm-vanilla": "cross-env OUT_NAME=ruffle_web CARGO_PROFILE=web-vanilla-wasm RUSTFLAGS=\"$RUSTFLAGS --cfg=web_sys_unstable_apis -Aunknown_lints\" npm run build:wasm",
2323

2424
"//7": "# Dispatches to either building the real, or copying the fake (stand-in),",
2525
"//8": "# 'with-extensions' module.",
2626
"build:wasm-extensions": "node -e \"process.exit(process.env.ENABLE_WASM_EXTENSIONS == 'true' ? 0 : 1)\" && npm run build:wasm-extensions-real || npm run build:wasm-extensions-fake",
27-
"build:wasm-extensions-real": "echo \"Building module with WebAssembly extensions\" && cross-env OUT_NAME=ruffle_web-wasm_extensions CARGO_PROFILE=web-wasm-extensions RUSTFLAGS=\"--cfg=web_sys_unstable_apis -Aunknown_lints -C target-feature=+bulk-memory,+simd128,+nontrapping-fptoint,+sign-ext,+reference-types\" WASM_BINDGEN_FLAGS=\"--reference-types\" WASM_OPT_FLAGS=\"--enable-reference-types\" npm run build:wasm",
27+
"build:wasm-extensions-real": "echo \"Building module with WebAssembly extensions\" && cross-env OUT_NAME=ruffle_web-wasm_extensions CARGO_PROFILE=web-wasm-extensions RUSTFLAGS=\"$RUSTFLAGS --cfg=web_sys_unstable_apis -Aunknown_lints -C target-feature=+bulk-memory,+simd128,+nontrapping-fptoint,+sign-ext,+reference-types\" WASM_BINDGEN_FLAGS=\"--reference-types\" WASM_OPT_FLAGS=\"--enable-reference-types\" npm run build:wasm",
2828
"build:wasm-extensions-fake": "echo \"Copying the vanilla module as stand-in\" && shx cp dist/ruffle_web_bg.wasm dist/ruffle_web-wasm_extensions_bg.wasm && shx cp dist/ruffle_web_bg.wasm.d.ts dist/ruffle_web-wasm_extensions_bg.wasm.d.ts && shx cp dist/ruffle_web.js dist/ruffle_web-wasm_extensions.js && shx cp dist/ruffle_web.d.ts dist/ruffle_web-wasm_extensions.d.ts",
2929

3030
"//9": "# This just chains together the three commands after it.",

0 commit comments

Comments
 (0)