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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); | 250 ui::PlatformImeController* ime = platform_window_->GetPlatformImeController(); |
251 if (ime) | 251 if (ime) |
252 ime->SetImeVisibility(visible); | 252 ime->SetImeVisibility(visible); |
253 } | 253 } |
254 | 254 |
255 void DefaultPlatformDisplay::Draw() { | 255 void DefaultPlatformDisplay::Draw() { |
256 if (!delegate_->GetRootWindow()->visible()) | 256 if (!delegate_->GetRootWindow()->visible()) |
257 return; | 257 return; |
258 | 258 |
259 // TODO(fsamuel): We should add a trace for generating a top level frame. | 259 // TODO(fsamuel): We should add a trace for generating a top level frame. |
260 cc::CompositorFrame frame(GenerateCompositorFrame()); | 260 std::unique_ptr<cc::CompositorFrame> frame(GenerateCompositorFrame()); |
261 frame_pending_ = true; | 261 frame_pending_ = true; |
262 if (display_compositor_) { | 262 if (display_compositor_) { |
263 display_compositor_->SubmitCompositorFrame( | 263 display_compositor_->SubmitCompositorFrame( |
264 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw, | 264 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw, |
265 weak_factory_.GetWeakPtr())); | 265 weak_factory_.GetWeakPtr())); |
266 } | 266 } |
267 dirty_rect_ = gfx::Rect(); | 267 dirty_rect_ = gfx::Rect(); |
268 } | 268 } |
269 | 269 |
270 void DefaultPlatformDisplay::DidDraw(cc::SurfaceDrawStatus status) { | 270 void DefaultPlatformDisplay::DidDraw(cc::SurfaceDrawStatus status) { |
(...skipping 28 matching lines...) Expand all Loading... |
299 if (metrics_.size_in_pixels == size && | 299 if (metrics_.size_in_pixels == size && |
300 metrics_.device_scale_factor == device_scale_factor) | 300 metrics_.device_scale_factor == device_scale_factor) |
301 return; | 301 return; |
302 | 302 |
303 ViewportMetrics old_metrics = metrics_; | 303 ViewportMetrics old_metrics = metrics_; |
304 metrics_.size_in_pixels = size; | 304 metrics_.size_in_pixels = size; |
305 metrics_.device_scale_factor = device_scale_factor; | 305 metrics_.device_scale_factor = device_scale_factor; |
306 delegate_->OnViewportMetricsChanged(old_metrics, metrics_); | 306 delegate_->OnViewportMetricsChanged(old_metrics, metrics_); |
307 } | 307 } |
308 | 308 |
309 cc::CompositorFrame DefaultPlatformDisplay::GenerateCompositorFrame() { | 309 std::unique_ptr<cc::CompositorFrame> |
| 310 DefaultPlatformDisplay::GenerateCompositorFrame() { |
310 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | 311 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); |
311 render_pass->damage_rect = dirty_rect_; | 312 render_pass->damage_rect = dirty_rect_; |
312 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); | 313 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); |
313 | 314 |
314 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), | 315 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), |
315 1.0f); | 316 1.0f); |
316 | 317 |
317 std::unique_ptr<cc::DelegatedFrameData> frame_data( | 318 std::unique_ptr<cc::DelegatedFrameData> frame_data( |
318 new cc::DelegatedFrameData); | 319 new cc::DelegatedFrameData); |
319 frame_data->device_scale_factor = metrics_.device_scale_factor; | 320 frame_data->device_scale_factor = metrics_.device_scale_factor; |
320 frame_data->render_pass_list.push_back(std::move(render_pass)); | 321 frame_data->render_pass_list.push_back(std::move(render_pass)); |
321 | 322 |
322 cc::CompositorFrame frame; | 323 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); |
323 frame.delegated_frame_data = std::move(frame_data); | 324 frame->delegated_frame_data = std::move(frame_data); |
324 return frame; | 325 return frame; |
325 } | 326 } |
326 | 327 |
327 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { | 328 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { |
328 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); | 329 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); |
329 } | 330 } |
330 | 331 |
331 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { | 332 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { |
332 dirty_rect_.Union(damaged_region); | 333 dirty_rect_.Union(damaged_region); |
333 WantToDraw(); | 334 WantToDraw(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 407 |
407 void DefaultPlatformDisplay::RequestCopyOfOutput( | 408 void DefaultPlatformDisplay::RequestCopyOfOutput( |
408 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 409 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
409 if (display_compositor_) | 410 if (display_compositor_) |
410 display_compositor_->RequestCopyOfOutput(std::move(output_request)); | 411 display_compositor_->RequestCopyOfOutput(std::move(output_request)); |
411 } | 412 } |
412 | 413 |
413 } // namespace ws | 414 } // namespace ws |
414 | 415 |
415 } // namespace mus | 416 } // namespace mus |
OLD | NEW |