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" |
11 #include "cc/output/delegated_frame_data.h" | 11 #include "cc/output/delegated_frame_data.h" |
12 #include "cc/quads/render_pass.h" | 12 #include "cc/quads/render_pass.h" |
13 #include "cc/quads/shared_quad_state.h" | 13 #include "cc/quads/shared_quad_state.h" |
14 #include "cc/quads/surface_draw_quad.h" | 14 #include "cc/quads/surface_draw_quad.h" |
15 #include "components/mus/gles2/gpu_state.h" | 15 #include "components/mus/gles2/gpu_state.h" |
16 #include "components/mus/public/interfaces/gpu.mojom.h" | 16 #include "components/mus/public/interfaces/gpu.mojom.h" |
17 #include "components/mus/public/interfaces/quads.mojom.h" | 17 #include "components/mus/public/interfaces/quads.mojom.h" |
| 18 #include "components/mus/surfaces/display_compositor.h" |
18 #include "components/mus/surfaces/surfaces_state.h" | 19 #include "components/mus/surfaces/surfaces_state.h" |
19 #include "components/mus/surfaces/top_level_display_client.h" | |
20 #include "components/mus/ws/platform_display_factory.h" | 20 #include "components/mus/ws/platform_display_factory.h" |
21 #include "components/mus/ws/server_window.h" | 21 #include "components/mus/ws/server_window.h" |
22 #include "components/mus/ws/server_window_surface.h" | 22 #include "components/mus/ws/server_window_surface.h" |
23 #include "components/mus/ws/server_window_surface_manager.h" | 23 #include "components/mus/ws/server_window_surface_manager.h" |
24 #include "components/mus/ws/window_coordinate_conversions.h" | 24 #include "components/mus/ws/window_coordinate_conversions.h" |
25 #include "mojo/converters/geometry/geometry_type_converters.h" | 25 #include "mojo/converters/geometry/geometry_type_converters.h" |
26 #include "mojo/converters/input_events/input_events_type_converters.h" | 26 #include "mojo/converters/input_events/input_events_type_converters.h" |
27 #include "mojo/converters/input_events/mojo_extended_key_event_data.h" | 27 #include "mojo/converters/input_events/mojo_extended_key_event_data.h" |
28 #include "mojo/converters/surfaces/surfaces_type_converters.h" | 28 #include "mojo/converters/surfaces/surfaces_type_converters.h" |
29 #include "mojo/converters/surfaces/surfaces_utils.h" | 29 #include "mojo/converters/surfaces/surfaces_utils.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 #endif | 200 #endif |
201 platform_window_->SetBounds(bounds); | 201 platform_window_->SetBounds(bounds); |
202 platform_window_->Show(); | 202 platform_window_->Show(); |
203 } | 203 } |
204 | 204 |
205 DefaultPlatformDisplay::~DefaultPlatformDisplay() { | 205 DefaultPlatformDisplay::~DefaultPlatformDisplay() { |
206 // Don't notify the delegate from the destructor. | 206 // Don't notify the delegate from the destructor. |
207 delegate_ = nullptr; | 207 delegate_ = nullptr; |
208 | 208 |
209 // Invalidate WeakPtrs now to avoid callbacks back into the | 209 // Invalidate WeakPtrs now to avoid callbacks back into the |
210 // DefaultPlatformDisplay during destruction of |top_level_display_client_|. | 210 // DefaultPlatformDisplay during destruction of |display_compositor_|. |
211 weak_factory_.InvalidateWeakPtrs(); | 211 weak_factory_.InvalidateWeakPtrs(); |
212 top_level_display_client_.reset(); | 212 display_compositor_.reset(); |
213 // Destroy the PlatformWindow early on as it may call us back during | 213 // Destroy the PlatformWindow early on as it may call us back during |
214 // destruction and we want to be in a known state. But destroy the surface | 214 // destruction and we want to be in a known state. But destroy the surface |
215 // first because it can still be using the platform window. | 215 // first because it can still be using the platform window. |
216 platform_window_.reset(); | 216 platform_window_.reset(); |
217 } | 217 } |
218 | 218 |
219 void DefaultPlatformDisplay::SchedulePaint(const ServerWindow* window, | 219 void DefaultPlatformDisplay::SchedulePaint(const ServerWindow* window, |
220 const gfx::Rect& bounds) { | 220 const gfx::Rect& bounds) { |
221 DCHECK(window); | 221 DCHECK(window); |
222 if (!window->IsDrawn()) | 222 if (!window->IsDrawn()) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 ime->SetImeVisibility(visible); | 280 ime->SetImeVisibility(visible); |
281 } | 281 } |
282 | 282 |
283 void DefaultPlatformDisplay::Draw() { | 283 void DefaultPlatformDisplay::Draw() { |
284 if (!delegate_->GetRootWindow()->visible()) | 284 if (!delegate_->GetRootWindow()->visible()) |
285 return; | 285 return; |
286 | 286 |
287 // TODO(fsamuel): We should add a trace for generating a top level frame. | 287 // TODO(fsamuel): We should add a trace for generating a top level frame. |
288 std::unique_ptr<cc::CompositorFrame> frame(GenerateCompositorFrame()); | 288 std::unique_ptr<cc::CompositorFrame> frame(GenerateCompositorFrame()); |
289 frame_pending_ = true; | 289 frame_pending_ = true; |
290 if (top_level_display_client_) { | 290 if (display_compositor_) { |
291 top_level_display_client_->SubmitCompositorFrame( | 291 display_compositor_->SubmitCompositorFrame( |
292 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw, | 292 std::move(frame), base::Bind(&DefaultPlatformDisplay::DidDraw, |
293 weak_factory_.GetWeakPtr())); | 293 weak_factory_.GetWeakPtr())); |
294 } | 294 } |
295 dirty_rect_ = gfx::Rect(); | 295 dirty_rect_ = gfx::Rect(); |
296 } | 296 } |
297 | 297 |
298 void DefaultPlatformDisplay::DidDraw() { | 298 void DefaultPlatformDisplay::DidDraw(cc::SurfaceDrawStatus status) { |
299 frame_pending_ = false; | 299 frame_pending_ = false; |
300 delegate_->OnCompositorFrameDrawn(); | 300 delegate_->OnCompositorFrameDrawn(); |
301 if (!dirty_rect_.IsEmpty()) | 301 if (!dirty_rect_.IsEmpty()) |
302 WantToDraw(); | 302 WantToDraw(); |
303 } | 303 } |
304 | 304 |
305 bool DefaultPlatformDisplay::IsFramePending() const { | 305 bool DefaultPlatformDisplay::IsFramePending() const { |
306 return frame_pending_; | 306 return frame_pending_; |
307 } | 307 } |
308 | 308 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 ui::PlatformWindowState new_state) {} | 413 ui::PlatformWindowState new_state) {} |
414 | 414 |
415 void DefaultPlatformDisplay::OnLostCapture() { | 415 void DefaultPlatformDisplay::OnLostCapture() { |
416 delegate_->OnNativeCaptureLost(); | 416 delegate_->OnNativeCaptureLost(); |
417 } | 417 } |
418 | 418 |
419 void DefaultPlatformDisplay::OnAcceleratedWidgetAvailable( | 419 void DefaultPlatformDisplay::OnAcceleratedWidgetAvailable( |
420 gfx::AcceleratedWidget widget, | 420 gfx::AcceleratedWidget widget, |
421 float device_pixel_ratio) { | 421 float device_pixel_ratio) { |
422 if (widget != gfx::kNullAcceleratedWidget) { | 422 if (widget != gfx::kNullAcceleratedWidget) { |
423 top_level_display_client_.reset( | 423 display_compositor_.reset( |
424 new TopLevelDisplayClient(widget, gpu_state_, surfaces_state_)); | 424 new DisplayCompositor(base::ThreadTaskRunnerHandle::Get(), widget, |
425 delegate_->OnTopLevelSurfaceChanged( | 425 gpu_state_, surfaces_state_)); |
426 top_level_display_client_->surface_id()); | 426 delegate_->OnTopLevelSurfaceChanged(display_compositor_->surface_id()); |
427 } | 427 } |
428 UpdateMetrics(metrics_.size_in_pixels.To<gfx::Size>(), device_pixel_ratio); | 428 UpdateMetrics(metrics_.size_in_pixels.To<gfx::Size>(), device_pixel_ratio); |
429 } | 429 } |
430 | 430 |
431 void DefaultPlatformDisplay::OnAcceleratedWidgetDestroyed() { | 431 void DefaultPlatformDisplay::OnAcceleratedWidgetDestroyed() { |
432 NOTREACHED(); | 432 NOTREACHED(); |
433 } | 433 } |
434 | 434 |
435 void DefaultPlatformDisplay::OnActivationChanged(bool active) {} | 435 void DefaultPlatformDisplay::OnActivationChanged(bool active) {} |
436 | 436 |
437 void DefaultPlatformDisplay::RequestCopyOfOutput( | 437 void DefaultPlatformDisplay::RequestCopyOfOutput( |
438 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 438 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
439 if (top_level_display_client_) | 439 if (display_compositor_) |
440 top_level_display_client_->RequestCopyOfOutput(std::move(output_request)); | 440 display_compositor_->RequestCopyOfOutput(std::move(output_request)); |
441 } | 441 } |
442 | 442 |
443 } // namespace ws | 443 } // namespace ws |
444 | 444 |
445 } // namespace mus | 445 } // namespace mus |
OLD | NEW |