mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-16 03:51:16 +00:00
View: the canvas is drawn through the monitor profile on Windows and X11
Preferences > Performance > Use Monitor Profile for Canvas (on by default, `monitorProfileDisplay`) converts the canvas's art, artboard paper and transparency grid from sRGB into the ICC profile of the display that shows most of the main window, after any proof. Arranged panes and the render worker's frames are converted too; the worker keeps its frame in sRGB. - Windows: the display's default profile for its standard color mode (ColorProfileGetDisplayDefault, GetICMProfileW where it is missing). A display with Advanced Color on is left to Windows. - X11: colord's profile for the RandR output, then the output's `_ICC_PROFILE`, then the screen's when only one output is active. - A Wayland session stays sRGB; macOS converts the window itself. - A profile that is missing, larger than 1 MiB, not an RGB display profile or unreadable leaves the canvas sRGB, with the reason in `ui.inspect`'s `displayProfile`. The conversion is sampled into a 33x33x33 table when a profile is read, on a background thread. Exports, `ui.render` and the document are unchanged.
This commit is contained in:
@@ -368,6 +368,7 @@ pub const PREF_SPECS: &[PrefSpec] = &[
|
||||
p!("realTimeDrawing", "Performance", "", "Real-time Drawing and Editing", bool),
|
||||
p!("renderThreads", "Performance", "", "Render Threads (-1 = Automatic)", int(-1, 64)),
|
||||
p!("linuxDisplayServer", "Performance", "", "Linux Display Server", choice(LINUX_DISPLAY_SERVERS)),
|
||||
p!("monitorProfileDisplay", "Performance", "", "Use Monitor Profile for Canvas", bool),
|
||||
// File Handling
|
||||
p!("backgroundSave", "File Handling", "", "Enable Background Save", bool),
|
||||
p!("backgroundExport", "File Handling", "", "Enable Background Export", bool),
|
||||
|
||||
@@ -220,6 +220,10 @@ pub struct Prefs {
|
||||
/// Wayland session, where dropped files arrive (#1151); `x11WithPen` opens it through XWayland
|
||||
/// only when a pen is attached (#2028). Read when the app starts.
|
||||
pub linux_display_server: String,
|
||||
/// The desktop canvas converts its sRGB into the ICC profile of the display that shows the
|
||||
/// window, where the system doesn't (Windows without Advanced Color, X11). Display only: it
|
||||
/// changes no document, proof or export.
|
||||
pub monitor_profile_display: bool,
|
||||
// File Handling
|
||||
pub background_save: bool,
|
||||
pub background_export: bool,
|
||||
@@ -496,6 +500,7 @@ impl Default for Prefs {
|
||||
real_time_drawing: true,
|
||||
render_threads: -1,
|
||||
linux_display_server: s("automatic"),
|
||||
monitor_profile_display: true,
|
||||
background_save: true,
|
||||
background_export: true,
|
||||
autosave_recovery: true,
|
||||
|
||||
@@ -464,6 +464,34 @@ fn linux_display_server_defaults_to_automatic_and_validates() {
|
||||
assert_eq!(s.prefs.linux_display_server, "automatic");
|
||||
}
|
||||
|
||||
/// Performance › Use Monitor Profile for Canvas: on by default and for preference files written
|
||||
/// before it, a boolean only, saved, listed under Performance, and set without changing the
|
||||
/// document.
|
||||
#[test]
|
||||
fn monitor_profile_display_is_on_by_default_and_changes_no_document() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();
|
||||
assert!(s.prefs.monitor_profile_display);
|
||||
let old: Prefs = serde_json::from_value(json!({"gpuPerformance": true})).unwrap();
|
||||
assert!(old.monitor_profile_display);
|
||||
let (revision, doc) = (s.active().unwrap().revision, s.active().unwrap().doc.clone());
|
||||
s.execute("prefs.set", &json!({"key": "monitorProfileDisplay", "value": false})).unwrap();
|
||||
assert!(!s.prefs.monitor_profile_display);
|
||||
assert_eq!(s.prefs.to_json()["monitorProfileDisplay"], false);
|
||||
for bad in [json!("off"), json!(0), json!(null)] {
|
||||
assert!(s.execute("prefs.set", &json!({"key": "monitorProfileDisplay", "value": bad})).is_err(), "{bad}");
|
||||
assert!(!s.prefs.monitor_profile_display);
|
||||
}
|
||||
assert_eq!(s.active().unwrap().revision, revision);
|
||||
assert!(std::sync::Arc::ptr_eq(&s.active().unwrap().doc, &doc), "the document is not edited");
|
||||
let l = s.execute("prefs.list", &json!({})).unwrap();
|
||||
let row = l.as_array().unwrap().iter().find(|e| e["key"] == "monitorProfileDisplay").unwrap().clone();
|
||||
assert_eq!((row["category"].as_str(), row["label"].as_str()), (Some("Performance"), Some("Use Monitor Profile for Canvas")));
|
||||
s.execute("prefs.reset", &json!({"category": "Performance"})).unwrap();
|
||||
assert!(s.prefs.monitor_profile_display);
|
||||
}
|
||||
|
||||
/// Linux Display Server's pen choice (#2028): set by value or by label, saved, and off by default.
|
||||
#[test]
|
||||
fn linux_display_server_has_a_choice_for_an_attached_pen() {
|
||||
|
||||
Reference in New Issue
Block a user