Make texture size not 1x1

This commit is contained in:
Dennis Kobert
2025-12-21 22:53:10 +01:00
parent 4a9fb5162b
commit de8bdc7209
@@ -22,7 +22,7 @@ impl<'i> Convert<Table<Raster<GPU>>, &'i WgpuExecutor> for Table<Vector> {
log::debug!("rasterizing vector data with footprint {footprint:?}"); log::debug!("rasterizing vector data with footprint {footprint:?}");
let vector = &self; let vector = &self;
log::debug!("{:?}", vector); log::debug!("{vector:?}");
// Create a Vello scene for this vector // Create a Vello scene for this vector
let mut scene = vello::Scene::new(); let mut scene = vello::Scene::new();
@@ -33,18 +33,14 @@ impl<'i> Convert<Table<Raster<GPU>>, &'i WgpuExecutor> for Table<Vector> {
// Render the scene to a GPU texture // Render the scene to a GPU texture
let resolution = footprint.resolution; let resolution = footprint.resolution;
let background = core_types::Color::BLACK; let background = core_types::Color::TRANSPARENT;
// Use async rendering to get the texture // Use async rendering to get the texture
let texture = async { let texture = executor
executor .render_vello_scene_to_texture(&scene, resolution, &context, background)
.render_vello_scene_to_texture(&scene, resolution, &context, background) .await
.await .expect("Failed to render Vello scene to texture");
.expect("Failed to render Vello scene to texture")
};
// Block on the texture creation (we're in an async context)
let texture = futures::executor::block_on(texture);
let device = &executor.context.device; let device = &executor.context.device;
let queue = &executor.context.queue; let queue = &executor.context.queue;
let mut encoder = device.create_command_encoder(&CommandEncoderDescriptor::default()); let mut encoder = device.create_command_encoder(&CommandEncoderDescriptor::default());
@@ -70,6 +66,8 @@ impl<'i> Convert<Table<Raster<GPU>>, &'i WgpuExecutor> for Table<Vector> {
let command_buffer = encoder.finish(); let command_buffer = encoder.finish();
queue.submit([command_buffer]); queue.submit([command_buffer]);
Table::new_from_element(Raster::new_gpu(new_texture)) let mut table = Table::new_from_element(Raster::new_gpu(new_texture));
*(table.get_mut(0).as_mut().unwrap().transform) = DAffine2::from_scale((texture.width() as f64, texture.height() as f64).into());
table
} }
} }