Chromium Code Reviews| 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/display_client_compositor_frame_sink.h" | 10 #include "services/ui/ws/display_client_compositor_frame_sink.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 namespace ws { | 30 namespace ws { |
| 31 | 31 |
| 32 PlatformDisplayDefault::PlatformDisplayDefault( | 32 PlatformDisplayDefault::PlatformDisplayDefault( |
| 33 ServerWindow* root_window, | 33 ServerWindow* root_window, |
| 34 const display::ViewportMetrics& metrics) | 34 const display::ViewportMetrics& metrics) |
| 35 : root_window_(root_window), | 35 : root_window_(root_window), |
| 36 #if !defined(OS_ANDROID) | 36 #if !defined(OS_ANDROID) |
| 37 image_cursors_(new ImageCursors), | 37 image_cursors_(new ImageCursors), |
| 38 #endif | 38 #endif |
| 39 metrics_(metrics), | 39 metrics_(metrics), |
| 40 widget_(gfx::kNullAcceleratedWidget), | 40 widget_(gfx::kNullAcceleratedWidget) { |
| 41 init_device_scale_factor_(metrics.device_scale_factor) { | |
| 42 } | 41 } |
| 43 | 42 |
| 44 PlatformDisplayDefault::~PlatformDisplayDefault() { | 43 PlatformDisplayDefault::~PlatformDisplayDefault() { |
| 45 // Don't notify the delegate from the destructor. | 44 // Don't notify the delegate from the destructor. |
| 46 delegate_ = nullptr; | 45 delegate_ = nullptr; |
| 47 | 46 |
| 48 frame_generator_.reset(); | 47 frame_generator_.reset(); |
| 49 // Destroy the PlatformWindow early on as it may call us back during | 48 // Destroy the PlatformWindow early on as it may call us back during |
| 50 // destruction and we want to be in a known state. But destroy the surface | 49 // destruction and we want to be in a known state. But destroy the surface |
| 51 // first because it can still be using the platform window. | 50 // first because it can still be using the platform window. |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 | 126 |
| 128 bool PlatformDisplayDefault::UpdateViewportMetrics( | 127 bool PlatformDisplayDefault::UpdateViewportMetrics( |
| 129 const display::ViewportMetrics& metrics) { | 128 const display::ViewportMetrics& metrics) { |
| 130 if (metrics_ == metrics) | 129 if (metrics_ == metrics) |
| 131 return false; | 130 return false; |
| 132 | 131 |
| 133 gfx::Rect bounds = platform_window_->GetBounds(); | 132 gfx::Rect bounds = platform_window_->GetBounds(); |
| 134 if (bounds.size() != metrics.bounds_in_pixels.size()) { | 133 if (bounds.size() != metrics.bounds_in_pixels.size()) { |
| 135 bounds.set_size(metrics.bounds_in_pixels.size()); | 134 bounds.set_size(metrics.bounds_in_pixels.size()); |
| 136 platform_window_->SetBounds(bounds); | 135 platform_window_->SetBounds(bounds); |
| 136 if (frame_generator_) | |
| 137 frame_generator_->OnWindowBoundsChanged(bounds.size()); | |
|
kylechar
2017/03/22 21:27:36
optional: metrics.pixel_size, or move this down in
Alex Z.
2017/03/23 14:18:44
Done.
| |
| 137 } | 138 } |
| 138 | 139 |
| 139 metrics_ = metrics; | 140 metrics_ = metrics; |
| 140 if (frame_generator_) | 141 if (frame_generator_) |
| 141 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor); | 142 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor); |
| 142 return true; | 143 return true; |
| 143 } | 144 } |
| 144 | 145 |
| 145 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const { | 146 gfx::AcceleratedWidget PlatformDisplayDefault::GetAcceleratedWidget() const { |
| 146 return widget_; | 147 return widget_; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 widget_, mojo::MakeRequest(&compositor_frame_sink), | 251 widget_, mojo::MakeRequest(&compositor_frame_sink), |
| 251 std::move(compositor_frame_sink_client), | 252 std::move(compositor_frame_sink_client), |
| 252 mojo::MakeRequest(&display_private)); | 253 mojo::MakeRequest(&display_private)); |
| 253 | 254 |
| 254 auto display_client_compositor_frame_sink = | 255 auto display_client_compositor_frame_sink = |
| 255 base::MakeUnique<DisplayClientCompositorFrameSink>( | 256 base::MakeUnique<DisplayClientCompositorFrameSink>( |
| 256 root_window_->frame_sink_id(), std::move(compositor_frame_sink), | 257 root_window_->frame_sink_id(), std::move(compositor_frame_sink), |
| 257 std::move(display_private), | 258 std::move(display_private), |
| 258 std::move(compositor_frame_sink_client_request)); | 259 std::move(compositor_frame_sink_client_request)); |
| 259 frame_generator_ = base::MakeUnique<FrameGenerator>( | 260 frame_generator_ = base::MakeUnique<FrameGenerator>( |
| 260 root_window_, std::move(display_client_compositor_frame_sink)); | 261 std::move(display_client_compositor_frame_sink)); |
| 261 frame_generator_->SetDeviceScaleFactor(init_device_scale_factor_); | 262 frame_generator_->OnWindowBoundsChanged(root_window_->bounds().size()); |
|
kylechar
2017/03/22 21:27:36
metrics_.pixel_size here?
Alex Z.
2017/03/23 14:18:44
Done.
| |
| 263 frame_generator_->SetDeviceScaleFactor(metrics_.device_scale_factor); | |
| 262 } | 264 } |
| 263 | 265 |
| 264 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { | 266 void PlatformDisplayDefault::OnAcceleratedWidgetDestroyed() { |
| 265 NOTREACHED(); | 267 NOTREACHED(); |
| 266 } | 268 } |
| 267 | 269 |
| 268 void PlatformDisplayDefault::OnActivationChanged(bool active) {} | 270 void PlatformDisplayDefault::OnActivationChanged(bool active) {} |
| 269 | 271 |
| 270 } // namespace ws | 272 } // namespace ws |
| 271 } // namespace ui | 273 } // namespace ui |
| OLD | NEW |