| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/surfaces/display_compositor.h" | 5 #include "services/ui/surfaces/display_compositor.h" |
| 6 | 6 |
| 7 #include "cc/output/copy_output_request.h" | 7 #include "cc/output/copy_output_request.h" |
| 8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
| 9 #include "cc/output/renderer_settings.h" | 9 #include "cc/output/renderer_settings.h" |
| 10 #include "cc/output/texture_mailbox_deleter.h" | 10 #include "cc/output/texture_mailbox_deleter.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 | 24 |
| 25 DisplayCompositor::DisplayCompositor( | 25 DisplayCompositor::DisplayCompositor( |
| 26 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 26 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 27 gfx::AcceleratedWidget widget, | 27 gfx::AcceleratedWidget widget, |
| 28 const scoped_refptr<GpuState>& gpu_state, | 28 const scoped_refptr<GpuState>& gpu_state, |
| 29 const scoped_refptr<SurfacesState>& surfaces_state) | 29 const scoped_refptr<SurfacesState>& surfaces_state) |
| 30 : task_runner_(task_runner), | 30 : task_runner_(task_runner), |
| 31 surfaces_state_(surfaces_state), | 31 surfaces_state_(surfaces_state), |
| 32 factory_(surfaces_state->manager(), this), | 32 factory_(surfaces_state->next_client_id(), |
| 33 allocator_(surfaces_state->next_client_id()) { | 33 surfaces_state->manager(), |
| 34 allocator_.RegisterSurfaceClientId(surfaces_state_->manager()); | 34 this), |
| 35 surfaces_state_->manager()->RegisterSurfaceFactoryClient( | 35 allocator_(factory_.client_id()) { |
| 36 allocator_.client_id(), this); | |
| 37 | |
| 38 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( | 36 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( |
| 39 new SurfacesContextProvider(widget, gpu_state)); | 37 new SurfacesContextProvider(widget, gpu_state)); |
| 40 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 38 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
| 41 CHECK(surfaces_context_provider->BindToCurrentThread()); | 39 CHECK(surfaces_context_provider->BindToCurrentThread()); |
| 42 | 40 |
| 43 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( | 41 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( |
| 44 new cc::DelayBasedBeginFrameSource( | 42 new cc::DelayBasedBeginFrameSource( |
| 45 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); | 43 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); |
| 46 | 44 |
| 47 std::unique_ptr<cc::OutputSurface> display_output_surface; | 45 std::unique_ptr<cc::OutputSurface> display_output_surface; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 display_.reset(new cc::Display( | 67 display_.reset(new cc::Display( |
| 70 nullptr /* bitmap_manager */, nullptr /* gpu_memory_buffer_manager */, | 68 nullptr /* bitmap_manager */, nullptr /* gpu_memory_buffer_manager */, |
| 71 cc::RendererSettings(), std::move(synthetic_begin_frame_source), | 69 cc::RendererSettings(), std::move(synthetic_begin_frame_source), |
| 72 std::move(display_output_surface), std::move(scheduler), | 70 std::move(display_output_surface), std::move(scheduler), |
| 73 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); | 71 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); |
| 74 display_->Initialize(this, surfaces_state_->manager(), | 72 display_->Initialize(this, surfaces_state_->manager(), |
| 75 allocator_.client_id()); | 73 allocator_.client_id()); |
| 76 } | 74 } |
| 77 | 75 |
| 78 DisplayCompositor::~DisplayCompositor() { | 76 DisplayCompositor::~DisplayCompositor() { |
| 79 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( | |
| 80 allocator_.client_id()); | |
| 81 } | 77 } |
| 82 | 78 |
| 83 void DisplayCompositor::SubmitCompositorFrame( | 79 void DisplayCompositor::SubmitCompositorFrame( |
| 84 cc::CompositorFrame frame, | 80 cc::CompositorFrame frame, |
| 85 const base::Callback<void(cc::SurfaceDrawStatus)>& callback) { | 81 const base::Callback<void(cc::SurfaceDrawStatus)>& callback) { |
| 86 gfx::Size frame_size = | 82 gfx::Size frame_size = |
| 87 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 83 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
| 88 if (frame_size.IsEmpty() || frame_size != display_size_) { | 84 if (frame_size.IsEmpty() || frame_size != display_size_) { |
| 89 if (!surface_id_.is_null()) | 85 if (!surface_id_.is_null()) |
| 90 factory_.Destroy(surface_id_); | 86 factory_.Destroy(surface_id_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 115 void DisplayCompositor::DisplayOutputSurfaceLost() { | 111 void DisplayCompositor::DisplayOutputSurfaceLost() { |
| 116 // TODO(fsamuel): This looks like it would crash if a frame was in flight and | 112 // TODO(fsamuel): This looks like it would crash if a frame was in flight and |
| 117 // will be submitted. | 113 // will be submitted. |
| 118 display_.reset(); | 114 display_.reset(); |
| 119 } | 115 } |
| 120 | 116 |
| 121 void DisplayCompositor::DisplaySetMemoryPolicy( | 117 void DisplayCompositor::DisplaySetMemoryPolicy( |
| 122 const cc::ManagedMemoryPolicy& policy) {} | 118 const cc::ManagedMemoryPolicy& policy) {} |
| 123 | 119 |
| 124 } // namespace ui | 120 } // namespace ui |
| OLD | NEW |