Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify display list construction in the API #592

Merged
merged 3 commits into from Nov 28, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Move more details into DisplayListBuilder

Bookkeeping for pipeline_id and the current scroll layer id is logic
that is shared among all clients. We can just move this into
DisplayListBuilder.
  • Loading branch information
mrobinson committed Nov 25, 2016
commit 5be4382515dfbdf0e393ab41b45ef94c6fcead45
@@ -32,11 +32,6 @@ impl Notifier {
}
}

pub struct WebRenderFrameBuilder {
pub root_pipeline_id: PipelineId,
pub next_scroll_layer_id: usize,
}

impl webrender_traits::RenderNotifier for Notifier {
fn new_frame_ready(&mut self) {
self.window_proxy.wakeup_event_loop();
@@ -101,11 +96,11 @@ fn main() {
let notifier = Box::new(Notifier::new(window.create_window_proxy()));
renderer.set_render_notifier(notifier);

let pipeline_id = PipelineId(0, 0);
let epoch = Epoch(0);
let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);

let mut builder = webrender_traits::DisplayListBuilder::new();
let pipeline_id = PipelineId(0, 0);
let mut builder = webrender_traits::DisplayListBuilder::new(pipeline_id);

let bounds = Rect::new(Point2D::new(0.0, 0.0), Size2D::new(width as f32, height as f32));
builder.push_stacking_context(webrender_traits::ScrollPolicy::Scrollable,
@@ -205,7 +200,6 @@ fn main() {
api.set_root_display_list(
root_background_color,
epoch,
pipeline_id,
Size2D::new(width as f32, height as f32),
builder);
api.set_root_pipeline(pipeline_id);
@@ -165,9 +165,9 @@ impl RenderApi {
pub fn set_root_display_list(&self,
background_color: ColorF,
epoch: Epoch,
pipeline_id: PipelineId,
viewport_size: Size2D<f32>,
builder: DisplayListBuilder) {
let pipeline_id = builder.pipeline_id;
let (display_list, auxiliary_lists) = builder.finalize();
let msg = ApiMsg::SetRootDisplayList(background_color,
epoch,
@@ -13,8 +13,8 @@ use {DisplayItem, DisplayListMode, FilterOp, YuvColorSpace};
use {FontKey, GlyphInstance, GradientDisplayItem, GradientStop, IframeDisplayItem};
use {ImageDisplayItem, ImageKey, ImageMask, ImageRendering, ItemRange, MixBlendMode, PipelineId};
use {PushScrollLayerItem, PushStackingContextDisplayItem, RectangleDisplayItem, ScrollLayerId};
use {ScrollPolicy, SpecificDisplayItem, StackingContext, TextDisplayItem, WebGLContextId};
use {WebGLDisplayItem, YuvImageDisplayItem};
use {ScrollPolicy, ServoScrollRootId, SpecificDisplayItem, StackingContext, TextDisplayItem};
use {WebGLContextId, WebGLDisplayItem, YuvImageDisplayItem};

impl BuiltDisplayListDescriptor {
pub fn size(&self) -> usize {
@@ -49,14 +49,18 @@ pub struct DisplayListBuilder {
pub mode: DisplayListMode,
pub list: Vec<DisplayItem>,
auxiliary_lists_builder: AuxiliaryListsBuilder,
pub pipeline_id: PipelineId,
next_scroll_layer_id: usize,
}

impl DisplayListBuilder {
pub fn new() -> DisplayListBuilder {
pub fn new(pipeline_id: PipelineId) -> DisplayListBuilder {
DisplayListBuilder {
mode: DisplayListMode::Default,
list: Vec::new(),
auxiliary_lists_builder: AuxiliaryListsBuilder::new(),
pipeline_id: pipeline_id,
next_scroll_layer_id: 0,
}
}

@@ -292,10 +296,13 @@ impl DisplayListBuilder {
pub fn push_scroll_layer(&mut self,
clip: Rect<f32>,
content_size: Size2D<f32>,
id: ScrollLayerId) {
scroll_root_id: ServoScrollRootId) {
let scroll_layer_id = self.next_scroll_layer_id;
self.next_scroll_layer_id += 1;

let item = PushScrollLayerItem {
content_size: content_size,
id: id,
id: ScrollLayerId::new(self.pipeline_id, scroll_layer_id, scroll_root_id),
};

let item = DisplayItem {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.