Skip to content

Commit

Permalink
Update WR (gradients, batching, text run, border changes).
Browse files Browse the repository at this point in the history
- Tidy and optimize the batching code.
- Support tiling / repeat for linear and radial gradients.
- Fix some edge cases of subpixel text AA.
- Add clip mask support to border shaders.
- Optimization to text run creation on CPU.
- Handle more box-shadow clipping cases.
- Fix a panic that could occur when window size is 0.
- Clip / scroll API improvements.
  • Loading branch information
gw3583 committed Apr 12, 2017
1 parent 065f500 commit 9e874f5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 38 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions components/compositing/compositor.rs
Expand Up @@ -39,7 +39,7 @@ use style_traits::viewport::ViewportConstraints;
use time::{precise_time_ns, precise_time_s};
use touch::{TouchHandler, TouchAction};
use webrender;
use webrender_traits::{self, LayoutPoint, ScrollEventPhase, ScrollLayerId, ScrollLocation};
use webrender_traits::{self, LayoutPoint, ScrollEventPhase, ClipId, ScrollLocation};
use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};

#[derive(Debug, PartialEq)]
Expand Down Expand Up @@ -797,8 +797,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
pipeline_id: PipelineId,
scroll_root_id: ScrollRootId,
point: Point2D<f32>) {
let id = ScrollLayerId::new(scroll_root_id.0 as u64, pipeline_id.to_webrender());
self.webrender_api.scroll_layer_with_id(LayoutPoint::from_untyped(&point), id);
let id = ClipId::new(scroll_root_id.0 as u64, pipeline_id.to_webrender());
self.webrender_api.scroll_node_with_id(LayoutPoint::from_untyped(&point), id);
}

fn handle_window_message(&mut self, event: WindowEvent) {
Expand Down Expand Up @@ -1389,7 +1389,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {

fn send_viewport_rects(&self) {
let mut stacking_context_scroll_states_per_pipeline = HashMap::new();
for scroll_layer_state in self.webrender_api.get_scroll_layer_state() {
for scroll_layer_state in self.webrender_api.get_scroll_node_state() {
let external_id = match scroll_layer_state.id.external_id() {
Some(id) => id,
None => continue,
Expand Down
4 changes: 2 additions & 2 deletions components/layout/display_list_builder.rs
Expand Up @@ -985,8 +985,8 @@ impl FragmentDisplayListBuilding for Fragment {
})
}

let center = Point2D::new(absolute_bounds.origin.x + absolute_bounds.size.width / 2,
absolute_bounds.origin.y + absolute_bounds.size.height / 2);
let center = Point2D::new(absolute_bounds.size.width / 2,
absolute_bounds.size.height / 2);

Some(display_list::Gradient {
start_point: center - delta,
Expand Down
18 changes: 11 additions & 7 deletions components/layout/webrender_helpers.rs
Expand Up @@ -16,7 +16,7 @@ use msg::constellation_msg::PipelineId;
use style::computed_values::{image_rendering, mix_blend_mode};
use style::computed_values::filter::{self, Filter};
use style::values::computed::BorderStyle;
use webrender_traits::{self, DisplayListBuilder, ExtendMode, LayoutTransform, ScrollLayerId};
use webrender_traits::{self, DisplayListBuilder, ExtendMode, LayoutTransform, ClipId};

pub trait WebRenderDisplayListConverter {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
Expand Down Expand Up @@ -374,7 +374,11 @@ impl WebRenderDisplayItemConverter for DisplayItem {
end_point,
item.gradient.stops.clone(),
ExtendMode::Clamp);
builder.push_gradient(rect, clip, gradient);
builder.push_gradient(rect,
clip,
gradient,
rect.size,
webrender_traits::LayoutSize::zero());
}
DisplayItem::Line(..) => {
println!("TODO DisplayItem::Line");
Expand Down Expand Up @@ -421,7 +425,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
}
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
DisplayItem::PushScrollRoot(ref item) => {
let our_id = ScrollLayerId::new(item.scroll_root.id.0 as u64, builder.pipeline_id);
let our_id = ClipId::new(item.scroll_root.id.0 as u64, builder.pipeline_id);
let clip = item.scroll_root.clip.to_clip_region(builder);
let content_rect = item.scroll_root.content_rect.to_rectf();
let webrender_id = builder.define_clip(content_rect, clip, Some(our_id));
Expand All @@ -432,15 +436,15 @@ impl WebRenderDisplayItemConverter for DisplayItem {
}
}
trait WebRenderScrollRootIdConverter {
fn convert_to_webrender(&self, pipeline_id: webrender_traits::PipelineId) -> ScrollLayerId;
fn convert_to_webrender(&self, pipeline_id: webrender_traits::PipelineId) -> ClipId;
}

impl WebRenderScrollRootIdConverter for ScrollRootId {
fn convert_to_webrender(&self, pipeline_id: webrender_traits::PipelineId) -> ScrollLayerId {
fn convert_to_webrender(&self, pipeline_id: webrender_traits::PipelineId) -> ClipId {
if *self == ScrollRootId::root() {
ScrollLayerId::root_scroll_layer(pipeline_id)
ClipId::root_scroll_node(pipeline_id)
} else {
ScrollLayerId::new(self.0 as u64, pipeline_id)
ClipId::new(self.0 as u64, pipeline_id)
}
}
}

0 comments on commit 9e874f5

Please sign in to comment.