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