mirror of
https://github.com/servo/servo.git
synced 2025-07-05 14:33:38 +01:00
Auto merge of #23493 - oneturkmen:remove-get-opts, r=jdm
compositing: removed opts-get <!-- Please describe your changes on the following line: --> Removed all `opts::get()` from `compositing` component. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix *partially* #22854 (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because they are not feature- or bug-related changes. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23493) <!-- Reviewable:end -->
This commit is contained in:
commit
2ee155ea3a
4 changed files with 65 additions and 21 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -635,7 +635,6 @@ dependencies = [
|
||||||
"pixels 0.0.1",
|
"pixels 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"script_traits 0.0.1",
|
"script_traits 0.0.1",
|
||||||
"servo_config 0.0.1",
|
|
||||||
"servo_geometry 0.0.1",
|
"servo_geometry 0.0.1",
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
|
|
|
@ -32,7 +32,6 @@ num-traits = "0.2"
|
||||||
pixels = {path = "../pixels", optional = true}
|
pixels = {path = "../pixels", optional = true}
|
||||||
profile_traits = {path = "../profile_traits"}
|
profile_traits = {path = "../profile_traits"}
|
||||||
script_traits = {path = "../script_traits"}
|
script_traits = {path = "../script_traits"}
|
||||||
servo_config = {path = "../config"}
|
|
||||||
servo_geometry = {path = "../geometry"}
|
servo_geometry = {path = "../geometry"}
|
||||||
servo_url = {path = "../url"}
|
servo_url = {path = "../url"}
|
||||||
style_traits = {path = "../style_traits"}
|
style_traits = {path = "../style_traits"}
|
||||||
|
|
|
@ -30,7 +30,6 @@ use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchEven
|
||||||
use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg};
|
use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg};
|
||||||
use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId};
|
use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId};
|
||||||
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
use script_traits::{UntrustedNodeAddress, WindowSizeData, WindowSizeType};
|
||||||
use servo_config::opts;
|
|
||||||
use servo_geometry::DeviceIndependentPixel;
|
use servo_geometry::DeviceIndependentPixel;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
@ -194,6 +193,19 @@ pub struct IOCompositor<Window: WindowMethods + ?Sized> {
|
||||||
|
|
||||||
/// Current mouse cursor.
|
/// Current mouse cursor.
|
||||||
cursor: Cursor,
|
cursor: Cursor,
|
||||||
|
|
||||||
|
output_file: Option<String>,
|
||||||
|
|
||||||
|
is_running_problem_test: bool,
|
||||||
|
|
||||||
|
/// True to exit after page load ('-x').
|
||||||
|
exit_after_load: bool,
|
||||||
|
|
||||||
|
/// True to translate mouse input into touch events.
|
||||||
|
convert_mouse_to_touch: bool,
|
||||||
|
|
||||||
|
/// Ratio of device pixels per px at the default scale.
|
||||||
|
device_pixels_per_px: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
@ -259,8 +271,16 @@ enum CompositeTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
fn new(window: Rc<Window>, state: InitialCompositorState) -> Self {
|
fn new(
|
||||||
let composite_target = match opts::get().output_file {
|
window: Rc<Window>,
|
||||||
|
state: InitialCompositorState,
|
||||||
|
output_file: Option<String>,
|
||||||
|
is_running_problem_test: bool,
|
||||||
|
exit_after_load: bool,
|
||||||
|
convert_mouse_to_touch: bool,
|
||||||
|
device_pixels_per_px: Option<f32>,
|
||||||
|
) -> Self {
|
||||||
|
let composite_target = match output_file {
|
||||||
Some(_) => CompositeTarget::PngFile,
|
Some(_) => CompositeTarget::PngFile,
|
||||||
None => CompositeTarget::Window,
|
None => CompositeTarget::Window,
|
||||||
};
|
};
|
||||||
|
@ -295,11 +315,32 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
webvr_heartbeats: state.webvr_heartbeats,
|
webvr_heartbeats: state.webvr_heartbeats,
|
||||||
pending_paint_metrics: HashMap::new(),
|
pending_paint_metrics: HashMap::new(),
|
||||||
cursor: Cursor::None,
|
cursor: Cursor::None,
|
||||||
|
output_file,
|
||||||
|
is_running_problem_test,
|
||||||
|
exit_after_load,
|
||||||
|
convert_mouse_to_touch,
|
||||||
|
device_pixels_per_px,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(window: Rc<Window>, state: InitialCompositorState) -> Self {
|
pub fn create(
|
||||||
let mut compositor = IOCompositor::new(window, state);
|
window: Rc<Window>,
|
||||||
|
state: InitialCompositorState,
|
||||||
|
output_file: Option<String>,
|
||||||
|
is_running_problem_test: bool,
|
||||||
|
exit_after_load: bool,
|
||||||
|
convert_mouse_to_touch: bool,
|
||||||
|
device_pixels_per_px: Option<f32>,
|
||||||
|
) -> Self {
|
||||||
|
let mut compositor = IOCompositor::new(
|
||||||
|
window,
|
||||||
|
state,
|
||||||
|
output_file,
|
||||||
|
is_running_problem_test,
|
||||||
|
exit_after_load,
|
||||||
|
convert_mouse_to_touch,
|
||||||
|
device_pixels_per_px,
|
||||||
|
);
|
||||||
|
|
||||||
// Set the size of the root layer.
|
// Set the size of the root layer.
|
||||||
compositor.update_zoom_transform();
|
compositor.update_zoom_transform();
|
||||||
|
@ -404,12 +445,12 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
);
|
);
|
||||||
if is_ready {
|
if is_ready {
|
||||||
self.ready_to_save_state = ReadyState::ReadyToSaveImage;
|
self.ready_to_save_state = ReadyState::ReadyToSaveImage;
|
||||||
if opts::get().is_running_problem_test {
|
if self.is_running_problem_test {
|
||||||
println!("ready to save image!");
|
println!("ready to save image!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.ready_to_save_state = ReadyState::Unknown;
|
self.ready_to_save_state = ReadyState::Unknown;
|
||||||
if opts::get().is_running_problem_test {
|
if self.is_running_problem_test {
|
||||||
println!("resetting ready_to_save_state!");
|
println!("resetting ready_to_save_state!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,7 +490,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
(Msg::LoadComplete(_), ShutdownState::NotShuttingDown) => {
|
(Msg::LoadComplete(_), ShutdownState::NotShuttingDown) => {
|
||||||
// If we're painting in headless mode, schedule a recomposite.
|
// If we're painting in headless mode, schedule a recomposite.
|
||||||
if opts::get().output_file.is_some() || opts::get().exit_after_load {
|
if self.output_file.is_some() || self.exit_after_load {
|
||||||
self.composite_if_necessary(CompositingReason::Headless);
|
self.composite_if_necessary(CompositingReason::Headless);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -625,7 +666,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) {
|
pub fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) {
|
||||||
if opts::get().convert_mouse_to_touch {
|
if self.convert_mouse_to_touch {
|
||||||
match mouse_window_event {
|
match mouse_window_event {
|
||||||
MouseWindowEvent::Click(_, _) => {},
|
MouseWindowEvent::Click(_, _) => {},
|
||||||
MouseWindowEvent::MouseDown(_, p) => self.on_touch_down(TouchId(0), p),
|
MouseWindowEvent::MouseDown(_, p) => self.on_touch_down(TouchId(0), p),
|
||||||
|
@ -686,7 +727,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_mouse_window_move_event_class(&mut self, cursor: DevicePoint) {
|
pub fn on_mouse_window_move_event_class(&mut self, cursor: DevicePoint) {
|
||||||
if opts::get().convert_mouse_to_touch {
|
if self.convert_mouse_to_touch {
|
||||||
self.on_touch_move(TouchId(0), cursor);
|
self.on_touch_move(TouchId(0), cursor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -986,9 +1027,9 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel> {
|
||||||
match opts::get().device_pixels_per_px {
|
match self.device_pixels_per_px {
|
||||||
Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px),
|
Some(device_pixels_per_px) => TypedScale::new(device_pixels_per_px),
|
||||||
None => match opts::get().output_file {
|
None => match self.output_file {
|
||||||
Some(_) => TypedScale::new(1.0),
|
Some(_) => TypedScale::new(1.0),
|
||||||
None => self.embedder_coordinates.hidpi_factor,
|
None => self.embedder_coordinates.hidpi_factor,
|
||||||
},
|
},
|
||||||
|
@ -1125,7 +1166,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
// for saving.
|
// for saving.
|
||||||
// Reset the flag so that we check again in the future
|
// Reset the flag so that we check again in the future
|
||||||
// TODO: only reset this if we load a new document?
|
// TODO: only reset this if we load a new document?
|
||||||
if opts::get().is_running_problem_test {
|
if self.is_running_problem_test {
|
||||||
println!("was ready to save, resetting ready_to_save_state");
|
println!("was ready to save, resetting ready_to_save_state");
|
||||||
}
|
}
|
||||||
self.ready_to_save_state = ReadyState::Unknown;
|
self.ready_to_save_state = ReadyState::Unknown;
|
||||||
|
@ -1138,13 +1179,13 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
let target = self.composite_target;
|
let target = self.composite_target;
|
||||||
match self.composite_specific_target(target) {
|
match self.composite_specific_target(target) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if opts::get().output_file.is_some() || opts::get().exit_after_load {
|
if self.output_file.is_some() || self.exit_after_load {
|
||||||
println!("Shutting down the Constellation after generating an output file or exit flag specified");
|
println!("Shutting down the Constellation after generating an output file or exit flag specified");
|
||||||
self.start_shutting_down();
|
self.start_shutting_down();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if opts::get().is_running_problem_test {
|
if self.is_running_problem_test {
|
||||||
if e != UnableToComposite::NotReadyToPaintImage(
|
if e != UnableToComposite::NotReadyToPaintImage(
|
||||||
NotReadyToPaint::WaitingOnConstellation,
|
NotReadyToPaint::WaitingOnConstellation,
|
||||||
) {
|
) {
|
||||||
|
@ -1178,7 +1219,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
let wait_for_stable_image = match target {
|
let wait_for_stable_image = match target {
|
||||||
CompositeTarget::WindowAndPng | CompositeTarget::PngFile => true,
|
CompositeTarget::WindowAndPng | CompositeTarget::PngFile => true,
|
||||||
CompositeTarget::Window => opts::get().exit_after_load,
|
CompositeTarget::Window => self.exit_after_load,
|
||||||
};
|
};
|
||||||
|
|
||||||
if wait_for_stable_image {
|
if wait_for_stable_image {
|
||||||
|
@ -1279,7 +1320,7 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
ProfilerCategory::ImageSaving,
|
ProfilerCategory::ImageSaving,
|
||||||
None,
|
None,
|
||||||
self.time_profiler_chan.clone(),
|
self.time_profiler_chan.clone(),
|
||||||
|| match opts::get().output_file.as_ref() {
|
|| match self.output_file.as_ref() {
|
||||||
Some(path) => match File::create(path) {
|
Some(path) => match File::create(path) {
|
||||||
Ok(mut file) => {
|
Ok(mut file) => {
|
||||||
let img = gl::draw_img(gl, rt_info, width, height);
|
let img = gl::draw_img(gl, rt_info, width, height);
|
||||||
|
@ -1315,11 +1356,11 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
|
||||||
|
|
||||||
fn composite_if_necessary(&mut self, reason: CompositingReason) {
|
fn composite_if_necessary(&mut self, reason: CompositingReason) {
|
||||||
if self.composition_request == CompositionRequest::NoCompositingNecessary {
|
if self.composition_request == CompositionRequest::NoCompositingNecessary {
|
||||||
if opts::get().is_running_problem_test {
|
if self.is_running_problem_test {
|
||||||
println!("updating composition_request ({:?})", reason);
|
println!("updating composition_request ({:?})", reason);
|
||||||
}
|
}
|
||||||
self.composition_request = CompositionRequest::CompositeNow(reason)
|
self.composition_request = CompositionRequest::CompositeNow(reason)
|
||||||
} else if opts::get().is_running_problem_test {
|
} else if self.is_running_problem_test {
|
||||||
println!(
|
println!(
|
||||||
"composition_request is already {:?}",
|
"composition_request is already {:?}",
|
||||||
self.composition_request
|
self.composition_request
|
||||||
|
|
|
@ -337,6 +337,11 @@ where
|
||||||
webrender_api,
|
webrender_api,
|
||||||
webvr_heartbeats,
|
webvr_heartbeats,
|
||||||
},
|
},
|
||||||
|
opts.output_file.clone(),
|
||||||
|
opts.is_running_problem_test,
|
||||||
|
opts.exit_after_load,
|
||||||
|
opts.convert_mouse_to_touch,
|
||||||
|
opts.device_pixels_per_px,
|
||||||
);
|
);
|
||||||
|
|
||||||
Servo {
|
Servo {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue