| 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 "components/mus/surfaces/display_compositor.h" | 5 #include "components/mus/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" |
| 11 #include "cc/scheduler/begin_frame_source.h" |
| 12 #include "cc/scheduler/delay_based_time_source.h" |
| 10 #include "cc/surfaces/display.h" | 13 #include "cc/surfaces/display.h" |
| 14 #include "cc/surfaces/display_scheduler.h" |
| 11 #include "components/mus/surfaces/direct_output_surface.h" | 15 #include "components/mus/surfaces/direct_output_surface.h" |
| 12 #include "components/mus/surfaces/surfaces_context_provider.h" | 16 #include "components/mus/surfaces/surfaces_context_provider.h" |
| 13 | 17 |
| 14 #if defined(USE_OZONE) | 18 #if defined(USE_OZONE) |
| 15 #include "components/mus/surfaces/direct_output_surface_ozone.h" | 19 #include "components/mus/surfaces/direct_output_surface_ozone.h" |
| 16 #include "gpu/command_buffer/client/gles2_interface.h" | 20 #include "gpu/command_buffer/client/gles2_interface.h" |
| 17 #endif | 21 #endif |
| 18 | 22 |
| 19 namespace mus { | 23 namespace mus { |
| 20 | 24 |
| 21 DisplayCompositor::DisplayCompositor( | 25 DisplayCompositor::DisplayCompositor( |
| 22 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 26 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 23 gfx::AcceleratedWidget widget, | 27 gfx::AcceleratedWidget widget, |
| 24 const scoped_refptr<GpuState>& gpu_state, | 28 const scoped_refptr<GpuState>& gpu_state, |
| 25 const scoped_refptr<SurfacesState>& surfaces_state) | 29 const scoped_refptr<SurfacesState>& surfaces_state) |
| 26 : task_runner_(task_runner), | 30 : task_runner_(task_runner), |
| 27 surfaces_state_(surfaces_state), | 31 surfaces_state_(surfaces_state), |
| 28 factory_(surfaces_state->manager(), this), | 32 factory_(surfaces_state->manager(), this), |
| 29 allocator_(surfaces_state->next_id_namespace()) { | 33 allocator_(surfaces_state->next_id_namespace()) { |
| 30 allocator_.RegisterSurfaceIdNamespace(surfaces_state_->manager()); | 34 allocator_.RegisterSurfaceIdNamespace(surfaces_state_->manager()); |
| 31 surfaces_state_->manager()->RegisterSurfaceFactoryClient( | 35 surfaces_state_->manager()->RegisterSurfaceFactoryClient( |
| 32 allocator_.id_namespace(), this); | 36 allocator_.id_namespace(), this); |
| 33 | 37 |
| 34 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( | 38 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( |
| 35 new SurfacesContextProvider(widget, gpu_state)); | 39 new SurfacesContextProvider(widget, gpu_state)); |
| 36 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 40 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
| 37 CHECK(surfaces_context_provider->BindToCurrentThread()); | 41 CHECK(surfaces_context_provider->BindToCurrentThread()); |
| 38 | 42 |
| 43 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( |
| 44 new cc::DelayBasedBeginFrameSource( |
| 45 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); |
| 46 |
| 39 std::unique_ptr<cc::OutputSurface> display_output_surface; | 47 std::unique_ptr<cc::OutputSurface> display_output_surface; |
| 40 if (surfaces_context_provider->ContextCapabilities().surfaceless) { | 48 if (surfaces_context_provider->ContextCapabilities().surfaceless) { |
| 41 #if defined(USE_OZONE) | 49 #if defined(USE_OZONE) |
| 42 display_output_surface = base::WrapUnique(new DirectOutputSurfaceOzone( | 50 display_output_surface = base::WrapUnique(new DirectOutputSurfaceOzone( |
| 43 surfaces_context_provider, widget, task_runner_.get(), GL_TEXTURE_2D, | 51 surfaces_context_provider, widget, synthetic_begin_frame_source.get(), |
| 44 GL_RGB)); | 52 GL_TEXTURE_2D, GL_RGB)); |
| 45 #else | 53 #else |
| 46 NOTREACHED(); | 54 NOTREACHED(); |
| 47 #endif | 55 #endif |
| 48 } else { | 56 } else { |
| 49 display_output_surface = base::WrapUnique( | 57 display_output_surface = base::WrapUnique(new DirectOutputSurface( |
| 50 new DirectOutputSurface(surfaces_context_provider, task_runner_.get())); | 58 surfaces_context_provider, synthetic_begin_frame_source.get())); |
| 51 } | 59 } |
| 52 | 60 |
| 53 int max_frames_pending = | 61 int max_frames_pending = |
| 54 display_output_surface->capabilities().max_frames_pending; | 62 display_output_surface->capabilities().max_frames_pending; |
| 55 DCHECK_GT(max_frames_pending, 0); | 63 DCHECK_GT(max_frames_pending, 0); |
| 56 | 64 |
| 57 display_.reset( | 65 std::unique_ptr<cc::DisplayScheduler> scheduler( |
| 58 new cc::Display(surfaces_state_->manager(), nullptr /* bitmap_manager */, | 66 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), |
| 59 nullptr /* gpu_memory_buffer_manager */, | 67 task_runner_.get(), max_frames_pending)); |
| 60 cc::RendererSettings(), allocator_.id_namespace(), | 68 |
| 61 task_runner_.get(), std::move(display_output_surface))); | 69 display_.reset(new cc::Display( |
| 70 surfaces_state_->manager(), nullptr /* bitmap_manager */, |
| 71 nullptr /* gpu_memory_buffer_manager */, cc::RendererSettings(), |
| 72 allocator_.id_namespace(), std::move(synthetic_begin_frame_source), |
| 73 std::move(display_output_surface), std::move(scheduler), |
| 74 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); |
| 62 | 75 |
| 63 bool init = display_->Initialize(this); | 76 bool init = display_->Initialize(this); |
| 64 DCHECK(init); // The context provider was already bound above. | 77 DCHECK(init); // The context provider was already bound above. |
| 65 } | 78 } |
| 66 | 79 |
| 67 DisplayCompositor::~DisplayCompositor() { | 80 DisplayCompositor::~DisplayCompositor() { |
| 68 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( | 81 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( |
| 69 allocator_.id_namespace()); | 82 allocator_.id_namespace()); |
| 70 } | 83 } |
| 71 | 84 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void DisplayCompositor::DisplayOutputSurfaceLost() { | 117 void DisplayCompositor::DisplayOutputSurfaceLost() { |
| 105 // TODO(fsamuel): This looks like it would crash if a frame was in flight and | 118 // TODO(fsamuel): This looks like it would crash if a frame was in flight and |
| 106 // will be submitted. | 119 // will be submitted. |
| 107 display_.reset(); | 120 display_.reset(); |
| 108 } | 121 } |
| 109 | 122 |
| 110 void DisplayCompositor::DisplaySetMemoryPolicy( | 123 void DisplayCompositor::DisplaySetMemoryPolicy( |
| 111 const cc::ManagedMemoryPolicy& policy) {} | 124 const cc::ManagedMemoryPolicy& policy) {} |
| 112 | 125 |
| 113 } // namespace mus | 126 } // namespace mus |
| OLD | NEW |