mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 22:28:11 +08:00
Disable Vello renderer checkbox in preferences if browser doesn't support WebGPU (#1844)
* Disable vello checkbox if no wgpu support is available * Fix compile error * Check wgpu status on every diagogue open * Execute graph on settings change * Remove tooltip and disabled status from settings category --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
0893ac49a6
commit
fad289804a
@@ -45,12 +45,18 @@ impl PreferencesDialogMessageHandler {
|
||||
})
|
||||
.widget_holder(),
|
||||
];
|
||||
let vello_tooltip = "Use the experimental Vello renderer (your browser must support WebGPU)";
|
||||
let use_vello = vec![
|
||||
TextLabel::new("Renderer").min_width(60).italic(true).widget_holder(),
|
||||
TextLabel::new("Vello (Experimental)").table_align(true).widget_holder(),
|
||||
TextLabel::new("Vello (Experimental)")
|
||||
.table_align(true)
|
||||
.tooltip(vello_tooltip)
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.widget_holder(),
|
||||
Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
CheckboxInput::new(preferences.use_vello)
|
||||
.tooltip("Use the experimental Vello renderer (your browser must support WebGPU)")
|
||||
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
|
||||
.tooltip(vello_tooltip)
|
||||
.disabled(!preferences.supports_wgpu())
|
||||
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::UseVello { use_vello: checkbox_input.checked }.into())
|
||||
.widget_holder(),
|
||||
];
|
||||
|
||||
@@ -642,6 +642,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
|
||||
responses.add(FrontendMessage::UpdateOpenDocumentsList { open_documents });
|
||||
}
|
||||
PortfolioMessage::UpdateVelloPreference => {
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
self.persistent_data.use_vello = preferences.use_vello;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,13 @@ impl PreferencesMessageHandler {
|
||||
pub fn editor_preferences(&self) -> EditorPreferences {
|
||||
EditorPreferences {
|
||||
imaginate_hostname: self.imaginate_server_hostname.clone(),
|
||||
use_vello: self.use_vello,
|
||||
use_vello: self.use_vello && self.supports_wgpu(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn supports_wgpu(&self) -> bool {
|
||||
graph_craft::wasm_application_io::wgpu_available().unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PreferencesMessageHandler {
|
||||
|
||||
@@ -153,7 +153,15 @@ impl NodeRuntime {
|
||||
}
|
||||
|
||||
pub async fn run(&mut self) {
|
||||
// TODO: Currently we still render the document after we submit the node graph execution request. This should be avoided in the future.
|
||||
if self.editor_api.application_io.is_none() {
|
||||
self.editor_api = WasmEditorApi {
|
||||
application_io: Some(WasmApplicationIo::new().await.into()),
|
||||
font_cache: self.editor_api.font_cache.clone(),
|
||||
node_graph_message_sender: Box::new(self.sender.clone()),
|
||||
editor_preferences: Box::new(self.editor_preferences.clone()),
|
||||
}
|
||||
.into();
|
||||
}
|
||||
|
||||
let mut font = None;
|
||||
let mut preferences = None;
|
||||
@@ -232,16 +240,6 @@ impl NodeRuntime {
|
||||
}
|
||||
|
||||
async fn update_network(&mut self, graph: NodeNetwork) -> Result<(), String> {
|
||||
if self.editor_api.application_io.is_none() {
|
||||
self.editor_api = WasmEditorApi {
|
||||
application_io: Some(WasmApplicationIo::new().await.into()),
|
||||
font_cache: self.editor_api.font_cache.clone(),
|
||||
node_graph_message_sender: Box::new(self.sender.clone()),
|
||||
editor_preferences: Box::new(self.editor_preferences.clone()),
|
||||
}
|
||||
.into();
|
||||
}
|
||||
|
||||
let scoped_network = wrap_network_in_scope(graph, self.editor_api.clone());
|
||||
self.monitor_nodes = scoped_network
|
||||
.recursive_nodes()
|
||||
|
||||
Reference in New Issue
Block a user