| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/ws/server_window.h" | 5 #include "services/ui/ws/server_window.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "services/ui/common/transient_window_utils.h" | 11 #include "services/ui/common/transient_window_utils.h" |
| 12 #include "services/ui/public/interfaces/window_manager.mojom.h" | 12 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 13 #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" |
| 13 #include "services/ui/ws/server_window_delegate.h" | 14 #include "services/ui/ws/server_window_delegate.h" |
| 14 #include "services/ui/ws/server_window_observer.h" | 15 #include "services/ui/ws/server_window_observer.h" |
| 15 #include "services/ui/ws/server_window_surface_manager.h" | |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 | 18 |
| 19 namespace ws { | 19 namespace ws { |
| 20 | 20 |
| 21 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) | 21 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id) |
| 22 : ServerWindow(delegate, id, Properties()) {} | 22 : ServerWindow(delegate, id, Properties()) {} |
| 23 | 23 |
| 24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, | 24 ServerWindow::ServerWindow(ServerWindowDelegate* delegate, |
| 25 const WindowId& id, | 25 const WindowId& id, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 void ServerWindow::RemoveObserver(ServerWindowObserver* observer) { | 77 void ServerWindow::RemoveObserver(ServerWindowObserver* observer) { |
| 78 DCHECK(observers_.HasObserver(observer)); | 78 DCHECK(observers_.HasObserver(observer)); |
| 79 observers_.RemoveObserver(observer); | 79 observers_.RemoveObserver(observer); |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool ServerWindow::HasObserver(ServerWindowObserver* observer) { | 82 bool ServerWindow::HasObserver(ServerWindowObserver* observer) { |
| 83 return observers_.HasObserver(observer); | 83 return observers_.HasObserver(observer); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ServerWindow::CreateSurface( | 86 void ServerWindow::CreateCompositorFrameSink( |
| 87 mojom::SurfaceType surface_type, | 87 mojom::CompositorFrameSinkType compositor_frame_sink_type, |
| 88 mojo::InterfaceRequest<cc::mojom::MojoCompositorFrameSink> request, | 88 cc::mojom::MojoCompositorFrameSinkRequest request, |
| 89 cc::mojom::MojoCompositorFrameSinkClientPtr client) { | 89 cc::mojom::MojoCompositorFrameSinkClientPtr client) { |
| 90 GetOrCreateSurfaceManager()->CreateSurface(surface_type, std::move(request), | 90 GetOrCreateCompositorFrameSinkManager()->CreateCompositorFrameSink( |
| 91 std::move(client)); | 91 compositor_frame_sink_type, std::move(request), std::move(client)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void ServerWindow::Add(ServerWindow* child) { | 94 void ServerWindow::Add(ServerWindow* child) { |
| 95 // We assume validation checks happened already. | 95 // We assume validation checks happened already. |
| 96 DCHECK(child); | 96 DCHECK(child); |
| 97 DCHECK(child != this); | 97 DCHECK(child != this); |
| 98 DCHECK(!child->Contains(this)); | 98 DCHECK(!child->Contains(this)); |
| 99 if (child->parent() == this) { | 99 if (child->parent() == this) { |
| 100 if (children_.size() == 1) | 100 if (children_.size() == 1) |
| 101 return; // Already in the right position. | 101 return; // Already in the right position. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 bool ServerWindow::IsDrawn() const { | 357 bool ServerWindow::IsDrawn() const { |
| 358 const ServerWindow* root = delegate_->GetRootWindow(this); | 358 const ServerWindow* root = delegate_->GetRootWindow(this); |
| 359 if (!root || !root->visible()) | 359 if (!root || !root->visible()) |
| 360 return false; | 360 return false; |
| 361 const ServerWindow* window = this; | 361 const ServerWindow* window = this; |
| 362 while (window && window != root && window->visible()) | 362 while (window && window != root && window->visible()) |
| 363 window = window->parent(); | 363 window = window->parent(); |
| 364 return root == window; | 364 return root == window; |
| 365 } | 365 } |
| 366 | 366 |
| 367 ServerWindowSurfaceManager* ServerWindow::GetOrCreateSurfaceManager() { | 367 ServerWindowCompositorFrameSinkManager* |
| 368 if (!surface_manager_.get()) | 368 ServerWindow::GetOrCreateCompositorFrameSinkManager() { |
| 369 surface_manager_ = base::MakeUnique<ServerWindowSurfaceManager>(this); | 369 if (!compositor_frame_sink_manager_.get()) |
| 370 return surface_manager_.get(); | 370 compositor_frame_sink_manager_ = |
| 371 base::MakeUnique<ServerWindowCompositorFrameSinkManager>(this); |
| 372 return compositor_frame_sink_manager_.get(); |
| 371 } | 373 } |
| 372 | 374 |
| 373 void ServerWindow::SetUnderlayOffset(const gfx::Vector2d& offset) { | 375 void ServerWindow::SetUnderlayOffset(const gfx::Vector2d& offset) { |
| 374 if (offset == underlay_offset_) | 376 if (offset == underlay_offset_) |
| 375 return; | 377 return; |
| 376 | 378 |
| 377 underlay_offset_ = offset; | 379 underlay_offset_ = offset; |
| 378 delegate_->OnScheduleWindowPaint(this); | 380 delegate_->OnScheduleWindowPaint(this); |
| 379 } | 381 } |
| 380 | 382 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 457 } |
| 456 | 458 |
| 457 // static | 459 // static |
| 458 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { | 460 ServerWindow** ServerWindow::GetStackingTarget(ServerWindow* window) { |
| 459 return &window->stacking_target_; | 461 return &window->stacking_target_; |
| 460 } | 462 } |
| 461 | 463 |
| 462 } // namespace ws | 464 } // namespace ws |
| 463 | 465 |
| 464 } // namespace ui | 466 } // namespace ui |
| OLD | NEW |