pixels icon indicating copy to clipboard operation
pixels copied to clipboard

Remove pixels::SurfaceTexture?

Open parasyte opened this issue 4 years ago • 0 comments

Tracking ticket for a public API change proposal. The idea was introduced in https://github.com/parasyte/pixels/issues/185#issuecomment-902416291

wgpu::SurfaceConfiguration contains the same basic information that we need for surface management (mainly the size). We can replace our pixels::SurfaceTexture type with a wgpu::SurfaceConfiguration. It would change the old way of creating a builder:

let surface_texture = SurfaceTexture::new(window_size.width, window_size.height, &window);
let builder = PixelsBuilder::new(width, height, surface_texture);

To the new way:

let surface_config = pixels::surface_config(window_size.width, window_size.height, None);
let builder = PixelsBuilder::new(width, height, &window, surface_config);

Where pixels::surface_config has this function signature:

pub fn surface_config(width: u32, height: u32, format: Option<wgpu::TextureFormat>) -> wgpu::SurfaceConfiguration

The only reason to do this would be to have Pixels own a SurfaceConfiguration instead of creating a new one every time the surface needs to be reconfigured. And of course, exposing the configuration publicly. The pixels::surface_config() helper is optional, and a surface configuration can be created in any way.

parasyte avatar Sep 01 '21 01:09 parasyte