mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Generate only a single frame during "update the rendering" (#38858)
Instead of generating a frame for every display list, which might be one rendered frame per `<iframe>`, generate only a single frame per call to "update the rendering." This should make rendering more efficient when there are `<iframe>`s present and also open up optimizations for non-display list frames. Testing: This could potentially reduce flashing of content during rendering updates, but that is very difficult to test. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
4f68508624
commit
e7a963cca0
6 changed files with 40 additions and 10 deletions
|
@ -2111,6 +2111,9 @@ impl Window {
|
|||
// properly process ScrollBehavior here.
|
||||
let reflow_phases_run =
|
||||
self.reflow(ReflowGoal::UpdateScrollNode(scroll_id, Vector2D::new(x, y)));
|
||||
if reflow_phases_run.needs_frame() {
|
||||
self.compositor_api().generate_frame();
|
||||
}
|
||||
|
||||
// > If the scroll position did not change as a result of the user interaction or programmatic
|
||||
// > invocation, where no translations were applied as a result, then no scrollend event fires
|
||||
|
@ -2351,7 +2354,9 @@ impl Window {
|
|||
// iframe size updates.
|
||||
//
|
||||
// See <https://github.com/servo/servo/issues/14719>
|
||||
self.Document().update_the_rendering();
|
||||
if self.Document().update_the_rendering().needs_frame() {
|
||||
self.compositor_api().generate_frame();
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn layout_blocked(&self) -> bool {
|
||||
|
|
|
@ -67,9 +67,7 @@ use js::jsapi::{
|
|||
};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::ParentRuntime;
|
||||
use layout_api::{
|
||||
LayoutConfig, LayoutFactory, ReflowPhasesRun, RestyleReason, ScriptThreadFactory,
|
||||
};
|
||||
use layout_api::{LayoutConfig, LayoutFactory, RestyleReason, ScriptThreadFactory};
|
||||
use media::WindowGLContext;
|
||||
use metrics::MAX_TASK_NS;
|
||||
use net_traits::image_cache::{ImageCache, ImageCacheResponseMessage};
|
||||
|
@ -1118,7 +1116,7 @@ impl ScriptThread {
|
|||
// steps per doc in docs. Currently `<iframe>` resizing depends on a parent being able to
|
||||
// queue resize events on a child and have those run in the same call to this method, so
|
||||
// that needs to be sorted out to fix this.
|
||||
let mut built_any_display_lists = false;
|
||||
let mut should_generate_frame = false;
|
||||
for pipeline_id in documents_in_order.iter() {
|
||||
let document = self
|
||||
.documents
|
||||
|
@ -1201,19 +1199,21 @@ impl ScriptThread {
|
|||
|
||||
// > Step 22: For each doc of docs, update the rendering or user interface of
|
||||
// > doc and its node navigable to reflect the current state.
|
||||
built_any_display_lists = document
|
||||
.update_the_rendering()
|
||||
.contains(ReflowPhasesRun::BuiltDisplayList) ||
|
||||
built_any_display_lists;
|
||||
should_generate_frame =
|
||||
document.update_the_rendering().needs_frame() || should_generate_frame;
|
||||
|
||||
// TODO: Process top layer removals according to
|
||||
// https://drafts.csswg.org/css-position-4/#process-top-layer-removals.
|
||||
}
|
||||
|
||||
if should_generate_frame {
|
||||
self.compositor_api.generate_frame();
|
||||
}
|
||||
|
||||
// Perform a microtask checkpoint as the specifications says that *update the rendering*
|
||||
// should be run in a task and a microtask checkpoint is always done when running tasks.
|
||||
self.perform_a_microtask_checkpoint(can_gc);
|
||||
built_any_display_lists
|
||||
should_generate_frame
|
||||
}
|
||||
|
||||
/// Schedule a rendering update ("update the rendering"), if necessary. This
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue