Skip to content
Permalink
Browse files

Directly build WebRender LineDisplayItem

Remove unused SimpleMatrixDetection.
  • Loading branch information
pyfisch committed Oct 28, 2018
1 parent e5da0eb commit 93abe795c6a9d3e67b0cc9c131451653364b780f
@@ -20,7 +20,7 @@ use display_list::items::{BaseDisplayItem, BLUR_INFLATION_FACTOR, ClipScrollNode
use display_list::items::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
use display_list::items::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
use display_list::items::{DisplayListSection, CommonDisplayItem};
use display_list::items::{IframeDisplayItem, LineDisplayItem, OpaqueNode};
use display_list::items::{IframeDisplayItem, OpaqueNode};
use display_list::items::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
use display_list::items::{StackingContext, StackingContextType, StickyFrameData};
use display_list::items::{TextOrientation, WebRenderImageInfo};
@@ -1573,11 +1573,17 @@ impl FragmentDisplayListBuilding for Fragment {
style.get_cursor(CursorKind::Default),
DisplayListSection::Content,
);
state.add_display_item(DisplayItem::Line(Box::new(LineDisplayItem {
base: base,
color: ColorF::rgb(0, 200, 0),
style: LineStyle::Dashed,
})));
// TODO(gw): Use a better estimate for wavy line thickness.
let wavy_line_thickness = (0.33 * base.bounds.size.height).ceil();
state.add_display_item(DisplayItem::Line(CommonDisplayItem::new(
base,
webrender_api::LineDisplayItem {
orientation: webrender_api::LineOrientation::Horizontal,
wavy_line_thickness,
color: ColorF::rgb(0, 200, 0),
style: LineStyle::Dashed,
},
)));
}

fn build_debug_borders_around_fragment(
@@ -2272,11 +2278,17 @@ impl FragmentDisplayListBuilding for Fragment {
DisplayListSection::Content,
);

state.add_display_item(DisplayItem::Line(Box::new(LineDisplayItem {
base: base,
color: color.to_layout(),
style: LineStyle::Solid,
})));
// TODO(gw): Use a better estimate for wavy line thickness.
let wavy_line_thickness = (0.33 * base.bounds.size.height).ceil();
state.add_display_item(DisplayItem::Line(CommonDisplayItem::new(
base,
webrender_api::LineDisplayItem {
orientation: webrender_api::LineOrientation::Horizontal,
wavy_line_thickness,
color: color.to_layout(),
style: LineStyle::Solid,
},
)));
}

fn unique_id(&self) -> u64 {
@@ -23,10 +23,10 @@ use std::collections::HashMap;
use std::f32;
use std::fmt;
use webrender_api as wr;
use webrender_api::{BorderRadius, ClipMode, ColorF};
use webrender_api::{BorderRadius, ClipMode};
use webrender_api::{ComplexClipRegion, ExternalScrollId, FilterOp};
use webrender_api::{GlyphInstance, GradientStop, ImageKey, LayoutPoint};
use webrender_api::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D, LineStyle};
use webrender_api::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D};
use webrender_api::{MixBlendMode, ScrollSensitivity, Shadow};
use webrender_api::{StickyOffsetBounds, TransformStyle};

@@ -380,7 +380,7 @@ pub enum DisplayItem {
Border(Box<CommonDisplayItem<wr::BorderDisplayItem, Vec<GradientStop>>>),
Gradient(Box<CommonDisplayItem<wr::GradientDisplayItem, Vec<GradientStop>>>),
RadialGradient(Box<CommonDisplayItem<wr::RadialGradientDisplayItem, Vec<GradientStop>>>),
Line(Box<LineDisplayItem>),
Line(Box<CommonDisplayItem<wr::LineDisplayItem>>),
BoxShadow(Box<CommonDisplayItem<wr::BoxShadowDisplayItem>>),
PushTextShadow(Box<PushTextShadowDisplayItem>),
PopAllTextShadows(Box<PopAllTextShadowsDisplayItem>),
@@ -678,18 +678,6 @@ pub struct IframeDisplayItem {
pub iframe: PipelineId,
}

/// Paints a line segment.
#[derive(Clone, Serialize)]
pub struct LineDisplayItem {
pub base: BaseDisplayItem,

/// The line segment color.
pub color: ColorF,

/// The line segment style.
pub style: LineStyle,
}

#[derive(Clone, Serialize)]
pub struct CommonDisplayItem<T, U = ()> {
pub base: BaseDisplayItem,
@@ -865,27 +853,3 @@ impl WebRenderImageInfo {

/// The type of the scroll offset list. This is only populated if WebRender is in use.
pub type ScrollOffsetMap = HashMap<ExternalScrollId, Vector2D<f32>>;

pub trait SimpleMatrixDetection {
fn is_identity_or_simple_translation(&self) -> bool;
}

impl SimpleMatrixDetection for LayoutTransform {
#[inline]
fn is_identity_or_simple_translation(&self) -> bool {
let (_0, _1) = (0.0, 1.0);
self.m11 == _1 &&
self.m12 == _0 &&
self.m13 == _0 &&
self.m14 == _0 &&
self.m21 == _0 &&
self.m22 == _1 &&
self.m23 == _0 &&
self.m24 == _0 &&
self.m31 == _0 &&
self.m32 == _0 &&
self.m33 == _1 &&
self.m34 == _0 &&
self.m44 == _1
}
}
@@ -131,14 +131,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
);
},
DisplayItem::Line(ref item) => {
builder.push_line(
&self.prim_info(),
// TODO(gw): Use a better estimate for wavy line thickness.
(0.33 * item.base.bounds.size.height).ceil(),
webrender_api::LineOrientation::Horizontal,
&item.color,
item.style,
);
builder.push_item(SpecificDisplayItem::Line(item.item), &self.prim_info());
},
DisplayItem::BoxShadow(ref item) => {
builder.push_item(SpecificDisplayItem::BoxShadow(item.item), &self.prim_info());

0 comments on commit 93abe79

Please sign in to comment.
You can’t perform that action at this time.