mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Reduce the number of calls to the embedder by grouping the screen and window coordinates into one structure
This commit is contained in:
parent
28c92db268
commit
10abe03948
7 changed files with 150 additions and 160 deletions
|
@ -121,19 +121,11 @@ pub enum AnimationState {
|
|||
}
|
||||
|
||||
pub trait WindowMethods {
|
||||
/// Returns the rendering area size in hardware pixels.
|
||||
fn framebuffer_size(&self) -> DeviceUintSize;
|
||||
/// Returns the position and size of the window within the rendering area.
|
||||
fn window_rect(&self) -> DeviceUintRect;
|
||||
/// Presents the window to the screen (perhaps by page flipping).
|
||||
fn present(&self);
|
||||
|
||||
/// Return the size of the window with head and borders and position of the window values
|
||||
fn client_window(&self, ctx: TopLevelBrowsingContextId) -> (DeviceUintSize, DeviceIntPoint);
|
||||
/// Return the size of the screen.
|
||||
fn screen_size(&self, ctx: TopLevelBrowsingContextId) -> DeviceUintSize;
|
||||
/// Return the available size of the screen.
|
||||
fn screen_avail_size(&self, ctx: TopLevelBrowsingContextId) -> DeviceUintSize;
|
||||
/// Get the coordinates of the native window, the screen and the framebuffer.
|
||||
fn get_coordinates(&self) -> EmbedderCoordinates;
|
||||
/// Set the size inside of borders and head
|
||||
fn set_inner_size(&self, ctx: TopLevelBrowsingContextId, size: DeviceUintSize);
|
||||
/// Set the window position
|
||||
|
@ -158,9 +150,6 @@ pub trait WindowMethods {
|
|||
/// Called when the history state has changed.
|
||||
fn history_changed(&self, ctx: TopLevelBrowsingContextId, Vec<LoadData>, usize);
|
||||
|
||||
/// Returns the scale factor of the system (device pixels / device independent pixels).
|
||||
fn hidpi_factor(&self) -> TypedScale<f32, DeviceIndependentPixel, DevicePixel>;
|
||||
|
||||
/// Returns a thread-safe object to wake up the window's event loop.
|
||||
fn create_event_loop_waker(&self) -> Box<EventLoopWaker>;
|
||||
|
||||
|
@ -193,3 +182,19 @@ pub trait WindowMethods {
|
|||
/// Called when a pipeline panics.
|
||||
fn handle_panic(&self, browser_id: TopLevelBrowsingContextId, reason: String, backtrace: Option<String>);
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct EmbedderCoordinates {
|
||||
/// The pixel density of the display.
|
||||
pub hidpi_factor: TypedScale<f32, DeviceIndependentPixel, DevicePixel>,
|
||||
/// Size of the screen.
|
||||
pub screen: DeviceUintSize,
|
||||
/// Size of the available screen space (screen without toolbars and docks).
|
||||
pub screen_avail: DeviceUintSize,
|
||||
/// Size of the native window.
|
||||
pub window: (DeviceUintSize, DeviceIntPoint),
|
||||
/// Size of the GL buffer in the window.
|
||||
pub framebuffer: DeviceUintSize,
|
||||
/// Coordinates of the document within the framebuffer.
|
||||
pub viewport: DeviceUintRect,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue