mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 14:28:11 +08:00
Cache Vello render output as stitchable textures (#3722)
* WIP render caching * Hook up render cache to render pipeline * Fixed offsets * Initial cleanup * Integrate cache with context invalidation * Cleanup * Improve rounding and reduce tile size to fix vello not rendering * Include pointer position in cache key * Avoid unwraps and zero sized textures * Destroy textures after blitting to surface * Fix context dependencies * Exclude footprint from render params * Batch animation frame messages * Add vello max render size to preference dialogue * Remove unused import * Reorder vello preference * Clean up preferences dialog * Apply review suggestions * Cap max render region size --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
5aca75dcbd
commit
0531769c41
@@ -5,6 +5,7 @@ use crate::messages::preferences::SelectionMode;
|
||||
use crate::messages::prelude::*;
|
||||
use crate::messages::tool::utility_types::ToolType;
|
||||
use graph_craft::wasm_application_io::EditorPreferences;
|
||||
use graphene_std::application_io::GetEditorPreferences;
|
||||
|
||||
#[derive(ExtractField)]
|
||||
pub struct PreferencesMessageContext<'a> {
|
||||
@@ -16,12 +17,13 @@ pub struct PreferencesMessageContext<'a> {
|
||||
pub struct PreferencesMessageHandler {
|
||||
pub selection_mode: SelectionMode,
|
||||
pub zoom_with_scroll: bool,
|
||||
pub use_vello: bool,
|
||||
pub vello_preference: graph_craft::wasm_application_io::VelloPreference,
|
||||
pub brush_tool: bool,
|
||||
pub graph_wire_style: GraphWireStyle,
|
||||
pub viewport_zoom_wheel_rate: f64,
|
||||
pub ui_scale: f64,
|
||||
pub disable_ui_acceleration: bool,
|
||||
pub max_render_region_size: u32,
|
||||
}
|
||||
|
||||
impl PreferencesMessageHandler {
|
||||
@@ -35,13 +37,18 @@ impl PreferencesMessageHandler {
|
||||
|
||||
pub fn editor_preferences(&self) -> EditorPreferences {
|
||||
EditorPreferences {
|
||||
use_vello: self.use_vello && self.supports_wgpu(),
|
||||
vello_preference: self.vello_preference,
|
||||
max_render_region_size: self.max_render_region_size,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_wgpu(&self) -> bool {
|
||||
graph_craft::wasm_application_io::wgpu_available().unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn use_vello(&self) -> bool {
|
||||
self.editor_preferences().use_vello()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PreferencesMessageHandler {
|
||||
@@ -49,12 +56,13 @@ impl Default for PreferencesMessageHandler {
|
||||
Self {
|
||||
selection_mode: SelectionMode::Touched,
|
||||
zoom_with_scroll: matches!(MappingVariant::default(), MappingVariant::ZoomWithScroll),
|
||||
use_vello: EditorPreferences::default().use_vello,
|
||||
vello_preference: EditorPreferences::default().vello_preference,
|
||||
brush_tool: false,
|
||||
graph_wire_style: GraphWireStyle::default(),
|
||||
viewport_zoom_wheel_rate: VIEWPORT_ZOOM_WHEEL_RATE,
|
||||
ui_scale: UI_SCALE_DEFAULT,
|
||||
disable_ui_acceleration: false,
|
||||
max_render_region_size: EditorPreferences::default().max_render_region_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,10 +90,11 @@ impl MessageHandler<PreferencesMessage, PreferencesMessageContext<'_>> for Prefe
|
||||
}
|
||||
|
||||
// Per-preference messages
|
||||
PreferencesMessage::UseVello { use_vello } => {
|
||||
self.use_vello = use_vello;
|
||||
PreferencesMessage::VelloPreference { preference } => {
|
||||
self.vello_preference = preference;
|
||||
responses.add(PortfolioMessage::UpdateVelloPreference);
|
||||
responses.add(PortfolioMessage::EditorPreferences);
|
||||
responses.add(PreferencesDialogMessage::Update);
|
||||
}
|
||||
PreferencesMessage::BrushTool { enabled } => {
|
||||
self.brush_tool = enabled;
|
||||
@@ -120,6 +129,11 @@ impl MessageHandler<PreferencesMessage, PreferencesMessageContext<'_>> for Prefe
|
||||
PreferencesMessage::DisableUIAcceleration { disable_ui_acceleration } => {
|
||||
self.disable_ui_acceleration = disable_ui_acceleration;
|
||||
}
|
||||
PreferencesMessage::MaxRenderRegionSize { size } => {
|
||||
self.max_render_region_size = size;
|
||||
responses.add(PortfolioMessage::UpdateVelloPreference);
|
||||
responses.add(PortfolioMessage::EditorPreferences);
|
||||
}
|
||||
}
|
||||
|
||||
responses.add(FrontendMessage::TriggerSavePreferences { preferences: self.clone() });
|
||||
|
||||
Reference in New Issue
Block a user