Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(258)

Side by Side Diff: ui/aura/mus/window_port_mus.cc

Issue 2790673003: Aura-Mus: Enable Surface Synchronization behind flag (Closed)
Patch Set: Addressed Sadrul's comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/aura/mus/window_port_mus.h ('k') | ui/aura/mus/window_tree_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
19 #include "ui/display/screen.h"
18 20
19 namespace aura { 21 namespace aura {
20 22
23 namespace {
24 // Helper function to get the device_scale_factor() of the display::Display
25 // nearest to |window|.
26 float ScaleFactorForDisplay(Window* window) {
27 return display::Screen::GetScreen()
28 ->GetDisplayNearestWindow(window)
29 .device_scale_factor();
30 }
31 } // namespace
32
21 WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default; 33 WindowPortMus::WindowMusChangeDataImpl::WindowMusChangeDataImpl() = default;
22 34
23 WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default; 35 WindowPortMus::WindowMusChangeDataImpl::~WindowMusChangeDataImpl() = default;
24 36
25 // static 37 // static
26 WindowMus* WindowMus::Get(Window* window) { 38 WindowMus* WindowMus::Get(Window* window) {
27 return WindowPortMus::Get(window); 39 return WindowPortMus::Get(window);
28 } 40 }
29 41
30 WindowPortMus::WindowPortMus(WindowTreeClient* client, 42 WindowPortMus::WindowPortMus(WindowTreeClient* client,
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 289
278 void WindowPortMus::SetFrameSinkIdFromServer( 290 void WindowPortMus::SetFrameSinkIdFromServer(
279 const cc::FrameSinkId& frame_sink_id) { 291 const cc::FrameSinkId& frame_sink_id) {
280 frame_sink_id_ = frame_sink_id; 292 frame_sink_id_ = frame_sink_id;
281 if (!pending_compositor_frame_sink_request_.is_null()) { 293 if (!pending_compositor_frame_sink_request_.is_null()) {
282 // TOP_LEVEL_IN_WM, and EMBED_IN_OWNER windows should not be requesting 294 // TOP_LEVEL_IN_WM, and EMBED_IN_OWNER windows should not be requesting
283 // CompositorFrameSinks. 295 // CompositorFrameSinks.
284 DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type()); 296 DCHECK_NE(WindowMusType::TOP_LEVEL_IN_WM, window_mus_type());
285 DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type()); 297 DCHECK_NE(WindowMusType::EMBED_IN_OWNER, window_mus_type());
286 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run(); 298 base::ResetAndReturn(&pending_compositor_frame_sink_request_).Run();
299 return;
287 } 300 }
288 // TODO(fsamuel): If the window type is TOP_LEVEL_IN_WM or EMBED_IN_OWNER then 301 UpdatePrimarySurfaceInfo();
289 // we should check if we have a cc::LocalSurfaeId ready as well. If we do,
290 // then we are ready to embed.
291 } 302 }
292 303
293 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId( 304 const cc::LocalSurfaceId& WindowPortMus::GetOrAllocateLocalSurfaceId(
294 const gfx::Size& surface_size) { 305 const gfx::Size& surface_size) {
295 if (last_surface_size_ == surface_size && local_surface_id_.is_valid()) 306 if (last_surface_size_ == surface_size && local_surface_id_.is_valid())
296 return local_surface_id_; 307 return local_surface_id_;
297 308
298 local_surface_id_ = local_surface_id_allocator_.GenerateId(); 309 local_surface_id_ = local_surface_id_allocator_.GenerateId();
299 last_surface_size_ = surface_size; 310 last_surface_size_ = surface_size;
300 311
301 // TODO(fsamuel): If surface synchronization is enabled and the FrameSinkId 312 // If surface synchronization is enabled and the FrameSinkId is available,
302 // is available, then immediately embed the SurfaceId. The newly generated 313 // then immediately embed the SurfaceId. The newly generated frame by the
303 // frame by the embedder will block in the display compositor until the 314 // embedder will block in the display compositor until the child submits a
304 // child submits a corresponding CompositorFrame or a deadline hits. 315 // corresponding CompositorFrame or a deadline hits.
316 if (window_tree_client_->enable_surface_synchronization_ &&
317 frame_sink_id_.is_valid()) {
318 UpdatePrimarySurfaceInfo();
319 }
305 320
306 return local_surface_id_; 321 return local_surface_id_;
307 } 322 }
308 323
309 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) { 324 void WindowPortMus::SetPrimarySurfaceInfo(const cc::SurfaceInfo& surface_info) {
310 primary_surface_info_ = surface_info; 325 primary_surface_info_ = surface_info;
311 UpdatePrimarySurfaceInfoInternal(); 326 UpdateClientSurfaceEmbedder();
327 }
328
329 void WindowPortMus::SetFallbackSurfaceInfo(
330 const cc::SurfaceInfo& surface_info) {
331 DCHECK(client_surface_embedder_);
332 client_surface_embedder_->SetFallbackSurfaceInfo(surface_info);
312 } 333 }
313 334
314 void WindowPortMus::DestroyFromServer() { 335 void WindowPortMus::DestroyFromServer() {
315 std::unique_ptr<ScopedServerChange> remove_from_parent_change; 336 std::unique_ptr<ScopedServerChange> remove_from_parent_change;
316 if (window_->parent()) { 337 if (window_->parent()) {
317 ServerChangeData data; 338 ServerChangeData data;
318 data.child_id = server_id(); 339 data.child_id = server_id();
319 WindowPortMus* parent = Get(window_->parent()); 340 WindowPortMus* parent = Get(window_->parent());
320 remove_from_parent_change = base::MakeUnique<ScopedServerChange>( 341 remove_from_parent_change = base::MakeUnique<ScopedServerChange>(
321 parent, ServerChangeType::REMOVE, data); 342 parent, ServerChangeType::REMOVE, data);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index); 471 window_tree_client_->OnWindowMusMoveChild(this, current_index, dest_index);
451 } 472 }
452 } 473 }
453 474
454 void WindowPortMus::OnVisibilityChanged(bool visible) { 475 void WindowPortMus::OnVisibilityChanged(bool visible) {
455 ServerChangeData change_data; 476 ServerChangeData change_data;
456 change_data.visible = visible; 477 change_data.visible = visible;
457 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data)) 478 if (!RemoveChangeByTypeAndData(ServerChangeType::VISIBLE, change_data))
458 window_tree_client_->OnWindowMusSetVisible(this, visible); 479 window_tree_client_->OnWindowMusSetVisible(this, visible);
459 // We should only embed a client if its visible. 480 // We should only embed a client if its visible.
460 UpdatePrimarySurfaceInfoInternal(); 481 UpdateClientSurfaceEmbedder();
461 } 482 }
462 483
463 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds, 484 void WindowPortMus::OnDidChangeBounds(const gfx::Rect& old_bounds,
464 const gfx::Rect& new_bounds) { 485 const gfx::Rect& new_bounds) {
465 ServerChangeData change_data; 486 ServerChangeData change_data;
466 change_data.bounds_in_dip = new_bounds; 487 change_data.bounds_in_dip = new_bounds;
467 if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data)) 488 if (!RemoveChangeByTypeAndData(ServerChangeType::BOUNDS, change_data))
468 window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds); 489 window_tree_client_->OnWindowMusBoundsChanged(this, old_bounds, new_bounds);
469 } 490 }
470 491
(...skipping 20 matching lines...) Expand all
491 change_data.property_name = 512 change_data.property_name =
492 GetPropertyConverter()->GetTransportNameForPropertyKey(key); 513 GetPropertyConverter()->GetTransportNameForPropertyKey(key);
493 // TODO(sky): investigate to see if we need to compare data. In particular do 514 // TODO(sky): investigate to see if we need to compare data. In particular do
494 // we ever have a case where changing a property cascades into changing the 515 // we ever have a case where changing a property cascades into changing the
495 // same property? 516 // same property?
496 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data)) 517 if (!RemoveChangeByTypeAndData(ServerChangeType::PROPERTY, change_data))
497 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value, 518 window_tree_client_->OnWindowMusPropertyChanged(this, key, old_value,
498 std::move(data)); 519 std::move(data));
499 } 520 }
500 521
501 void WindowPortMus::UpdatePrimarySurfaceInfoInternal() { 522 void WindowPortMus::UpdatePrimarySurfaceInfo() {
523 bool embeds_surface = window_mus_type() == WindowMusType::TOP_LEVEL_IN_WM ||
524 window_mus_type() == WindowMusType::EMBED_IN_OWNER;
525 if (!embeds_surface)
526 return;
527
528 if (!frame_sink_id_.is_valid() || !local_surface_id_.is_valid())
529 return;
530
531 primary_surface_info_ =
532 cc::SurfaceInfo(cc::SurfaceId(frame_sink_id_, local_surface_id_),
533 ScaleFactorForDisplay(window_), last_surface_size_);
534
535 UpdateClientSurfaceEmbedder();
536 }
537
538 void WindowPortMus::UpdateClientSurfaceEmbedder() {
502 if (!client_surface_embedder_ && primary_surface_info_.is_valid()) 539 if (!client_surface_embedder_ && primary_surface_info_.is_valid())
503 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>(window_); 540 client_surface_embedder_ = base::MakeUnique<ClientSurfaceEmbedder>(window_);
504 541
505 if (primary_surface_info_.is_valid() && window_->IsVisible()) 542 if (primary_surface_info_.is_valid() && window_->IsVisible())
506 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_); 543 client_surface_embedder_->SetPrimarySurfaceInfo(primary_surface_info_);
507 else 544 else
508 client_surface_embedder_.reset(); 545 client_surface_embedder_.reset();
509 } 546 }
510 547
511 } // namespace aura 548 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/mus/window_port_mus.h ('k') | ui/aura/mus/window_tree_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698