Auto merge of #16360 - glennw:update-wr-borders, r=jdm

Update WR (gradients, batching, text run, border changes).

- 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.

<!-- 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/16360)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-12 12:03:10 -05:00 committed by GitHub
commit 43bd0cae0d
4 changed files with 42 additions and 38 deletions

50
Cargo.lock generated
View file

@ -297,7 +297,7 @@ dependencies = [
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"offscreen_gl_context 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)", "offscreen_gl_context 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)",
"servo_config 0.0.1", "servo_config 0.0.1",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -311,7 +311,7 @@ dependencies = [
"ipc-channel 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -432,8 +432,8 @@ dependencies = [
"servo_url 0.0.1", "servo_url 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender 0.30.0 (git+https://github.com/servo/webrender)", "webrender 0.31.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -468,7 +468,7 @@ dependencies = [
"servo_remutex 0.0.1", "servo_remutex 0.0.1",
"servo_url 0.0.1", "servo_url 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
] ]
@ -715,7 +715,7 @@ dependencies = [
"servo_geometry 0.0.1", "servo_geometry 0.0.1",
"servo_url 0.0.1", "servo_url 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1001,7 +1001,7 @@ dependencies = [
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"truetype 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)", "truetype 0.26.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "xi-unicode 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1080,7 +1080,7 @@ dependencies = [
"servo_url 0.0.1", "servo_url 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "x11 2.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -1398,7 +1398,7 @@ dependencies = [
"style_traits 0.0.1", "style_traits 0.0.1",
"unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-bidi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-script 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1438,7 +1438,7 @@ dependencies = [
"servo_geometry 0.0.1", "servo_geometry 0.0.1",
"servo_url 0.0.1", "servo_url 0.0.1",
"style 0.0.1", "style 0.0.1",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1452,7 +1452,7 @@ dependencies = [
"profile_traits 0.0.1", "profile_traits 0.0.1",
"script_traits 0.0.1", "script_traits 0.0.1",
"servo_url 0.0.1", "servo_url 0.0.1",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1529,8 +1529,8 @@ dependencies = [
"style 0.0.1", "style 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"webdriver_server 0.0.1", "webdriver_server 0.0.1",
"webrender 0.30.0 (git+https://github.com/servo/webrender)", "webrender 0.31.0 (git+https://github.com/servo/webrender)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"webvr 0.0.1", "webvr 0.0.1",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
] ]
@ -1679,7 +1679,7 @@ dependencies = [
"heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 0.9.11 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1723,7 +1723,7 @@ dependencies = [
"unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicase 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -1782,7 +1782,7 @@ dependencies = [
"servo_url 0.0.1", "servo_url 0.0.1",
"url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
@ -2308,7 +2308,7 @@ dependencies = [
"unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"webvr 0.0.1", "webvr 0.0.1",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
"xml5ever 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "xml5ever 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3170,8 +3170,8 @@ dependencies = [
[[package]] [[package]]
name = "webrender" name = "webrender"
version = "0.30.0" version = "0.31.0"
source = "git+https://github.com/servo/webrender#a260d8e378b1e67b87679125d00b477c70afbd74" source = "git+https://github.com/servo/webrender#2625654b435ebba0815379dc6fba42415e3abc2b"
dependencies = [ dependencies = [
"app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 1.0.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 1.0.0-alpha6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3193,13 +3193,13 @@ dependencies = [
"thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "threadpool 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
] ]
[[package]] [[package]]
name = "webrender_traits" name = "webrender_traits"
version = "0.31.0" version = "0.32.0"
source = "git+https://github.com/servo/webrender#a260d8e378b1e67b87679125d00b477c70afbd74" source = "git+https://github.com/servo/webrender#2625654b435ebba0815379dc6fba42415e3abc2b"
dependencies = [ dependencies = [
"app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "app_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3223,7 +3223,7 @@ dependencies = [
"msg 0.0.1", "msg 0.0.1",
"script_traits 0.0.1", "script_traits 0.0.1",
"servo_config 0.0.1", "servo_config 0.0.1",
"webrender_traits 0.31.0 (git+https://github.com/servo/webrender)", "webrender_traits 0.32.0 (git+https://github.com/servo/webrender)",
"webvr_traits 0.0.1", "webvr_traits 0.0.1",
] ]
@ -3565,8 +3565,8 @@ dependencies = [
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" "checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
"checksum webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d548aabf87411b1b4ba91fd07eacd8b238135c7131a452b8a9f6386209167e18" "checksum webdriver 0.22.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d548aabf87411b1b4ba91fd07eacd8b238135c7131a452b8a9f6386209167e18"
"checksum webrender 0.30.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum webrender 0.31.0 (git+https://github.com/servo/webrender)" = "<none>"
"checksum webrender_traits 0.31.0 (git+https://github.com/servo/webrender)" = "<none>" "checksum webrender_traits 0.32.0 (git+https://github.com/servo/webrender)" = "<none>"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum ws 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04614a58714f3fd4a8b1da4bcae9f031c532d35988c3d39627619248113f8be8" "checksum ws 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "04614a58714f3fd4a8b1da4bcae9f031c532d35988c3d39627619248113f8be8"

View file

@ -39,7 +39,7 @@ use style_traits::viewport::ViewportConstraints;
use time::{precise_time_ns, precise_time_s}; use time::{precise_time_ns, precise_time_s};
use touch::{TouchHandler, TouchAction}; use touch::{TouchHandler, TouchAction};
use webrender; 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}; use windowing::{self, MouseWindowEvent, WindowEvent, WindowMethods, WindowNavigateMsg};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
@ -797,8 +797,8 @@ impl<Window: WindowMethods> IOCompositor<Window> {
pipeline_id: PipelineId, pipeline_id: PipelineId,
scroll_root_id: ScrollRootId, scroll_root_id: ScrollRootId,
point: Point2D<f32>) { point: Point2D<f32>) {
let id = ScrollLayerId::new(scroll_root_id.0 as u64, pipeline_id.to_webrender()); let id = ClipId::new(scroll_root_id.0 as u64, pipeline_id.to_webrender());
self.webrender_api.scroll_layer_with_id(LayoutPoint::from_untyped(&point), id); self.webrender_api.scroll_node_with_id(LayoutPoint::from_untyped(&point), id);
} }
fn handle_window_message(&mut self, event: WindowEvent) { fn handle_window_message(&mut self, event: WindowEvent) {
@ -1389,7 +1389,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn send_viewport_rects(&self) { fn send_viewport_rects(&self) {
let mut stacking_context_scroll_states_per_pipeline = HashMap::new(); 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() { let external_id = match scroll_layer_state.id.external_id() {
Some(id) => id, Some(id) => id,
None => continue, None => continue,

View file

@ -985,8 +985,8 @@ impl FragmentDisplayListBuilding for Fragment {
}) })
} }
let center = Point2D::new(absolute_bounds.origin.x + absolute_bounds.size.width / 2, let center = Point2D::new(absolute_bounds.size.width / 2,
absolute_bounds.origin.y + absolute_bounds.size.height / 2); absolute_bounds.size.height / 2);
Some(display_list::Gradient { Some(display_list::Gradient {
start_point: center - delta, start_point: center - delta,

View file

@ -16,7 +16,7 @@ use msg::constellation_msg::PipelineId;
use style::computed_values::{image_rendering, mix_blend_mode}; use style::computed_values::{image_rendering, mix_blend_mode};
use style::computed_values::filter::{self, Filter}; use style::computed_values::filter::{self, Filter};
use style::values::computed::BorderStyle; use style::values::computed::BorderStyle;
use webrender_traits::{self, DisplayListBuilder, ExtendMode, LayoutTransform, ScrollLayerId}; use webrender_traits::{self, DisplayListBuilder, ExtendMode, LayoutTransform, ClipId};
pub trait WebRenderDisplayListConverter { pub trait WebRenderDisplayListConverter {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder; fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
@ -374,7 +374,11 @@ impl WebRenderDisplayItemConverter for DisplayItem {
end_point, end_point,
item.gradient.stops.clone(), item.gradient.stops.clone(),
ExtendMode::Clamp); ExtendMode::Clamp);
builder.push_gradient(rect, clip, gradient); builder.push_gradient(rect,
clip,
gradient,
rect.size,
webrender_traits::LayoutSize::zero());
} }
DisplayItem::Line(..) => { DisplayItem::Line(..) => {
println!("TODO DisplayItem::Line"); println!("TODO DisplayItem::Line");
@ -421,7 +425,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
} }
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(), DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
DisplayItem::PushScrollRoot(ref item) => { 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 clip = item.scroll_root.clip.to_clip_region(builder);
let content_rect = item.scroll_root.content_rect.to_rectf(); let content_rect = item.scroll_root.content_rect.to_rectf();
let webrender_id = builder.define_clip(content_rect, clip, Some(our_id)); let webrender_id = builder.define_clip(content_rect, clip, Some(our_id));
@ -432,15 +436,15 @@ impl WebRenderDisplayItemConverter for DisplayItem {
} }
} }
trait WebRenderScrollRootIdConverter { 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 { 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() { if *self == ScrollRootId::root() {
ScrollLayerId::root_scroll_layer(pipeline_id) ClipId::root_scroll_node(pipeline_id)
} else { } else {
ScrollLayerId::new(self.0 as u64, pipeline_id) ClipId::new(self.0 as u64, pipeline_id)
} }
} }
} }