| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/display.h" | 5 #include "services/ui/ws/display.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/debug/debugger.h" | 11 #include "base/debug/debugger.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "mojo/common/common_type_converters.h" | 13 #include "mojo/common/common_type_converters.h" |
| 13 #include "services/shell/public/interfaces/connector.mojom.h" | 14 #include "services/shell/public/interfaces/connector.mojom.h" |
| 14 #include "services/ui/common/types.h" | 15 #include "services/ui/common/types.h" |
| 15 #include "services/ui/ws/display_binding.h" | 16 #include "services/ui/ws/display_binding.h" |
| 16 #include "services/ui/ws/display_manager.h" | 17 #include "services/ui/ws/display_manager.h" |
| 17 #include "services/ui/ws/focus_controller.h" | 18 #include "services/ui/ws/focus_controller.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 | 75 |
| 75 DisplayManager* Display::display_manager() { | 76 DisplayManager* Display::display_manager() { |
| 76 return window_server_->display_manager(); | 77 return window_server_->display_manager(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 const DisplayManager* Display::display_manager() const { | 80 const DisplayManager* Display::display_manager() const { |
| 80 return window_server_->display_manager(); | 81 return window_server_->display_manager(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 mojom::DisplayPtr Display::ToMojomDisplay() const { | 84 mojom::WsDisplayPtr Display::ToWsDisplay() const { |
| 84 mojom::DisplayPtr display_ptr = mojom::Display::New(); | 85 mojom::WsDisplayPtr display_ptr = mojom::WsDisplay::New(); |
| 85 display_ptr = mojom::Display::New(); | 86 |
| 86 display_ptr->id = id_; | 87 display_ptr->display = ToDisplay(); |
| 87 // TODO(sky): Display should know it's origin. | 88 |
| 88 display_ptr->bounds.SetRect(0, 0, root_->bounds().size().width(), | |
| 89 root_->bounds().size().height()); | |
| 90 // TODO(sky): window manager needs an API to set the work area. | |
| 91 display_ptr->work_area = display_ptr->bounds; | |
| 92 display_ptr->device_pixel_ratio = platform_display_->GetDeviceScaleFactor(); | |
| 93 display_ptr->rotation = platform_display_->GetRotation(); | |
| 94 // TODO(sky): make this real. | 89 // TODO(sky): make this real. |
| 95 display_ptr->is_primary = true; | 90 display_ptr->is_primary = true; |
| 96 // TODO(sky): make this real. | 91 // TODO(sky): make this real. |
| 97 display_ptr->touch_support = mojom::TouchSupport::UNKNOWN; | |
| 98 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); | 92 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); |
| 99 return display_ptr; | 93 return display_ptr; |
| 100 } | 94 } |
| 101 | 95 |
| 96 ::display::Display Display::ToDisplay() const { |
| 97 ::display::Display display(id_); |
| 98 |
| 99 // TODO(sky): Display should know its origin. |
| 100 display.set_bounds(gfx::Rect(0, 0, root_->bounds().size().width(), |
| 101 root_->bounds().size().height())); |
| 102 // TODO(sky): window manager needs an API to set the work area. |
| 103 display.set_work_area(display.bounds()); |
| 104 display.set_device_scale_factor(platform_display_->GetDeviceScaleFactor()); |
| 105 display.set_rotation(platform_display_->GetRotation()); |
| 106 display.set_touch_support( |
| 107 ::display::Display::TouchSupport::TOUCH_SUPPORT_UNKNOWN); |
| 108 |
| 109 return display; |
| 110 } |
| 111 |
| 102 void Display::SchedulePaint(const ServerWindow* window, | 112 void Display::SchedulePaint(const ServerWindow* window, |
| 103 const gfx::Rect& bounds) { | 113 const gfx::Rect& bounds) { |
| 104 DCHECK(root_->Contains(window)); | 114 DCHECK(root_->Contains(window)); |
| 105 platform_display_->SchedulePaint(window, bounds); | 115 platform_display_->SchedulePaint(window, bounds); |
| 106 } | 116 } |
| 107 | 117 |
| 108 void Display::ScheduleSurfaceDestruction(ServerWindow* window) { | 118 void Display::ScheduleSurfaceDestruction(ServerWindow* window) { |
| 109 if (!platform_display_->IsFramePending()) { | 119 if (!platform_display_->IsFramePending()) { |
| 110 window->DestroySurfacesScheduledForDestruction(); | 120 window->DestroySurfacesScheduledForDestruction(); |
| 111 return; | 121 return; |
| 112 } | 122 } |
| 113 if (windows_needing_frame_destruction_.count(window)) | 123 if (windows_needing_frame_destruction_.count(window)) |
| 114 return; | 124 return; |
| 115 windows_needing_frame_destruction_.insert(window); | 125 windows_needing_frame_destruction_.insert(window); |
| 116 window->AddObserver(this); | 126 window->AddObserver(this); |
| 117 } | 127 } |
| 118 | 128 |
| 119 mojom::Rotation Display::GetRotation() const { | 129 ::display::Display::Rotation Display::GetRotation() const { |
| 120 return platform_display_->GetRotation(); | 130 return platform_display_->GetRotation(); |
| 121 } | 131 } |
| 122 | 132 |
| 123 gfx::Size Display::GetSize() const { | 133 gfx::Size Display::GetSize() const { |
| 124 return root_->bounds().size(); | 134 return root_->bounds().size(); |
| 125 } | 135 } |
| 126 | 136 |
| 127 int64_t Display::GetPlatformDisplayId() const { | 137 int64_t Display::GetPlatformDisplayId() const { |
| 128 return platform_display_->GetDisplayId(); | 138 return platform_display_->GetDisplayId(); |
| 129 } | 139 } |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 424 } |
| 415 | 425 |
| 416 void Display::OnWindowManagerWindowTreeFactoryReady( | 426 void Display::OnWindowManagerWindowTreeFactoryReady( |
| 417 WindowManagerWindowTreeFactory* factory) { | 427 WindowManagerWindowTreeFactory* factory) { |
| 418 if (!binding_) | 428 if (!binding_) |
| 419 CreateWindowManagerDisplayRootFromFactory(factory); | 429 CreateWindowManagerDisplayRootFromFactory(factory); |
| 420 } | 430 } |
| 421 | 431 |
| 422 } // namespace ws | 432 } // namespace ws |
| 423 } // namespace ui | 433 } // namespace ui |
| OLD | NEW |