Bug 1361751 - Update webrender to 964df2f. r=jrmuizel

This includes the Cargo.lock file changes and regenerated bindings.
This commit is contained in:
Kartikaya Gupta 2017-05-10 10:28:39 -04:00
Родитель 27c2836b77
Коммит 7818effada
22 изменённых файлов: 835 добавлений и 700 удалений

Просмотреть файл

@ -79,4 +79,4 @@ to make sure that mozjs_sys also has its Cargo.lock file updated if needed, henc
the need to run the cargo update command in js/src as well. Hopefully this will
be resolved soon.
Latest Commit: 8516d6c04235e684d9bf9c783ba4fc99dab3bf02
Latest Commit: 964df2fa00f330daf4f233669e37133f93113792

Просмотреть файл

@ -12,7 +12,7 @@ Clips are defined using the ClipRegion in both cases.
```rust
pub struct ClipRegion {
pub main: LayoutRect,
pub complex: ItemRange,
pub complex: ItemRange<ComplexClip>,
pub image_mask: Option<ImageMask>,
}
```

Просмотреть файл

@ -17,10 +17,10 @@ use std::env;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
use webrender_traits::{ColorF, Epoch, GlyphInstance};
use webrender_traits::{ClipRegionToken, ColorF, DisplayListBuilder, Epoch, GlyphInstance};
use webrender_traits::{DeviceIntPoint, DeviceUintSize, LayoutPoint, LayoutRect, LayoutSize};
use webrender_traits::{ImageData, ImageDescriptor, ImageFormat};
use webrender_traits::{PipelineId, TransformStyle, BoxShadowClipMode};
use webrender_traits::{PipelineId, RenderApi, TransformStyle, BoxShadowClipMode};
#[derive(Debug)]
enum Gesture {
@ -191,6 +191,26 @@ impl webrender_traits::RenderNotifier for Notifier {
}
}
fn push_sub_clip(api: &RenderApi, builder: &mut DisplayListBuilder, bounds: &LayoutRect)
-> ClipRegionToken {
let mask_image = api.generate_image_key();
api.add_image(mask_image,
ImageDescriptor::new(2, 2, ImageFormat::A8, true),
ImageData::new(vec![0, 80, 180, 255]),
None);
let mask = webrender_traits::ImageMask {
image: mask_image,
rect: LayoutRect::new(LayoutPoint::new(75.0, 75.0), LayoutSize::new(100.0, 100.0)),
repeat: false,
};
let complex = webrender_traits::ComplexClipRegion::new(
LayoutRect::new(LayoutPoint::new(50.0, 50.0), LayoutSize::new(100.0, 100.0)),
webrender_traits::BorderRadius::uniform(20.0));
builder.push_clip_region(bounds, vec![complex], Some(mask))
}
fn main() {
let args: Vec<String> = env::args().collect();
let res_path = if args.len() > 1 {
@ -252,31 +272,15 @@ fn main() {
None,
webrender_traits::MixBlendMode::Normal,
Vec::new());
let sub_clip = {
let mask_image = api.generate_image_key();
api.add_image(
mask_image,
ImageDescriptor::new(2, 2, ImageFormat::A8, true),
ImageData::new(vec![0, 80, 180, 255]),
None,
);
let mask = webrender_traits::ImageMask {
image: mask_image,
rect: LayoutRect::new(LayoutPoint::new(75.0, 75.0), LayoutSize::new(100.0, 100.0)),
repeat: false,
};
let complex = webrender_traits::ComplexClipRegion::new(
LayoutRect::new(LayoutPoint::new(50.0, 50.0), LayoutSize::new(100.0, 100.0)),
webrender_traits::BorderRadius::uniform(20.0));
builder.new_clip_region(&bounds, vec![complex], Some(mask))
};
let clip = push_sub_clip(&api, &mut builder, &bounds);
builder.push_rect(LayoutRect::new(LayoutPoint::new(100.0, 100.0), LayoutSize::new(100.0, 100.0)),
sub_clip,
clip,
ColorF::new(0.0, 1.0, 0.0, 1.0));
let clip = push_sub_clip(&api, &mut builder, &bounds);
builder.push_rect(LayoutRect::new(LayoutPoint::new(250.0, 100.0), LayoutSize::new(100.0, 100.0)),
sub_clip,
clip,
ColorF::new(0.0, 1.0, 0.0, 1.0));
let border_side = webrender_traits::BorderSide {
color: ColorF::new(0.0, 0.0, 1.0, 1.0),
@ -295,8 +299,10 @@ fn main() {
left: border_side,
radius: webrender_traits::BorderRadius::uniform(20.0),
});
let clip = push_sub_clip(&api, &mut builder, &bounds);
builder.push_border(LayoutRect::new(LayoutPoint::new(100.0, 100.0), LayoutSize::new(100.0, 100.0)),
sub_clip,
clip,
border_widths,
border_details);
@ -359,8 +365,9 @@ fn main() {
},
];
let clip = builder.push_clip_region(&bounds, Vec::new(), None);
builder.push_text(text_bounds,
webrender_traits::ClipRegion::simple(&bounds),
clip,
&glyphs,
font_key,
ColorF::new(1.0, 1.0, 0.0, 1.0),
@ -379,7 +386,7 @@ fn main() {
let spread_radius = 0.0;
let simple_border_radius = 8.0;
let box_shadow_type = BoxShadowClipMode::Inset;
let full_screen_clip = builder.new_clip_region(&bounds, Vec::new(), None);
let full_screen_clip = builder.push_clip_region(&bounds, Vec::new(), None);
builder.push_box_shadow(rect,
full_screen_clip,

Просмотреть файл

@ -12,7 +12,7 @@ extern crate webrender_traits;
use gleam::gl;
use std::collections::HashMap;
use webrender_traits::{BlobImageData, BlobImageDescriptor, BlobImageError, BlobImageRenderer, BlobImageRequest};
use webrender_traits::{BlobImageResult, ImageStore, ClipRegion, ColorF, ColorU, Epoch};
use webrender_traits::{BlobImageResult, ImageStore, ColorF, ColorU, Epoch};
use webrender_traits::{DeviceUintSize, DeviceUintRect, LayoutPoint, LayoutRect, LayoutSize};
use webrender_traits::{ImageData, ImageDescriptor, ImageFormat, ImageRendering, ImageKey, TileSize};
use webrender_traits::{PipelineId, RasterizedBlobImage, TransformStyle};
@ -204,18 +204,21 @@ fn main() {
None,
webrender_traits::MixBlendMode::Normal,
Vec::new());
let clip = builder.push_clip_region(&bounds, vec![], None);
builder.push_image(
LayoutRect::new(LayoutPoint::new(30.0, 30.0), LayoutSize::new(500.0, 500.0)),
ClipRegion::simple(&bounds),
clip,
LayoutSize::new(500.0, 500.0),
LayoutSize::new(0.0, 0.0),
ImageRendering::Auto,
blob_img1,
);
let clip = builder.push_clip_region(&bounds, vec![], None);
builder.push_image(
LayoutRect::new(LayoutPoint::new(600.0, 60.0), LayoutSize::new(200.0, 200.0)),
ClipRegion::simple(&bounds),
clip,
LayoutSize::new(200.0, 200.0),
LayoutSize::new(0.0, 0.0),
ImageRendering::Auto,

Просмотреть файл

@ -10,7 +10,7 @@ extern crate webrender_traits;
use gleam::gl;
use std::env;
use std::path::PathBuf;
use webrender_traits::{ClipId, ClipRegion, ColorF, DeviceUintSize, Epoch, LayoutPoint, LayoutRect};
use webrender_traits::{ClipId, ColorF, DeviceUintSize, Epoch, LayoutPoint, LayoutRect};
use webrender_traits::{LayoutSize, PipelineId, ScrollEventPhase, ScrollLocation, TransformStyle};
use webrender_traits::WorldPoint;
@ -123,47 +123,55 @@ fn main() {
webrender_traits::MixBlendMode::Normal,
Vec::new());
// set the scrolling clip
let clip = builder.push_clip_region(&scrollbox, vec![], None);
let clip_id = builder.define_clip((0, 0).to(1000, 1000),
ClipRegion::simple(&scrollbox),
clip,
Some(ClipId::new(42, pipeline_id)));
builder.push_clip_id(clip_id);
// now put some content into it.
// start with a white background
let clip = builder.push_clip_region(&(0, 0).to(1000, 1000), vec![], None);
builder.push_rect((0, 0).to(500, 500),
ClipRegion::simple(&(0, 0).to(1000, 1000)),
clip,
ColorF::new(1.0, 1.0, 1.0, 1.0));
// let's make a 50x50 blue square as a visual reference
let clip = builder.push_clip_region(&(0, 0).to(50, 50), vec![], None);
builder.push_rect((0, 0).to(50, 50),
ClipRegion::simple(&(0, 0).to(50, 50)),
clip,
ColorF::new(0.0, 0.0, 1.0, 1.0));
// and a 50x50 green square next to it with an offset clip
// to see what that looks like
let clip = builder.push_clip_region(&(60, 10).to(110, 60), vec![], None);
builder.push_rect((50, 0).to(100, 50),
ClipRegion::simple(&(60, 10).to(110, 60)),
clip,
ColorF::new(0.0, 1.0, 0.0, 1.0));
// Below the above rectangles, set up a nested scrollbox. It's still in
// the same stacking context, so note that the rects passed in need to
// be relative to the stacking context.
let clip = builder.push_clip_region(&(0, 100).to(200, 300), vec![], None);
let nested_clip_id = builder.define_clip((0, 100).to(300, 400),
ClipRegion::simple(&(0, 100).to(200, 300)),
clip,
Some(ClipId::new(43, pipeline_id)));
builder.push_clip_id(nested_clip_id);
// give it a giant gray background just to distinguish it and to easily
// visually identify the nested scrollbox
let clip = builder.push_clip_region(&(-1000, -1000).to(5000, 5000), vec![], None);
builder.push_rect((-1000, -1000).to(5000, 5000),
ClipRegion::simple(&(-1000, -1000).to(5000, 5000)),
clip,
ColorF::new(0.5, 0.5, 0.5, 1.0));
// add a teal square to visualize the scrolling/clipping behaviour
// as you scroll the nested scrollbox with WASD keys
let clip = builder.push_clip_region(&(0, 100).to(50, 150), vec![], None);
builder.push_rect((0, 100).to(50, 150),
ClipRegion::simple(&(0, 100).to(50, 150)),
clip,
ColorF::new(0.0, 1.0, 1.0, 1.0));
// just for good measure add another teal square in the bottom-right
// corner of the nested scrollframe content, which can be scrolled into
// view by the user
let clip = builder.push_clip_region(&(250, 350).to(300, 400), vec![], None);
builder.push_rect((250, 350).to(300, 400),
ClipRegion::simple(&(250, 350).to(300, 400)),
clip,
ColorF::new(0.0, 1.0, 1.0, 1.0));
builder.pop_clip_id(); // nested_clip_id

Просмотреть файл

@ -14,7 +14,7 @@ use glutin::TouchPhase;
use std::collections::HashMap;
use std::env;
use std::path::PathBuf;
use webrender_traits::{ClipRegion, ColorF, Epoch};
use webrender_traits::{ColorF, Epoch};
use webrender_traits::{DeviceIntPoint, DeviceUintSize, LayoutPoint, LayoutRect, LayoutSize};
use webrender_traits::{ImageData, ImageDescriptor, ImageFormat};
use webrender_traits::{PipelineId, TransformStyle};
@ -275,16 +275,18 @@ fn main() {
None,
);
let clip = builder.push_clip_region(&bounds, vec![], None);
builder.push_yuv_image(
LayoutRect::new(LayoutPoint::new(100.0, 0.0), LayoutSize::new(100.0, 100.0)),
ClipRegion::simple(&bounds),
clip,
YuvData::NV12(yuv_chanel1, yuv_chanel2),
YuvColorSpace::Rec601,
);
let clip = builder.push_clip_region(&bounds, vec![], None);
builder.push_yuv_image(
LayoutRect::new(LayoutPoint::new(300.0, 0.0), LayoutSize::new(100.0, 100.0)),
ClipRegion::simple(&bounds),
clip,
YuvData::PlanarYCbCr(yuv_chanel1, yuv_chanel2_1, yuv_chanel3),
YuvColorSpace::Rec601,
);

Просмотреть файл

@ -15,12 +15,12 @@ use resource_cache::ResourceCache;
use scene::{Scene, SceneProperties};
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use tiling::{AuxiliaryListsMap, CompositeOps, PrimitiveFlags};
use tiling::{CompositeOps, DisplayListMap, PrimitiveFlags};
use util::{ComplexClipRegionHelpers, subtract_rect};
use webrender_traits::{AuxiliaryLists, ClipAndScrollInfo, ClipDisplayItem, ClipId, ClipRegion};
use webrender_traits::{ColorF, DeviceUintRect, DeviceUintSize, DisplayItem, Epoch, FilterOp};
use webrender_traits::{ImageDisplayItem, LayerPoint, LayerRect, LayerSize, LayerToScrollTransform};
use webrender_traits::{LayoutRect, LayoutTransform, MixBlendMode, PipelineId, ScrollEventPhase};
use webrender_traits::{BuiltDisplayList, BuiltDisplayListIter, ClipAndScrollInfo, ClipDisplayItem};
use webrender_traits::{ClipId, ClipRegion, ColorF, DeviceUintRect, DeviceUintSize, Epoch, FilterOp};
use webrender_traits::{ImageDisplayItem, ItemRange, LayerPoint, LayerRect, LayerSize, LayerToScrollTransform};
use webrender_traits::{LayoutTransform, MixBlendMode, PipelineId, ScrollEventPhase};
use webrender_traits::{ScrollLayerState, ScrollLocation, ScrollPolicy, SpecificDisplayItem};
use webrender_traits::{StackingContext, TileOffset, WorldPoint};
@ -66,25 +66,11 @@ pub struct Frame {
frame_builder: Option<FrameBuilder>,
}
trait DisplayListHelpers {
fn starting_stacking_context<'a>(&'a self) -> Option<(&'a StackingContext, &'a LayoutRect)>;
}
impl DisplayListHelpers for Vec<DisplayItem> {
fn starting_stacking_context<'a>(&'a self) -> Option<(&'a StackingContext, &'a LayoutRect)> {
self.first().and_then(|item| match item.item {
SpecificDisplayItem::PushStackingContext(ref specific_item) => {
Some((&specific_item.stacking_context, &item.rect))
},
_ => None,
})
}
}
trait StackingContextHelpers {
fn mix_blend_mode_for_compositing(&self) -> Option<MixBlendMode>;
fn filter_ops_for_compositing(&self,
auxiliary_lists: &AuxiliaryLists,
display_list: &BuiltDisplayList,
input_filters: ItemRange<FilterOp>,
properties: &SceneProperties) -> Vec<LowLevelFilterOp>;
}
@ -97,11 +83,12 @@ impl StackingContextHelpers for StackingContext {
}
fn filter_ops_for_compositing(&self,
auxiliary_lists: &AuxiliaryLists,
display_list: &BuiltDisplayList,
input_filters: ItemRange<FilterOp>,
properties: &SceneProperties) -> Vec<LowLevelFilterOp> {
let mut filters = vec![];
for filter in auxiliary_lists.filters(&self.filters) {
match *filter {
for filter in display_list.get(input_filters) {
match filter {
FilterOp::Blur(radius) => {
filters.push(LowLevelFilterOp::Blur(
radius,
@ -150,71 +137,16 @@ impl StackingContextHelpers for StackingContext {
}
}
struct DisplayListTraversal<'a> {
pub display_list: &'a [DisplayItem],
pub next_item_index: usize,
}
impl<'a> DisplayListTraversal<'a> {
pub fn new_skipping_first(display_list: &'a Vec<DisplayItem>) -> DisplayListTraversal {
DisplayListTraversal {
display_list: display_list,
next_item_index: 1,
}
}
pub fn skip_current_stacking_context(&mut self) {
let mut depth = 0;
for item in self {
match item.item {
SpecificDisplayItem::PushStackingContext(..) => depth += 1,
SpecificDisplayItem::PopStackingContext if depth == 0 => return,
SpecificDisplayItem::PopStackingContext => depth -= 1,
_ => {}
}
debug_assert!(depth >= 0);
}
}
pub fn current_stacking_context_empty(&self) -> bool {
match self.peek() {
Some(item) => item.item == SpecificDisplayItem::PopStackingContext,
None => true,
}
}
fn peek(&self) -> Option<&'a DisplayItem> {
if self.next_item_index >= self.display_list.len() {
return None
}
Some(&self.display_list[self.next_item_index])
}
}
impl<'a> Iterator for DisplayListTraversal<'a> {
type Item = &'a DisplayItem;
fn next(&mut self) -> Option<&'a DisplayItem> {
if self.next_item_index >= self.display_list.len() {
return None
}
let item = &self.display_list[self.next_item_index];
self.next_item_index += 1;
Some(item)
}
}
fn clip_intersection(original_rect: &LayerRect,
region: &ClipRegion,
aux_lists: &AuxiliaryLists)
display_list: &BuiltDisplayList)
-> Option<LayerRect> {
if region.image_mask.is_some() {
return None;
}
let clips = aux_lists.complex_clip_regions(&region.complex);
let clips = display_list.get(region.complex_clips);
let base_rect = region.main.intersection(original_rect);
clips.iter().fold(base_rect, |inner_combined, ccr| {
clips.fold(base_rect, |inner_combined, ccr| {
inner_combined.and_then(|combined| {
ccr.get_inner_rect_full().and_then(|ir| ir.intersection(&combined))
})
@ -297,13 +229,16 @@ impl Frame {
self.pipeline_epoch_map.insert(root_pipeline_id, root_pipeline.epoch);
let (root_stacking_context, root_bounds) = match display_list.starting_stacking_context() {
Some(some) => some,
None => {
warn!("Pipeline display list does not start with a stacking context.");
return;
}
};
let mut traversal = display_list.iter();
let (root_stacking_context, root_bounds, root_filters) =
match traversal.starting_stacking_context() {
Some(some) => some,
None => {
warn!("Pipeline display list does not start with a stacking context.");
return;
}
};
let background_color = root_pipeline.background_color.and_then(|color| {
if color.a > 0.0 {
@ -331,15 +266,15 @@ impl Frame {
device_pixel_ratio,
&mut self.clip_scroll_tree);
let mut traversal = DisplayListTraversal::new_skipping_first(display_list);
self.flatten_stacking_context(&mut traversal,
root_pipeline_id,
&mut context,
clip_id,
LayerPoint::zero(),
0,
root_bounds,
root_stacking_context);
&root_bounds,
&root_stacking_context,
root_filters);
}
self.frame_builder = Some(frame_builder);
@ -363,14 +298,15 @@ impl Frame {
}
fn flatten_stacking_context<'a>(&mut self,
traversal: &mut DisplayListTraversal<'a>,
traversal: &mut BuiltDisplayListIter<'a>,
pipeline_id: PipelineId,
context: &mut FlattenContext,
context_scroll_node_id: ClipId,
mut reference_frame_relative_offset: LayerPoint,
level: i32,
bounds: &LayerRect,
stacking_context: &StackingContext) {
stacking_context: &StackingContext,
filters: ItemRange<FilterOp>) {
// Avoid doing unnecessary work for empty stacking contexts.
if traversal.current_stacking_context_empty() {
traversal.skip_current_stacking_context();
@ -378,11 +314,12 @@ impl Frame {
}
let composition_operations = {
let auxiliary_lists = context.scene.pipeline_auxiliary_lists
.get(&pipeline_id)
.expect("No auxiliary lists?!");
// TODO(optimization?): self.traversal.display_list()
let display_list = context.scene.display_lists
.get(&pipeline_id)
.expect("No display list?!");
CompositeOps::new(
stacking_context.filter_ops_for_compositing(auxiliary_lists, &context.scene.properties),
stacking_context.filter_ops_for_compositing(display_list, filters, &context.scene.properties),
stacking_context.mix_blend_mode_for_compositing())
};
@ -499,8 +436,11 @@ impl Frame {
None => return,
};
let mut traversal = display_list.iter();
let (iframe_stacking_context,
iframe_stacking_context_bounds) = match display_list.starting_stacking_context() {
iframe_stacking_context_bounds,
iframe_filters) = match traversal.starting_stacking_context() {
Some(some) => some,
None => {
warn!("Pipeline display list does not start with a stacking context.");
@ -532,35 +472,50 @@ impl Frame {
&ClipRegion::simple(&iframe_rect),
&mut self.clip_scroll_tree);
let mut traversal = DisplayListTraversal::new_skipping_first(display_list);
self.flatten_stacking_context(&mut traversal,
pipeline_id,
context,
iframe_clip_id,
LayerPoint::zero(),
0,
iframe_stacking_context_bounds,
iframe_stacking_context);
&iframe_stacking_context_bounds,
&iframe_stacking_context,
iframe_filters);
context.builder.pop_reference_frame();
}
fn flatten_items<'a>(&mut self,
traversal: &mut DisplayListTraversal<'a>,
traversal: &mut BuiltDisplayListIter<'a>,
pipeline_id: PipelineId,
context: &mut FlattenContext,
reference_frame_relative_offset: LayerPoint,
level: i32) {
while let Some(item) = traversal.next() {
let mut clip_and_scroll = item.clip_and_scroll;
// All this continue_traversal stuff is a big borrowck hack ;_;
// Non-lexical lifetimes should fix it.
//
// Basic idea: when we recurse, we make an independent traversal, then assign
// it to this variable to be swapped in at the start of the loop. We can't
// while-let because we need a brief period where the item doesn't exist.
let mut continue_traversal: Option<BuiltDisplayListIter<'a>> = None;
loop {
if let Some(trav) = continue_traversal.take() {
*traversal = trav;
}
let item = match traversal.next() {
Some(item) => item,
None => break,
};
let mut clip_and_scroll = item.clip_and_scroll();
clip_and_scroll.scroll_node_id =
context.clip_id_with_replacement(clip_and_scroll.scroll_node_id);
match item.item {
match *item.item() {
SpecificDisplayItem::WebGL(ref info) => {
context.builder.add_webgl_rectangle(clip_and_scroll,
item.rect,
&item.clip,
item.rect(),
item.clip_region(),
info.context_id);
}
SpecificDisplayItem::Image(ref info) => {
@ -571,15 +526,15 @@ impl Frame {
let image_size = DeviceUintSize::new(image.descriptor.width, image.descriptor.height);
self.decompose_image(clip_and_scroll,
context,
&item.rect,
&item.clip,
&item.rect(),
item.clip_region(),
info,
image_size,
tile_size as u32);
} else {
context.builder.add_image(clip_and_scroll,
item.rect,
&item.clip,
item.rect(),
item.clip_region(),
&info.stretch_size,
&info.tile_spacing,
None,
@ -590,73 +545,76 @@ impl Frame {
}
SpecificDisplayItem::YuvImage(ref info) => {
context.builder.add_yuv_image(clip_and_scroll,
item.rect,
&item.clip,
item.rect(),
item.clip_region(),
info.yuv_data,
info.color_space);
}
SpecificDisplayItem::Text(ref text_info) => {
context.builder.add_text(clip_and_scroll,
item.rect,
&item.clip,
item.rect(),
item.clip_region(),
text_info.font_key,
text_info.size,
text_info.blur_radius,
&text_info.color,
text_info.glyphs,
item.glyphs(),
item.display_list().get(item.glyphs()).count(),
text_info.glyph_options);
}
SpecificDisplayItem::Rectangle(ref info) => {
let auxiliary_lists = context.scene.pipeline_auxiliary_lists
.get(&pipeline_id)
.expect("No auxiliary lists?!");
let display_list = context.scene.display_lists
.get(&pipeline_id)
.expect("No display list?!");
// Try to extract the opaque inner rectangle out of the clipped primitive.
if let Some(opaque_rect) = clip_intersection(&item.rect, &item.clip, auxiliary_lists) {
if let Some(opaque_rect) = clip_intersection(&item.rect(), item.clip_region(), display_list) {
let mut results = Vec::new();
subtract_rect(&item.rect, &opaque_rect, &mut results);
subtract_rect(&item.rect(), &opaque_rect, &mut results);
// The inner rectangle is considered opaque within this layer.
// It may still inherit some masking from the clip stack.
context.builder.add_solid_rectangle(clip_and_scroll,
&opaque_rect,
&ClipRegion::simple(&item.clip.main),
&ClipRegion::simple(&item.clip_region().main),
&info.color,
PrimitiveFlags::None);
for transparent_rect in &results {
context.builder.add_solid_rectangle(clip_and_scroll,
transparent_rect,
&item.clip,
item.clip_region(),
&info.color,
PrimitiveFlags::None);
}
} else {
context.builder.add_solid_rectangle(clip_and_scroll,
&item.rect,
&item.clip,
&item.rect(),
item.clip_region(),
&info.color,
PrimitiveFlags::None);
}
}
SpecificDisplayItem::Gradient(ref info) => {
context.builder.add_gradient(clip_and_scroll,
item.rect,
&item.clip,
item.rect(),
item.clip_region(),
info.gradient.start_point,
info.gradient.end_point,
info.gradient.stops,
item.gradient_stops(),
item.display_list()
.get(item.gradient_stops()).count(),
info.gradient.extend_mode,
info.tile_size,
info.tile_spacing);
}
SpecificDisplayItem::RadialGradient(ref info) => {
context.builder.add_radial_gradient(clip_and_scroll,
item.rect,
&item.clip,
item.rect(),
item.clip_region(),
info.gradient.start_center,
info.gradient.start_radius,
info.gradient.end_center,
info.gradient.end_radius,
info.gradient.ratio_xy,
info.gradient.stops,
item.gradient_stops(),
info.gradient.extend_mode,
info.tile_size,
info.tile_spacing);
@ -664,7 +622,7 @@ impl Frame {
SpecificDisplayItem::BoxShadow(ref box_shadow_info) => {
context.builder.add_box_shadow(clip_and_scroll,
&box_shadow_info.box_bounds,
&item.clip,
item.clip_region(),
&box_shadow_info.offset,
&box_shadow_info.color,
box_shadow_info.blur_radius,
@ -673,38 +631,48 @@ impl Frame {
box_shadow_info.clip_mode);
}
SpecificDisplayItem::Border(ref info) => {
context.builder.add_border(clip_and_scroll,
item.rect,
&item.clip,
info);
item.rect(),
item.clip_region(),
info,
item.gradient_stops(),
item.display_list()
.get(item.gradient_stops()).count());
}
SpecificDisplayItem::PushStackingContext(ref info) => {
self.flatten_stacking_context(traversal,
let mut subtraversal = item.sub_iter();
self.flatten_stacking_context(&mut subtraversal,
pipeline_id,
context,
item.clip_and_scroll.scroll_node_id,
item.clip_and_scroll().scroll_node_id,
reference_frame_relative_offset,
level + 1,
&item.rect,
&info.stacking_context);
&item.rect(),
&info.stacking_context,
item.filters());
continue_traversal = Some(subtraversal);
}
SpecificDisplayItem::Iframe(ref info) => {
self.flatten_iframe(info.pipeline_id,
clip_and_scroll.scroll_node_id,
&item.rect,
&item.rect(),
context,
reference_frame_relative_offset);
}
SpecificDisplayItem::Clip(ref info) => {
let content_rect = &item.rect.translate(&reference_frame_relative_offset);
let content_rect = &item.rect().translate(&reference_frame_relative_offset);
self.flatten_clip(context,
pipeline_id,
clip_and_scroll.scroll_node_id,
&info,
&content_rect,
&item.clip);
item.clip_region());
}
SpecificDisplayItem::PopStackingContext => return,
SpecificDisplayItem::SetGradientStops | SpecificDisplayItem::SetClipRegion(_) => {
// Do nothing; these are dummy items for the display list parser
}
}
}
}
@ -822,7 +790,7 @@ impl Frame {
// ###################-+ -+
// # | | |//# | | image size
// # | | |//# | |
// #----+----+----+--#-+ | -+
// #----+----+----+--#-+ | -+
// # | | |//# | | | regular tile size
// # | | |//# | | |
// #----+----+----+--#-+ | -+-+
@ -1002,14 +970,14 @@ impl Frame {
pub fn build(&mut self,
resource_cache: &mut ResourceCache,
auxiliary_lists_map: &AuxiliaryListsMap,
display_lists: &DisplayListMap,
device_pixel_ratio: f32,
pan: LayerPoint,
texture_cache_profile: &mut TextureCacheProfileCounters)
-> RendererFrame {
self.clip_scroll_tree.update_all_node_transforms(pan);
let frame = self.build_frame(resource_cache,
auxiliary_lists_map,
display_lists,
device_pixel_ratio,
texture_cache_profile);
resource_cache.expire_old_resources(self.id);
@ -1018,7 +986,7 @@ impl Frame {
fn build_frame(&mut self,
resource_cache: &mut ResourceCache,
auxiliary_lists_map: &AuxiliaryListsMap,
display_lists: &DisplayListMap,
device_pixel_ratio: f32,
texture_cache_profile: &mut TextureCacheProfileCounters)
-> RendererFrame {
@ -1027,7 +995,7 @@ impl Frame {
builder.build(resource_cache,
self.id,
&mut self.clip_scroll_tree,
auxiliary_lists_map,
display_lists,
device_pixel_ratio,
texture_cache_profile)
);

Просмотреть файл

@ -22,7 +22,7 @@ use clip_scroll_tree::ClipScrollTree;
use std::{cmp, f32, i32, mem, usize};
use euclid::{SideOffsets2D, TypedPoint3D};
use tiling::{ContextIsolation, StackingContextIndex};
use tiling::{AuxiliaryListsMap, ClipScrollGroup, ClipScrollGroupIndex, CompositeOps, Frame};
use tiling::{ClipScrollGroup, ClipScrollGroupIndex, CompositeOps, DisplayListMap, Frame};
use tiling::{PackedLayer, PackedLayerIndex, PrimitiveFlags, PrimitiveRunCmd, RenderPass};
use tiling::{RenderTargetContext, RenderTaskCollection, ScrollbarPrimitive, StackingContext};
use util::{self, pack_as_float, subtract_rect, recycle_vec};
@ -30,9 +30,10 @@ use util::RectHelpers;
use webrender_traits::{BorderDetails, BorderDisplayItem, BoxShadowClipMode, ClipAndScrollInfo};
use webrender_traits::{ClipId, ClipRegion, ColorF, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
use webrender_traits::{DeviceUintRect, DeviceUintSize, ExtendMode, FontKey, FontRenderMode};
use webrender_traits::{GlyphOptions, ImageKey, ImageRendering, ItemRange, LayerPoint, LayerRect};
use webrender_traits::{LayerSize, LayerToScrollTransform, PipelineId, RepeatMode, TileOffset};
use webrender_traits::{TransformStyle, WebGLContextId, WorldPixel, YuvColorSpace, YuvData};
use webrender_traits::{GlyphInstance, GlyphOptions, GradientStop, ImageKey, ImageRendering};
use webrender_traits::{ItemRange, LayerPoint, LayerRect, LayerSize, LayerToScrollTransform};
use webrender_traits::{PipelineId, RepeatMode, TileOffset, TransformStyle, WebGLContextId};
use webrender_traits::{WorldPixel, YuvColorSpace, YuvData};
#[derive(Debug, Clone)]
struct ImageBorderSegment {
@ -419,7 +420,9 @@ impl FrameBuilder {
clip_and_scroll: ClipAndScrollInfo,
rect: LayerRect,
clip_region: &ClipRegion,
border_item: &BorderDisplayItem) {
border_item: &BorderDisplayItem,
gradient_stops: ItemRange<GradientStop>,
gradient_stops_count: usize) {
let create_segments = |outset: SideOffsets2D<f32>| {
// Calculate the modified rect as specific by border-image-outset
let origin = LayerPoint::new(rect.origin.x - outset.left,
@ -579,7 +582,8 @@ impl FrameBuilder {
clip_region,
border.gradient.start_point - segment_rel,
border.gradient.end_point - segment_rel,
border.gradient.stops,
gradient_stops,
gradient_stops_count,
border.gradient.extend_mode,
segment.size,
LayerSize::zero());
@ -597,7 +601,7 @@ impl FrameBuilder {
border.gradient.end_center - segment_rel,
border.gradient.end_radius,
border.gradient.ratio_xy,
border.gradient.stops,
gradient_stops,
border.gradient.extend_mode,
segment.size,
LayerSize::zero());
@ -612,7 +616,8 @@ impl FrameBuilder {
clip_region: &ClipRegion,
start_point: LayerPoint,
end_point: LayerPoint,
stops: ItemRange,
stops: ItemRange<GradientStop>,
stops_count: usize,
extend_mode: ExtendMode,
tile_size: LayerSize,
tile_spacing: LayerSize) {
@ -643,6 +648,7 @@ impl FrameBuilder {
let gradient_cpu = GradientPrimitiveCpu {
stops_range: stops,
stops_count: stops_count,
extend_mode: extend_mode,
reverse_stops: reverse_stops,
cache_dirty: true,
@ -684,7 +690,7 @@ impl FrameBuilder {
end_center: LayerPoint,
end_radius: f32,
ratio_xy: f32,
stops: ItemRange,
stops: ItemRange<GradientStop>,
extend_mode: ExtendMode,
tile_size: LayerSize,
tile_spacing: LayerSize) {
@ -721,7 +727,8 @@ impl FrameBuilder {
size: Au,
blur_radius: Au,
color: &ColorF,
glyph_range: ItemRange,
glyph_range: ItemRange<GlyphInstance>,
glyph_count: usize,
glyph_options: Option<GlyphOptions>) {
if color.a == 0.0 {
return
@ -746,6 +753,7 @@ impl FrameBuilder {
logical_font_size: size,
blur_radius: blur_radius,
glyph_range: glyph_range,
glyph_count: glyph_count,
cache_dirty: true,
glyph_instances: Vec::new(),
color_texture_id: SourceTexture::Invalid,
@ -1064,7 +1072,7 @@ impl FrameBuilder {
fn build_layer_screen_rects_and_cull_layers(&mut self,
screen_rect: &DeviceIntRect,
clip_scroll_tree: &mut ClipScrollTree,
auxiliary_lists_map: &AuxiliaryListsMap,
display_lists: &DisplayListMap,
resource_cache: &mut ResourceCache,
profile_counters: &mut FrameProfileCounters,
device_pixel_ratio: f32) {
@ -1072,7 +1080,7 @@ impl FrameBuilder {
LayerRectCalculationAndCullingPass::create_and_run(self,
screen_rect,
clip_scroll_tree,
auxiliary_lists_map,
display_lists,
resource_cache,
profile_counters,
device_pixel_ratio);
@ -1326,7 +1334,7 @@ impl FrameBuilder {
resource_cache: &mut ResourceCache,
frame_id: FrameId,
clip_scroll_tree: &mut ClipScrollTree,
auxiliary_lists_map: &AuxiliaryListsMap,
display_lists: &DisplayListMap,
device_pixel_ratio: f32,
texture_cache_profile: &mut TextureCacheProfileCounters)
-> Frame {
@ -1353,7 +1361,7 @@ impl FrameBuilder {
self.build_layer_screen_rects_and_cull_layers(&screen_rect,
clip_scroll_tree,
auxiliary_lists_map,
display_lists,
resource_cache,
&mut profile_counters,
device_pixel_ratio);
@ -1433,7 +1441,7 @@ struct LayerRectCalculationAndCullingPass<'a> {
frame_builder: &'a mut FrameBuilder,
screen_rect: &'a DeviceIntRect,
clip_scroll_tree: &'a mut ClipScrollTree,
auxiliary_lists_map: &'a AuxiliaryListsMap,
display_lists: &'a DisplayListMap,
resource_cache: &'a mut ResourceCache,
profile_counters: &'a mut FrameProfileCounters,
device_pixel_ratio: f32,
@ -1453,7 +1461,7 @@ impl<'a> LayerRectCalculationAndCullingPass<'a> {
fn create_and_run(frame_builder: &'a mut FrameBuilder,
screen_rect: &'a DeviceIntRect,
clip_scroll_tree: &'a mut ClipScrollTree,
auxiliary_lists_map: &'a AuxiliaryListsMap,
display_lists: &'a DisplayListMap,
resource_cache: &'a mut ResourceCache,
profile_counters: &'a mut FrameProfileCounters,
device_pixel_ratio: f32) {
@ -1462,7 +1470,7 @@ impl<'a> LayerRectCalculationAndCullingPass<'a> {
frame_builder: frame_builder,
screen_rect: screen_rect,
clip_scroll_tree: clip_scroll_tree,
auxiliary_lists_map: auxiliary_lists_map,
display_lists: display_lists,
resource_cache: resource_cache,
profile_counters: profile_counters,
device_pixel_ratio: device_pixel_ratio,
@ -1525,14 +1533,14 @@ impl<'a> LayerRectCalculationAndCullingPass<'a> {
_ => continue,
};
let auxiliary_lists = self.auxiliary_lists_map.get(&node.pipeline_id)
.expect("No auxiliary lists?");
let display_list = self.display_lists.get(&node.pipeline_id)
.expect("No display list?");
mask_info.update(&node_clip_info.clip_sources,
&packed_layer.transform,
&mut self.frame_builder.prim_store.gpu_data32,
self.device_pixel_ratio,
auxiliary_lists);
display_list);
for clip_source in &node_clip_info.clip_sources {
if let Some(mask) = clip_source.image_mask() {
@ -1693,8 +1701,8 @@ impl<'a> LayerRectCalculationAndCullingPass<'a> {
let stacking_context =
&mut self.frame_builder.stacking_context_store[stacking_context_index.0];
let packed_layer = &self.frame_builder.packed_layers[packed_layer_index.0];
let auxiliary_lists = self.auxiliary_lists_map.get(&pipeline_id)
.expect("No auxiliary lists?");
let display_list = self.display_lists.get(&pipeline_id)
.expect("No display list?");
for i in 0..prim_count {
let prim_index = PrimitiveIndex(prim_index.0 + i);
if self.frame_builder.prim_store.build_bounding_rect(prim_index,
@ -1706,7 +1714,7 @@ impl<'a> LayerRectCalculationAndCullingPass<'a> {
self.resource_cache,
&packed_layer.transform,
self.device_pixel_ratio,
auxiliary_lists) {
display_list) {
self.frame_builder.prim_store.build_bounding_rect(prim_index,
self.screen_rect,
&packed_layer.transform,

Просмотреть файл

@ -8,7 +8,7 @@ use prim_store::{ClipData, GpuBlock32, PrimitiveStore};
use prim_store::{CLIP_DATA_GPU_SIZE, MASK_DATA_GPU_SIZE};
use renderer::VertexDataStore;
use util::{ComplexClipRegionHelpers, MatrixHelpers, TransformedRect};
use webrender_traits::{AuxiliaryLists, BorderRadius, ClipRegion, ComplexClipRegion, ImageMask};
use webrender_traits::{BorderRadius, BuiltDisplayList, ClipRegion, ComplexClipRegion, ImageMask};
use webrender_traits::{DeviceIntRect, LayerToWorldTransform};
use webrender_traits::{LayerRect, LayerPoint, LayerSize};
use std::ops::Not;
@ -154,8 +154,7 @@ impl MaskCacheInfo {
debug_assert!(image.is_none()); // TODO(gw): Support >1 image mask!
image = Some((info, clip_store.alloc(MASK_DATA_GPU_SIZE)));
}
complex_clip_count += region.complex.length;
complex_clip_count += region.complex_clip_count;
if region_mode == RegionMode::IncludeRect {
complex_clip_count += 1;
}
@ -193,7 +192,7 @@ impl MaskCacheInfo {
transform: &LayerToWorldTransform,
clip_store: &mut VertexDataStore<GpuBlock32>,
device_pixel_ratio: f32,
aux_lists: &AuxiliaryLists) {
display_list: &BuiltDisplayList) {
let is_aligned = transform.can_losslessly_transform_and_perspective_project_a_2d_rect();
// If we haven't cached this info, or if the transform type has changed
@ -238,7 +237,7 @@ impl MaskCacheInfo {
None => local_rect,
};
let clips = aux_lists.complex_clip_regions(&region.complex);
let clips = display_list.get(region.complex_clips);
if !self.is_aligned && region_mode == RegionMode::IncludeRect {
// we have an extra clip rect coming from the transformed layer
debug_assert!(self.effective_complex_clip_count < self.complex_clip_range.item_count);
@ -254,8 +253,8 @@ impl MaskCacheInfo {
self.effective_complex_clip_count += clips.len();
let slice = clip_store.get_slice_mut(address, CLIP_DATA_GPU_SIZE * clips.len());
for (clip, chunk) in clips.iter().zip(slice.chunks_mut(CLIP_DATA_GPU_SIZE)) {
let data = ClipData::from_clip_region(clip);
for (clip, chunk) in clips.zip(slice.chunks_mut(CLIP_DATA_GPU_SIZE)) {
let data = ClipData::from_clip_region(&clip);
PrimitiveStore::populate_clip_data(chunk, data);
local_rect = local_rect.and_then(|r| r.intersection(&clip.rect));
local_inner = local_inner.and_then(|r| clip.get_inner_rect_safe()

Просмотреть файл

@ -14,14 +14,14 @@ use resource_cache::{CacheItem, ImageProperties, ResourceCache};
use std::mem;
use std::usize;
use util::{TransformedRect, recycle_vec};
use webrender_traits::{AuxiliaryLists, ColorF, ImageKey, ImageRendering, YuvColorSpace, YuvFormat};
use webrender_traits::{ClipRegion, ComplexClipRegion, ItemRange, GlyphKey};
use webrender_traits::{BuiltDisplayList, ColorF, ImageKey, ImageRendering, YuvColorSpace};
use webrender_traits::{YuvFormat, ClipRegion, ComplexClipRegion, ItemRange, GlyphKey};
use webrender_traits::{FontKey, FontRenderMode, WebGLContextId};
use webrender_traits::{device_length, DeviceIntRect, DeviceIntSize};
use webrender_traits::{DeviceRect, DevicePoint, DeviceSize};
use webrender_traits::{LayerRect, LayerSize, LayerPoint, LayoutPoint};
use webrender_traits::{LayerToWorldTransform, GlyphInstance, GlyphOptions};
use webrender_traits::{ExtendMode, GradientStop, TileOffset};
use webrender_traits::{ExtendMode, GradientStop, AuxIter, TileOffset};
pub const CLIP_DATA_GPU_SIZE: usize = 5;
pub const MASK_DATA_GPU_SIZE: usize = 1;
@ -271,7 +271,8 @@ pub struct GradientPrimitiveGpu {
#[derive(Debug)]
pub struct GradientPrimitiveCpu {
pub stops_range: ItemRange,
pub stops_range: ItemRange<GradientStop>,
pub stops_count: usize,
pub extend_mode: ExtendMode,
pub reverse_stops: bool,
pub cache_dirty: bool,
@ -293,7 +294,7 @@ pub struct RadialGradientPrimitiveGpu {
#[derive(Debug)]
pub struct RadialGradientPrimitiveCpu {
pub stops_range: ItemRange,
pub stops_range: ItemRange<GradientStop>,
pub extend_mode: ExtendMode,
pub cache_dirty: bool,
}
@ -379,7 +380,7 @@ impl GradientData {
}
// Build the gradient data from the supplied stops, reversing them if necessary.
fn build(&mut self, src_stops: &[GradientStop], reverse_stops: bool) {
fn build(&mut self, src_stops: AuxIter<GradientStop>, reverse_stops: bool) {
const MAX_IDX: usize = GRADIENT_DATA_RESOLUTION;
const MIN_IDX: usize = 0;
@ -440,7 +441,8 @@ pub struct TextRunPrimitiveCpu {
pub font_key: FontKey,
pub logical_font_size: Au,
pub blur_radius: Au,
pub glyph_range: ItemRange,
pub glyph_range: ItemRange<GlyphInstance>,
pub glyph_count: usize,
pub cache_dirty: bool,
// TODO(gw): Maybe make this an Arc for sharing with resource cache
pub glyph_instances: Vec<GlyphInstance>,
@ -710,8 +712,8 @@ impl PrimitiveStore {
}
PrimitiveContainer::TextRun(mut text_cpu, text_gpu) => {
let gpu_address = self.gpu_data16.push(text_gpu);
let gpu_glyphs_address = self.gpu_data16.alloc(text_cpu.glyph_range.length);
text_cpu.resource_address = self.gpu_resource_rects.alloc(text_cpu.glyph_range.length);
let gpu_glyphs_address = self.gpu_data16.alloc(text_cpu.glyph_count);
text_cpu.resource_address = self.gpu_resource_rects.alloc(text_cpu.glyph_count);
let metadata = PrimitiveMetadata {
is_opaque: false,
@ -721,7 +723,7 @@ impl PrimitiveStore {
cpu_prim_index: SpecificPrimitiveIndex(self.cpu_text_runs.len()),
gpu_prim_index: gpu_address,
gpu_data_address: gpu_glyphs_address,
gpu_data_count: text_cpu.glyph_range.length as i32,
gpu_data_count: text_cpu.glyph_count as i32,
render_task: None,
clip_task: None,
};
@ -792,7 +794,7 @@ impl PrimitiveStore {
}
PrimitiveContainer::AlignedGradient(gradient_cpu, gradient_gpu) => {
let gpu_address = self.gpu_data64.push(gradient_gpu);
let gpu_stops_address = self.gpu_data32.alloc(gradient_cpu.stops_range.length);
let gpu_stops_address = self.gpu_data32.alloc(gradient_cpu.stops_count);
let metadata = PrimitiveMetadata {
// TODO: calculate if the gradient is actually opaque
@ -803,7 +805,7 @@ impl PrimitiveStore {
cpu_prim_index: SpecificPrimitiveIndex(self.cpu_gradients.len()),
gpu_prim_index: gpu_address,
gpu_data_address: gpu_stops_address,
gpu_data_count: gradient_cpu.stops_range.length as i32,
gpu_data_count: gradient_cpu.stops_count as i32,
render_task: None,
clip_task: None,
};
@ -985,7 +987,7 @@ impl PrimitiveStore {
let font_size_dp = text.logical_font_size.scale_by(device_pixel_ratio);
let dest_rects = self.gpu_resource_rects.get_slice_mut(text.resource_address,
text.glyph_range.length);
text.glyph_count);
let texture_id = resource_cache.get_glyphs(text.font_key,
font_size_dp,
@ -1131,7 +1133,7 @@ impl PrimitiveStore {
resource_cache: &mut ResourceCache,
layer_transform: &LayerToWorldTransform,
device_pixel_ratio: f32,
auxiliary_lists: &AuxiliaryLists) -> bool {
display_list: &BuiltDisplayList) -> bool {
let metadata = &mut self.cpu_metadata[prim_index.0];
let mut prim_needs_resolve = false;
@ -1142,9 +1144,9 @@ impl PrimitiveStore {
layer_transform,
&mut self.gpu_data32,
device_pixel_ratio,
auxiliary_lists);
display_list);
for clip in &metadata.clips {
if let ClipSource::Region(ClipRegion{ image_mask: Some(ref mask), .. }, _) = *clip {
if let ClipSource::Region(ClipRegion{ image_mask: Some(ref mask), .. }, ..) = *clip {
resource_cache.request_image(mask.image, ImageRendering::Auto, None);
prim_needs_resolve = true;
}
@ -1175,23 +1177,24 @@ impl PrimitiveStore {
let text = &mut self.cpu_text_runs[metadata.cpu_prim_index.0];
let font_size_dp = text.logical_font_size.scale_by(device_pixel_ratio);
let src_glyphs = auxiliary_lists.glyph_instances(&text.glyph_range);
let src_glyphs = display_list.get(text.glyph_range);
prim_needs_resolve = true;
if text.cache_dirty {
rebuild_bounding_rect = true;
text.cache_dirty = false;
debug_assert!(metadata.gpu_data_count == text.glyph_range.length as i32);
debug_assert!(metadata.gpu_data_count == src_glyphs.len() as i32);
debug_assert!(text.glyph_instances.is_empty());
let dest_glyphs = self.gpu_data16.get_slice_mut(metadata.gpu_data_address,
text.glyph_range.length);
src_glyphs.len());
let mut glyph_key = GlyphKey::new(text.font_key,
font_size_dp,
text.color,
src_glyphs[0].index,
src_glyphs[0].point,
0,
LayoutPoint::new(0.0, 0.0),
text.render_mode);
let mut local_rect = LayerRect::zero();
let mut actual_glyph_count = 0;
@ -1302,13 +1305,13 @@ impl PrimitiveStore {
PrimitiveKind::AlignedGradient => {
let gradient = &mut self.cpu_gradients[metadata.cpu_prim_index.0];
if gradient.cache_dirty {
let src_stops = auxiliary_lists.gradient_stops(&gradient.stops_range);
let src_stops = display_list.get(gradient.stops_range);
debug_assert!(metadata.gpu_data_count == gradient.stops_range.length as i32);
debug_assert!(metadata.gpu_data_count == src_stops.len() as i32);
let dest_stops = self.gpu_data32.get_slice_mut(metadata.gpu_data_address,
gradient.stops_range.length);
src_stops.len());
for (src, dest) in src_stops.iter().zip(dest_stops.iter_mut()) {
for (src, dest) in src_stops.zip(dest_stops.iter_mut()) {
*dest = GpuBlock32::from(GradientStopGpu {
offset: src.offset,
color: src.color,
@ -1322,7 +1325,8 @@ impl PrimitiveStore {
PrimitiveKind::AngleGradient => {
let gradient = &mut self.cpu_gradients[metadata.cpu_prim_index.0];
if gradient.cache_dirty {
let src_stops = auxiliary_lists.gradient_stops(&gradient.stops_range);
let src_stops = display_list.get(gradient.stops_range);
let dest_gradient = self.gpu_gradient_data.get_mut(metadata.gpu_data_address);
dest_gradient.build(src_stops, gradient.reverse_stops);
gradient.cache_dirty = false;
@ -1331,7 +1335,8 @@ impl PrimitiveStore {
PrimitiveKind::RadialGradient => {
let gradient = &mut self.cpu_radial_gradients[metadata.cpu_prim_index.0];
if gradient.cache_dirty {
let src_stops = auxiliary_lists.gradient_stops(&gradient.stops_range);
let src_stops = display_list.get(gradient.stops_range);
let dest_gradient = self.gpu_gradient_data.get_mut(metadata.gpu_data_address);
dest_gradient.build(src_stops, false);
gradient.cache_dirty = false;

Просмотреть файл

@ -18,7 +18,7 @@ use thread_profiler::register_thread_with_profiler;
use threadpool::ThreadPool;
use webgl_types::{GLContextHandleWrapper, GLContextWrapper};
use webrender_traits::{DeviceIntPoint, DeviceUintPoint, DeviceUintRect, DeviceUintSize, LayerPoint};
use webrender_traits::{ApiMsg, AuxiliaryLists, BuiltDisplayList, IdNamespace, ImageData};
use webrender_traits::{ApiMsg, BuiltDisplayList, IdNamespace, ImageData};
use webrender_traits::{PipelineId, RenderNotifier, RenderDispatcher, WebGLCommand, WebGLContextId};
use webrender_traits::channel::{PayloadSenderHelperMethods, PayloadReceiverHelperMethods, PayloadReceiver, PayloadSender, MsgReceiver};
use webrender_traits::{BlobImageRenderer, VRCompositorCommand, VRCompositorHandler};
@ -181,63 +181,57 @@ impl RenderBackend {
pipeline_id,
viewport_size,
display_list_descriptor,
auxiliary_lists_descriptor,
preserve_frame_state) => {
profile_scope!("SetDisplayList");
let mut leftover_auxiliary_data = vec![];
let mut auxiliary_data;
let mut leftover_data = vec![];
let mut data;
loop {
auxiliary_data = self.payload_rx.recv_payload().unwrap();
data = self.payload_rx.recv_payload().unwrap();
{
if auxiliary_data.epoch == epoch &&
auxiliary_data.pipeline_id == pipeline_id {
if data.epoch == epoch &&
data.pipeline_id == pipeline_id {
break
}
}
leftover_auxiliary_data.push(auxiliary_data)
leftover_data.push(data)
}
for leftover_auxiliary_data in leftover_auxiliary_data {
self.payload_tx.send_payload(leftover_auxiliary_data).unwrap()
for leftover_data in leftover_data {
self.payload_tx.send_payload(leftover_data).unwrap()
}
if let Some(ref mut r) = self.recorder {
r.write_payload(frame_counter, &auxiliary_data.to_data());
r.write_payload(frame_counter, &data.to_data());
}
let built_display_list =
BuiltDisplayList::from_data(auxiliary_data.display_list_data,
BuiltDisplayList::from_data(data.display_list_data,
display_list_descriptor);
let auxiliary_lists =
AuxiliaryLists::from_data(auxiliary_data.auxiliary_lists_data,
auxiliary_lists_descriptor);
if !preserve_frame_state {
self.discard_frame_state_for_pipeline(pipeline_id);
}
let display_list_len = built_display_list.data().len();
let aux_list_len = auxiliary_lists.data().len();
let (builder_start_time, builder_finish_time) = built_display_list.times();
let display_list_received_time = precise_time_ns();
profile_counters.total_time.profile(|| {
self.scene.set_display_list(pipeline_id,
epoch,
built_display_list,
background_color,
viewport_size,
auxiliary_lists);
viewport_size);
self.build_scene();
});
// Note: this isn't quite right as auxiliary values will be
// Note: this isn't quite right as auxiliary values will be
// pulled out somewhere in the prim_store, but aux values are
// really simple and cheap to access, so it's not a big deal.
let display_list_consumed_time = precise_time_ns();
profile_counters.ipc.set(builder_start_time, builder_finish_time,
profile_counters.ipc.set(builder_start_time, builder_finish_time,
display_list_received_time, display_list_consumed_time,
display_list_len + aux_list_len);
display_list_len);
}
ApiMsg::SetRootPipeline(pipeline_id) => {
profile_scope!("SetRootPipeline");
@ -491,7 +485,7 @@ impl RenderBackend {
let pan = LayerPoint::new(self.pan.x as f32 / accumulated_scale_factor,
self.pan.y as f32 / accumulated_scale_factor);
let frame = self.frame.build(&mut self.resource_cache,
&self.scene.pipeline_auxiliary_lists,
&self.scene.display_lists,
accumulated_scale_factor,
pan,
texture_cache_profile);

Просмотреть файл

@ -5,9 +5,8 @@
use fnv::FnvHasher;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use tiling::AuxiliaryListsMap;
use webrender_traits::{AuxiliaryLists, BuiltDisplayList, PipelineId, Epoch, ColorF};
use webrender_traits::{DisplayItem, DynamicProperties, LayerSize, LayoutTransform};
use webrender_traits::{BuiltDisplayList, PipelineId, Epoch, ColorF};
use webrender_traits::{DynamicProperties, LayerSize, LayoutTransform};
use webrender_traits::{PropertyBinding, PropertyBindingId};
/// Stores a map of the animated property bindings for the current display list. These
@ -93,8 +92,7 @@ pub struct ScenePipeline {
pub struct Scene {
pub root_pipeline_id: Option<PipelineId>,
pub pipeline_map: HashMap<PipelineId, ScenePipeline, BuildHasherDefault<FnvHasher>>,
pub pipeline_auxiliary_lists: AuxiliaryListsMap,
pub display_lists: HashMap<PipelineId, Vec<DisplayItem>, BuildHasherDefault<FnvHasher>>,
pub display_lists: HashMap<PipelineId, BuiltDisplayList, BuildHasherDefault<FnvHasher>>,
pub properties: SceneProperties,
}
@ -103,7 +101,6 @@ impl Scene {
Scene {
root_pipeline_id: None,
pipeline_map: HashMap::default(),
pipeline_auxiliary_lists: HashMap::default(),
display_lists: HashMap::default(),
properties: SceneProperties::new(),
}
@ -118,11 +115,9 @@ impl Scene {
epoch: Epoch,
built_display_list: BuiltDisplayList,
background_color: Option<ColorF>,
viewport_size: LayerSize,
auxiliary_lists: AuxiliaryLists) {
viewport_size: LayerSize) {
self.pipeline_auxiliary_lists.insert(pipeline_id, auxiliary_lists);
self.display_lists.insert(pipeline_id, built_display_list.into_display_items());
self.display_lists.insert(pipeline_id, built_display_list);
let new_pipeline = ScenePipeline {
pipeline_id: pipeline_id,

Просмотреть файл

@ -24,7 +24,7 @@ use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use texture_cache::TexturePage;
use util::{TransformedRect, TransformedRectKind};
use webrender_traits::{AuxiliaryLists, ClipAndScrollInfo, ClipId, ColorF, DeviceIntPoint};
use webrender_traits::{BuiltDisplayList, ClipAndScrollInfo, ClipId, ColorF, DeviceIntPoint};
use webrender_traits::{DeviceIntRect, DeviceIntSize, DeviceUintPoint, DeviceUintSize};
use webrender_traits::{ExternalImageType, FontRenderMode, ImageRendering, LayerPoint, LayerRect};
use webrender_traits::{LayerToWorldTransform, MixBlendMode, PipelineId, TransformStyle};
@ -36,9 +36,9 @@ use webrender_traits::{YuvColorSpace, YuvFormat};
const OPAQUE_TASK_INDEX: RenderTaskIndex = RenderTaskIndex(i32::MAX as usize);
pub type AuxiliaryListsMap = HashMap<PipelineId,
AuxiliaryLists,
BuildHasherDefault<FnvHasher>>;
pub type DisplayListMap = HashMap<PipelineId,
BuiltDisplayList,
BuildHasherDefault<FnvHasher>>;
trait AlphaBatchHelpers {
fn get_color_textures(&self, metadata: &PrimitiveMetadata) -> [SourceTexture; 3];

Просмотреть файл

@ -211,20 +211,6 @@ struct WrVecU8 {
}
};
struct WrAuxiliaryListsDescriptor {
size_t gradient_stops_size;
size_t complex_clip_regions_size;
size_t filters_size;
size_t glyph_instances_size;
bool operator==(const WrAuxiliaryListsDescriptor& aOther) const {
return gradient_stops_size == aOther.gradient_stops_size &&
complex_clip_regions_size == aOther.complex_clip_regions_size &&
filters_size == aOther.filters_size &&
glyph_instances_size == aOther.glyph_instances_size;
}
};
struct WrOpacityProperty {
uint64_t id;
float opacity;

Просмотреть файл

@ -12,6 +12,7 @@ webgl = ["offscreen_gl_context"]
[dependencies]
app_units = "0.4"
bincode = "1.0.0-alpha2"
byteorder = "1.0"
euclid = "0.11"
gleam = "0.4"

Просмотреть файл

@ -8,7 +8,7 @@ use offscreen_gl_context::{GLContextAttributes, GLLimits};
use std::cell::Cell;
use std::fmt;
use std::marker::PhantomData;
use {AuxiliaryLists, AuxiliaryListsDescriptor, BuiltDisplayList, BuiltDisplayListDescriptor};
use {BuiltDisplayList, BuiltDisplayListDescriptor};
use {ClipId, ColorF, DeviceIntPoint, DeviceIntSize, DeviceUintRect, DeviceUintSize, FontKey};
use {GlyphDimensions, GlyphKey, ImageData, ImageDescriptor, ImageKey, LayoutPoint, LayoutSize};
use {LayoutTransform, NativeFontHandle, WorldPoint};
@ -33,14 +33,12 @@ pub enum ApiMsg {
CloneApi(MsgSender<IdNamespace>),
/// Supplies a new frame to WebRender.
///
/// After receiving this message, WebRender will read the display list, followed by the
/// auxiliary lists, from the payload channel.
/// After receiving this message, WebRender will read the display list from the payload channel.
SetDisplayList(Option<ColorF>,
Epoch,
PipelineId,
LayoutSize,
BuiltDisplayListDescriptor,
AuxiliaryListsDescriptor,
bool),
SetPageZoom(ZoomFactor),
SetPinchZoom(ZoomFactor),
@ -294,7 +292,6 @@ impl RenderApi {
/// * `viewport_size`: The size of the viewport for this frame.
/// * `pipeline_id`: The ID of the pipeline that is supplying this display list.
/// * `display_list`: The root Display list used in this frame.
/// * `auxiliary_lists`: Various items that the display lists and stacking contexts reference.
/// * `preserve_frame_state`: If a previous frame exists which matches this pipeline
/// id, this setting determines if frame state (such as scrolling
/// position) should be preserved for this new display list.
@ -304,16 +301,14 @@ impl RenderApi {
background_color: Option<ColorF>,
epoch: Epoch,
viewport_size: LayoutSize,
(pipeline_id, display_list, auxiliary_lists): (PipelineId, BuiltDisplayList, AuxiliaryLists),
(pipeline_id, display_list): (PipelineId, BuiltDisplayList),
preserve_frame_state: bool) {
let (dl_data, dl_desc) = display_list.into_data();
let (aux_data, aux_desc) = auxiliary_lists.into_data();
let msg = ApiMsg::SetDisplayList(background_color,
epoch,
pipeline_id,
viewport_size,
dl_desc,
aux_desc,
preserve_frame_state);
self.api_sender.send(msg).unwrap();
@ -321,7 +316,6 @@ impl RenderApi {
epoch: epoch,
pipeline_id: pipeline_id,
display_list_data: dl_data,
auxiliary_lists_data: aux_data
}).unwrap();
}

Просмотреть файл

@ -18,7 +18,6 @@ pub struct Payload {
/// A pipeline id to key the payload with, along with the epoch.
pub pipeline_id: PipelineId,
pub display_list_data: Vec<u8>,
pub auxiliary_lists_data: Vec<u8>
}
impl Payload {
@ -31,16 +30,12 @@ impl Payload {
let mut data = Vec::with_capacity(mem::size_of::<u32>() +
2 * mem::size_of::<u32>() +
mem::size_of::<u64>() +
self.display_list_data.len() +
mem::size_of::<u64>() +
self.auxiliary_lists_data.len());
self.display_list_data.len());
data.write_u32::<LittleEndian>(self.epoch.0).unwrap();
data.write_u32::<LittleEndian>(self.pipeline_id.0).unwrap();
data.write_u32::<LittleEndian>(self.pipeline_id.1).unwrap();
data.write_u64::<LittleEndian>(self.display_list_data.len() as u64).unwrap();
data.extend_from_slice(&self.display_list_data);
data.write_u64::<LittleEndian>(self.auxiliary_lists_data.len() as u64).unwrap();
data.extend_from_slice(&self.auxiliary_lists_data);
data
}
@ -55,17 +50,13 @@ impl Payload {
let mut built_display_list_data = vec![0; dl_size];
payload_reader.read_exact(&mut built_display_list_data[..]).unwrap();
let aux_size = payload_reader.read_u64::<LittleEndian>().unwrap() as usize;
let mut auxiliary_lists_data = vec![0; aux_size];
payload_reader.read_exact(&mut auxiliary_lists_data[..]).unwrap();
// TODO(new-ipc): assert_eq!(payload_reader.position(), data.len() as u64);
assert_eq!(payload_reader.position(), data.len() as u64);
Payload {
epoch: epoch,
pipeline_id: pipeline_id,
display_list_data: built_display_list_data,
auxiliary_lists_data: auxiliary_lists_data,
}
}
}

Просмотреть файл

@ -4,11 +4,15 @@
use app_units::Au;
use euclid::SideOffsets2D;
use display_list::AuxiliaryListsBuilder;
use {ColorF, FontKey, ImageKey, PipelineId, WebGLContextId};
use {ColorF, FontKey, ImageKey, ItemRange, PipelineId, WebGLContextId};
use {LayoutPoint, LayoutRect, LayoutSize, LayoutTransform};
use {PropertyBinding};
// NOTE: some of these structs have an "IMPLICIT" comment.
// This indicates that the BuiltDisplayList will have serialized
// a list of values nearby that this item consumes. The traversal
// iterator should handle finding these.
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ClipAndScrollInfo {
pub scroll_node_id: ClipId,
@ -39,7 +43,6 @@ impl ClipAndScrollInfo {
pub struct DisplayItem {
pub item: SpecificDisplayItem,
pub rect: LayoutRect,
pub clip: ClipRegion,
pub clip_and_scroll: ClipAndScrollInfo,
}
@ -58,13 +61,8 @@ pub enum SpecificDisplayItem {
Iframe(IframeDisplayItem),
PushStackingContext(PushStackingContextDisplayItem),
PopStackingContext,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct ItemRange {
pub start: usize,
pub length: usize,
SetGradientStops,
SetClipRegion(ClipRegion),
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
@ -80,13 +78,12 @@ pub struct RectangleDisplayItem {
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct TextDisplayItem {
pub glyphs: ItemRange,
pub font_key: FontKey,
pub size: Au,
pub color: ColorF,
pub blur_radius: Au,
pub glyph_options: Option<GlyphOptions>,
}
} // IMPLICIT: glyphs: Vec<GlyphInstance>
#[derive(Clone, Copy, Debug, Deserialize, Hash, Eq, PartialEq, PartialOrd, Ord, Serialize)]
pub struct GlyphOptions {
@ -229,9 +226,8 @@ pub enum ExtendMode {
pub struct Gradient {
pub start_point: LayoutPoint,
pub end_point: LayoutPoint,
pub stops: ItemRange,
pub extend_mode: ExtendMode,
}
} // IMPLICIT: stops: Vec<GradientStop>
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct GradientDisplayItem {
@ -255,9 +251,8 @@ pub struct RadialGradient {
pub end_center: LayoutPoint,
pub end_radius: f32,
pub ratio_xy: f32,
pub stops: ItemRange,
pub extend_mode: ExtendMode,
}
} // IMPLICIT stops: Vec<GradientStop>
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct RadialGradientDisplayItem {
@ -278,8 +273,7 @@ pub struct StackingContext {
pub transform_style: TransformStyle,
pub perspective: Option<LayoutTransform>,
pub mix_blend_mode: MixBlendMode,
pub filters: ItemRange,
}
} // IMPLICIT: filters: Vec<FilterOp>
#[repr(u32)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
@ -423,9 +417,12 @@ pub struct ImageMask {
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct ClipRegion {
pub main: LayoutRect,
pub complex: ItemRange,
pub image_mask: Option<ImageMask>,
}
#[serde(default, skip_serializing, skip_deserializing)]
pub complex_clips: ItemRange<ComplexClipRegion>,
#[serde(default, skip_serializing, skip_deserializing)]
pub complex_clip_count: usize,
}
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct ComplexClipRegion {
@ -435,26 +432,6 @@ pub struct ComplexClipRegion {
pub radii: BorderRadius,
}
impl StackingContext {
pub fn new(scroll_policy: ScrollPolicy,
transform: Option<PropertyBinding<LayoutTransform>>,
transform_style: TransformStyle,
perspective: Option<LayoutTransform>,
mix_blend_mode: MixBlendMode,
filters: Vec<FilterOp>,
auxiliary_lists_builder: &mut AuxiliaryListsBuilder)
-> StackingContext {
StackingContext {
scroll_policy: scroll_policy,
transform: transform,
transform_style: transform_style,
perspective: perspective,
mix_blend_mode: mix_blend_mode,
filters: auxiliary_lists_builder.add_filters(&filters),
}
}
}
impl BorderRadius {
pub fn zero() -> BorderRadius {
BorderRadius {
@ -512,27 +489,36 @@ impl BorderRadius {
impl ClipRegion {
pub fn new(rect: &LayoutRect,
complex: Vec<ComplexClipRegion>,
image_mask: Option<ImageMask>,
auxiliary_lists_builder: &mut AuxiliaryListsBuilder)
image_mask: Option<ImageMask>)
-> ClipRegion {
ClipRegion {
main: *rect,
complex: auxiliary_lists_builder.add_complex_clip_regions(&complex),
image_mask: image_mask,
complex_clips: ItemRange::default(),
complex_clip_count: 0,
}
}
pub fn simple(rect: &LayoutRect) -> ClipRegion {
ClipRegion {
main: *rect,
complex: ItemRange::empty(),
image_mask: None,
complex_clips: ItemRange::default(),
complex_clip_count: 0,
}
}
pub fn empty() -> ClipRegion {
ClipRegion {
main: LayoutRect::zero(),
image_mask: None,
complex_clips: ItemRange::default(),
complex_clip_count: 0,
}
}
pub fn is_complex(&self) -> bool {
self.complex.length !=0 || self.image_mask.is_some()
self.complex_clip_count != 0 || self.image_mask.is_some()
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -6,6 +6,7 @@
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments, float_cmp))]
extern crate app_units;
extern crate bincode;
extern crate byteorder;
#[cfg(feature = "nightly")]
extern crate core;

1
toolkit/library/gtest/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -1044,6 +1044,7 @@ name = "webrender_traits"
version = "0.36.0"
dependencies = [
"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)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",

1
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -1031,6 +1031,7 @@ name = "webrender_traits"
version = "0.36.0"
dependencies = [
"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)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-foundation 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"core-graphics 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",