canvas: Remove all the canvas layerization infrastructure

It was never complete, and with webrender as a backend the way we render
WebGL contexts has changed a bit.

This should remove quite a bit of overhead.
This commit is contained in:
Emilio Cobos Álvarez 2016-03-23 16:29:19 +01:00
parent ef8d36d208
commit a02daf7144
8 changed files with 6 additions and 90 deletions

View file

@ -15,12 +15,11 @@ use gfx_traits::color;
use ipc_channel::ipc::IpcSharedMemory;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use layers::platform::surface::NativeSurface;
use num::ToPrimitive;
use premultiplytable::PREMULTIPLY_TABLE;
use std::borrow::ToOwned;
use std::mem;
use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::channel;
use util::opts;
use util::thread::spawn_named;
use util::vec::byte_swap;
@ -205,13 +204,6 @@ impl<'a> CanvasPaintThread<'a> {
}
}
}
CanvasMsg::FromPaint(message) => {
match message {
FromPaintMsg::SendNativeSurface(chan) => {
painter.send_native_surface(chan)
}
}
}
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D thread"),
}
}
@ -550,12 +542,6 @@ impl<'a> CanvasPaintThread<'a> {
})
}
fn send_native_surface(&self, _chan: Sender<NativeSurface>) {
// FIXME(mrobinson): We need a handle on the NativeDisplay to create compatible
// NativeSurfaces for the compositor.
unimplemented!()
}
fn image_data(&self,
dest_rect: Rect<i32>,
canvas_size: Size2D<f64>,

View file

@ -2,16 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use canvas_traits::{CanvasCommonMsg, CanvasMsg, CanvasPixelData, CanvasData, CanvasWebGLMsg};
use canvas_traits::{FromLayoutMsg, FromPaintMsg};
use canvas_traits::{CanvasCommonMsg, CanvasMsg, CanvasPixelData, CanvasData, CanvasWebGLMsg, FromLayoutMsg};
use euclid::size::Size2D;
use gleam::gl;
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
use ipc_channel::router::ROUTER;
use layers::platform::surface::NativeSurface;
use offscreen_gl_context::{ColorAttachmentType, GLContext, GLContextAttributes, NativeGLContext};
use std::borrow::ToOwned;
use std::sync::mpsc::{Sender, channel};
use std::sync::mpsc::channel;
use util::thread::spawn_named;
use util::vec::byte_swap;
use webrender_traits;
@ -93,12 +91,6 @@ impl WebGLPaintThread {
painter.send_data(chan),
}
}
CanvasMsg::FromPaint(message) => {
match message {
FromPaintMsg::SendNativeSurface(chan) =>
painter.send_native_surface(chan),
}
}
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLThread"),
}
}
@ -147,12 +139,6 @@ impl WebGLPaintThread {
}
}
fn send_native_surface(&self, _: Sender<NativeSurface>) {
// FIXME(ecoal95): We need to make a clone of the surface in order to
// implement this
unimplemented!()
}
#[allow(unsafe_code)]
fn recreate(&mut self, size: Size2D<i32>) -> Result<(), &'static str> {
match self.data {

View file

@ -55,7 +55,6 @@ pub enum CanvasMsg {
Canvas2d(Canvas2dMsg),
Common(CanvasCommonMsg),
FromLayout(FromLayoutMsg),
FromPaint(FromPaintMsg),
WebGL(CanvasWebGLMsg),
}
@ -82,23 +81,6 @@ pub enum FromLayoutMsg {
SendData(IpcSender<CanvasData>),
}
#[derive(Clone)]
pub enum FromPaintMsg {
SendNativeSurface(Sender<NativeSurface>),
}
impl Serialize for FromPaintMsg {
fn serialize<S>(&self, _: &mut S) -> Result<(), S::Error> where S: Serializer {
panic!("can't serialize a `FromPaintMsg`!")
}
}
impl Deserialize for FromPaintMsg {
fn deserialize<D>(_: &mut D) -> Result<FromPaintMsg, D::Error> where D: Deserializer {
panic!("can't deserialize a `FromPaintMsg`!")
}
}
#[derive(Clone, Deserialize, Serialize)]
pub enum Canvas2dMsg {
Arc(Point2D<f32>, f32, f32, f32, bool),

View file

@ -7,7 +7,6 @@
use app_units::Au;
use azure::AzFloat;
use azure::azure_hl::{BackendType, Color, DrawTarget, SurfaceFormat};
use canvas_traits::CanvasMsg;
use display_list::{DisplayItem, DisplayList, DisplayListEntry, DisplayListTraversal};
use display_list::{LayerInfo, StackingContext, StackingContextId, StackingContextType};
use euclid::Matrix4;
@ -343,7 +342,6 @@ pub enum Msg {
#[derive(Deserialize, Serialize)]
pub enum LayoutToPaintMsg {
PaintInit(Epoch, Arc<DisplayList>),
CanvasLayer(LayerId, IpcSender<CanvasMsg>),
Exit(IpcSender<()>),
}
@ -379,9 +377,6 @@ pub struct PaintThread<C> {
/// Communication handles to each of the worker threads.
worker_threads: Vec<WorkerThreadProxy>,
/// A map to track the canvas specific layers
canvas_map: HashMap<LayerId, IpcSender<CanvasMsg>>,
}
// 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 {
paint_permission: false,
current_epoch: None,
worker_threads: worker_threads,
canvas_map: HashMap::new()
};
let reporter_name = format!("paint-reporter-{}", id);
@ -475,11 +469,6 @@ impl<C> PaintThread<C> where C: PaintListener + Send + 'static {
self.initialize_layers();
}
}
// Inserts a new canvas renderer to the layer map
Msg::FromLayout(LayoutToPaintMsg::CanvasLayer(layer_id, canvas_renderer)) => {
debug!("Renderer received for canvas with layer {:?}", layer_id);
self.canvas_map.insert(layer_id, canvas_renderer);
}
Msg::FromChrome(ChromeToPaintMsg::Paint(requests, frame_tree_id)) => {
if self.paint_permission && self.root_display_list.is_some() {
let mut replies = Vec::new();

View file

@ -8,7 +8,6 @@
#![allow(unsafe_code)]
use app_units::Au;
use canvas_traits::CanvasMsg;
use euclid::Rect;
use fnv::FnvHasher;
use gfx::display_list::WebRenderImageInfo;
@ -16,7 +15,7 @@ use gfx::font_cache_thread::FontCacheThread;
use gfx::font_context::FontContext;
use gfx_traits::LayerId;
use heapsize::HeapSizeOf;
use ipc_channel::ipc::{self, IpcSender, IpcSharedMemory};
use ipc_channel::ipc::{self, IpcSharedMemory};
use net_traits::image::base::Image;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread, ImageResponse, ImageState};
use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
@ -24,7 +23,6 @@ use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::rc::Rc;
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex, RwLock};
use style::context::{LocalStyleContext, StyleContext};
use style::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
@ -95,9 +93,6 @@ pub struct SharedLayoutContext {
/// The URL.
pub url: Url,
/// A channel to send canvas renderers to paint thread, in order to correctly paint the layers
pub canvas_layers_sender: Mutex<Sender<(LayerId, IpcSender<CanvasMsg>)>>,
/// The visible rects for each layer, as reported to us by the compositor.
pub visible_rects: Arc<HashMap<LayerId, Rect<Au>, BuildHasherDefault<FnvHasher>>>,

View file

@ -1197,13 +1197,7 @@ impl FragmentDisplayListBuilding for Fragment {
let (sender, receiver) = ipc::channel().unwrap();
ipc_renderer.send(CanvasMsg::FromLayout(
FromLayoutMsg::SendData(sender))).unwrap();
let data = receiver.recv().unwrap();
// Propagate the layer and the renderer to the paint task.
state.layout_context.shared.canvas_layers_sender.lock().unwrap().send(
(layer_id, (*ipc_renderer).clone())).unwrap();
data
receiver.recv().unwrap()
},
None => CanvasData::Pixels(CanvasPixelData {
image_data: IpcSharedMemory::from_byte(0xFFu8, width * height * 4),

View file

@ -10,7 +10,6 @@
use animation;
use app_units::Au;
use azure::azure::AzColor;
use canvas_traits::CanvasMsg;
use construct::ConstructionResult;
use context::{LayoutContext, SharedLayoutContext, heap_size_of_local_context};
use display_list_builder::ToGfxColor;
@ -186,11 +185,6 @@ pub struct LayoutThread {
/// Is this the first reflow in this LayoutThread?
first_reflow: bool,
/// To receive a canvas renderer associated to a layer, this message is propagated
/// to the paint chan
canvas_layers_receiver: Receiver<(LayerId, IpcSender<CanvasMsg>)>,
canvas_layers_sender: Sender<(LayerId, IpcSender<CanvasMsg>)>,
/// The workers that we use for parallel operation.
parallel_traversal: Option<WorkQueue<SharedLayoutContext, WorkQueueData>>,
@ -406,7 +400,6 @@ impl LayoutThread {
// Create the channel on which new animations can be sent.
let (new_animations_sender, new_animations_receiver) = channel();
let (canvas_layers_sender, canvas_layers_receiver) = channel();
// Proxy IPC messages from the pipeline to the layout thread.
let pipeline_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(pipeline_port);
@ -449,8 +442,6 @@ impl LayoutThread {
image_cache_sender: ImageCacheChan(ipc_image_cache_sender),
font_cache_receiver: font_cache_receiver,
font_cache_sender: ipc_font_cache_sender,
canvas_layers_receiver: canvas_layers_receiver,
canvas_layers_sender: canvas_layers_sender,
parallel_traversal: parallel_traversal,
generation: 0,
new_animations_sender: new_animations_sender,
@ -521,7 +512,6 @@ impl LayoutThread {
image_cache_thread: self.image_cache_thread.clone(),
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
canvas_layers_sender: Mutex::new(self.canvas_layers_sender.clone()),
url: (*url).clone(),
visible_rects: self.visible_rects.clone(),
webrender_image_cache: self.webrender_image_cache.clone(),
@ -1148,12 +1138,6 @@ impl LayoutThread {
self.root_flow = self.try_get_layout_root(node);
}
// Send new canvas renderers to the paint thread
while let Ok((layer_id, renderer)) = self.canvas_layers_receiver.try_recv() {
// Just send if there's an actual renderer
self.paint_chan.send(LayoutToPaintMsg::CanvasLayer(layer_id, renderer)).unwrap();
}
// Perform post-style recalculation layout passes.
self.perform_post_style_recalc_layout_passes(&data.reflow_info,
&mut rw_data,

View file

@ -15,7 +15,7 @@ use flow::{self, Flow, CAN_BE_FRAGMENTED};
use gfx::display_list::OpaqueNode;
use incremental::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, RestyleDamage};
use std::mem;
use style::context::{StyleContext, ReflowGoal};
use style::context::StyleContext;
use style::matching::MatchMethods;
use style::traversal::{DomTraversalContext, STYLE_BLOOM};
use style::traversal::{put_thread_local_bloom_filter, recalc_style_at};