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 e95980110ddaace3857bfceea00b377d889d60a2..cfd1ebb2d77fa4e6cfc96647298525d5e8ece18e 100644 |
| --- a/ui/aura/mus/window_port_mus.cc |
| +++ b/ui/aura/mus/window_port_mus.cc |
| @@ -15,9 +15,21 @@ |
| #include "ui/aura/window_delegate.h" |
| #include "ui/aura/window_observer.h" |
| #include "ui/base/class_property.h" |
| +#include "ui/display/display.h" |
| +#include "ui/display/screen.h" |
| namespace aura { |
| +namespace { |
| +// Helper function to get the device_scale_factor() of the display::Display |
| +// nearest to |window|. |
| +float ScaleFactorForDisplay(Window* window) { |
| + return display::Screen::GetScreen() |
| + ->GetDisplayNearestWindow(window) |
| + .device_scale_factor(); |
| +} |
| +} // namespace |
| + |
| WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default; |
| WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default; |
| @@ -284,10 +296,16 @@ void WindowPortMus::SetFrameSinkIdFromServer( |
| DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type()); |
| DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type()); |
| base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); |
| + return; |
| + } |
| + if ((window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| + window_mus_type() == WindowMusType::EMBED_IN_OWNER) && |
| + local_surface_id_.is_valid()) { |
| + cc::SurfaceInfo surface_info( |
| + cc::SurfaceId(frame_sink_id_, local_surface_id_), |
| + ScaleFactorForDisplay(window_), window_->bounds().size()); |
| + SetPrimarySurfaceInfo(surface_info); |
| } |
| - // TODO(fsamuel): If the window type is TOP_LEVEL_IN_WM or EMBED_IN_OWNER then |
| - // we should check if we have a cc::LocalSurfaeId ready as well. If we do, |
| - // then we are ready to embed. |
| } |
| const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( |
| @@ -298,10 +316,19 @@ const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( |
| local_surface_id_ = local_surface_id_allocator_.GenerateId(); |
| last_surface_size_ = surface_size; |
| - // TODO(fsamuel): If surface synchronization is enabled and the FrameSinkId |
| - // is available, then immediately embed the SurfaceId. The newly generated |
| - // frame by the embedder will block in the display compositor until the |
| - // child submits a corresponding CompositorFrame or a deadline hits. |
| + // If surface synchronization is enabled and the FrameSinkId is available, |
| + // then immediately embed the SurfaceId. The newly generated frame by the |
| + // embedder will block in the display compositor until the child submits a |
| + // corresponding CompositorFrame or a deadline hits. |
| + if (window_tree_client_->enable_surface_synchronization_ && |
| + frame_sink_id_.is_valid()) { |
| + DCHECK(window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| + window_mus_type() == WindowMusType::EMBED_IN_OWNER); |
| + cc::SurfaceInfo surface_info( |
| + cc::SurfaceId(frame_sink_id_, local_surface_id_), |
| + ScaleFactorForDisplay(window_), surface_size); |
| + SetPrimarySurfaceInfo(surface_info); |
| + } |
|
sadrul
2017/03/31 01:26:20
Can we have a method that does this? e.g.
void
Fady Samuel
2017/03/31 01:57:43
Done.
|
| return local_surface_id_; |
| } |
| @@ -311,6 +338,12 @@ void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { |
| UpdatePrimarySurfaceInfoInternal(); |
| } |
| +void WindowPortMus::SetFallbackSurfaceInfo( |
| + const cc::SurfaceInfo& surface_info) { |
| + DCHECK(client_surface_embedder_); |
| + client_surface_embedder_->SetFallbackSurfaceInfo(surface_info); |
|
sadrul
2017/03/31 01:26:20
What happens if the window is hidden + shown after
Fady Samuel
2017/03/31 01:57:43
The fallback surface is lost (it is no longer refe
|
| +} |
| + |
| void WindowPortMus::DestroyFromServer() { |
| std::unique_ptr<ScopedServerChange> remove_from_parent_change; |
| if (window_->parent()) { |