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