| 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/platform_display.h" | 5 #include "services/ui/ws/platform_display.h" |
| 6 | 6 |
| 7 #include "base/numerics/safe_conversions.h" | 7 #include "base/numerics/safe_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "cc/ipc/quads.mojom.h" | 9 #include "cc/ipc/quads.mojom.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "ui/ozone/public/ozone_platform.h" | 36 #include "ui/ozone/public/ozone_platform.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 namespace ui { | 39 namespace ui { |
| 40 | 40 |
| 41 namespace ws { | 41 namespace ws { |
| 42 | 42 |
| 43 // static | 43 // static |
| 44 PlatformDisplayFactory* PlatformDisplay::factory_ = nullptr; | 44 PlatformDisplayFactory* PlatformDisplay::factory_ = nullptr; |
| 45 | 45 |
| 46 PlatformDisplay::PlatformDisplay(int64_t id) : id_(id) {} |
| 47 |
| 46 // static | 48 // static |
| 47 PlatformDisplay* PlatformDisplay::Create( | 49 PlatformDisplay* PlatformDisplay::Create( |
| 48 const PlatformDisplayInitParams& init_params) { | 50 const PlatformDisplayInitParams& init_params) { |
| 49 if (factory_) | 51 if (factory_) |
| 50 return factory_->CreatePlatformDisplay(); | 52 return factory_->CreatePlatformDisplay(); |
| 51 | 53 |
| 52 return new DefaultPlatformDisplay(init_params); | 54 return new DefaultPlatformDisplay(init_params); |
| 53 } | 55 } |
| 54 | 56 |
| 55 DefaultPlatformDisplay::DefaultPlatformDisplay( | 57 DefaultPlatformDisplay::DefaultPlatformDisplay( |
| 56 const PlatformDisplayInitParams& init_params) | 58 const PlatformDisplayInitParams& init_params) |
| 57 : display_id_(init_params.display_id), | 59 : PlatformDisplay(init_params.display_id), |
| 58 #if !defined(OS_ANDROID) | 60 #if !defined(OS_ANDROID) |
| 59 cursor_loader_(ui::CursorLoader::Create()), | 61 cursor_loader_(ui::CursorLoader::Create()), |
| 60 #endif | 62 #endif |
| 61 frame_generator_(new FrameGenerator(this, | 63 frame_generator_(new FrameGenerator(this, init_params.surfaces_state)) { |
| 62 init_params.surfaces_state)) { | |
| 63 metrics_.bounds = init_params.display_bounds; | 64 metrics_.bounds = init_params.display_bounds; |
| 64 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. | 65 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. |
| 65 } | 66 } |
| 66 | 67 |
| 67 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { | 68 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { |
| 68 delegate_ = delegate; | 69 delegate_ = delegate; |
| 69 | 70 |
| 70 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
| 71 platform_window_.reset(new ui::WinWindow(this, metrics_.bounds)); | 72 platform_window_.reset(new ui::WinWindow(this, metrics_.bounds)); |
| 72 #elif defined(USE_X11) | 73 #elif defined(USE_X11) |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { | 155 void DefaultPlatformDisplay::SetImeVisibility(bool visible) { |
| 155 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); | 156 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); |
| 156 if (ime) | 157 if (ime) |
| 157 ime->SetImeVisibility(visible); | 158 ime->SetImeVisibility(visible); |
| 158 } | 159 } |
| 159 | 160 |
| 160 bool DefaultPlatformDisplay::IsFramePending() const { | 161 bool DefaultPlatformDisplay::IsFramePending() const { |
| 161 return frame_generator_->is_frame_pending(); | 162 return frame_generator_->is_frame_pending(); |
| 162 } | 163 } |
| 163 | 164 |
| 164 int64_t DefaultPlatformDisplay::GetDisplayId() const { | |
| 165 return display_id_; | |
| 166 } | |
| 167 | |
| 168 gfx::Rect DefaultPlatformDisplay::GetBounds() const { | 165 gfx::Rect DefaultPlatformDisplay::GetBounds() const { |
| 169 return metrics_.bounds; | 166 return metrics_.bounds; |
| 170 } | 167 } |
| 171 | 168 |
| 172 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Rect& bounds, | 169 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Rect& bounds, |
| 173 float device_scale_factor) { | 170 float device_scale_factor) { |
| 174 if (display::Display::HasForceDeviceScaleFactor()) | 171 if (display::Display::HasForceDeviceScaleFactor()) |
| 175 device_scale_factor = display::Display::GetForcedDeviceScaleFactor(); | 172 device_scale_factor = display::Display::GetForcedDeviceScaleFactor(); |
| 176 if (metrics_.bounds == bounds && | 173 if (metrics_.bounds == bounds && |
| 177 metrics_.device_scale_factor == device_scale_factor) | 174 metrics_.device_scale_factor == device_scale_factor) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return delegate_ ? delegate_->IsInHighContrastMode() : false; | 275 return delegate_ ? delegate_->IsInHighContrastMode() : false; |
| 279 } | 276 } |
| 280 | 277 |
| 281 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() { | 278 const ViewportMetrics& DefaultPlatformDisplay::GetViewportMetrics() { |
| 282 return metrics_; | 279 return metrics_; |
| 283 } | 280 } |
| 284 | 281 |
| 285 } // namespace ws | 282 } // namespace ws |
| 286 | 283 |
| 287 } // namespace ui | 284 } // namespace ui |
| OLD | NEW |