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 std::unique_ptr<cc::CompositorFrame> frame(GenerateCompositorFrame()); | 260 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 std::unique_ptr<cc::CompositorFrame> | 309 cc::CompositorFrame DefaultPlatformDisplay::GenerateCompositorFrame() { |
310 DefaultPlatformDisplay::GenerateCompositorFrame() { | |
311 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); | 310 std::unique_ptr<cc::RenderPass> render_pass = cc::RenderPass::Create(); |
312 render_pass->damage_rect = dirty_rect_; | 311 render_pass->damage_rect = dirty_rect_; |
313 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); | 312 render_pass->output_rect = gfx::Rect(metrics_.size_in_pixels); |
314 | 313 |
315 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), | 314 DrawWindowTree(render_pass.get(), delegate_->GetRootWindow(), gfx::Vector2d(), |
316 1.0f); | 315 1.0f); |
317 | 316 |
318 std::unique_ptr<cc::DelegatedFrameData> frame_data( | 317 std::unique_ptr<cc::DelegatedFrameData> frame_data( |
319 new cc::DelegatedFrameData); | 318 new cc::DelegatedFrameData); |
320 frame_data->device_scale_factor = metrics_.device_scale_factor; | 319 frame_data->device_scale_factor = metrics_.device_scale_factor; |
321 frame_data->render_pass_list.push_back(std::move(render_pass)); | 320 frame_data->render_pass_list.push_back(std::move(render_pass)); |
322 | 321 |
323 std::unique_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | 322 cc::CompositorFrame frame; |
324 frame->delegated_frame_data = std::move(frame_data); | 323 frame.delegated_frame_data = std::move(frame_data); |
325 return frame; | 324 return frame; |
326 } | 325 } |
327 | 326 |
328 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { | 327 void DefaultPlatformDisplay::OnBoundsChanged(const gfx::Rect& new_bounds) { |
329 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); | 328 UpdateMetrics(new_bounds.size(), metrics_.device_scale_factor); |
330 } | 329 } |
331 | 330 |
332 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { | 331 void DefaultPlatformDisplay::OnDamageRect(const gfx::Rect& damaged_region) { |
333 dirty_rect_.Union(damaged_region); | 332 dirty_rect_.Union(damaged_region); |
334 WantToDraw(); | 333 WantToDraw(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 406 |
408 void DefaultPlatformDisplay::RequestCopyOfOutput( | 407 void DefaultPlatformDisplay::RequestCopyOfOutput( |
409 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 408 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
410 if (display_compositor_) | 409 if (display_compositor_) |
411 display_compositor_->RequestCopyOfOutput(std::move(output_request)); | 410 display_compositor_->RequestCopyOfOutput(std::move(output_request)); |
412 } | 411 } |
413 | 412 |
414 } // namespace ws | 413 } // namespace ws |
415 | 414 |
416 } // namespace mus | 415 } // namespace mus |
OLD | NEW |