| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/aura/mus/window_port_mus.h" | 5 #include "ui/aura/mus/window_port_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/client/aura_constants.h" | 8 #include "ui/aura/client/aura_constants.h" |
| 9 #include "ui/aura/client/transient_window_client.h" | 9 #include "ui/aura/client/transient_window_client.h" |
| 10 #include "ui/aura/mus/client_surface_embedder.h" | 10 #include "ui/aura/mus/client_surface_embedder.h" |
| 11 #include "ui/aura/mus/property_converter.h" | 11 #include "ui/aura/mus/property_converter.h" |
| 12 #include "ui/aura/mus/window_tree_client.h" | 12 #include "ui/aura/mus/window_tree_client.h" |
| 13 #include "ui/aura/mus/window_tree_client_delegate.h" | 13 #include "ui/aura/mus/window_tree_client_delegate.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_delegate.h" | 15 #include "ui/aura/window_delegate.h" |
| 16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/base/class_property.h" | 17 #include "ui/base/class_property.h" |
| 18 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
| 19 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
| 20 #include "ui/gfx/geometry/dip_util.h" |
| 20 | 21 |
| 21 namespace aura { | 22 namespace aura { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 // Helper function to get the device_scale_factor() of the display::Display | 25 // Helper function to get the device_scale_factor() of the display::Display |
| 25 // nearest to |window|. | 26 // nearest to |window|. |
| 26 float ScaleFactorForDisplay(Window* window) { | 27 float ScaleFactorForDisplay(Window* window) { |
| 27 return display::Screen::GetScreen() | 28 return display::Screen::GetScreen() |
| 28 ->GetDisplayNearestWindow(window) | 29 ->GetDisplayNearestWindow(window) |
| 29 .device_scale_factor(); | 30 .device_scale_factor(); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 else | 242 else |
| 242 window_->StackChildAbove(child->GetWindow(), relative->GetWindow()); | 243 window_->StackChildAbove(child->GetWindow(), relative->GetWindow()); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void WindowPortMus::SetBoundsFromServer( | 246 void WindowPortMus::SetBoundsFromServer( |
| 246 const gfx::Rect& bounds, | 247 const gfx::Rect& bounds, |
| 247 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 248 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
| 248 ServerChangeData data; | 249 ServerChangeData data; |
| 249 data.bounds_in_dip = bounds; | 250 data.bounds_in_dip = bounds; |
| 250 ScopedServerChange change(this, ServerChangeType::BOUNDS, data); | 251 ScopedServerChange change(this, ServerChangeType::BOUNDS, data); |
| 251 last_surface_size_ = bounds.size(); | 252 float device_scale_factor = ScaleFactorForDisplay(window_); |
| 253 last_surface_size_in_pixels_ = |
| 254 gfx::ConvertSizeToPixel(device_scale_factor, bounds.size()); |
| 252 if (local_surface_id) | 255 if (local_surface_id) |
| 253 local_surface_id_ = *local_surface_id; | 256 local_surface_id_ = *local_surface_id; |
| 254 else | 257 else |
| 255 local_surface_id_ = cc::LocalSurfaceId(); | 258 local_surface_id_ = cc::LocalSurfaceId(); |
| 256 window_->SetBounds(bounds); | 259 window_->SetBounds(bounds); |
| 257 } | 260 } |
| 258 | 261 |
| 259 void WindowPortMus::SetVisibleFromServer(bool visible) { | 262 void WindowPortMus::SetVisibleFromServer(bool visible) { |
| 260 ServerChangeData data; | 263 ServerChangeData data; |
| 261 data.visible = visible; | 264 data.visible = visible; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // CompositorFrameSinks. | 297 // CompositorFrameSinks. |
| 295 DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type()); | 298 DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type()); |
| 296 DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type()); | 299 DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type()); |
| 297 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); | 300 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); |
| 298 return; | 301 return; |
| 299 } | 302 } |
| 300 UpdatePrimarySurfaceInfo(); | 303 UpdatePrimarySurfaceInfo(); |
| 301 } | 304 } |
| 302 | 305 |
| 303 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( | 306 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( |
| 304 const gfx::Size& surface_size) { | 307 const gfx::Size& surface_size_in_pixels) { |
| 305 if (last_surface_size_ == surface_size && local_surface_id_.is_valid()) | 308 if (last_surface_size_in_pixels_ == surface_size_in_pixels && |
| 309 local_surface_id_.is_valid()) { |
| 306 return local_surface_id_; | 310 return local_surface_id_; |
| 311 } |
| 307 | 312 |
| 308 local_surface_id_ = local_surface_id_allocator_.GenerateId(); | 313 local_surface_id_ = local_surface_id_allocator_.GenerateId(); |
| 309 last_surface_size_ = surface_size; | 314 last_surface_size_in_pixels_ = surface_size_in_pixels; |
| 310 | 315 |
| 311 // If surface synchronization is enabled and the FrameSinkId is available, | 316 // If surface synchronization is enabled and the FrameSinkId is available, |
| 312 // then immediately embed the SurfaceId. The newly generated frame by the | 317 // then immediately embed the SurfaceId. The newly generated frame by the |
| 313 // embedder will block in the display compositor until the child submits a | 318 // embedder will block in the display compositor until the child submits a |
| 314 // corresponding CompositorFrame or a deadline hits. | 319 // corresponding CompositorFrame or a deadline hits. |
| 315 if (window_tree_client_->enable_surface_synchronization_ && | 320 if (window_tree_client_->enable_surface_synchronization_ && |
| 316 frame_sink_id_.is_valid()) { | 321 frame_sink_id_.is_valid()) { |
| 317 UpdatePrimarySurfaceInfo(); | 322 UpdatePrimarySurfaceInfo(); |
| 318 } | 323 } |
| 319 | 324 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 527 |
| 523 void WindowPortMus::UpdatePrimarySurfaceInfo() { | 528 void WindowPortMus::UpdatePrimarySurfaceInfo() { |
| 524 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || | 529 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| 525 window_mus_type() == WindowMusType::EMBED_IN_OWNER; | 530 window_mus_type() == WindowMusType::EMBED_IN_OWNER; |
| 526 if (!embeds_surface || !window_tree_client_->enable_surface_synchronization_) | 531 if (!embeds_surface || !window_tree_client_->enable_surface_synchronization_) |
| 527 return; | 532 return; |
| 528 | 533 |
| 529 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) | 534 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid()) |
| 530 return; | 535 return; |
| 531 | 536 |
| 532 SetPrimarySurfaceInfo( | 537 SetPrimarySurfaceInfo(cc::SurfaceInfo( |
| 533 cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_), | 538 cc::SurfaceId(frame_sink_id_, local_surface_id_), |
| 534 ScaleFactorForDisplay(window_), last_surface_size_)); | 539 ScaleFactorForDisplay(window_), last_surface_size_in_pixels_)); |
| 535 } | 540 } |
| 536 | 541 |
| 537 void WindowPortMus::UpdateClientSurfaceEmbedder() { | 542 void WindowPortMus::UpdateClientSurfaceEmbedder() { |
| 538 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || | 543 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM || |
| 539 window_mus_type() == WindowMusType::EMBED_IN_OWNER; | 544 window_mus_type() == WindowMusType::EMBED_IN_OWNER; |
| 540 if (!embeds_surface) | 545 if (!embeds_surface) |
| 541 return; | 546 return; |
| 542 | 547 |
| 543 if (!client_surface_embedder_) { | 548 if (!client_surface_embedder_) { |
| 544 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( | 549 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>( |
| 545 window_, window_tree_client_->normal_client_area_insets_); | 550 window_, window_tree_client_->normal_client_area_insets_); |
| 546 } | 551 } |
| 547 | 552 |
| 548 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); | 553 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); |
| 549 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); | 554 client_surface_embedder_->SetFallbackSurfaceInfo(fallback_surface_info_); |
| 550 } | 555 } |
| 551 | 556 |
| 552 } // namespace aura | 557 } // namespace aura |
| OLD | NEW |