mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-05 19:12:08 -10:00
Take the premultiplied render target from the texture pool (fixup #4807)
This commit is contained in:
1 parent
a1bb538b9d
commit
dd996adbcb
1 file changed
+4
-17
@@ -55,8 +55,6 @@ pub(crate) struct VelloRenderer {
|
||||
pub struct VelloCanvas {
|
||||
/// Scenes to draw into, one for each depth of effects groups nested in a render, reused between renders to keep their allocations.
|
||||
spare_scenes: Vec<vello_gpu::Scene>,
|
||||
/// The premultiplied texture Vello GPU renders into before conversion to straight alpha, kept while the render size stays the same.
|
||||
premultiplied_target: Option<wgpu::Texture>,
|
||||
images: ImageTextures,
|
||||
effect_textures: EffectTextures,
|
||||
}
|
||||
@@ -357,21 +355,10 @@ impl RenderContext<'_> {
|
||||
|
||||
// Vello GPU renders premultiplied, which is converted to straight alpha unless the target wants it premultiplied
|
||||
let target_view = target.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
let premultiplied_view = match (target_alpha, &self.canvas.premultiplied_target) {
|
||||
(TargetAlpha::Premultiplied, _) => target_view.clone(),
|
||||
(TargetAlpha::Straight, Some(texture)) if texture.width() == size.x && texture.height() == size.y => texture.create_view(&wgpu::TextureViewDescriptor::default()),
|
||||
(TargetAlpha::Straight, _) => {
|
||||
let texture = create_texture(
|
||||
device,
|
||||
"vello_gpu_premultiplied_target",
|
||||
size,
|
||||
TEXTURE_FORMAT,
|
||||
wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::TEXTURE_BINDING,
|
||||
);
|
||||
let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
self.canvas.premultiplied_target = Some(texture);
|
||||
view
|
||||
}
|
||||
let premultiplied_target = (target_alpha == TargetAlpha::Straight).then(|| self.executor.request_texture(size));
|
||||
let premultiplied_view = match &premultiplied_target {
|
||||
Some(texture) => texture.create_view(&wgpu::TextureViewDescriptor::default()),
|
||||
None => target_view.clone(),
|
||||
};
|
||||
let target_init = TargetInit::Clear(ClearSettings::Viewport { color: peniko::Color::TRANSPARENT });
|
||||
|
||||
|
||||
Reference in new issue
Block a user