Auto merge of #17892 - kvark:wr, r=glennw

WR multi-document update

<!-- Please describe your changes on the following line: -->
The PR updates WR version to support multiple documents (https://github.com/servo/webrender/pull/1509) but doesn't take advantage of this new feature yet.
It also makes Servo to use `DevicePixel` from WR instead of rolling out another one.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because _____ no extra logic

<!-- 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/17892)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-28 13:26:52 -05:00 committed by GitHub
commit 12a49dc0be
14 changed files with 111 additions and 85 deletions

5
Cargo.lock generated
View file

@ -3089,6 +3089,7 @@ dependencies = [
"heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
"serde 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_api 0.48.0 (git+https://github.com/servo/webrender)",
]
[[package]]
@ -3468,7 +3469,7 @@ dependencies = [
[[package]]
name = "webrender"
version = "0.48.0"
source = "git+https://github.com/servo/webrender#283192c41743a59da87b065cbc14c659d94c90b5"
source = "git+https://github.com/servo/webrender#1ec6fb9ae47d8356920975a4be60552608dbfa1b"
dependencies = [
"app_units 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3497,7 +3498,7 @@ dependencies = [
[[package]]
name = "webrender_api"
version = "0.48.0"
source = "git+https://github.com/servo/webrender#283192c41743a59da87b065cbc14c659d94c90b5"
source = "git+https://github.com/servo/webrender#1ec6fb9ae47d8356920975a4be60552608dbfa1b"
dependencies = [
"app_units 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -6,7 +6,7 @@ use CompositionPipeline;
use SendableFrameTree;
use compositor_thread::{CompositorProxy, CompositorReceiver};
use compositor_thread::{InitialCompositorState, Msg, RenderListener};
use euclid::{Point2D, TypedPoint2D, TypedVector2D, TypedRect, ScaleFactor, TypedSize2D};
use euclid::{Point2D, TypedPoint2D, TypedVector2D, ScaleFactor};
use gfx_traits::Epoch;
use gleam::gl;
use image::{DynamicImage, ImageFormat, RgbImage};
@ -34,7 +34,8 @@ use style_traits::viewport::ViewportConstraints;
use time::{precise_time_ns, precise_time_s};
use touch::{TouchHandler, TouchAction};
use webrender;
use webrender_api::{self, ClipId, LayoutPoint, LayoutVector2D, ScrollEventPhase, ScrollLocation, ScrollClamping};
use webrender_api::{self, ClipId, DeviceUintRect, DeviceUintSize, LayoutPoint, LayoutVector2D};
use webrender_api::{ScrollEventPhase, ScrollLocation, ScrollClamping};
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods};
#[derive(Debug, PartialEq)]
@ -110,10 +111,10 @@ pub struct IOCompositor<Window: WindowMethods> {
scale: ScaleFactor<f32, LayerPixel, DevicePixel>,
/// The size of the rendering area.
frame_size: TypedSize2D<u32, DevicePixel>,
frame_size: DeviceUintSize,
/// The position and size of the window within the rendering area.
window_rect: TypedRect<u32, DevicePixel>,
window_rect: DeviceUintRect,
/// "Mobile-style" zoom that does not reflow the page.
viewport_zoom: PinchZoomFactor,
@ -179,6 +180,9 @@ pub struct IOCompositor<Window: WindowMethods> {
/// The webrender renderer.
webrender: webrender::Renderer,
/// The active webrender document.
webrender_document: webrender_api::DocumentId,
/// The webrender interface, if enabled.
webrender_api: webrender_api::RenderApi,
@ -378,7 +382,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
scroll_in_progress: false,
in_scroll_transaction: None,
webrender: state.webrender,
webrender_api: state.webrender_api_sender.create_api(),
webrender_document: state.webrender_document,
webrender_api: state.webrender_api,
}
}
@ -675,8 +680,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.root_pipeline = Some(frame_tree.pipeline.clone());
let pipeline_id = frame_tree.pipeline.id.to_webrender();
self.webrender_api.set_root_pipeline(pipeline_id);
self.webrender_api.generate_frame(None);
self.webrender_api.set_root_pipeline(self.webrender_document, pipeline_id);
self.webrender_api.generate_frame(self.webrender_document, None);
self.create_pipeline_details_for_frame_tree(&frame_tree);
@ -700,14 +705,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn send_window_size(&self, size_type: WindowSizeType) {
let dppx = self.page_zoom * self.hidpi_factor();
let window_rect = {
let offset = webrender_api::DeviceUintPoint::new(self.window_rect.origin.x, self.window_rect.origin.y);
let size = webrender_api::DeviceUintSize::new(self.window_rect.size.width, self.window_rect.size.height);
webrender_api::DeviceUintRect::new(offset, size)
};
let frame_size = webrender_api::DeviceUintSize::new(self.frame_size.width, self.frame_size.height);
self.webrender_api.set_window_parameters(frame_size, window_rect);
self.webrender_api.set_window_parameters(self.webrender_document, self.frame_size, self.window_rect);
let initial_viewport = self.window_rect.size.to_f32() / dppx;
@ -727,7 +725,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
fn scroll_fragment_to_point(&mut self, id: ClipId, point: Point2D<f32>) {
self.webrender_api.scroll_node_with_id(LayoutPoint::from_untyped(&point), id,
self.webrender_api.scroll_node_with_id(self.webrender_document,
LayoutPoint::from_untyped(&point),
id,
ScrollClamping::ToContentBounds);
}
@ -821,12 +821,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
WindowEvent::ToggleWebRenderProfiler => {
let profiler_enabled = self.webrender.get_profiler_enabled();
self.webrender.set_profiler_enabled(!profiler_enabled);
self.webrender_api.generate_frame(None);
self.webrender_api.generate_frame(self.webrender_document, None);
}
}
}
fn on_resize_window_event(&mut self, new_size: TypedSize2D<u32, DevicePixel>) {
fn on_resize_window_event(&mut self, new_size: DeviceUintSize) {
debug!("compositor resizing to {:?}", new_size.to_untyped());
// A size change could also mean a resolution change.
@ -1123,7 +1123,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
(combined_event.cursor.to_f32() / self.scale).to_untyped();
let location = webrender_api::ScrollLocation::Delta(delta);
let cursor = webrender_api::WorldPoint::from_untyped(&cursor);
self.webrender_api.scroll(location, cursor, combined_event.phase);
self.webrender_api.scroll(self.webrender_document, location, cursor, combined_event.phase);
last_combined_event = None
}
}
@ -1179,7 +1179,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
};
let cursor = (combined_event.cursor.to_f32() / self.scale).to_untyped();
let cursor = webrender_api::WorldPoint::from_untyped(&cursor);
self.webrender_api.scroll(scroll_location, cursor, combined_event.phase);
self.webrender_api.scroll(self.webrender_document, scroll_location, cursor, combined_event.phase);
self.waiting_for_results_of_scroll = true
}
@ -1277,7 +1277,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn update_page_zoom_for_webrender(&mut self) {
let page_zoom = webrender_api::ZoomFactor::new(self.page_zoom.get());
self.webrender_api.set_page_zoom(page_zoom);
self.webrender_api.set_page_zoom(self.webrender_document, page_zoom);
}
/// Simulate a pinch zoom
@ -1315,7 +1315,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn send_viewport_rects(&self) {
let mut scroll_states_per_pipeline = HashMap::new();
for scroll_layer_state in self.webrender_api.get_scroll_node_state() {
for scroll_layer_state in self.webrender_api.get_scroll_node_state(self.webrender_document) {
if scroll_layer_state.id.external_id().is_none() &&
!scroll_layer_state.id.is_root_scroll_node() {
continue;
@ -1464,8 +1464,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
debug!("compositor: compositing");
// Paint the scene.
let size = webrender_api::DeviceUintSize::from_untyped(&self.frame_size.to_untyped());
self.webrender.render(size);
self.webrender.render(self.frame_size);
});
let rv = match target {
@ -1565,7 +1564,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
}
if self.webrender.layers_are_bouncing_back() {
self.webrender_api.tick_scrolling_bounce_animations();
self.webrender_api.tick_scrolling_bounce_animations(self.webrender_document);
self.send_viewport_rects()
}
}

View file

@ -194,5 +194,6 @@ pub struct InitialCompositorState {
pub mem_profiler_chan: mem::ProfilerChan,
/// Instance of webrender API
pub webrender: webrender::Renderer,
pub webrender_api_sender: webrender_api::RenderApiSender,
pub webrender_document: webrender_api::DocumentId,
pub webrender_api: webrender_api::RenderApi,
}

View file

@ -6,7 +6,7 @@
use compositor_thread::EventLoopWaker;
use euclid::{Point2D, Size2D};
use euclid::{TypedPoint2D, TypedRect, ScaleFactor, TypedSize2D};
use euclid::{ScaleFactor, TypedPoint2D, TypedSize2D};
use gleam::gl;
use ipc_channel::ipc::IpcSender;
use msg::constellation_msg::{Key, KeyModifiers, KeyState, TraversalDirection};
@ -18,7 +18,7 @@ use std::fmt::{Debug, Error, Formatter};
use std::rc::Rc;
use style_traits::DevicePixel;
use style_traits::cursor::Cursor;
use webrender_api::ScrollLocation;
use webrender_api::{DeviceUintSize, DeviceUintRect, ScrollLocation};
#[derive(Clone)]
pub enum MouseWindowEvent {
@ -41,7 +41,7 @@ pub enum WindowEvent {
/// message, the window must make the same GL context as in `PrepareRenderingEvent` current.
Refresh,
/// Sent when the window is resized.
Resize(TypedSize2D<u32, DevicePixel>),
Resize(DeviceUintSize),
/// Touchpad Pressure
TouchpadPressure(TypedPoint2D<f32, DevicePixel>, f32, TouchpadPressurePhase),
/// Sent when a new URL is to be loaded.
@ -105,9 +105,9 @@ pub enum AnimationState {
pub trait WindowMethods {
/// Returns the rendering area size in hardware pixels.
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel>;
fn framebuffer_size(&self) -> DeviceUintSize;
/// Returns the position and size of the window within the rendering area.
fn window_rect(&self) -> TypedRect<u32, DevicePixel>;
fn window_rect(&self) -> DeviceUintRect;
/// 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).

View file

@ -228,8 +228,11 @@ pub struct Constellation<Message, LTF, STF> {
/// timer thread.
scheduler_chan: IpcSender<TimerSchedulerMsg>,
/// A single WebRender document the constellation operates on.
webrender_document: webrender_api::DocumentId,
/// A channel for the constellation to send messages to the
/// Webrender thread.
/// WebRender thread.
webrender_api_sender: webrender_api::RenderApiSender,
/// The set of all event loops in the browser. We generate a new
@ -325,6 +328,9 @@ pub struct InitialConstellationState {
/// A channel to the memory profiler thread.
pub mem_profiler_chan: mem::ProfilerChan,
/// Webrender document ID.
pub webrender_document: webrender_api::DocumentId,
/// Webrender API.
pub webrender_api_sender: webrender_api::RenderApiSender,
@ -561,6 +567,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
webdriver: WebDriverData::new(),
scheduler_chan: TimerScheduler::start(),
document_states: HashMap::new(),
webrender_document: state.webrender_document,
webrender_api_sender: state.webrender_api_sender,
shutting_down: false,
handled_warnings: VecDeque::new(),
@ -664,9 +671,9 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
let result = Pipeline::spawn::<Message, LTF, STF>(InitialPipelineState {
id: pipeline_id,
browsing_context_id: browsing_context_id,
top_level_browsing_context_id: top_level_browsing_context_id,
parent_info: parent_info,
browsing_context_id,
top_level_browsing_context_id,
parent_info,
constellation_chan: self.script_sender.clone(),
layout_to_constellation_chan: self.layout_sender.clone(),
scheduler_chan: self.scheduler_chan.clone(),
@ -675,17 +682,18 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
bluetooth_thread: self.bluetooth_thread.clone(),
swmanager_thread: self.swmanager_sender.clone(),
font_cache_thread: self.font_cache_thread.clone(),
resource_threads: resource_threads,
resource_threads,
time_profiler_chan: self.time_profiler_chan.clone(),
mem_profiler_chan: self.mem_profiler_chan.clone(),
window_size: initial_window_size,
event_loop: event_loop,
load_data: load_data,
event_loop,
load_data,
device_pixel_ratio: self.window_size.device_pixel_ratio,
pipeline_namespace_id: self.next_pipeline_namespace_id(),
prev_visibility: prev_visibility,
prev_visibility,
webrender_api_sender: self.webrender_api_sender.clone(),
is_private: is_private,
webrender_document: self.webrender_document,
is_private,
webvr_thread: self.webvr_thread.clone()
});

View file

@ -156,6 +156,7 @@ pub struct InitialPipelineState {
/// Information about the page to load.
pub load_data: LoadData,
/// The ID of the pipeline namespace for this script thread.
pub pipeline_namespace_id: PipelineNamespaceId,
@ -165,6 +166,9 @@ pub struct InitialPipelineState {
/// Webrender api.
pub webrender_api_sender: webrender_api::RenderApiSender,
/// The ID of the document processed by this script thread.
pub webrender_document: webrender_api::DocumentId,
/// Whether this pipeline is considered private.
pub is_private: bool,
/// A channel to the webvr thread.
@ -265,6 +269,7 @@ impl Pipeline {
script_content_process_shutdown_chan: script_content_process_shutdown_chan,
script_content_process_shutdown_port: script_content_process_shutdown_port,
webrender_api_sender: state.webrender_api_sender,
webrender_document: state.webrender_document,
webvr_thread: state.webvr_thread,
};
@ -464,6 +469,7 @@ pub struct UnprivilegedPipelineContent {
script_content_process_shutdown_chan: IpcSender<()>,
script_content_process_shutdown_port: IpcReceiver<()>,
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
webvr_thread: Option<IpcSender<WebVRMsg>>,
}
@ -510,6 +516,7 @@ impl UnprivilegedPipelineContent {
self.mem_profiler_chan,
Some(self.layout_content_process_shutdown_chan),
self.webrender_api_sender,
self.webrender_document,
self.prefs.get("layout.threads").expect("exists").value()
.as_u64().expect("count") as usize,
paint_time_metrics);

View file

@ -242,6 +242,9 @@ pub struct LayoutThread {
/// Webrender interface.
webrender_api: webrender_api::RenderApi,
/// Webrender document.
webrender_document: webrender_api::DocumentId,
/// The timer object to control the timing of the animations. This should
/// only be a test-mode timer during testing for animations.
timer: Timer,
@ -275,6 +278,7 @@ impl LayoutThreadFactory for LayoutThread {
mem_profiler_chan: mem::ProfilerChan,
content_process_shutdown_chan: Option<IpcSender<()>>,
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
layout_threads: usize,
paint_time_metrics: PaintTimeMetrics) {
thread::Builder::new().name(format!("LayoutThread {:?}", id)).spawn(move || {
@ -298,6 +302,7 @@ impl LayoutThreadFactory for LayoutThread {
time_profiler_chan,
mem_profiler_chan.clone(),
webrender_api_sender,
webrender_document,
layout_threads,
paint_time_metrics);
@ -460,6 +465,7 @@ impl LayoutThread {
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: mem::ProfilerChan,
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
layout_threads: usize,
paint_time_metrics: PaintTimeMetrics)
-> LayoutThread {
@ -533,6 +539,7 @@ impl LayoutThread {
epoch: Cell::new(Epoch(0)),
viewport_size: Size2D::new(Au(0), Au(0)),
webrender_api: webrender_api_sender.create_api(),
webrender_document,
stylist: stylist,
rw_data: Arc::new(Mutex::new(
LayoutThreadData {
@ -802,6 +809,7 @@ impl LayoutThread {
self.mem_profiler_chan.clone(),
info.content_process_shutdown_chan,
self.webrender_api.clone_sender(),
self.webrender_document,
info.layout_threads,
info.paint_time_metrics);
}
@ -1045,12 +1053,13 @@ impl LayoutThread {
self.paint_time_metrics.maybe_set_first_contentful_paint(self, &display_list);
self.webrender_api.set_display_list(
Some(get_root_flow_background_color(layout_root)),
self.webrender_document,
webrender_api::Epoch(epoch.0),
Some(get_root_flow_background_color(layout_root)),
viewport_size,
builder.finalize(),
true);
self.webrender_api.generate_frame(None);
self.webrender_api.generate_frame(self.webrender_document, None);
});
}

View file

@ -50,6 +50,7 @@ pub trait LayoutThreadFactory {
mem_profiler_chan: mem::ProfilerChan,
content_process_shutdown_chan: Option<IpcSender<()>>,
webrender_api_sender: webrender_api::RenderApiSender,
webrender_document: webrender_api::DocumentId,
layout_threads: usize,
paint_time_metrics: PaintTimeMetrics);
}

View file

@ -66,10 +66,8 @@ use std::fmt;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, RecvTimeoutError};
use style_traits::CSSPixel;
use style_traits::DevicePixel;
use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
use webrender_api::ClipId;
use webrender_api::ImageKey;
use webrender_api::{ClipId, DevicePixel, ImageKey};
use webvr_traits::{WebVREvent, WebVRMsg};
pub use script_msg::{LayoutMsg, ScriptMsg, EventResult, LogEntry};

View file

@ -174,10 +174,6 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
None
};
let framebuffer_size = window.framebuffer_size();
let framebuffer_size = webrender_api::DeviceUintSize::new(framebuffer_size.width,
framebuffer_size.height);
webrender::Renderer::new(window.gl(), webrender::RendererOptions {
device_pixel_ratio: device_pixel_ratio,
resource_override_path: Some(resource_path),
@ -191,9 +187,12 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
renderer_kind: renderer_kind,
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
..Default::default()
}, framebuffer_size).expect("Unable to initialize webrender!")
}).expect("Unable to initialize webrender!")
};
let webrender_api = webrender_api_sender.create_api();
let webrender_document = webrender_api.add_document(window.framebuffer_size());
// Important that this call is done in a single-threaded fashion, we
// can't defer it after `create_constellation` has started.
script::init();
@ -211,7 +210,8 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
devtools_chan,
supports_clipboard,
&webrender,
webrender_api_sender.clone());
webrender_document,
webrender_api_sender);
// Send the constellation's swmanager sender to service worker manager thread
script::init_service_workers(sw_senders);
@ -230,8 +230,9 @@ impl<Window> Browser<Window> where Window: WindowMethods + 'static {
constellation_chan: constellation_chan.clone(),
time_profiler_chan: time_profiler_chan,
mem_profiler_chan: mem_profiler_chan,
webrender: webrender,
webrender_api_sender: webrender_api_sender,
webrender,
webrender_document,
webrender_api,
});
Browser {
@ -287,6 +288,7 @@ fn create_constellation(user_agent: Cow<'static, str>,
devtools_chan: Option<Sender<devtools_traits::DevtoolsControlMsg>>,
supports_clipboard: bool,
webrender: &webrender::Renderer,
webrender_document: webrender_api::DocumentId,
webrender_api_sender: webrender_api::RenderApiSender)
-> (Sender<ConstellationMsg>, SWManagerSenders) {
let bluetooth_thread: IpcSender<BluetoothRequest> = BluetoothThreadFactory::new();
@ -302,17 +304,18 @@ fn create_constellation(user_agent: Cow<'static, str>,
let resource_sender = public_resource_threads.sender();
let initial_state = InitialConstellationState {
compositor_proxy: compositor_proxy,
debugger_chan: debugger_chan,
devtools_chan: devtools_chan,
bluetooth_thread: bluetooth_thread,
font_cache_thread: font_cache_thread,
public_resource_threads: public_resource_threads,
private_resource_threads: private_resource_threads,
time_profiler_chan: time_profiler_chan,
mem_profiler_chan: mem_profiler_chan,
supports_clipboard: supports_clipboard,
webrender_api_sender: webrender_api_sender,
compositor_proxy,
debugger_chan,
devtools_chan,
bluetooth_thread,
font_cache_thread,
public_resource_threads,
private_resource_threads,
time_profiler_chan,
mem_profiler_chan,
supports_clipboard,
webrender_document,
webrender_api_sender,
};
let (constellation_chan, from_swmanager_sender) =
Constellation::<script_layout_interface::message::Msg,

View file

@ -22,3 +22,4 @@ heapsize = {version = "0.4", optional = true}
heapsize_derive = {version = "0.1", optional = true}
selectors = { path = "../selectors" }
serde = {version = "1.0", optional = true}
webrender_api = {git = "https://github.com/servo/webrender"}

View file

@ -21,6 +21,9 @@ extern crate euclid;
#[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive;
extern crate selectors;
#[cfg(feature = "servo")] #[macro_use] extern crate serde;
extern crate webrender_api;
pub use webrender_api::DevicePixel;
use cssparser::{CowRcStr, Token};
use selectors::parser::SelectorParseError;
@ -59,12 +62,6 @@ impl PinchZoomFactor {
#[derive(Clone, Copy, Debug)]
pub enum CSSPixel {}
/// One hardware pixel.
///
/// This unit corresponds to the smallest addressable element of the display hardware.
#[derive(Copy, Clone, Debug)]
pub enum DevicePixel {}
// In summary, the hierarchy of pixel units and the factors to convert from one to the next:
//
// DevicePixel

View file

@ -19,7 +19,7 @@ use wrappers::CefWrap;
use compositing::compositor_thread::EventLoopWaker;
use compositing::windowing::{WindowEvent, WindowMethods};
use euclid::{Point2D, TypedPoint2D, TypedRect, Size2D, TypedSize2D, ScaleFactor};
use euclid::{Point2D, TypedPoint2D, Size2D, TypedSize2D, ScaleFactor};
use gleam::gl;
use msg::constellation_msg::{Key, KeyModifiers};
use net_traits::net_error_list::NetError;
@ -38,6 +38,7 @@ use style_traits::DevicePixel;
extern crate x11;
#[cfg(target_os="linux")]
use self::x11::xlib::{XInitThreads,XOpenDisplay};
use webrender_api::{DeviceUintSize, DeviceUintRect};
#[cfg(target_os="linux")]
pub static mut DISPLAY: *mut c_void = 0 as *mut c_void;
@ -46,7 +47,7 @@ pub static mut DISPLAY: *mut c_void = 0 as *mut c_void;
#[derive(Clone)]
pub struct Window {
cef_browser: RefCell<Option<CefBrowser>>,
size: TypedSize2D<u32, DevicePixel>,
size: DeviceUintSize,
gl: Rc<gl::Gl>,
}
@ -174,7 +175,7 @@ impl WindowMethods for Window {
self.gl.clone()
}
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel> {
fn framebuffer_size(&self) -> DeviceUintSize {
let browser = self.cef_browser.borrow();
match *browser {
None => self.size,
@ -205,16 +206,16 @@ impl WindowMethods for Window {
}
}
TypedSize2D::new(rect.width as u32, rect.height as u32)
DeviceUintSize::new(rect.width as u32, rect.height as u32)
}
}
}
}
fn window_rect(&self) -> TypedRect<u32, DevicePixel> {
fn window_rect(&self) -> DeviceUintRect {
let size = self.framebuffer_size();
let origin = TypedPoint2D::zero();
TypedRect::new(origin, size)
DeviceUintRect::new(origin, size)
}
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel> {

View file

@ -8,7 +8,7 @@ use NestedEventLoopListener;
use compositing::compositor_thread::EventLoopWaker;
use compositing::windowing::{AnimationState, MouseWindowEvent};
use compositing::windowing::{WindowEvent, WindowMethods};
use euclid::{Point2D, Size2D, TypedPoint2D, TypedVector2D, TypedRect, ScaleFactor, TypedSize2D};
use euclid::{Point2D, Size2D, TypedPoint2D, TypedVector2D, ScaleFactor, TypedSize2D};
#[cfg(target_os = "windows")]
use gdi32;
use gleam::gl;
@ -43,7 +43,7 @@ use style_traits::DevicePixel;
use style_traits::cursor::Cursor;
#[cfg(target_os = "windows")]
use user32;
use webrender_api::ScrollLocation;
use webrender_api::{DeviceUintRect, DeviceUintSize, ScrollLocation};
#[cfg(target_os = "windows")]
use winapi;
@ -962,24 +962,24 @@ impl WindowMethods for Window {
self.gl.clone()
}
fn framebuffer_size(&self) -> TypedSize2D<u32, DevicePixel> {
fn framebuffer_size(&self) -> DeviceUintSize {
match self.kind {
WindowKind::Window(ref window) => {
let scale_factor = window.hidpi_factor() as u32;
// TODO(ajeffrey): can this fail?
let (width, height) = window.get_inner_size().expect("Failed to get window inner size.");
TypedSize2D::new(width * scale_factor, height * scale_factor)
DeviceUintSize::new(width, height) * scale_factor
}
WindowKind::Headless(ref context) => {
TypedSize2D::new(context.width, context.height)
DeviceUintSize::new(context.width, context.height)
}
}
}
fn window_rect(&self) -> TypedRect<u32, DevicePixel> {
fn window_rect(&self) -> DeviceUintRect {
let size = self.framebuffer_size();
let origin = TypedPoint2D::zero();
TypedRect::new(origin, size)
DeviceUintRect::new(origin, size)
}
fn size(&self) -> TypedSize2D<f32, DeviceIndependentPixel> {