| 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 "components/mus/ws/platform_display.h" | 5 #include "components/mus/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/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 gpu_state_(init_params.gpu_state), | 170 gpu_state_(init_params.gpu_state), |
| 171 surfaces_state_(init_params.surfaces_state), | 171 surfaces_state_(init_params.surfaces_state), |
| 172 delegate_(nullptr), | 172 delegate_(nullptr), |
| 173 draw_timer_(false, false), | 173 draw_timer_(false, false), |
| 174 frame_pending_(false), | 174 frame_pending_(false), |
| 175 #if !defined(OS_ANDROID) | 175 #if !defined(OS_ANDROID) |
| 176 cursor_loader_(ui::CursorLoader::Create()), | 176 cursor_loader_(ui::CursorLoader::Create()), |
| 177 #endif | 177 #endif |
| 178 weak_factory_(this) { | 178 weak_factory_(this) { |
| 179 metrics_.size_in_pixels = mojo::Size::New(); | 179 metrics_.size_in_pixels = mojo::Size::New(); |
| 180 metrics_.size_in_pixels->width = 1024; | 180 metrics_.size_in_pixels->width = init_params.display_bounds.width(); |
| 181 metrics_.size_in_pixels->height = 768; | 181 metrics_.size_in_pixels->height = init_params.display_bounds.height(); |
| 182 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. |
| 182 } | 183 } |
| 183 | 184 |
| 184 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { | 185 void DefaultPlatformDisplay::Init(PlatformDisplayDelegate* delegate) { |
| 185 delegate_ = delegate; | 186 delegate_ = delegate; |
| 186 | 187 |
| 187 gfx::Rect bounds(metrics_.size_in_pixels.To<gfx::Size>()); | 188 gfx::Rect bounds(metrics_.size_in_pixels.To<gfx::Size>()); |
| 188 #if defined(OS_WIN) | 189 #if defined(OS_WIN) |
| 189 platform_window_.reset(new ui::WinWindow(this, bounds)); | 190 platform_window_.reset(new ui::WinWindow(this, bounds)); |
| 190 #elif defined(USE_X11) | 191 #elif defined(USE_X11) |
| 191 platform_window_.reset(new ui::X11Window(this)); | 192 platform_window_.reset(new ui::X11Window(this)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 303 } |
| 303 | 304 |
| 304 bool DefaultPlatformDisplay::IsFramePending() const { | 305 bool DefaultPlatformDisplay::IsFramePending() const { |
| 305 return frame_pending_; | 306 return frame_pending_; |
| 306 } | 307 } |
| 307 | 308 |
| 308 void DefaultPlatformDisplay::WantToDraw() { | 309 void DefaultPlatformDisplay::WantToDraw() { |
| 309 if (draw_timer_.IsRunning() || frame_pending_) | 310 if (draw_timer_.IsRunning() || frame_pending_) |
| 310 return; | 311 return; |
| 311 | 312 |
| 313 // TODO(rjkroege): Use vblank to kick off Draw. |
| 312 draw_timer_.Start( | 314 draw_timer_.Start( |
| 313 FROM_HERE, base::TimeDelta(), | 315 FROM_HERE, base::TimeDelta(), |
| 314 base::Bind(&DefaultPlatformDisplay::Draw, weak_factory_.GetWeakPtr())); | 316 base::Bind(&DefaultPlatformDisplay::Draw, weak_factory_.GetWeakPtr())); |
| 315 } | 317 } |
| 316 | 318 |
| 317 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Size& size, | 319 void DefaultPlatformDisplay::UpdateMetrics(const gfx::Size& size, |
| 318 float device_pixel_ratio) { | 320 float device_pixel_ratio) { |
| 319 if (display::Display::HasForceDeviceScaleFactor()) | 321 if (display::Display::HasForceDeviceScaleFactor()) |
| 320 device_pixel_ratio = display::Display::GetForcedDeviceScaleFactor(); | 322 device_pixel_ratio = display::Display::GetForcedDeviceScaleFactor(); |
| 321 if (metrics_.size_in_pixels.To<gfx::Size>() == size && | 323 if (metrics_.size_in_pixels.To<gfx::Size>() == size && |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 436 |
| 435 void DefaultPlatformDisplay::RequestCopyOfOutput( | 437 void DefaultPlatformDisplay::RequestCopyOfOutput( |
| 436 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 438 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
| 437 if (top_level_display_client_) | 439 if (top_level_display_client_) |
| 438 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); | 440 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); |
| 439 } | 441 } |
| 440 | 442 |
| 441 } // namespace ws | 443 } // namespace ws |
| 442 | 444 |
| 443 } // namespace mus | 445 } // namespace mus |
| OLD | NEW |