aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-03-06 20:03:42 -0800
committerGitHub <noreply@github.com>2017-03-06 20:03:42 -0800
commit005f1b6326f24f0e42a01a76ec3c3de70bfaa533 (patch)
tree1d21830d64f54e42e3bfd55facab9c92eb55da63
parent1d497857e8a5cf85f8165e4c2fd8df878f683206 (diff)
parent2a05534efba24b5c8e1df2648af3dc7f17228272 (diff)
downloadservo-005f1b6326f24f0e42a01a76ec3c3de70bfaa533.tar.gz
servo-005f1b6326f24f0e42a01a76ec3c3de70bfaa533.zip
Auto merge of #15831 - paulrouget:winParams, r=glennw
introduce frame_size and window_rect follow up of https://github.com/servo/webrender/pull/951 --- <!-- 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 webrender/issues/833 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes do not require tests because I don't know how to test that feature <!-- 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/15831) <!-- Reviewable:end -->
-rw-r--r--components/compositing/compositor.rs40
-rw-r--r--components/compositing/windowing.rs5
-rw-r--r--ports/cef/window.rs9
-rw-r--r--ports/glutin/window.rs7
4 files changed, 50 insertions, 11 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs
index dc3313fb595..a4061351939 100644
--- a/components/compositing/compositor.rs
+++ b/components/compositing/compositor.rs
@@ -9,6 +9,7 @@ use compositor_thread::{InitialCompositorState, Msg, RenderListener};
use delayed_composition::DelayedCompositionTimerProxy;
use euclid::Point2D;
use euclid::point::TypedPoint2D;
+use euclid::rect::TypedRect;
use euclid::scale_factor::ScaleFactor;
use euclid::size::TypedSize2D;
use gfx_traits::{Epoch, FragmentType, ScrollRootId};
@@ -140,8 +141,11 @@ pub struct IOCompositor<Window: WindowMethods> {
/// The scene scale, to allow for zooming and high-resolution painting.
scale: ScaleFactor<f32, LayerPixel, DevicePixel>,
- /// The application window size.
- window_size: TypedSize2D<u32, DevicePixel>,
+ /// The size of the rendering area.
+ frame_size: TypedSize2D<u32, DevicePixel>,
+
+ /// The position and size of the window within the rendering area.
+ window_rect: TypedRect<u32, DevicePixel>,
/// The overridden viewport.
viewport: Option<(TypedPoint2D<u32, DevicePixel>, TypedSize2D<u32, DevicePixel>)>,
@@ -376,7 +380,8 @@ impl webrender_traits::RenderDispatcher for CompositorThreadDispatcher {
impl<Window: WindowMethods> IOCompositor<Window> {
fn new(window: Rc<Window>, state: InitialCompositorState)
-> IOCompositor<Window> {
- let window_size = window.framebuffer_size();
+ let frame_size = window.framebuffer_size();
+ let window_rect = window.window_rect();
let scale_factor = window.hidpi_factor();
let composite_target = match opts::get().output_file {
Some(_) => CompositeTarget::PngFile,
@@ -388,7 +393,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
port: state.receiver,
root_pipeline: None,
pipeline_details: HashMap::new(),
- window_size: window_size,
+ frame_size: frame_size,
+ window_rect: window_rect,
scale: ScaleFactor::new(1.0),
viewport: None,
scale_factor: scale_factor,
@@ -756,7 +762,18 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn send_window_size(&self, size_type: WindowSizeType) {
let dppx = self.page_zoom * self.hidpi_factor();
- let initial_viewport = self.window_size.to_f32() / dppx;
+
+ let window_rect = {
+ let offset = webrender_traits::DeviceUintPoint::new(self.window_rect.origin.x, self.window_rect.origin.y);
+ let size = webrender_traits::DeviceUintSize::new(self.window_rect.size.width, self.window_rect.size.height);
+ webrender_traits::DeviceUintRect::new(offset, size)
+ };
+
+ let frame_size = webrender_traits::DeviceUintSize::new(self.frame_size.width, self.frame_size.height);
+ self.webrender_api.set_window_parameters(frame_size, window_rect);
+
+ let initial_viewport = self.window_rect.size.to_f32() / dppx;
+
let msg = ConstellationMsg::WindowSize(WindowSizeData {
device_pixel_ratio: dppx,
initial_viewport: initial_viewport,
@@ -892,11 +909,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.update_zoom_transform();
}
- if self.window_size == new_size {
+ let new_window_rect = self.window.window_rect();
+ let new_frame_size = self.window.framebuffer_size();
+
+ if self.window_rect == new_window_rect &&
+ self.frame_size == new_frame_size {
return;
}
- self.window_size = new_size;
+ self.frame_size = new_size;
+ self.window_rect = new_window_rect;
self.send_window_size(WindowSizeType::Resize);
}
@@ -1485,7 +1507,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
target: CompositeTarget)
-> Result<Option<Image>, UnableToComposite> {
let (width, height) =
- (self.window_size.width as usize, self.window_size.height as usize);
+ (self.frame_size.width as usize, self.frame_size.height as usize);
if !self.window.prepare_for_composite(width, height) {
return Err(UnableToComposite::WindowUnprepared)
}
@@ -1523,7 +1545,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
debug!("compositor: compositing");
// Paint the scene.
- let size = webrender_traits::DeviceUintSize::from_untyped(&self.window_size.to_untyped());
+ let size = webrender_traits::DeviceUintSize::from_untyped(&self.frame_size.to_untyped());
self.webrender.render(size);
});
diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs
index 85d73af2f9f..84a1365af0d 100644
--- a/components/compositing/windowing.rs
+++ b/components/compositing/windowing.rs
@@ -7,6 +7,7 @@
use compositor_thread::{CompositorProxy, CompositorReceiver};
use euclid::{Point2D, Size2D};
use euclid::point::TypedPoint2D;
+use euclid::rect::TypedRect;
use euclid::scale_factor::ScaleFactor;
use euclid::size::TypedSize2D;
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
@@ -106,8 +107,10 @@ impl Debug for WindowEvent {
}
pub trait WindowMethods {
- /// Returns the size of the window in hardware pixels.
+ /// Returns the rendering area size in hardware pixels.
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel>;
+ /// Returns the position and size of the window within the rendering area.
+ fn window_rect(&self) -> TypedRect<u32, DevicePixel>;
/// Returns the size of the window in density-independent "px" units.
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel>;
/// Presents the window to the screen (perhaps by page flipping).
diff --git a/ports/cef/window.rs b/ports/cef/window.rs
index 4c31a890774..ecf8a1f2984 100644
--- a/ports/cef/window.rs
+++ b/ports/cef/window.rs
@@ -19,7 +19,8 @@ use wrappers::CefWrap;
use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver};
use compositing::windowing::{WindowEvent, WindowMethods};
-use euclid::point::Point2D;
+use euclid::point::{Point2D, TypedPoint2D};
+use euclid::rect::TypedRect;
use euclid::scale_factor::ScaleFactor;
use euclid::size::{Size2D, TypedSize2D};
use gleam::gl;
@@ -206,6 +207,12 @@ impl WindowMethods for Window {
}
}
+ fn window_rect(&self) -> TypedRect<u32, DevicePixel> {
+ let size = self.framebuffer_size();
+ let origin = TypedPoint2D::zero();
+ TypedRect::new(origin, size)
+ }
+
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel> {
let browser = self.cef_browser.borrow();
match *browser {
diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index 79582972de7..04cc8fbe2b0 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -9,6 +9,7 @@ use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver};
use compositing::windowing::{MouseWindowEvent, WindowNavigateMsg};
use compositing::windowing::{WindowEvent, WindowMethods};
use euclid::{Point2D, Size2D, TypedPoint2D};
+use euclid::rect::TypedRect;
use euclid::scale_factor::ScaleFactor;
use euclid::size::TypedSize2D;
#[cfg(target_os = "windows")]
@@ -797,6 +798,12 @@ impl WindowMethods for Window {
}
}
+ fn window_rect(&self) -> TypedRect<u32, DevicePixel> {
+ let size = self.framebuffer_size();
+ let origin = TypedPoint2D::zero();
+ TypedRect::new(origin, size)
+ }
+
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel> {
match self.kind {
WindowKind::Window(ref window) => {