aboutsummaryrefslogtreecommitdiffstats
path: root/components/constellation
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2019-11-06 16:10:36 -0500
committerJosh Matthews <josh@joshmatthews.net>2019-11-06 16:13:55 -0500
commit7c365b0324b2723d5df2437e59555bfc1835a68f (patch)
treeab4ac6bb4ca966885f512041079567080d722f2b /components/constellation
parentfd260f78c80a070727ba88d7b5f7cc40eb7efb5a (diff)
downloadservo-7c365b0324b2723d5df2437e59555bfc1835a68f.tar.gz
servo-7c365b0324b2723d5df2437e59555bfc1835a68f.zip
Centralize definitions of window sizes and DPI in compositor/constellation during startup.
Diffstat (limited to 'components/constellation')
-rw-r--r--components/constellation/constellation.rs27
-rw-r--r--components/constellation/pipeline.rs26
2 files changed, 11 insertions, 42 deletions
diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs
index 685f620f6b5..1607eea424f 100644
--- a/components/constellation/constellation.rs
+++ b/components/constellation/constellation.rs
@@ -112,7 +112,7 @@ use compositing::SendableFrameTree;
use crossbeam_channel::{after, never, unbounded, Receiver, Sender};
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
use embedder_traits::{Cursor, EmbedderMsg, EmbedderProxy, EventLoopWaker};
-use euclid::{default::Size2D as UntypedSize2D, Scale, Size2D};
+use euclid::{default::Size2D as UntypedSize2D, Size2D};
use gfx::font_cache_thread::FontCacheThread;
use gfx_traits::Epoch;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
@@ -157,7 +157,6 @@ use script_traits::{MessagePortMsg, PortMessageTask, StructuredSerializedData};
use script_traits::{SWManagerMsg, ScopeThings, UpdatePipelineIdReason, WebDriverCommandMsg};
use serde::{Deserialize, Serialize};
use servo_config::{opts, pref};
-use servo_geometry::DeviceIndependentPixel;
use servo_rand::{random, Rng, ServoRng, SliceRandom};
use servo_remutex::ReentrantMutex;
use servo_url::{Host, ImmutableOrigin, ServoUrl};
@@ -463,10 +462,6 @@ pub struct Constellation<Message, LTF, STF> {
/// Mechanism to force the compositor to process events.
event_loop_waker: Option<Box<dyn EventLoopWaker>>,
-
- /// The ratio of device pixels per px at the default scale. If unspecified, will use the
- /// platform default setting.
- device_pixels_per_px: Option<f32>,
}
/// State needed to construct a constellation.
@@ -523,10 +518,6 @@ pub struct InitialConstellationState {
/// Mechanism to force the compositor to process events.
pub event_loop_waker: Option<Box<dyn EventLoopWaker>>,
-
- /// The ratio of device pixels per px at the default scale. If unspecified, will use the
- /// platform default setting.
- pub device_pixels_per_px: Option<f32>,
}
/// Data needed for webdriver
@@ -702,8 +693,7 @@ where
/// Create a new constellation thread.
pub fn start(
state: InitialConstellationState,
- initial_window_size: Size2D<u32, DeviceIndependentPixel>,
- device_pixels_per_px: Option<f32>,
+ initial_window_size: WindowSizeData,
random_pipeline_closure_probability: Option<f32>,
random_pipeline_closure_seed: Option<usize>,
is_running_problem_test: bool,
@@ -811,10 +801,7 @@ where
next_pipeline_namespace_id: PipelineNamespaceId(2),
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
- window_size: WindowSizeData {
- initial_viewport: initial_window_size.to_f32() * Scale::new(1.0),
- device_pixel_ratio: Scale::new(device_pixels_per_px.unwrap_or(1.0)),
- },
+ window_size: initial_window_size,
phantom: PhantomData,
webdriver: WebDriverData::new(),
timer_scheduler: TimerScheduler::new(),
@@ -844,7 +831,6 @@ where
glplayer_threads: state.glplayer_threads,
player_context: state.player_context,
event_loop_waker: state.event_loop_waker,
- device_pixels_per_px,
};
constellation.run();
@@ -1074,10 +1060,12 @@ where
resource_threads,
time_profiler_chan: self.time_profiler_chan.clone(),
mem_profiler_chan: self.mem_profiler_chan.clone(),
- window_size: initial_window_size,
+ window_size: WindowSizeData {
+ initial_viewport: initial_window_size,
+ device_pixel_ratio: self.window_size.device_pixel_ratio,
+ },
event_loop,
load_data,
- device_pixel_ratio: self.window_size.device_pixel_ratio,
prev_visibility: is_visible,
webrender_api_sender: self.webrender_api_sender.clone(),
webrender_document: self.webrender_document,
@@ -1089,7 +1077,6 @@ where
webxr_registry: self.webxr_registry.clone(),
player_context: self.player_context.clone(),
event_loop_waker: self.event_loop_waker.as_ref().map(|w| (*w).clone_box()),
- device_pixels_per_px: self.device_pixels_per_px,
});
let pipeline = match result {
diff --git a/components/constellation/pipeline.rs b/components/constellation/pipeline.rs
index 2579343f3fe..3ac5ded15ed 100644
--- a/components/constellation/pipeline.rs
+++ b/components/constellation/pipeline.rs
@@ -12,7 +12,6 @@ use compositing::CompositorProxy;
use crossbeam_channel::{unbounded, Sender};
use devtools_traits::{DevtoolsControlMsg, ScriptToDevtoolsControlMsg};
use embedder_traits::EventLoopWaker;
-use euclid::{Scale, Size2D};
use gfx::font_cache_thread::FontCacheThread;
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
use ipc_channel::router::ROUTER;
@@ -47,8 +46,6 @@ use std::process;
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
-use style_traits::CSSPixel;
-use style_traits::DevicePixel;
use webvr_traits::WebVRMsg;
/// A `Pipeline` is the constellation's view of a `Document`. Each pipeline has an
@@ -165,10 +162,7 @@ pub struct InitialPipelineState {
pub mem_profiler_chan: profile_mem::ProfilerChan,
/// Information about the initial window size.
- pub window_size: Size2D<f32, CSSPixel>,
-
- /// Information about the device pixel ratio.
- pub device_pixel_ratio: Scale<f32, CSSPixel, DevicePixel>,
+ pub window_size: WindowSizeData,
/// The ID of the pipeline namespace for this script thread.
pub pipeline_namespace_id: PipelineNamespaceId,
@@ -205,10 +199,6 @@ pub struct InitialPipelineState {
/// Mechanism to force the compositor to process events.
pub event_loop_waker: Option<Box<dyn EventLoopWaker>>,
-
- /// The ratio of device pixels per px at the default scale. If unspecified, will use the
- /// platform default setting.
- pub device_pixels_per_px: Option<f32>,
}
pub struct NewPipeline {
@@ -228,11 +218,6 @@ impl Pipeline {
// probably requires a general low-memory strategy.
let (pipeline_chan, pipeline_port) = ipc::channel().expect("Pipeline main chan");
- let window_size = WindowSizeData {
- initial_viewport: state.window_size,
- device_pixel_ratio: state.device_pixel_ratio,
- };
-
let (script_chan, sampler_chan) = match state.event_loop {
Some(script_chan) => {
let new_layout_info = NewLayoutInfo {
@@ -242,7 +227,7 @@ impl Pipeline {
top_level_browsing_context_id: state.top_level_browsing_context_id,
opener: state.opener,
load_data: state.load_data.clone(),
- window_size: window_size,
+ window_size: state.window_size,
pipeline_port: pipeline_port,
};
@@ -301,7 +286,7 @@ impl Pipeline {
resource_threads: state.resource_threads,
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
- window_size: window_size,
+ window_size: state.window_size,
layout_to_constellation_chan: state.layout_to_constellation_chan,
script_chan: script_chan.clone(),
load_data: state.load_data.clone(),
@@ -316,7 +301,6 @@ impl Pipeline {
webvr_chan: state.webvr_chan,
webxr_registry: state.webxr_registry,
player_context: state.player_context,
- device_pixels_per_px: state.device_pixels_per_px,
};
// Spawn the child process.
@@ -523,7 +507,6 @@ pub struct UnprivilegedPipelineContent {
webvr_chan: Option<IpcSender<WebVRMsg>>,
webxr_registry: webxr_api::Registry,
player_context: WindowGLContext,
- device_pixels_per_px: Option<f32>,
}
impl UnprivilegedPipelineContent {
@@ -614,8 +597,7 @@ impl UnprivilegedPipelineContent {
paint_time_metrics,
layout_thread_busy_flag.clone(),
self.opts.load_webfonts_synchronously,
- self.opts.initial_window_size,
- self.device_pixels_per_px,
+ self.window_size,
self.opts.dump_display_list,
self.opts.dump_display_list_json,
self.opts.dump_style_tree,