Skip to content

Commit 2887623

Browse files
author
bors-servo
committed
Auto merge of #10150 - emilio:canvas-cleanup, r=jdm
Canvas cleanup This PR cleans up the layerization infrastructure for canvas, which was unused, and removes unused dependencies. It also takes in account my recent username change to update angle's dependency (offscreen_gl_context requires extra work due to webrender depending on it). r? @jdm <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10150) <!-- Reviewable:end -->
2 parents f1baba9 + 5a6eaf8 commit 2887623

File tree

20 files changed

+22
-131
lines changed

20 files changed

+22
-131
lines changed

components/canvas/canvas_paint_thread.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ use gfx_traits::color;
1515
use ipc_channel::ipc::IpcSharedMemory;
1616
use ipc_channel::ipc::{self, IpcSender};
1717
use ipc_channel::router::ROUTER;
18-
use layers::platform::surface::NativeSurface;
1918
use num::ToPrimitive;
2019
use premultiplytable::PREMULTIPLY_TABLE;
2120
use std::borrow::ToOwned;
2221
use std::mem;
23-
use std::sync::mpsc::{Sender, channel};
22+
use std::sync::mpsc::channel;
2423
use util::opts;
2524
use util::thread::spawn_named;
2625
use util::vec::byte_swap;
@@ -205,13 +204,6 @@ impl<'a> CanvasPaintThread<'a> {
205204
}
206205
}
207206
}
208-
CanvasMsg::FromPaint(message) => {
209-
match message {
210-
FromPaintMsg::SendNativeSurface(chan) => {
211-
painter.send_native_surface(chan)
212-
}
213-
}
214-
}
215207
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D thread"),
216208
}
217209
}
@@ -550,12 +542,6 @@ impl<'a> CanvasPaintThread<'a> {
550542
})
551543
}
552544

553-
fn send_native_surface(&self, _chan: Sender<NativeSurface>) {
554-
// FIXME(mrobinson): We need a handle on the NativeDisplay to create compatible
555-
// NativeSurfaces for the compositor.
556-
unimplemented!()
557-
}
558-
559545
fn image_data(&self,
560546
dest_rect: Rect<i32>,
561547
canvas_size: Size2D<f64>,

components/canvas/webgl_paint_thread.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use canvas_traits::{CanvasCommonMsg, CanvasMsg, CanvasPixelData, CanvasData, CanvasWebGLMsg};
6-
use canvas_traits::{FromLayoutMsg, FromPaintMsg};
5+
use canvas_traits::{CanvasCommonMsg, CanvasMsg, CanvasPixelData, CanvasData, CanvasWebGLMsg, FromLayoutMsg};
76
use euclid::size::Size2D;
87
use gleam::gl;
98
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
109
use ipc_channel::router::ROUTER;
11-
use layers::platform::surface::NativeSurface;
1210
use offscreen_gl_context::{ColorAttachmentType, GLContext, GLContextAttributes, NativeGLContext};
1311
use std::borrow::ToOwned;
14-
use std::sync::mpsc::{Sender, channel};
12+
use std::sync::mpsc::channel;
1513
use util::thread::spawn_named;
1614
use util::vec::byte_swap;
1715
use webrender_traits;
@@ -83,7 +81,7 @@ impl WebGLPaintThread {
8381
CanvasMsg::Common(message) => {
8482
match message {
8583
CanvasCommonMsg::Close => break,
86-
// TODO(ecoal95): handle error nicely
84+
// TODO(emilio): handle error nicely
8785
CanvasCommonMsg::Recreate(size) => painter.recreate(size).unwrap(),
8886
}
8987
},
@@ -93,12 +91,6 @@ impl WebGLPaintThread {
9391
painter.send_data(chan),
9492
}
9593
}
96-
CanvasMsg::FromPaint(message) => {
97-
match message {
98-
FromPaintMsg::SendNativeSurface(chan) =>
99-
painter.send_native_surface(chan),
100-
}
101-
}
10294
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLThread"),
10395
}
10496
}
@@ -147,12 +139,6 @@ impl WebGLPaintThread {
147139
}
148140
}
149141

