| 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/ipc/quads.mojom.h" | 9 #include "cc/ipc/quads.mojom.h" |
| 10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 PlatformDisplay* PlatformDisplay::Create( | 135 PlatformDisplay* PlatformDisplay::Create( |
| 136 const PlatformDisplayInitParams& init_params) { | 136 const PlatformDisplayInitParams& init_params) { |
| 137 if (factory_) | 137 if (factory_) |
| 138 return factory_->CreatePlatformDisplay(); | 138 return factory_->CreatePlatformDisplay(); |
| 139 | 139 |
| 140 return new DefaultPlatformDisplay(init_params); | 140 return new DefaultPlatformDisplay(init_params); |
| 141 } | 141 } |
| 142 | 142 |
| 143 DefaultPlatformDisplay::DefaultPlatformDisplay( | 143 DefaultPlatformDisplay::DefaultPlatformDisplay( |
| 144 const PlatformDisplayInitParams& init_params) | 144 const PlatformDisplayInitParams& init_params) |
| 145 : gpu_state_(init_params.gpu_state), | 145 : display_id_(init_params.display_id), |
| 146 gpu_state_(init_params.gpu_state), |
| 146 surfaces_state_(init_params.surfaces_state), | 147 surfaces_state_(init_params.surfaces_state), |
| 147 delegate_(nullptr), | 148 delegate_(nullptr), |
| 148 draw_timer_(false, false), | 149 draw_timer_(false, false), |
| 149 frame_pending_(false), | 150 frame_pending_(false), |
| 150 #if !defined(OS_ANDROID) | 151 #if !defined(OS_ANDROID) |
| 151 cursor_loader_(ui::CursorLoader::Create()), | 152 cursor_loader_(ui::CursorLoader::Create()), |
| 152 #endif | 153 #endif |
| 153 weak_factory_(this) { | 154 weak_factory_(this) { |
| 154 metrics_.size_in_pixels = init_params.display_bounds.size(); | 155 metrics_.size_in_pixels = init_params.display_bounds.size(); |
| 155 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. | 156 // TODO(rjkroege): Preserve the display_id when Ozone platform can use it. |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 frame_pending_ = false; | 273 frame_pending_ = false; |
| 273 delegate_->OnCompositorFrameDrawn(); | 274 delegate_->OnCompositorFrameDrawn(); |
| 274 if (!dirty_rect_.IsEmpty()) | 275 if (!dirty_rect_.IsEmpty()) |
| 275 WantToDraw(); | 276 WantToDraw(); |
| 276 } | 277 } |
| 277 | 278 |
| 278 bool DefaultPlatformDisplay::IsFramePending() const { | 279 bool DefaultPlatformDisplay::IsFramePending() const { |
| 279 return frame_pending_; | 280 return frame_pending_; |
| 280 } | 281 } |
| 281 | 282 |
| 283 int64_t DefaultPlatformDisplay::GetDisplayId() const { |
| 284 return display_id_; |
| 285 } |
| 286 |
| 282 void DefaultPlatformDisplay::WantToDraw() { | 287 void DefaultPlatformDisplay::WantToDraw() { |
| 283 if (draw_timer_.IsRunning() || frame_pending_) | 288 if (draw_timer_.IsRunning() || frame_pending_) |
| 284 return; | 289 return; |
| 285 | 290 |
| 286 // TODO(rjkroege): Use vblank to kick off Draw. | 291 // TODO(rjkroege): Use vblank to kick off Draw. |
| 287 draw_timer_.Start( | 292 draw_timer_.Start( |
| 288 FROM_HERE, base::TimeDelta(), | 293 FROM_HERE, base::TimeDelta(), |
| 289 base::Bind(&DefaultPlatformDisplay::Draw, weak_factory_.GetWeakPtr())); | 294 base::Bind(&DefaultPlatformDisplay::Draw, weak_factory_.GetWeakPtr())); |
| 290 } | 295 } |
| 291 | 296 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 409 |
| 405 void DefaultPlatformDisplay::RequestCopyOfOutput( | 410 void DefaultPlatformDisplay::RequestCopyOfOutput( |
| 406 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 411 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
| 407 if (display_compositor_) | 412 if (display_compositor_) |
| 408 display_compositor_->RequestCopyOfOutput(std::move(output_request)); | 413 display_compositor_->RequestCopyOfOutput(std::move(output_request)); |
| 409 } | 414 } |
| 410 | 415 |
| 411 } // namespace ws | 416 } // namespace ws |
| 412 | 417 |
| 413 } // namespace mus | 418 } // namespace mus |
| OLD | NEW |