mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Layerize canvas
Note that this keeps using readback right now, `NativeSurface` painting will be implemented soon. Also see https://github.com/servo/servo/issues/6142
This commit is contained in:
parent
6481058309
commit
3350522306
35 changed files with 769 additions and 500 deletions
|
@ -20,6 +20,7 @@ use layers::platform::surface::{NativeGraphicsMetadata, NativePaintingGraphicsCo
|
|||
use layers::platform::surface::NativeSurface;
|
||||
use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet};
|
||||
use layers;
|
||||
use canvas_traits::CanvasMsg;
|
||||
use msg::compositor_msg::{Epoch, FrameTreeId, LayerId};
|
||||
use msg::compositor_msg::{LayerProperties, PaintListener, ScrollPolicy};
|
||||
use msg::constellation_msg::Msg as ConstellationMsg;
|
||||
|
@ -30,8 +31,9 @@ use rand::{self, Rng};
|
|||
use skia::SkiaGrGLNativeContextRef;
|
||||
use std::borrow::ToOwned;
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::mpsc::{Receiver, Sender, channel};
|
||||
use std::collections::HashMap;
|
||||
use util::geometry::{Au, ZERO_POINT};
|
||||
use util::opts;
|
||||
use util::task::spawn_named_with_send_on_failure;
|
||||
|
@ -69,6 +71,7 @@ pub struct PaintRequest {
|
|||
|
||||
pub enum Msg {
|
||||
PaintInit(Epoch, Arc<StackingContext>),
|
||||
CanvasLayer(LayerId, Arc<Mutex<Sender<CanvasMsg>>>),
|
||||
Paint(Vec<PaintRequest>, FrameTreeId),
|
||||
UnusedBuffer(Vec<Box<LayerBuffer>>),
|
||||
PaintPermissionGranted,
|
||||
|
@ -125,6 +128,9 @@ pub struct PaintTask<C> {
|
|||
/// Tracks the number of buffers that the compositor currently owns. The
|
||||
/// PaintTask waits to exit until all buffers are returned.
|
||||
used_buffer_count: usize,
|
||||
|
||||
/// A map to track the canvas specific layers
|
||||
canvas_map: HashMap<LayerId, Arc<Mutex<Sender<CanvasMsg>>>>,
|
||||
}
|
||||
|
||||
// If we implement this as a function, we get borrowck errors from borrowing
|
||||
|
@ -170,6 +176,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
|||
buffer_map: BufferMap::new(10000000),
|
||||
worker_threads: worker_threads,
|
||||
used_buffer_count: 0,
|
||||
canvas_map: HashMap::new()
|
||||
};
|
||||
|
||||
paint_task.start();
|
||||
|
@ -216,6 +223,11 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static {
|
|||
|
||||
self.initialize_layers();
|
||||
}
|
||||
// Inserts a new canvas renderer to the layer map
|
||||
Msg::CanvasLayer(layer_id, canvas_renderer) => {
|
||||
debug!("Renderer received for canvas with layer {:?}", layer_id);
|
||||
self.canvas_map.insert(layer_id, canvas_renderer);
|
||||
}
|
||||
Msg::Paint(requests, frame_tree_id) => {
|
||||
if !self.paint_permission {
|
||||
debug!("PaintTask: paint ready msg");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue