Commit 0adb8b8d authored by Albert Chaulk's avatar Albert Chaulk Committed by Commit Bot

Change how exo handles draw quads

Occasionally the renderer will provide an invalid surface ID, so in
that case we use the previous valid ID. This also checks that the
embed token is the same between both versions and updates it if
necessary

This can happen when a webcontents loads a new page, the old surface
is deprecated but the new one isn't ready yet

Bug: b/143651420
Test: on device
Change-Id: I943d242f3acba3e2daf3fe69b5e3d469087df781
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1900094
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713128}
parent 1afc8398
...@@ -1029,20 +1029,24 @@ void Surface::AppendContentsToFrame(const gfx::Point& origin, ...@@ -1029,20 +1029,24 @@ void Surface::AppendContentsToFrame(const gfx::Point& origin,
// If this surface is being replaced by a SurfaceId emit a SurfaceDrawQuad. // If this surface is being replaced by a SurfaceId emit a SurfaceDrawQuad.
if (get_current_surface_id_) { if (get_current_surface_id_) {
auto current_surface_id = get_current_surface_id_.Run(); auto current_surface_id = get_current_surface_id_.Run();
// If the surface ID is valid update it, otherwise keep showing the old
// one for now.
if (current_surface_id.is_valid()) { if (current_surface_id.is_valid()) {
if (!first_embedded_surface_id_.is_valid()) latest_embedded_surface_id_ = current_surface_id;
if (!current_surface_id.HasSameEmbedTokenAs(
first_embedded_surface_id_)) {
first_embedded_surface_id_ = current_surface_id; first_embedded_surface_id_ = current_surface_id;
}
}
if (latest_embedded_surface_id_.is_valid()) {
viz::SurfaceDrawQuad* surface_quad = viz::SurfaceDrawQuad* surface_quad =
render_pass->CreateAndAppendDrawQuad<viz::SurfaceDrawQuad>(); render_pass->CreateAndAppendDrawQuad<viz::SurfaceDrawQuad>();
surface_quad->SetNew( surface_quad->SetNew(quad_state, quad_rect, quad_rect,
quad_state, quad_rect, quad_rect, viz::SurfaceRange(first_embedded_surface_id_,
viz::SurfaceRange(first_embedded_surface_id_, current_surface_id), latest_embedded_surface_id_),
background_color, background_color,
/*stretch_content_to_fill_bounds=*/true, /*stretch_content_to_fill_bounds=*/true,
/*ignores_input_event=*/false); /*ignores_input_event=*/false);
} else {
// If there is no valid surface, reset the start of the range.
first_embedded_surface_id_ = viz::SurfaceId();
} }
} else if (state_.alpha) { } else if (state_.alpha) {
// Texture quad is only needed if buffer is not fully transparent. // Texture quad is only needed if buffer is not fully transparent.
......
...@@ -447,6 +447,7 @@ class Surface final : public ui::PropertyHandler { ...@@ -447,6 +447,7 @@ class Surface final : public ui::PropertyHandler {
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
viz::SurfaceId first_embedded_surface_id_; viz::SurfaceId first_embedded_surface_id_;
viz::SurfaceId latest_embedded_surface_id_;
base::RepeatingCallback<viz::SurfaceId()> get_current_surface_id_; base::RepeatingCallback<viz::SurfaceId()> get_current_surface_id_;
DISALLOW_COPY_AND_ASSIGN(Surface); DISALLOW_COPY_AND_ASSIGN(Surface);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment