Chromium Code Reviews| Index: ui/aura/mus/window_port_mus.cc |
| diff --git a/ui/aura/mus/window_port_mus.cc b/ui/aura/mus/window_port_mus.cc |
| index f47ba8a4d07ea25f1a776da97c3c339e06d71e8a..4548e26eb9d2a777b1372a23cd8f27886fc50744 100644 |
| --- a/ui/aura/mus/window_port_mus.cc |
| +++ b/ui/aura/mus/window_port_mus.cc |
| @@ -8,6 +8,7 @@ |
| #include "components/viz/client/local_surface_id_provider.h" |
| #include "ui/aura/client/aura_constants.h" |
| #include "ui/aura/client/transient_window_client.h" |
| +#include "ui/aura/env.h" |
| #include "ui/aura/mus/client_surface_embedder.h" |
| #include "ui/aura/mus/property_converter.h" |
| #include "ui/aura/mus/window_tree_client.h" |
| @@ -306,18 +307,25 @@ const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( |
| if (frame_sink_id_.is_valid()) |
| UpdatePrimarySurfaceInfo(); |
| - return local_surface_id_; |
| -} |
| + if (local_compositor_frame_sink_) |
| + local_compositor_frame_sink_->SetLocalSurfaceId(local_surface_id_); |
| -void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { |
| - primary_surface_info_ = surface_info; |
| - UpdateClientSurfaceEmbedder(); |
| - if (window_->delegate()) |
| - window_->delegate()->OnWindowSurfaceChanged(surface_info); |
| + return local_surface_id_; |
| } |
| void WindowPortMus::SetFallbackSurfaceInfo( |
| const cc::SurfaceInfo& surface_info) { |
| + if (!frame_sink_id_.is_valid()) { |
| + // |primary_surface_info_| shold not be valid, since we didn't know the |
| + // |frame_sink_id_|. |
| + DCHECK(!primary_surface_info_.is_valid()); |
| + frame_sink_id_ = surface_info.id().frame_sink_id(); |
| + UpdatePrimarySurfaceInfo(); |
| + } |
| + |
| + // The frame sink id should never be changed. |
| + DCHECK_EQ(surface_info.id().frame_sink_id(), frame_sink_id_); |
| + |
| fallback_surface_info_ = surface_info; |
| UpdateClientSurfaceEmbedder(); |
| } |
| @@ -426,6 +434,10 @@ void WindowPortMus::NotifyEmbeddedAppDisconnected() { |
| observer.OnEmbeddedAppDisconnected(window_); |
| } |
| +bool WindowPortMus::HasLocalCompositorFrameSink() { |
| + return !!local_compositor_frame_sink_; |
| +} |
| + |
| void WindowPortMus::OnPreInit(Window* window) { |
| window_ = window; |
| window_tree_client_->OnWindowMusCreated(this); |
| @@ -521,38 +533,48 @@ void WindowPortMus::OnPropertyChanged(const void* key, |
| std::unique_ptr<cc::CompositorFrameSink> |
| WindowPortMus::CreateCompositorFrameSink() { |
| - // TODO(penghuang): Implement it for Mus. |
| - return nullptr; |
| + DCHECK_EQ(window_mus_type(), WindowMusType::LOCAL); |
| + DCHECK(!local_compositor_frame_sink_); |
| + auto frame_sink = RequestCompositorFrameSink( |
| + nullptr, |
| + aura::Env::GetInstance()->context_factory()->GetGpuMemoryBufferManager()); |
| + auto* viz_frame_sink = |
| + static_cast<viz::ClientCompositorFrameSink*>(frame_sink.get()); |
|
sky
2017/06/08 21:18:49
Why do you need the static_cast here?
Peng
2017/06/08 22:14:59
frame_sink is a cc:CFS. It doesn't have the GetWea
Fady Samuel
2017/06/08 22:16:45
Maybe create a "RequestCompositorFrameSinkInternal
Peng
2017/06/09 14:01:26
Done. By changing return type of RequestCompositor
|
| + local_compositor_frame_sink_ = viz_frame_sink->GetWeakPtr(); |
| + return frame_sink; |
| } |
| cc::SurfaceId WindowPortMus::GetSurfaceId() const { |
| - // TODO(penghuang): Implement it for Mus. |
| + // This is only used by WindowPortLocal in unit tests. |
| return cc::SurfaceId(); |
| } |
| void WindowPortMus::UpdatePrimarySurfaceInfo() { |
| - bool embeds_surface = |
| - window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| - window_mus_type() == WindowMusType::EMBED_IN_OWNER || |
| - window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED; |
| - if (!embeds_surface) |
| + if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM && |
| + window_mus_type() != WindowMusType::EMBED_IN_OWNER && |
| + window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED && |
| + window_mus_type() != WindowMusType::LOCAL) { |
| return; |
| + } |
| if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) |
| return; |
| - SetPrimarySurfaceInfo(cc::SurfaceInfo( |
| + primary_surface_info_ = cc::SurfaceInfo( |
| cc::SurfaceId(frame_sink_id_, local_surface_id_), |
| - ScaleFactorForDisplay(window_), last_surface_size_in_pixels_)); |
| + ScaleFactorForDisplay(window_), last_surface_size_in_pixels_); |
| + UpdateClientSurfaceEmbedder(); |
| + if (window_->delegate()) |
| + window_->delegate()->OnWindowSurfaceChanged(primary_surface_info_); |
| } |
| void WindowPortMus::UpdateClientSurfaceEmbedder() { |
| - bool embeds_surface = |
| - window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| - window_mus_type() == WindowMusType::EMBED_IN_OWNER || |
| - window_mus_type() == WindowMusType::DISPLAY_MANUALLY_CREATED; |
| - if (!embeds_surface) |
| + if (window_mus_type() != WindowMusType::TOP_LEVEL_IN_WM && |
| + window_mus_type() != WindowMusType::EMBED_IN_OWNER && |
| + window_mus_type() != WindowMusType::DISPLAY_MANUALLY_CREATED && |
| + window_mus_type() != WindowMusType::LOCAL) { |
| return; |
| + } |
| if (!client_surface_embedder_) { |
| client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( |