mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Canvas rendering for layout 2020
Update test expectations with layout 2020 canvas support
This commit is contained in:
parent
0bd794aed7
commit
f0e30f5b0c
26 changed files with 116 additions and 61 deletions
|
@ -5,7 +5,7 @@
|
|||
use crate::context::LayoutContext;
|
||||
use crate::element_data::{LayoutBox, LayoutDataForElement};
|
||||
use crate::geom::PhysicalSize;
|
||||
use crate::replaced::ReplacedContent;
|
||||
use crate::replaced::{CanvasInfo, CanvasSource, ReplacedContent};
|
||||
use crate::style_ext::{Display, DisplayGeneratingBox, DisplayInside, DisplayOutside};
|
||||
use crate::wrapper::GetRawData;
|
||||
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
|
||||
|
@ -14,9 +14,10 @@ use net_traits::image::base::Image as NetImage;
|
|||
use script_layout_interface::wrapper_traits::{
|
||||
LayoutNode, ThreadSafeLayoutElement, ThreadSafeLayoutNode,
|
||||
};
|
||||
use script_layout_interface::HTMLCanvasDataSource;
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use std::marker::PhantomData as marker;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use style::dom::{OpaqueNode, TNode};
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_parser::PseudoElement;
|
||||
|
@ -354,6 +355,7 @@ pub(crate) trait NodeExt<'dom>: 'dom + Copy + LayoutNode + Send + Sync {
|
|||
/// Returns the image if it’s loaded, and its size in image pixels
|
||||
/// adjusted for `image_density`.
|
||||
fn as_image(self) -> Option<(Option<Arc<NetImage>>, PhysicalSize<f64>)>;
|
||||
fn as_canvas(self) -> Option<(CanvasInfo, PhysicalSize<f64>)>;
|
||||
fn first_child(self) -> Option<Self>;
|
||||
fn next_sibling(self) -> Option<Self>;
|
||||
fn parent_node(self) -> Option<Self>;
|
||||
|
@ -399,6 +401,24 @@ where
|
|||
Some((resource, PhysicalSize::new(width, height)))
|
||||
}
|
||||
|
||||
fn as_canvas(self) -> Option<(CanvasInfo, PhysicalSize<f64>)> {
|
||||
let node = self.to_threadsafe();
|
||||
let canvas_data = node.canvas_data()?;
|
||||
let source = match canvas_data.source {
|
||||
HTMLCanvasDataSource::WebGL(texture_id) => CanvasSource::WebGL(texture_id),
|
||||
HTMLCanvasDataSource::Image(ipc_sender) => {
|
||||
CanvasSource::Image(ipc_sender.map(|renderer| Arc::new(Mutex::new(renderer))))
|
||||
},
|
||||
};
|
||||
Some((
|
||||
CanvasInfo {
|
||||
source,
|
||||
canvas_id: canvas_data.canvas_id,
|
||||
},
|
||||
PhysicalSize::new(canvas_data.width.into(), canvas_data.height.into()),
|
||||
))
|
||||
}
|
||||
|
||||
fn first_child(self) -> Option<Self> {
|
||||
TNode::first_child(&self)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue