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

Introduce PicturePrimitive::Image. #2031

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

Always

Just for now

Next

Introduce PicturePrimitive::Image.

Instead of constructing the render task tree each render (from the
stacking context tree), construct a compositing tree during scene
building. We create a Picture primitive whenever we *may* need to
draw to an intermediate surface (i.e. filters, mix-blend-mode,
3d rendering contexts, frame output).

During culling, we can then make decisions on whether a Picture
does get drawn to an intermediate surface, or drawn directly
into the parent target (e.g. if perspective is present, or
if a child stacking context needs isolation due to mix-blend-mode).

This opens up fixes for a number of issues, such as avoiding
rebuilding the scene in the presence of property bindings, proper
pixel snapping and clip mask handling for composited stacking
contexts, fixing the context isolation bugs when multiple effects
are present in addition to 3D rendering contexts.

A consequence of this change is that plane splitting is handled
later in the frame, during batch generation. This simplfies a lot
of the plane splitting code.

* Remove StackingContext structures after scene is created. Instead, they
  are only used during scene building, and then we drop the concept of a
  stacking context completely and rely on the Picture tree only.

* Move output frame handling from build frame to build scene - so we
  can allocate Pictures based on this.

* Pass clip node ID to push_stacking_context - will be used to handle #1957.

* Move plane splitting to batch generation phase.

* Remove (as no longer used):
    build() step of PicturePrimitive.
    HardwareCompositeOp.
    notify_waiting_for_root_stacking_context().
    RenderTask::inflate (handled implicitly in Picture).
    AlphaRenderItem - We now just walk the primitive runs, saving memory allocations and duplication.
  • Loading branch information
