Skip to content

Commit

Permalink
Auto merge of #18986 - glennw:update-wr-notifier, r=jdm
Browse files Browse the repository at this point in the history
Update WR (render notifier API changes).

These changes fix #13480.

<!-- 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/18986)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 24, 2017
2 parents 69b9c22 + 1da9dc9 commit 2bcb3b4
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 53 deletions.
59 changes: 29 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 10 additions & 15 deletions components/compositing/compositor.rs
Expand Up @@ -5,7 +5,7 @@
use CompositionPipeline;
use SendableFrameTree;
use compositor_thread::{CompositorProxy, CompositorReceiver};
use compositor_thread::{InitialCompositorState, Msg, RenderListener};
use compositor_thread::{InitialCompositorState, Msg};
use euclid::{TypedPoint2D, TypedVector2D, ScaleFactor};
use gfx_traits::Epoch;
use gleam::gl;
Expand Down Expand Up @@ -129,8 +129,6 @@ pub struct IOCompositor<Window: WindowMethods> {
/// The device pixel ratio for this window.
scale_factor: ScaleFactor<f32, DeviceIndependentPixel, DevicePixel>,

channel_to_self: CompositorProxy,

/// The type of composition to perform
composite_target: CompositeTarget,

Expand Down Expand Up @@ -313,25 +311,29 @@ fn initialize_png(gl: &gl::Gl, width: usize, height: usize) -> RenderTargetInfo
}
}

struct RenderNotifier {
#[derive(Clone)]
pub struct RenderNotifier {
compositor_proxy: CompositorProxy,
}

impl RenderNotifier {
fn new(compositor_proxy: CompositorProxy,
_: Sender<ConstellationMsg>) -> RenderNotifier {
pub fn new(compositor_proxy: CompositorProxy) -> RenderNotifier {
RenderNotifier {
compositor_proxy: compositor_proxy,
}
}
}

impl webrender_api::RenderNotifier for RenderNotifier {
fn new_frame_ready(&mut self) {
fn clone(&self) -> Box<webrender_api::RenderNotifier> {
Box::new(RenderNotifier::new(self.compositor_proxy.clone()))
}

fn new_frame_ready(&self) {
self.compositor_proxy.recomposite(CompositingReason::NewWebRenderFrame);
}

fn new_scroll_frame_ready(&mut self, composite_needed: bool) {
fn new_scroll_frame_ready(&self, composite_needed: bool) {
self.compositor_proxy.send(Msg::NewScrollFrameReady(composite_needed));
}
}
Expand All @@ -357,7 +359,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
window_rect: window_rect,
scale: ScaleFactor::new(1.0),
scale_factor: scale_factor,
channel_to_self: state.sender.clone(),
composition_request: CompositionRequest::NoCompositingNecessary,
touch_handler: TouchHandler::new(),
pending_scroll_zoom_events: Vec::new(),
Expand Down Expand Up @@ -387,12 +388,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
pub fn create(window: Rc<Window>, state: InitialCompositorState) -> IOCompositor<Window> {
let mut compositor = IOCompositor::new(window, state);

let compositor_proxy_for_webrender = compositor.channel_to_self
.clone();
let render_notifier = RenderNotifier::new(compositor_proxy_for_webrender,
compositor.constellation_chan.clone());
compositor.webrender.set_render_notifier(Box::new(render_notifier));

// Set the size of the root layer.
compositor.update_zoom_transform();

Expand Down
8 changes: 2 additions & 6 deletions components/compositing/compositor_thread.rs
Expand Up @@ -107,12 +107,8 @@ impl CompositorReceiver {
}
}

pub trait RenderListener {
fn recomposite(&mut self, reason: CompositingReason);
}

impl RenderListener for CompositorProxy {
fn recomposite(&mut self, reason: CompositingReason) {
impl CompositorProxy {
pub fn recomposite(&self, reason: CompositingReason) {
self.send(Msg::Recomposite(reason));
}
}
Expand Down
1 change: 1 addition & 0 deletions components/compositing/lib.rs
Expand Up @@ -27,6 +27,7 @@ extern crate webrender_api;

pub use compositor_thread::CompositorProxy;
pub use compositor::IOCompositor;
pub use compositor::RenderNotifier;
pub use compositor::ShutdownState;
use euclid::TypedSize2D;
use ipc_channel::ipc::IpcSender;
Expand Down
6 changes: 4 additions & 2 deletions components/servo/lib.rs
Expand Up @@ -71,7 +71,7 @@ use bluetooth::BluetoothThreadFactory;
use bluetooth_traits::BluetoothRequest;
use canvas::gl_context::GLContextFactory;
use canvas::webgl_thread::WebGLThreads;
use compositing::{IOCompositor, ShutdownState};
use compositing::{IOCompositor, ShutdownState, RenderNotifier};
use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver, InitialCompositorState};
use compositing::compositor_thread::{EmbedderMsg, EmbedderProxy, EmbedderReceiver};
use compositing::windowing::WindowEvent;
Expand Down Expand Up @@ -185,7 +185,9 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
let mut debug_flags = webrender::DebugFlags::empty();
debug_flags.set(webrender::DebugFlags::PROFILER_DBG, opts.webrender_stats);

webrender::Renderer::new(window.gl(), webrender::RendererOptions {
let render_notifier = Box::new(RenderNotifier::new(compositor_proxy.clone()));

webrender::Renderer::new(window.gl(), render_notifier, webrender::RendererOptions {
device_pixel_ratio: device_pixel_ratio,
resource_override_path: Some(resource_path),
enable_aa: opts.enable_text_antialiasing,
Expand Down
@@ -0,0 +1,3 @@
[border-left-applies-to-001.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-applies-to-002.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-applies-to-003.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-color-applies-to-001.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-color-applies-to-002.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-color-applies-to-003.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-width-applies-to-001.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-width-applies-to-002.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-left-width-applies-to-003.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-top-applies-to-001.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-top-applies-to-002.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-top-applies-to-003.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-top-color-applies-to-001.htm]
type: reftest
expected: FAIL
@@ -0,0 +1,3 @@
[border-top-color-applies-to-002.htm]
type: reftest
expected: FAIL

0 comments on commit 2bcb3b4

Please sign in to comment.