Skip to content

Commit 2bcb3b4

Browse files
author
bors-servo
authored
Auto merge of #18986 - glennw:update-wr-notifier, r=jdm
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 -->
2 parents 69b9c22 + 1da9dc9 commit 2bcb3b4

23 files changed

+100
-53
lines changed

Cargo.lock

Lines changed: 29 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/compositing/compositor.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use CompositionPipeline;
66
use SendableFrameTree;
77
use compositor_thread::{CompositorProxy, CompositorReceiver};
8-
use compositor_thread::{InitialCompositorState, Msg, RenderListener};
8+
use compositor_thread::{InitialCompositorState, Msg};
99
use euclid::{TypedPoint2D, TypedVector2D, ScaleFactor};
1010
use gfx_traits::Epoch;
1111
use gleam::gl;
@@ -129,8 +129,6 @@ pub struct IOCompositor<Window: WindowMethods> {
129129
/// The device pixel ratio for this window.
130130
scale_factor: ScaleFactor<f32, DeviceIndependentPixel, DevicePixel>,
131131

132-
channel_to_self: CompositorProxy,
133-
134132
/// The type of composition to perform
135133
composite_target: CompositeTarget,
136134

@@ -313,25 +311,29 @@ fn initialize_png(gl: &gl::Gl, width: usize, height: usize) -> RenderTargetInfo
313311
}
314312
}
315313

316-
struct RenderNotifier {
314+
#[derive(Clone)]
315+
pub struct RenderNotifier {
317316
compositor_proxy: CompositorProxy,
318317
}
319318

320319
impl RenderNotifier {
321-
fn new(compositor_proxy: CompositorProxy,
322-
_: Sender<ConstellationMsg>) -> RenderNotifier {
320+
pub fn new(compositor_proxy: CompositorProxy) -> RenderNotifier {
323321
RenderNotifier {
324322
compositor_proxy: compositor_proxy,
325323
}
326324
}
327325
}
328326

329327
impl webrender_api::RenderNotifier for RenderNotifier {
330-
fn new_frame_ready(&mut self) {
328+
fn clone(&self) -> Box<webrender_api::RenderNotifier> {
329+
Box::new(RenderNotifier::new(self.compositor_proxy.clone()))
330+
}
331+
332+
fn new_frame_ready(&self) {
331333
self.compositor_proxy.recomposite(CompositingReason::NewWebRenderFrame);
332334
}
333335

334-
fn new_scroll_frame_ready(&mut self, composite_needed: bool) {
336+
fn new_scroll_frame_ready(&self, composite_needed: bool) {
335337
self.compositor_proxy.send(Msg::NewScrollFrameReady(composite_needed));
336338
}
337339
}
@@ -357,7 +359,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
357359
window_rect: window_rect,
358360
scale: ScaleFactor::new(1.0),
359361
scale_factor: scale_factor,
360-
channel_to_self: state.sender.clone(),
361362
composition_request: CompositionRequest::NoCompositingNecessary,
362363
touch_handler: TouchHandler::new(),
363364
pending_scroll_zoom_events: Vec::new(),
@@ -387,12 +388,6 @@ impl<Window: WindowMethods> IOCompositor<Window> {
387388
pub fn create(window: Rc<Window>, state: InitialCompositorState) -> IOCompositor<Window> {
388389
let mut compositor = IOCompositor::new(window, state);
389390

390-
let compositor_proxy_for_webrender = compositor.channel_to_self
391-
.clone();
392-
let render_notifier = RenderNotifier::new(compositor_proxy_for_webrender,
393-
compositor.constellation_chan.clone());
394-
compositor.webrender.set_render_notifier(Box::new(render_notifier));
395-
396391
// Set the size of the root layer.
397392
compositor.update_zoom_transform();
398393

components/compositing/compositor_thread.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,8 @@ impl CompositorReceiver {
107107
}
108108
}
109109

110-
pub trait RenderListener {
111-
fn recomposite(&mut self, reason: CompositingReason);
112-
}
113-
114-
impl RenderListener for CompositorProxy {
115-
fn recomposite(&mut self, reason: CompositingReason) {
110+
impl CompositorProxy {
111+
pub fn recomposite(&self, reason: CompositingReason) {
116112
self.send(Msg::Recomposite(reason));
117113
}
118114
}

components/compositing/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern crate webrender_api;
2727

2828
pub use compositor_thread::CompositorProxy;
2929
pub use compositor::IOCompositor;
30+
pub use compositor::RenderNotifier;
3031
pub use compositor::ShutdownState;
3132
use euclid::TypedSize2D;
3233
use ipc_channel::ipc::IpcSender;

components/servo/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ use bluetooth::BluetoothThreadFactory;
7171
use bluetooth_traits::BluetoothRequest;
7272
use canvas::gl_context::GLContextFactory;
7373
use canvas::webgl_thread::WebGLThreads;
74-
use compositing::{IOCompositor, ShutdownState};
74+
use compositing::{IOCompositor, ShutdownState, RenderNotifier};
7575
use compositing::compositor_thread::{self, CompositorProxy, CompositorReceiver, InitialCompositorState};
7676
use compositing::compositor_thread::{EmbedderMsg, EmbedderProxy, EmbedderReceiver};
7777
use compositing::windowing::WindowEvent;
@@ -185,7 +185,9 @@ impl<Window> Servo<Window> where Window: WindowMethods + 'static {
185185
let mut debug_flags = webrender::DebugFlags::empty();
186186
debug_flags.set(webrender::DebugFlags::PROFILER_DBG, opts.webrender_stats);
187187

188-
webrender::Renderer::new(window.gl(), webrender::RendererOptions {
188+
let render_notifier = Box::new(RenderNotifier::new(compositor_proxy.clone()));
189+
190+
webrender::Renderer::new(window.gl(), render_notifier, webrender::RendererOptions {
189191
device_pixel_ratio: device_pixel_ratio,
190192
resource_override_path: Some(resource_path),
191193
enable_aa: opts.enable_text_antialiasing,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[border-left-applies-to-001.htm]
2+
type: reftest
3+
expected: FAIL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[border-left-applies-to-002.htm]
2+
type: reftest
3+
expected: FAIL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[border-left-applies-to-003.htm]
2+
type: reftest
3+
expected: FAIL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[border-left-color-applies-to-001.htm]
2+
type: reftest
3+
expected: FAIL
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[border-left-color-applies-to-002.htm]
2+
type: reftest
3+
expected: FAIL

0 commit comments

Comments
 (0)