Skip to content

Commit

Permalink
Auto merge of #22035 - pyfisch:line-item, r=emilio
Browse files Browse the repository at this point in the history
Directly build WebRender LineDisplayItem

Remove unused SimpleMatrixDetection.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22035)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 29, 2018
2 parents 1628bd5 + 93abe79 commit d9f5e8a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 58 deletions.
34 changes: 23 additions & 11 deletions components/layout/display_list/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down
42 changes: 3 additions & 39 deletions components/layout/display_list/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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>),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
}
9 changes: 1 addition & 8 deletions components/layout/display_list/webrender_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit d9f5e8a

Please sign in to comment.