Commit 5f4298e4 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

aura: cache FrameSinkId rather than relying on member

The current code is problematic because it's assuming
Window::SetEmbedFrameSinkId() synchronously calls
WindowPort::RegisterFrameSinkId(). That isn't necessarily the case as
Window calls RegisterFrameSinkId() when parented to a valid root. The fix
is to cache the FrameSinkId and compare against it.

BUG=none
TEST=none

Change-Id: Ib49b044921868ccca8c5feaba1d8a8716939bd28
Reviewed-on: https://chromium-review.googlesource.com/1240745Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593702}
parent d2d64c9f
......@@ -312,10 +312,8 @@ void WindowPortMus::SetPropertyFromServer(
void WindowPortMus::SetFrameSinkIdFromServer(
const viz::FrameSinkId& frame_sink_id) {
DCHECK(window_mus_type() == WindowMusType::EMBED_IN_OWNER);
{
base::AutoReset<bool> resetter(&is_setting_embed_frame_sink_id_, true);
window_->SetEmbedFrameSinkId(frame_sink_id);
}
embed_frame_sink_id_ = frame_sink_id;
window_->SetEmbedFrameSinkId(embed_frame_sink_id_);
UpdatePrimarySurfaceId();
}
......@@ -346,10 +344,8 @@ void WindowPortMus::SetFallbackSurfaceInfo(
// |primary_surface_id_| should not be valid, since we didn't know the
// |window_->frame_sink_id()|.
DCHECK(!primary_surface_id_.is_valid());
{
base::AutoReset<bool> resetter(&is_setting_embed_frame_sink_id_, true);
window_->SetEmbedFrameSinkId(surface_info.id().frame_sink_id());
}
embed_frame_sink_id_ = surface_info.id().frame_sink_id();
window_->SetEmbedFrameSinkId(embed_frame_sink_id_);
UpdatePrimarySurfaceId();
}
......@@ -592,10 +588,8 @@ WindowPortMus::CreateLayerTreeFrameSink() {
auto client_layer_tree_frame_sink = RequestLayerTreeFrameSink(
nullptr, window_->env()->context_factory()->GetGpuMemoryBufferManager());
local_layer_tree_frame_sink_ = client_layer_tree_frame_sink->GetWeakPtr();
{
base::AutoReset<bool> resetter(&is_setting_embed_frame_sink_id_, true);
window_->SetEmbedFrameSinkId(GenerateFrameSinkIdFromServerId());
}
embed_frame_sink_id_ = GenerateFrameSinkIdFromServerId();
window_->SetEmbedFrameSinkId(embed_frame_sink_id_);
gfx::Size size_in_pixel =
gfx::ConvertSizeToPixel(GetDeviceScaleFactor(), window_->bounds().size());
......@@ -614,7 +608,7 @@ bool WindowPortMus::ShouldRestackTransientChildren() {
}
void WindowPortMus::RegisterFrameSinkId(const viz::FrameSinkId& frame_sink_id) {
if (is_setting_embed_frame_sink_id_)
if (frame_sink_id == embed_frame_sink_id_)
return;
window_tree_client_->RegisterFrameSinkId(this, frame_sink_id);
......@@ -622,7 +616,7 @@ void WindowPortMus::RegisterFrameSinkId(const viz::FrameSinkId& frame_sink_id) {
void WindowPortMus::UnregisterFrameSinkId(
const viz::FrameSinkId& frame_sink_id) {
if (is_setting_embed_frame_sink_id_)
if (frame_sink_id == embed_frame_sink_id_)
return;
window_tree_client_->UnregisterFrameSinkId(this);
......
......@@ -313,8 +313,8 @@ class AURA_EXPORT WindowPortMus : public WindowPort, public WindowMus {
ui::CursorData cursor_;
// Set to true if SetEmbedFrameSinkId() is being called on the Window.
bool is_setting_embed_frame_sink_id_ = false;
// Set if this class calls SetEmbedFrameSinkId() on the associated window.
viz::FrameSinkId embed_frame_sink_id_;
// See description in single place that changes the value for details.
bool should_restack_transient_children_ = true;
......
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