| 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 "ui/aura/mus/window_tree_client.h" | 5 #include "ui/aura/mus/window_tree_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/auto_reset.h" | 13 #include "base/auto_reset.h" |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/command_line.h" |
| 15 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 16 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "cc/base/switches.h" |
| 17 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" | 19 #include "components/discardable_memory/client/client_discardable_shared_memory_
manager.h" |
| 18 #include "mojo/public/cpp/bindings/map.h" | 20 #include "mojo/public/cpp/bindings/map.h" |
| 19 #include "services/service_manager/public/cpp/connector.h" | 21 #include "services/service_manager/public/cpp/connector.h" |
| 20 #include "services/ui/common/accelerator_util.h" | 22 #include "services/ui/common/accelerator_util.h" |
| 21 #include "services/ui/public/cpp/gpu/gpu.h" | 23 #include "services/ui/public/cpp/gpu/gpu.h" |
| 22 #include "services/ui/public/cpp/property_type_converters.h" | 24 #include "services/ui/public/cpp/property_type_converters.h" |
| 23 #include "services/ui/public/interfaces/constants.mojom.h" | 25 #include "services/ui/public/interfaces/constants.mojom.h" |
| 24 #include "services/ui/public/interfaces/window_manager.mojom.h" | 26 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 25 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom
.h" | 27 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom
.h" |
| 26 #include "ui/aura/client/aura_constants.h" | 28 #include "ui/aura/client/aura_constants.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 if (create_discardable_memory) { | 218 if (create_discardable_memory) { |
| 217 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; | 219 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; |
| 218 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); | 220 connector->BindInterface(ui::mojom::kServiceName, &manager_ptr); |
| 219 discardable_shared_memory_manager_ = base::MakeUnique< | 221 discardable_shared_memory_manager_ = base::MakeUnique< |
| 220 discardable_memory::ClientDiscardableSharedMemoryManager>( | 222 discardable_memory::ClientDiscardableSharedMemoryManager>( |
| 221 std::move(manager_ptr), std::move(io_task_runner)); | 223 std::move(manager_ptr), std::move(io_task_runner)); |
| 222 base::DiscardableMemoryAllocator::SetInstance( | 224 base::DiscardableMemoryAllocator::SetInstance( |
| 223 discardable_shared_memory_manager_.get()); | 225 discardable_shared_memory_manager_.get()); |
| 224 } | 226 } |
| 225 } | 227 } |
| 228 enable_surface_synchronization_ = |
| 229 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 230 cc::switches::kEnableSurfaceSynchronization); |
| 226 } | 231 } |
| 227 | 232 |
| 228 WindowTreeClient::~WindowTreeClient() { | 233 WindowTreeClient::~WindowTreeClient() { |
| 229 in_destructor_ = true; | 234 in_destructor_ = true; |
| 230 | 235 |
| 231 if (discardable_shared_memory_manager_) | 236 if (discardable_shared_memory_manager_) |
| 232 base::DiscardableMemoryAllocator::SetInstance(nullptr); | 237 base::DiscardableMemoryAllocator::SetInstance(nullptr); |
| 233 | 238 |
| 234 for (WindowTreeClientObserver& observer : observers_) | 239 for (WindowTreeClientObserver& observer : observers_) |
| 235 observer.OnWillDestroyClient(this); | 240 observer.OnWillDestroyClient(this); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 DCHECK(cursor_location_mapping_); | 591 DCHECK(cursor_location_mapping_); |
| 587 } | 592 } |
| 588 | 593 |
| 589 void WindowTreeClient::SetWindowBoundsFromServer( | 594 void WindowTreeClient::SetWindowBoundsFromServer( |
| 590 WindowMus* window, | 595 WindowMus* window, |
| 591 const gfx::Rect& revert_bounds_in_pixels, | 596 const gfx::Rect& revert_bounds_in_pixels, |
| 592 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { | 597 const base::Optional<cc::LocalSurfaceId>& local_surface_id) { |
| 593 if (IsRoot(window)) { | 598 if (IsRoot(window)) { |
| 594 // WindowTreeHost expects bounds to be in pixels. | 599 // WindowTreeHost expects bounds to be in pixels. |
| 595 GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels); | 600 GetWindowTreeHostMus(window)->SetBoundsFromServer(revert_bounds_in_pixels); |
| 596 // TODO(fsamuel): Propagate |local_surface_id| to ui::Compositor. | 601 if (enable_surface_synchronization_ && local_surface_id && |
| 602 local_surface_id->is_valid()) { |
| 603 window->GetWindow()->GetHost()->compositor()->SetLocalSurfaceId( |
| 604 *local_surface_id); |
| 605 } |
| 597 return; | 606 return; |
| 598 } | 607 } |
| 599 | 608 |
| 600 window->SetBoundsFromServer(gfx::ConvertRectToDIP( | 609 window->SetBoundsFromServer(gfx::ConvertRectToDIP( |
| 601 ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels)); | 610 ScaleFactorForDisplay(window->GetWindow()), revert_bounds_in_pixels)); |
| 602 } | 611 } |
| 603 | 612 |
| 604 void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window, | 613 void WindowTreeClient::SetWindowVisibleFromServer(WindowMus* window, |
| 605 bool visible) { | 614 bool visible) { |
| 606 if (!IsRoot(window)) { | 615 if (!IsRoot(window)) { |
| (...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( | 1941 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( |
| 1933 this, capture_synchronizer_.get(), window)); | 1942 this, capture_synchronizer_.get(), window)); |
| 1934 } | 1943 } |
| 1935 | 1944 |
| 1936 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { | 1945 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { |
| 1937 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( | 1946 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( |
| 1938 this, focus_synchronizer_.get(), window)); | 1947 this, focus_synchronizer_.get(), window)); |
| 1939 } | 1948 } |
| 1940 | 1949 |
| 1941 } // namespace aura | 1950 } // namespace aura |
| OLD | NEW |