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