150-
fn send_native_surface(&self, _: Sender<NativeSurface>) {
151-
// FIXME(ecoal95): We need to make a clone of the surface in order to
152-
// implement this
153-
unimplemented!()
154-
}
155-
156142
#[allow(unsafe_code)]
157143
fn recreate(&mut self, size: Size2D<i32>) -> Result<(), &'static str> {
158144
match self.data {

components/canvas_traits/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ path = "../gfx_traits"
1515
git = "https://github.com/servo/rust-azure"
1616
features = ["plugins"]
1717

18-
[dependencies.layers]
19-
git = "https://github.com/servo/rust-layers"
20-
features = ["plugins"]
21-
2218
[dependencies.offscreen_gl_context]
2319
git = "https://github.com/ecoal95/rust-offscreen-rendering-context"
2420

components/canvas_traits/lib.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extern crate euclid;
1717
extern crate gfx_traits;
1818
extern crate heapsize;
1919
extern crate ipc_channel;
20-
extern crate layers;
2120
extern crate offscreen_gl_context;
2221
extern crate serde;
2322
extern crate util;
@@ -35,11 +34,8 @@ use euclid::rect::Rect;
3534
use euclid::size::Size2D;
3635
use gfx_traits::color;
3736
use ipc_channel::ipc::{IpcSender, IpcSharedMemory};
38-
use layers::platform::surface::NativeSurface;
39-
use serde::{Deserialize, Deserializer, Serialize, Serializer};
4037
use std::default::Default;
4138
use std::str::FromStr;
42-
use std::sync::mpsc::Sender;
4339

4440
pub use webrender_traits::{WebGLFramebufferBindingRequest, WebGLError, WebGLParameter, WebGLResult, WebGLContextId};
4541
pub use webrender_traits::WebGLCommand as CanvasWebGLMsg;
@@ -55,7 +51,6 @@ pub enum CanvasMsg {
5551
Canvas2d(Canvas2dMsg),
5652
Common(CanvasCommonMsg),
5753
FromLayout(FromLayoutMsg),
58-
FromPaint(FromPaintMsg),
5954
WebGL(CanvasWebGLMsg),
6055
}
6156

@@ -82,23 +77,6 @@ pub enum FromLayoutMsg {
8277
SendData(IpcSender<CanvasData>),
8378
}
8479

85-
#[derive(Clone)]
86-
pub enum FromPaintMsg {
87-
SendNativeSurface(Sender<NativeSurface>),
88-
}
89-
90-
impl Serialize for FromPaintMsg {
91-
fn serialize<S>(&self, _: &mut S) -> Result<(), S::Error> where S: Serializer {
92-
panic!("can't serialize a `FromPaintMsg`!")
93-
}
94-
}
95-
96-
impl Deserialize for FromPaintMsg {
97-
fn deserialize<D>(_: &mut D) -> Result<FromPaintMsg, D::Error> where D: Deserializer {
98-
panic!("can't deserialize a `FromPaintMsg`!")
99-
}
100-
}
101-
10280
#[derive(Clone, Deserialize, Serialize)]
10381
pub enum Canvas2dMsg {
10482
Arc(Point2D<f32>, f32, f32, f32, bool),

components/gfx/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ path = "../gfx_traits"
4141
[dependencies.net_traits]
4242
path = "../net_traits"
4343

44-
[dependencies.canvas_traits]
45-
path = "../canvas_traits"
46-
4744
[dependencies.util]
4845
path = "../util"
4946

components/gfx/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ extern crate app_units;
2525
extern crate azure;
2626
#[macro_use]
2727
extern crate bitflags;
28-
extern crate canvas_traits;
2928

3029
// Mac OS-specific library dependencies
3130
#[cfg(target_os = "macos")] extern crate core_foundation;

components/gfx/paint_thread.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use app_units::Au;
88
use azure::AzFloat;
99
use azure::azure_hl::{BackendType, Color, DrawTarget, SurfaceFormat};
10-
use canvas_traits::CanvasMsg;
1110
use display_list::{DisplayItem, DisplayList, DisplayListEntry, DisplayListTraversal};
1211
use display_list::{LayerInfo, StackingContext, StackingContextId, StackingContextType};
1312
use euclid::Matrix4;
@@ -343,7 +342,6 @@ pub enum Msg {
343342
#[derive(Deserialize, Serialize)]
344343
pub enum LayoutToPaintMsg {
345344
PaintInit(Epoch, Arc<DisplayList>),
346-
CanvasLayer(LayerId, IpcSender<CanvasMsg>),
347345
Exit(IpcSender<()>),
348346
}
349347

@@ -379,9 +377,6 @@ pub struct PaintThread<C> {
379377

380378
/// Communication handles to each of the worker threads.
381379
worker_threads: Vec<WorkerThreadProxy>,
382-
383-
/// A map to track the canvas specific layers
384-
canvas_map: HashMap<LayerId, IpcSender<CanvasMsg>>,
385380
}
386381

387382
// If we implement this as a function, we get borrowck errors from borrowing
@@ -431,7 +426,6 @@ impl<C> PaintThread<C> where C: PaintListener + Send + 'static {
431426
paint_permission: false,
432427
current_epoch: None,
433428
worker_threads: worker_threads,
434-
canvas_map: HashMap::new()
435429
};
436430

437431
let reporter_name = format!("paint-reporter-{}", id);
@@ -475,11 +469,6 @@ impl<C> PaintThread<C> where C: PaintListener + Send + 'static {
475469
self.initialize_layers();
476470
}
477471
}
478-
// Inserts a new canvas renderer to the layer map
479-
Msg::FromLayout(LayoutToPaintMsg::CanvasLayer(layer_id, canvas_renderer)) => {
480-
debug!("Renderer received for canvas with layer {:?}", layer_id);
481-
self.canvas_map.insert(layer_id, canvas_renderer);
482-
}
483472
Msg::FromChrome(ChromeToPaintMsg::Paint(requests, frame_tree_id)) => {
484473
if self.paint_permission && self.root_display_list.is_some() {
485474
let mut replies = Vec::new();

components/layout/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ path = "lib.rs"
1212
git = "https://github.com/servo/rust-azure"
1313
features = ["plugins"]
1414

15-
[dependencies.canvas]
16-
path = "../canvas"
17-
1815
[dependencies.canvas_traits]
1916
path = "../canvas_traits"
2017

components/layout/context.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@
88
#![allow(unsafe_code)]
99

1010
use app_units::Au;
11-
use canvas_traits::CanvasMsg;
1211
use euclid::Rect;
1312
use fnv::FnvHasher;
1413
use gfx::display_list::WebRenderImageInfo;
1514
use gfx::font_cache_thread::FontCacheThread;
1615
use gfx::font_context::FontContext;
1716
use gfx_traits::LayerId;
1817
use heapsize::HeapSizeOf;
19-
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
18+
use ipc_channel::ipc::{self, IpcSharedMemory};
2019
use net_traits::image::base::Image;
2120
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
2221
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
2322
use std::cell::{RefCell, RefMut};
2423
use std::collections::HashMap;
2524
use std::hash::BuildHasherDefault;
2625
use std::rc::Rc;
27-
use std::sync::mpsc::Sender;
2826
use std::sync::{Arc, Mutex, RwLock};
2927
use style::context::{LocalStyleContext, StyleContext};
3028
use style::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
@@ -95,9 +93,6 @@ pub struct SharedLayoutContext {
9593
/// The URL.
9694
pub url: Url,
9795

98-
/// A channel to send canvas renderers to paint thread, in order to correctly paint the layers
99-
pub canvas_layers_sender: Mutex<Sender<(LayerId, IpcSender<CanvasMsg>)>>,
100-
10196
/// The visible rects for each layer, as reported to us by the compositor.
10297
pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, BuildHasherDefault<FnvHasher>>>,
10398

components/layout/display_list_builder.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,13 +1197,7 @@ impl FragmentDisplayListBuilding for Fragment {
11971197
let (sender, receiver) = ipc::channel().unwrap();
11981198
ipc_renderer.send(CanvasMsg::FromLayout(
11991199
FromLayoutMsg::SendData(sender))).unwrap();
1200-
let data = receiver.recv().unwrap();
1201-
1202-
// Propagate the layer and the renderer to the paint task.
1203-
state.layout_context.shared.canvas_layers_sender.lock().unwrap().send(
1204-
(layer_id, (*ipc_renderer).clone())).unwrap();
1205-
1206-
data
1200+
receiver.recv().unwrap()
12071201
},
12081202
None => CanvasData::Pixels(CanvasPixelData {
12091203
image_data: IpcSharedMemory::from_byte(0xFFu8, width * height * 4),

0 commit comments

Comments
 (0)