Upgrade to the latest version of WebRender

This commit is contained in:
Martin Robinson 2017-07-06 19:21:22 +02:00 committed by Glenn Watson
parent 4b6e79337e
commit e58e8ab42e
88 changed files with 554 additions and 521 deletions

View file

@ -33,7 +33,8 @@ use style::values::computed::Filter;
use style_traits::cursor::Cursor;
use text::TextRun;
use text::glyph::ByteIndex;
use webrender_traits::{self, ClipId, ColorF, GradientStop, MixBlendMode, ScrollPolicy, TransformStyle, WebGLContextId};
use webrender_api::{self, ClipId, ColorF, GradientStop, LocalClip, MixBlendMode, ScrollPolicy};
use webrender_api::{TransformStyle, WebGLContextId};
pub use style::dom::OpaqueNode;
@ -556,6 +557,12 @@ impl fmt::Debug for StackingContext {
}
}
#[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
pub enum ScrollRootType {
ScrollFrame,
Clip,
}
/// Defines a stacking context.
#[derive(Clone, Debug, HeapSizeOf, Deserialize, Serialize)]
pub struct ScrollRoot {
@ -571,6 +578,9 @@ pub struct ScrollRoot {
/// The rect of the contents that can be scrolled inside of the scroll root.
pub content_rect: Rect<Au>,
/// The type of this ScrollRoot.
pub root_type: ScrollRootType
}
impl ScrollRoot {
@ -610,8 +620,8 @@ pub struct BaseDisplayItem {
/// Metadata attached to this display item.
pub metadata: DisplayItemMetadata,
/// The region to clip to.
pub clip: ClippingRegion,
/// The local clip for this item.
pub local_clip: LocalClip,
/// The section of the display list that this item belongs to.
pub section: DisplayListSection,
@ -627,22 +637,15 @@ impl BaseDisplayItem {
#[inline(always)]
pub fn new(bounds: &Rect<Au>,
metadata: DisplayItemMetadata,
clip: &ClippingRegion,
local_clip: LocalClip,
section: DisplayListSection,
stacking_context_id: StackingContextId,
scroll_root_id: ClipId)
-> BaseDisplayItem {
// Detect useless clipping regions here and optimize them to `ClippingRegion::max()`.
// The painting backend may want to optimize out clipping regions and this makes it easier
// for it to do so.
BaseDisplayItem {
bounds: *bounds,
metadata: metadata,
clip: if clip.does_not_clip_rect(&bounds) {
ClippingRegion::max()
} else {
(*clip).clone()
},
local_clip: local_clip,
section: section,
stacking_context_id: stacking_context_id,
scroll_root_id: scroll_root_id,
@ -657,7 +660,7 @@ impl BaseDisplayItem {
node: OpaqueNode(0),
pointing: None,
},
clip: ClippingRegion::max(),
local_clip: LocalClip::from(max_rect().to_rectf()),
section: DisplayListSection::Content,
stacking_context_id: StackingContextId::root(),
scroll_root_id: pipeline_id.root_scroll_node(),
@ -1023,10 +1026,10 @@ pub struct ImageBorder {
pub fill: bool,
/// How to repeat or stretch horizontal edges (border-image-repeat).
pub repeat_horizontal: webrender_traits::RepeatMode,
pub repeat_horizontal: webrender_api::RepeatMode,
/// How to repeat or stretch vertical edges (border-image-repeat).
pub repeat_vertical: webrender_traits::RepeatMode,
pub repeat_vertical: webrender_api::RepeatMode,
}
/// A border that is made of linear gradient
@ -1273,7 +1276,7 @@ impl DisplayItem {
let point = Point2D::new(point.x - Au::from_f32_px(scroll_offset.x),
point.y - Au::from_f32_px(scroll_offset.y));
if !base_item.clip.might_intersect_point(&point) {
if !base_item.local_clip.clip_rect().contains(&point.to_pointf()) {
// Clipped out.
return None;
}
@ -1356,7 +1359,7 @@ impl fmt::Debug for DisplayItem {
DisplayItem::DefineClip(_) => "".to_owned(),
},
self.bounds(),
self.base().clip
self.base().local_clip
)
}
}
@ -1366,7 +1369,7 @@ pub struct WebRenderImageInfo {
pub width: u32,
pub height: u32,
pub format: PixelFormat,
pub key: Option<webrender_traits::ImageKey>,
pub key: Option<webrender_api::ImageKey>,
}
impl WebRenderImageInfo {
@ -1399,3 +1402,29 @@ impl SimpleMatrixDetection for Transform3D<f32> {
self.m44 == _1
}
}
trait ToPointF {
fn to_pointf(&self) -> webrender_api::LayoutPoint;
}
impl ToPointF for Point2D<Au> {
fn to_pointf(&self) -> webrender_api::LayoutPoint {
webrender_api::LayoutPoint::new(self.x.to_f32_px(), self.y.to_f32_px())
}
}
trait ToRectF {
fn to_rectf(&self) -> webrender_api::LayoutRect;
}
impl ToRectF for Rect<Au> {
fn to_rectf(&self) -> webrender_api::LayoutRect {
let x = self.origin.x.to_f32_px();
let y = self.origin.y.to_f32_px();
let w = self.size.width.to_f32_px();
let h = self.size.height.to_f32_px();
let point = webrender_api::LayoutPoint::new(x, y);
let size = webrender_api::LayoutSize::new(w, h);
webrender_api::LayoutRect::new(point, size)
}
}