gw3583 committed Nov 13, 2017
commit 6ca43c34cb60513db0690f64be2527301b442d69
@@ -90,11 +90,6 @@ void main(void) {
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

vec4 Blur(float radius, vec2 direction) {
// TODO(gw): Support blur in WR2!
return vec4(1.0);
}

vec4 Contrast(vec4 Cs, float amount) {
return vec4(Cs.rgb * amount - 0.5 * amount + 0.5, 1.0);
}
@@ -135,8 +130,7 @@ void main(void) {

switch (vOp) {
case 0:
// Gaussian blur is specially handled:
oFragColor = Cs;// Blur(vAmount, vec2(0,0));
oFragColor = Cs;
break;
case 1:
oFragColor = Contrast(Cs, vAmount);
@@ -109,6 +109,7 @@ impl FrameBuilder {
}),
);
} else {
let pipeline_id = self.sc_stack.last().unwrap().pipeline_id;
let blur_offset = BLUR_SAMPLE_SCALE * blur_radius;
let mut extra_clips = vec![];

@@ -185,13 +186,12 @@ impl FrameBuilder {
Vec::new(),
clip_mode,
radii_kind,
pipeline_id,
);
pic_prim.add_primitive(
brush_prim_index,
&brush_rect,
clip_and_scroll
);
pic_prim.build();

// TODO(gw): Right now, we always use a clip out
// mask for outset shadows. We can make this
@@ -264,13 +264,12 @@ impl FrameBuilder {
BoxShadowClipMode::Inset,
// TODO(gw): Make use of optimization for inset.
BorderRadiusKind::NonUniform,
pipeline_id,
);
pic_prim.add_primitive(
brush_prim_index,
&brush_rect,
clip_and_scroll
);
pic_prim.build();

// Draw the picture one pixel outside the original
// rect to account for the inflate above. This
@@ -87,22 +87,20 @@ impl<'a> FlattenContext<'a> {
frame_size: &LayoutSize,
root_reference_frame_id: ClipId,
root_scroll_frame_id: ClipId,
output_pipelines: &FastHashSet<PipelineId>,
) {
let clip_id = ClipId::root_scroll_node(pipeline_id);

self.builder.push_stacking_context(
&LayerVector2D::zero(),
pipeline_id,
CompositeOps::default(),
TransformStyle::Flat,
true,
true,
ClipAndScrollInfo::simple(clip_id),
output_pipelines,
);

// We do this here, rather than above because we want any of the top-level
// stacking contexts in the display list to be treated like root stacking contexts.
// FIXME(mrobinson): Currently only the first one will, which for the moment is
// sufficient for all our use cases.
self.builder.notify_waiting_for_root_stacking_context();

// For the root pipeline, there's no need to add a full screen rectangle
// here, as it's handled by the framebuffer clear.
if self.scene.root_pipeline_id != Some(pipeline_id) {
@@ -121,7 +119,12 @@ impl<'a> FlattenContext<'a> {
}


self.flatten_items(traversal, pipeline_id, LayerVector2D::zero());
self.flatten_items(
traversal,
pipeline_id,
LayerVector2D::zero(),
output_pipelines,
);

if self.builder.config.enable_scrollbars {
let scrollbar_rect = LayerRect::new(LayerPoint::zero(), LayerSize::new(10.0, 70.0));
@@ -142,6 +145,7 @@ impl<'a> FlattenContext<'a> {
traversal: &mut BuiltDisplayListIter<'a>,
pipeline_id: PipelineId,
reference_frame_relative_offset: LayerVector2D,
output_pipelines: &FastHashSet<PipelineId>,
) {
loop {
let subtraversal = {
@@ -154,7 +158,12 @@ impl<'a> FlattenContext<'a> {
return;
}

self.flatten_item(item, pipeline_id, reference_frame_relative_offset)
self.flatten_item(
item,
pipeline_id,
reference_frame_relative_offset,
output_pipelines,
)
};

// If flatten_item created a sub-traversal, we need `traversal` to have the
@@ -221,6 +230,7 @@ impl<'a> FlattenContext<'a> {
stacking_context: &StackingContext,
filters: ItemRange<FilterOp>,
is_backface_visible: bool,
output_pipelines: &FastHashSet<PipelineId>,
) {
// Avoid doing unnecessary work for empty stacking contexts.
if traversal.current_stacking_context_empty() {
@@ -257,7 +267,7 @@ impl<'a> FlattenContext<'a> {
// that fixed position stacking contexts are positioned relative to us.
let is_reference_frame =
stacking_context.transform.is_some() || stacking_context.perspective.is_some();
if is_reference_frame {
let sc_scroll_node_id = if is_reference_frame {
let transform = stacking_context.transform.as_ref();
let transform = self.scene.properties.resolve_layout_transform(transform);
let perspective = stacking_context
@@ -281,26 +291,32 @@ impl<'a> FlattenContext<'a> {
);
self.replacements.push((context_scroll_node_id, clip_id));
reference_frame_relative_offset = LayerVector2D::zero();

clip_id
} else {
reference_frame_relative_offset = LayerVector2D::new(
reference_frame_relative_offset.x + bounds.origin.x,
reference_frame_relative_offset.y + bounds.origin.y,
);
}

context_scroll_node_id
};

self.builder.push_stacking_context(
&reference_frame_relative_offset,
pipeline_id,
composition_operations,
stacking_context.transform_style,
is_backface_visible,
false,
ClipAndScrollInfo::simple(sc_scroll_node_id),
output_pipelines,
);

self.flatten_items(
traversal,
pipeline_id,
reference_frame_relative_offset,
output_pipelines,
);

if stacking_context.scroll_policy == ScrollPolicy::Fixed {
@@ -322,6 +338,7 @@ impl<'a> FlattenContext<'a> {
bounds: &LayerRect,
local_clip: &LocalClip,
reference_frame_relative_offset: LayerVector2D,
output_pipelines: &FastHashSet<PipelineId>,
) {
let pipeline = match self.scene.pipelines.get(&pipeline_id) {
Some(pipeline) => pipeline,
@@ -374,6 +391,7 @@ impl<'a> FlattenContext<'a> {
&iframe_rect.size,
iframe_reference_frame_id,
ClipId::root_scroll_node(pipeline_id),
output_pipelines,
);

self.builder.pop_reference_frame();
@@ -384,6 +402,7 @@ impl<'a> FlattenContext<'a> {
item: DisplayItemRef<'a, 'b>,
pipeline_id: PipelineId,
reference_frame_relative_offset: LayerVector2D,
output_pipelines: &FastHashSet<PipelineId>,
) -> Option<BuiltDisplayListIter<'a>> {
let mut clip_and_scroll = item.clip_and_scroll();

@@ -548,6 +567,7 @@ impl<'a> FlattenContext<'a> {
&info.stacking_context,
item.filters(),
prim_info.is_backface_visible,
output_pipelines,
);
return Some(subtraversal);
}
@@ -558,6 +578,7 @@ impl<'a> FlattenContext<'a> {
&item.rect(),
&item.local_clip(),
reference_frame_relative_offset,
output_pipelines,
);
}
SpecificDisplayItem::Clip(ref info) => {
@@ -1088,6 +1109,7 @@ impl FrameContext {
window_size: DeviceUintSize,
inner_rect: DeviceUintRect,
device_pixel_ratio: f32,
output_pipelines: &FastHashSet<PipelineId>,
) -> Option<FrameBuilder> {
let root_pipeline_id = match scene.root_pipeline_id {
Some(root_pipeline_id) => root_pipeline_id,
@@ -1152,8 +1174,11 @@ impl FrameContext {
&root_pipeline.viewport_size,
reference_frame_id,
scroll_frame_id,
output_pipelines,
);

debug_assert!(roller.builder.picture_stack.is_empty());

self.pipeline_epoch_map.extend(roller.pipeline_epochs.drain(..));
roller.builder
};
@@ -1180,7 +1205,6 @@ impl FrameContext {
pipelines: &FastHashMap<PipelineId, ScenePipeline>,
device_pixel_ratio: f32,
pan: LayerPoint,
output_pipelines: &FastHashSet<PipelineId>,
texture_cache_profile: &mut TextureCacheProfileCounters,
gpu_cache_profile: &mut GpuCacheProfileCounters,
) -> RendererFrame {
@@ -1192,7 +1216,6 @@ impl FrameContext {
pipelines,
device_pixel_ratio,
pan,
output_pipelines,
texture_cache_profile,
gpu_cache_profile,
);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.