Skip to content

Commit

Permalink
Correct create_surface_from_(offscreen)_canvas docs.
Browse files Browse the repository at this point in the history
The function's does not depend on the `canvas` argument meeting the
given requirements to avoid undefined behavior, so it should just be a
normal contract, not a safety contract.
  • Loading branch information
jimblandy committed Aug 26, 2022
1 parent 2cd08a1 commit 778be11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 6 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ the same every time it is rendered, we now warn if it is missing.
#### General
- Add WGSL examples to complement existing examples written in GLSL by @norepimorphism in [#2888](https://github.com/gfx-rs/wgpu/pull/2888)

### Performance
- Expanded `StagingBelt` documentation by @kpreid in [#2905](https://github.com/gfx-rs/wgpu/pull/2905)

- Made `StagingBelt::write_buffer()` check more thoroughly for reusable memory; by @kpreid in [#2906](https://github.com/gfx-rs/wgpu/pull/2906)
- Fixed documentation for `Instance::create_surface_from_canvas` and
`Instance::create_surface_from_offscreen_canvas` regarding their
safety contract. These functions are not unsafe. [#2990](https://github.com/gfx-rs/wgpu/pull/2990)

### Documentation
### Performance

- Expanded `StagingBelt` documentation by @kpreid in [#2905](https://github.com/gfx-rs/wgpu/pull/2905)
- Made `StagingBelt::write_buffer()` check more thoroughly for reusable memory; by @kpreid in [#2906](https://github.com/gfx-rs/wgpu/pull/2906)

### Build Configuration

Expand Down
10 changes: 4 additions & 6 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,9 +1792,8 @@ impl Instance {

/// Creates a surface from a `web_sys::HtmlCanvasElement`.
///
/// # Safety
///
/// - canvas must be a valid <canvas> element to create a surface upon.
/// The `canvas` argument must be a valid `<canvas>` element to
/// create a surface upon.
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
pub fn create_surface_from_canvas(&self, canvas: &web_sys::HtmlCanvasElement) -> Surface {
Surface {
Expand All @@ -1805,9 +1804,8 @@ impl Instance {

/// Creates a surface from a `web_sys::OffscreenCanvas`.
///
/// # Safety
///
/// - canvas must be a valid OffscreenCanvas to create a surface upon.
/// The `canvas` argument must be a valid `OffscreenCanvas` object
/// to create a surface upon.
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
pub fn create_surface_from_offscreen_canvas(
&self,
Expand Down

0 comments on commit 778be11

Please sign in to comment.