| OLD | NEW |
| 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 "services/ui/ws/platform_display_default.h" | 5 #include "services/ui/ws/platform_display_default.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "gpu/ipc/client/gpu_channel_host.h" | 8 #include "gpu/ipc/client/gpu_channel_host.h" |
| 9 #include "services/ui/display/screen_manager.h" | 9 #include "services/ui/display/screen_manager.h" |
| 10 #include "services/ui/ws/platform_display_init_params.h" | 10 #include "services/ui/ws/platform_display_init_params.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 namespace ui { | 29 namespace ui { |
| 30 namespace ws { | 30 namespace ws { |
| 31 | 31 |
| 32 PlatformDisplayDefault::PlatformDisplayDefault( | 32 PlatformDisplayDefault::PlatformDisplayDefault( |
| 33 const PlatformDisplayInitParams& init_params) | 33 const PlatformDisplayInitParams& init_params) |
| 34 : display_id_(init_params.display_id), | 34 : display_id_(init_params.display_id), |
| 35 #if !defined(OS_ANDROID) | 35 #if !defined(OS_ANDROID) |
| 36 image_cursors_(new ImageCursors), | 36 image_cursors_(new ImageCursors), |
| 37 #endif | 37 #endif |
| 38 frame_generator_(new FrameGenerator(this, init_params.root_window)), | 38 frame_generator_(new FrameGenerator(this, init_params.root_window)), |
| 39 metrics_(init_params.metrics) { | 39 metrics_(init_params.metrics), |
| 40 widget_(gfx::kNullAcceleratedWidget) { |
| 40 frame_generator_->set_device_scale_factor( | 41 frame_generator_->set_device_scale_factor( |
| 41 init_params.metrics.device_scale_factor); | 42 init_params.metrics.device_scale_factor); |
| 42 } | 43 } |
| 43 | 44 |
| 44 PlatformDisplayDefault::~PlatformDisplayDefault() { | 45 PlatformDisplayDefault::~PlatformDisplayDefault() { |
| 45 // Don't notify the delegate from the destructor. | 46 // Don't notify the delegate from the destructor. |
| 46 delegate_ = nullptr; | 47 delegate_ = nullptr; |
| 47 | 48 |
| 48 frame_generator_.reset(); | 49 frame_generator_.reset(); |
| 49 // Destroy the PlatformWindow early on as it may call us back during | 50 // Destroy the PlatformWindow early on as it may call us back during |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 metrics_ = metrics; | 151 metrics_ = metrics; |
| 151 frame_generator_->set_device_scale_factor(metrics_.device_scale_factor); | 152 frame_generator_->set_device_scale_factor(metrics_.device_scale_factor); |
| 152 return true; | 153 return true; |
| 153 } | 154 } |
| 154 | 155 |
| 155 const display::ViewportMetrics& PlatformDisplayDefault::GetViewportMetrics() | 156 const display::ViewportMetrics& PlatformDisplayDefault::GetViewportMetrics() |
| 156 const { | 157 const { |
| 157 return metrics_; | 158 return metrics_; |
| 158 } | 159 } |
| 159 | 160 |
| 161 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const { |
| 162 return widget_; |
| 163 } |
| 164 |
| 160 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) { | 165 void PlatformDisplayDefault::UpdateEventRootLocation(ui::LocatedEvent* event) { |
| 161 gfx::Point location = event->location(); | 166 gfx::Point location = event->location(); |
| 162 location.Offset(metrics_.bounds.x(), metrics_.bounds.y()); | 167 location.Offset(metrics_.bounds.x(), metrics_.bounds.y()); |
| 163 event->set_root_location(location); | 168 event->set_root_location(location); |
| 164 } | 169 } |
| 165 | 170 |
| 166 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { | 171 void PlatformDisplayDefault::OnBoundsChanged(const gfx::Rect& new_bounds) { |
| 167 // We only care if the window size has changed. | 172 // We only care if the window size has changed. |
| 168 if (new_bounds.size() == metrics_.pixel_size) | 173 if (new_bounds.size() == metrics_.pixel_size) |
| 169 return; | 174 return; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 void PlatformDisplayDefault::OnLostCapture() { | 236 void PlatformDisplayDefault::OnLostCapture() { |
| 232 delegate_->OnNativeCaptureLost(); | 237 delegate_->OnNativeCaptureLost(); |
| 233 } | 238 } |
| 234 | 239 |
| 235 void PlatformDisplayDefault::OnAcceleratedWidgetAvailable( | 240 void PlatformDisplayDefault::OnAcceleratedWidgetAvailable( |
| 236 gfx::AcceleratedWidget widget, | 241 gfx::AcceleratedWidget widget, |
| 237 float device_scale_factor) { | 242 float device_scale_factor) { |
| 238 // This will get called after Init() is called, either synchronously as part | 243 // This will get called after Init() is called, either synchronously as part |
| 239 // of the Init() callstack or async after Init() has returned, depending on | 244 // of the Init() callstack or async after Init() has returned, depending on |
| 240 // the platform. | 245 // the platform. |
| 246 DCHECK_EQ(gfx::kNullAcceleratedWidget, widget_); |
| 247 widget_ = widget; |
| 241 delegate_->OnAcceleratedWidgetAvailable(); | 248 delegate_->OnAcceleratedWidgetAvailable(); |
| 242 frame_generator_->OnAcceleratedWidgetAvailable(widget); | 249 frame_generator_->OnAcceleratedWidgetAvailable(widget); |
| 243 } | 250 } |
| 244 | 251 |
| 245 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { | 252 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { |
| 246 NOTREACHED(); | 253 NOTREACHED(); |
| 247 } | 254 } |
| 248 | 255 |
| 249 void PlatformDisplayDefault::OnActivationChanged(bool active) {} | 256 void PlatformDisplayDefault::OnActivationChanged(bool active) {} |
| 250 | 257 |
| 251 bool PlatformDisplayDefault::IsInHighContrastMode() { | 258 bool PlatformDisplayDefault::IsInHighContrastMode() { |
| 252 return delegate_ ? delegate_->IsInHighContrastMode() : false; | 259 return delegate_ ? delegate_->IsInHighContrastMode() : false; |
| 253 } | 260 } |
| 254 | 261 |
| 255 } // namespace ws | 262 } // namespace ws |
| 256 } // namespace ui | 263 } // namespace ui |
| OLD | NEW |