Skip to content

Commit 752af95

Browse files
author
bors-servo
authored
Auto merge of #3507 - moz-gfx:__wrlastsync, r=moz-gfx
Sync changes from mozilla-central <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3507) <!-- Reviewable:end -->
2 parents fdffba8 + a6497f6 commit 752af95

File tree

8 files changed

+586
-410
lines changed

8 files changed

+586
-410
lines changed

webrender/src/batch.rs

Lines changed: 39 additions & 36 deletions
Large diffs are not rendered by default.

webrender/src/clip.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,21 @@ pub struct ClipChainInstance {
462462
pub pic_clip_rect: PictureRect,
463463
}
464464

465+
impl ClipChainInstance {
466+
pub fn empty() -> Self {
467+
ClipChainInstance {
468+
clips_range: ClipNodeRange {
469+
first: 0,
470+
count: 0,
471+
},
472+
local_clip_rect: LayoutRect::zero(),
473+
has_non_local_clips: false,
474+
needs_mask: false,
475+
pic_clip_rect: PictureRect::zero(),
476+
}
477+
}
478+
}
479+
465480
impl ClipStore {
466481
pub fn new() -> Self {
467482
ClipStore {

webrender/src/frame_builder.rs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ pub struct FrameBuilder {
7070
pub config: FrameBuilderConfig,
7171
}
7272

73+
pub struct FrameVisibilityContext<'a> {
74+
pub clip_scroll_tree: &'a ClipScrollTree,
75+
pub screen_world_rect: WorldRect,
76+
pub device_pixel_scale: DevicePixelScale,
77+
pub surfaces: &'a [SurfaceInfo],
78+
}
79+
80+
pub struct FrameVisibilityState<'a> {
81+
pub clip_store: &'a mut ClipStore,
82+
pub resource_cache: &'a mut ResourceCache,
83+
pub gpu_cache: &'a mut GpuCache,
84+
pub scratch: &'a mut PrimitiveScratchBuffer,
85+
}
86+
7387
pub struct FrameBuildingContext<'a> {
7488
pub device_pixel_scale: DevicePixelScale,
7589
pub scene_properties: &'a SceneProperties,
@@ -198,6 +212,16 @@ impl FrameBuilder {
198212
self.prim_store.destroy(
199213
retained_tiles,
200214
);
215+
216+
// In general, the pending retained tiles are consumed by the frame
217+
// builder the first time a frame is built after a new scene has
218+
// arrived. However, if two scenes arrive in quick succession, the
219+
// frame builder may not have had a chance to build a frame and
220+
// consume the pending tiles. In this case, the pending tiles will
221+
// be lost, causing a full invalidation of the entire screen. To
222+
// avoid this, if there are still pending tiles, include them in
223+
// the retained tiles passed to the next frame builder.
224+
retained_tiles.tiles.extend(self.pending_retained_tiles.tiles);
201225
}
202226

203227
/// Compute the contribution (bounding rectangles, and resources) of layers and their
@@ -295,6 +319,30 @@ impl FrameBuilder {
295319
scratch,
296320
);
297321

322+
{
323+
let visibility_context = FrameVisibilityContext {
324+
device_pixel_scale,
325+
clip_scroll_tree,
326+
screen_world_rect,
327+
surfaces: pic_update_state.surfaces,
328+
};
329+
330+
let mut visibility_state = FrameVisibilityState {
331+
resource_cache,
332+
gpu_cache,
333+
clip_store: &mut self.clip_store,
334+
scratch,
335+
};
336+
337+
self.prim_store.update_visibility(
338+
self.root_pic_index,
339+
ROOT_SURFACE_INDEX,
340+
&visibility_context,
341+
&mut visibility_state,
342+
resources,
343+
);
344+
}
345+
298346
let mut frame_state = FrameBuildingState {
299347
render_tasks,
300348
profile_counters,
@@ -336,7 +384,6 @@ impl FrameBuilder {
336384
prim_list,
337385
pic_context,
338386
pic_state,
339-
&mut frame_state,
340387
);
341388

342389
let child_tasks = frame_state

webrender/src/lib.rs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,33 @@ but it can also be used as such in a standalone application.
1212
WebRender currently depends on [FreeType](https://www.freetype.org/)
1313
1414
# Api Structure
15-
The main entry point to WebRender is the `webrender::Renderer`.
15+
The main entry point to WebRender is the [`crate::Renderer`].
1616
17-
By calling `Renderer::new(...)` you get a `Renderer`, as well as a `RenderApiSender`.
18-
Your `Renderer` is responsible to render the previously processed frames onto the screen.
17+
By calling [`Renderer::new(...)`](crate::Renderer::new) you get a [`Renderer`], as well as
18+
a [`RenderApiSender`](api::RenderApiSender). Your [`Renderer`] is responsible to render the
19+
previously processed frames onto the screen.
1920
20-
By calling `yourRenderApiSender.create_api()`, you'll get a `RenderApi` instance,
21-
which is responsible for managing resources and documents. A worker thread is used internally
22-
to untie the workload from the application thread and therefore be able to make better use of
23-
multicore systems.
21+
By calling [`yourRenderApiSender.create_api()`](api::RenderApiSender::create_api), you'll
22+
get a [`RenderApi`](api::RenderApi) instance, which is responsible for managing resources
23+
and documents. A worker thread is used internally to untie the workload from the application
24+
thread and therefore be able to make better use of multicore systems.
2425
2526
## Frame
2627
2728
What is referred to as a `frame`, is the current geometry on the screen.
28-
A new Frame is created by calling [`set_display_list()`][newframe] on the `RenderApi`.
29-
When the geometry is processed, the application will be informed via a `RenderNotifier`,
30-
a callback which you employ with [set_render_notifier][notifier] on the `Renderer`
29+
A new Frame is created by calling [`set_display_list()`](api::Transaction::set_display_list)
30+
on the [`RenderApi`](api::RenderApi). When the geometry is processed, the application will be
31+
informed via a [`RenderNotifier`](api::RenderNotifier), a callback which you pass to
32+
[`Renderer::new`].
3133
More information about [stacking contexts][stacking_contexts].
3234
33-
`set_display_list()` also needs to be supplied with `BuiltDisplayList`s.
34-
These are obtained by finalizing a `DisplayListBuilder`. These are used to draw your geometry.
35-
But it doesn't only contain trivial geometry, it can also store another StackingContext, as
36-
they're nestable.
35+
[`set_display_list()`](api::Transaction::set_display_list) also needs to be supplied with
36+
[`BuiltDisplayList`](api::BuiltDisplayList)s. These are obtained by finalizing a
37+
[`DisplayListBuilder`](api::DisplayListBuilder). These are used to draw your geometry. But it
38+
doesn't only contain trivial geometry, it can also store another
39+
[`StackingContext`](api::StackingContext), as they're nestable.
3740
3841
[stacking_contexts]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context
39-
[newframe]: ../webrender_api/struct.RenderApi.html#method.set_display_list
40-
[notifier]: renderer/struct.Renderer.html#method.set_render_notifier
4142
*/
4243

4344
// Cribbed from the |matches| crate, for simplicity.

0 commit comments

Comments
 (0)