diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-01-17 12:47:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-17 11:47:47 +0000 |
commit | 2d09552234b08fa091866e2f799df0e841a99070 (patch) | |
tree | 1f7a2f3ffa945cbdb68bec711b36ab8430424f0b /components | |
parent | e1b4649fafcfc0881367e8069f66359e3bfbc5eb (diff) | |
download | servo-2d09552234b08fa091866e2f799df0e841a99070.tar.gz servo-2d09552234b08fa091866e2f799df0e841a99070.zip |
prefs: Move some `DebugOptions` to `Preferences` and clean up (#34998)
- Move options configuring antialiasing and WebRender shader precache to
the `Preferences` to group them with other related WebRender and DOM
settings.
- Remove the option to disable antialiasing for canvases. This was
unused.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components')
-rw-r--r-- | components/canvas/canvas_data.rs | 4 | ||||
-rw-r--r-- | components/canvas/canvas_paint_thread.rs | 29 | ||||
-rw-r--r-- | components/canvas/raqote_backend.rs | 7 | ||||
-rw-r--r-- | components/config/opts.rs | 23 | ||||
-rw-r--r-- | components/config/prefs.rs | 9 | ||||
-rw-r--r-- | components/constellation/constellation.rs | 9 | ||||
-rw-r--r-- | components/servo/lib.rs | 8 | ||||
-rw-r--r-- | components/shared/canvas/lib.rs | 1 |
8 files changed, 21 insertions, 69 deletions
diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index c857b763838..97839f38905 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -25,7 +25,6 @@ use webrender_api::units::{DeviceIntSize, RectExt as RectExt_}; use webrender_api::{ImageDescriptor, ImageDescriptorFlags, ImageFormat, ImageKey}; use webrender_traits::{CrossProcessCompositorApi, ImageUpdate, SerializableImageData}; -use crate::canvas_paint_thread::AntialiasMode; use crate::raqote_backend::Repetition; /// The canvas data stores a state machine for the current status of @@ -445,7 +444,6 @@ impl<'a> CanvasData<'a> { pub fn new( size: Size2D<u64>, compositor_api: CrossProcessCompositorApi, - antialias: AntialiasMode, font_context: Arc<FontContext>, ) -> CanvasData<'a> { let backend = create_backend(); @@ -454,7 +452,7 @@ impl<'a> CanvasData<'a> { backend, drawtarget: draw_target, path_state: None, - state: CanvasPaintState::new(antialias), + state: CanvasPaintState::default(), saved_states: vec![], compositor_api, image_key: None, diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 7b3500e1290..673c151489d 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -20,11 +20,6 @@ use webrender_traits::CrossProcessCompositorApi; use crate::canvas_data::*; -pub enum AntialiasMode { - Default, - None, -} - pub struct CanvasPaintThread<'a> { canvases: HashMap<CanvasId, CanvasData<'a>>, next_canvas_id: CanvasId, @@ -95,12 +90,8 @@ impl<'a> CanvasPaintThread<'a> { } recv(create_receiver) -> msg => { match msg { - Ok(ConstellationCanvasMsg::Create { - id_sender: creator, - size, - antialias - }) => { - let canvas_id = canvas_paint_thread.create_canvas(size, antialias); + Ok(ConstellationCanvasMsg::Create { id_sender: creator, size }) => { + let canvas_id = canvas_paint_thread.create_canvas(size); creator.send(canvas_id).unwrap(); }, Ok(ConstellationCanvasMsg::Exit) => break, @@ -118,22 +109,12 @@ impl<'a> CanvasPaintThread<'a> { (create_sender, ipc_sender) } - pub fn create_canvas(&mut self, size: Size2D<u64>, antialias: bool) -> CanvasId { - let antialias = if antialias { - AntialiasMode::Default - } else { - AntialiasMode::None - }; - + pub fn create_canvas(&mut self, size: Size2D<u64>) -> CanvasId { let canvas_id = self.next_canvas_id; self.next_canvas_id.0 += 1; - let canvas_data = CanvasData::new( - size, - self.compositor_api.clone(), - antialias, - self.font_context.clone(), - ); + let canvas_data = + CanvasData::new(size, self.compositor_api.clone(), self.font_context.clone()); self.canvases.insert(canvas_id, canvas_data); canvas_id diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 432bfe82aa8..5f755bc36fa 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -21,7 +21,6 @@ use crate::canvas_data::{ self, Backend, CanvasPaintState, Color, CompositionOp, DrawOptions, Filter, GenericDrawTarget, GenericPathBuilder, GradientStop, GradientStops, Path, SourceSurface, StrokeOptions, TextRun, }; -use crate::canvas_paint_thread::AntialiasMode; thread_local! { /// The shared font cache used by all canvases that render on a thread. It would be nicer @@ -85,12 +84,12 @@ impl Backend for RaqoteBackend { } fn recreate_paint_state<'a>(&self, _state: &CanvasPaintState<'a>) -> CanvasPaintState<'a> { - CanvasPaintState::new(AntialiasMode::Default) + CanvasPaintState::default() } } -impl<'a> CanvasPaintState<'a> { - pub fn new(_antialias: AntialiasMode) -> CanvasPaintState<'a> { +impl Default for CanvasPaintState<'_> { + fn default() -> Self { let pattern = Pattern::Color(255, 0, 0, 0); CanvasPaintState { draw_options: DrawOptions::Raqote(raqote::DrawOptions::new()), diff --git a/components/config/opts.rs b/components/config/opts.rs index d00cd11bf1e..cbb7f58453c 100644 --- a/components/config/opts.rs +++ b/components/config/opts.rs @@ -121,20 +121,6 @@ pub struct DebugOptions { /// List all the debug options. pub help: bool, - /// If set with `disable-text-aa`, disable antialiasing on fonts. This is - /// primarily useful for reftests where pixel perfect results are required - /// when using fonts such as the Ahem font for layout tests. - pub disable_text_antialiasing: bool, - - /// Disable subpixel antialiasing of rendered text. - pub disable_subpixel_text_antialiasing: bool, - - /// Disable antialiasing of rendered text on the HTML canvas element. - /// If set with `disable-canvas-aa`, disable antialiasing on the HTML canvas - /// element. Like `disable-text-aa`, this is useful for reftests where - /// pixel perfect results are required. - pub disable_canvas_antialiasing: bool, - /// Print the DOM after each restyle. pub dump_style_tree: bool, @@ -180,11 +166,6 @@ pub struct DebugOptions { /// Show webrender profiling stats on screen. pub webrender_stats: bool, - /// True to compile all webrender shaders at init time. This is mostly - /// useful when modifying the shaders, to ensure they all compile - /// after each change is made. - pub precache_shaders: bool, - /// True to use OS native signposting facilities. This makes profiling events (script activity, /// reflow, compositing, etc.) appear in Instruments.app on macOS. pub signpost: bool, @@ -196,17 +177,13 @@ impl DebugOptions { match option { "help" => self.help = true, "convert-mouse-to-touch" => self.convert_mouse_to_touch = true, - "disable-canvas-aa" => self.disable_canvas_antialiasing = true, "disable-share-style-cache" => self.disable_share_style_cache = true, - "disable-subpixel-aa" => self.disable_subpixel_text_antialiasing = true, - "disable-text-aa" => self.disable_text_antialiasing = true, "dump-display-list" => self.dump_display_list = true, "dump-stacking-context-tree" => self.dump_stacking_context_tree = true, "dump-flow-tree" => self.dump_flow_tree = true, "dump-rule-tree" => self.dump_rule_tree = true, "dump-style-tree" => self.dump_style_tree = true, "gc-profile" => self.gc_profile = true, - "precache-shaders" => self.precache_shaders = true, "profile-script-events" => self.profile_script_events = true, "relayout-event" => self.relayout_event = true, "replace-surrogates" => self.replace_surrogates = true, diff --git a/components/config/prefs.rs b/components/config/prefs.rs index 1561198f281..98c4076ed7d 100644 --- a/components/config/prefs.rs +++ b/components/config/prefs.rs @@ -136,6 +136,13 @@ pub struct Preferences { pub dom_worklet_blockingsleep: bool, pub dom_worklet_testing_enabled: bool, pub dom_worklet_timeout_ms: i64, + /// True to compile all WebRender shaders when Servo initializes. This is mostly + /// useful when modifying the shaders, to ensure they all compile after each change is + /// made. + pub gfx_precache_shaders: bool, + /// Whether or not antialiasing is enabled for text rendering. + pub gfx_text_antialiasing_enabled: bool, + /// Whether or not subpixel antialiasing is enabled for text rendering. pub gfx_subpixel_text_antialiasing_enabled: bool, pub gfx_texture_swizzling_enabled: bool, pub js_asmjs_enabled: bool, @@ -305,6 +312,8 @@ impl Preferences { fonts_monospace: String::new(), fonts_sans_serif: String::new(), fonts_serif: String::new(), + gfx_precache_shaders: true, + gfx_text_antialiasing_enabled: true, gfx_subpixel_text_antialiasing_enabled: true, gfx_texture_swizzling_enabled: true, js_asmjs_enabled: true, diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 50932dbad9d..9a46e194075 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -463,12 +463,6 @@ pub struct Constellation<STF, SWF> { /// If True, exits on thread failure instead of displaying about:failure hard_fail: bool, - /// If set with --disable-canvas-aa, disable antialiasing on the HTML - /// canvas element. - /// Like --disable-text-aa, this is useful for reftests where pixel perfect - /// results are required. - enable_canvas_antialiasing: bool, - /// Entry point to create and get channels to a GLPlayerThread. glplayer_threads: Option<GLPlayerThreads>, @@ -622,7 +616,6 @@ where random_pipeline_closure_probability: Option<f32>, random_pipeline_closure_seed: Option<usize>, hard_fail: bool, - enable_canvas_antialiasing: bool, canvas_create_sender: Sender<ConstellationCanvasMsg>, canvas_ipc_sender: IpcSender<CanvasMsg>, ) -> Sender<FromCompositorMsg> { @@ -762,7 +755,6 @@ where pending_approval_navigations: HashMap::new(), pressed_mouse_buttons: 0, hard_fail, - enable_canvas_antialiasing, glplayer_threads: state.glplayer_threads, player_context: state.player_context, active_media_session: None, @@ -4551,7 +4543,6 @@ where if let Err(e) = self.canvas_sender.send(ConstellationCanvasMsg::Create { id_sender: canvas_id_sender, size, - antialias: self.enable_canvas_antialiasing, }) { return warn!("Create canvas paint thread failed ({})", e); } diff --git a/components/servo/lib.rs b/components/servo/lib.rs index b6b38f7e8e9..ba99fe2dd28 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -374,15 +374,14 @@ where // See: https://github.com/servo/servo/issues/31726 use_optimized_shaders: true, resource_override_path: opts.shaders_dir.clone(), - enable_aa: !opts.debug.disable_text_antialiasing, debug_flags, - precache_flags: if opts.debug.precache_shaders { + precache_flags: if pref!(gfx_precache_shaders) { ShaderPrecacheFlags::FULL_COMPILE } else { ShaderPrecacheFlags::empty() }, - enable_subpixel_aa: pref!(gfx_subpixel_text_antialiasing_enabled) && - !opts.debug.disable_subpixel_text_antialiasing, + enable_aa: pref!(gfx_text_antialiasing_enabled), + enable_subpixel_aa: pref!(gfx_subpixel_text_antialiasing_enabled), allow_texture_swizzling: pref!(gfx_texture_swizzling_enabled), clear_color, upload_method, @@ -1150,7 +1149,6 @@ fn create_constellation( opts.random_pipeline_closure_probability, opts.random_pipeline_closure_seed, opts.hard_fail, - !opts.debug.disable_canvas_antialiasing, canvas_create_sender, canvas_ipc_sender, ) diff --git a/components/shared/canvas/lib.rs b/components/shared/canvas/lib.rs index f1444ad1a3e..8d72c818284 100644 --- a/components/shared/canvas/lib.rs +++ b/components/shared/canvas/lib.rs @@ -19,7 +19,6 @@ pub enum ConstellationCanvasMsg { Create { id_sender: Sender<CanvasId>, size: Size2D<u64>, - antialias: bool, }, Exit, } |