| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/gpu_compositor_frame_sink.h" | 5 #include "services/ui/surfaces/gpu_compositor_frame_sink.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
| 12 #include "cc/output/output_surface.h" | 12 #include "cc/output/output_surface.h" |
| 13 #include "cc/output/texture_mailbox_deleter.h" | 13 #include "cc/output/texture_mailbox_deleter.h" |
| 14 #include "cc/quads/shared_quad_state.h" | 14 #include "cc/quads/shared_quad_state.h" |
| 15 #include "cc/quads/surface_draw_quad.h" | 15 #include "cc/quads/surface_draw_quad.h" |
| 16 #include "cc/scheduler/begin_frame_source.h" | 16 #include "cc/scheduler/begin_frame_source.h" |
| 17 #include "cc/surfaces/display_scheduler.h" | 17 #include "cc/surfaces/display_scheduler.h" |
| 18 #include "services/ui/surfaces/direct_output_surface.h" | |
| 19 #include "services/ui/surfaces/display_compositor.h" | 18 #include "services/ui/surfaces/display_compositor.h" |
| 19 #include "services/ui/surfaces/display_output_surface.h" |
| 20 | 20 |
| 21 #if defined(USE_OZONE) | 21 #if defined(USE_OZONE) |
| 22 #include "gpu/command_buffer/client/gles2_interface.h" | 22 #include "gpu/command_buffer/client/gles2_interface.h" |
| 23 #include "services/ui/surfaces/direct_output_surface_ozone.h" | 23 #include "services/ui/surfaces/display_output_surface_ozone.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 namespace ui { | 26 namespace ui { |
| 27 | 27 |
| 28 GpuCompositorFrameSink::GpuCompositorFrameSink( | 28 GpuCompositorFrameSink::GpuCompositorFrameSink( |
| 29 DisplayCompositor* display_compositor, | 29 DisplayCompositor* display_compositor, |
| 30 const cc::FrameSinkId& frame_sink_id, | 30 const cc::FrameSinkId& frame_sink_id, |
| 31 gpu::SurfaceHandle surface_handle, | 31 gpu::SurfaceHandle surface_handle, |
| 32 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 32 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 33 scoped_refptr<cc::InProcessContextProvider> context_provider, | 33 scoped_refptr<cc::InProcessContextProvider> context_provider, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 130 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
| 131 CHECK(context_provider->BindToCurrentThread()); | 131 CHECK(context_provider->BindToCurrentThread()); |
| 132 | 132 |
| 133 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( | 133 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( |
| 134 new cc::DelayBasedBeginFrameSource( | 134 new cc::DelayBasedBeginFrameSource( |
| 135 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); | 135 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner_.get()))); |
| 136 | 136 |
| 137 std::unique_ptr<cc::OutputSurface> display_output_surface; | 137 std::unique_ptr<cc::OutputSurface> display_output_surface; |
| 138 if (context_provider->ContextCapabilities().surfaceless) { | 138 if (context_provider->ContextCapabilities().surfaceless) { |
| 139 #if defined(USE_OZONE) | 139 #if defined(USE_OZONE) |
| 140 display_output_surface = base::MakeUnique<DirectOutputSurfaceOzone>( | 140 display_output_surface = base::MakeUnique<DisplayOutputSurfaceOzone>( |
| 141 std::move(context_provider), surface_handle, | 141 std::move(context_provider), surface_handle, |
| 142 synthetic_begin_frame_source.get(), gpu_memory_buffer_manager, | 142 synthetic_begin_frame_source.get(), gpu_memory_buffer_manager, |
| 143 GL_TEXTURE_2D, GL_RGB); | 143 GL_TEXTURE_2D, GL_RGB); |
| 144 #else | 144 #else |
| 145 NOTREACHED(); | 145 NOTREACHED(); |
| 146 #endif | 146 #endif |
| 147 } else { | 147 } else { |
| 148 display_output_surface = base::MakeUnique<DirectOutputSurface>( | 148 display_output_surface = base::MakeUnique<DisplayOutputSurface>( |
| 149 std::move(context_provider), synthetic_begin_frame_source.get()); | 149 std::move(context_provider), synthetic_begin_frame_source.get()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 int max_frames_pending = | 152 int max_frames_pending = |
| 153 display_output_surface->capabilities().max_frames_pending; | 153 display_output_surface->capabilities().max_frames_pending; |
| 154 DCHECK_GT(max_frames_pending, 0); | 154 DCHECK_GT(max_frames_pending, 0); |
| 155 | 155 |
| 156 std::unique_ptr<cc::DisplayScheduler> scheduler( | 156 std::unique_ptr<cc::DisplayScheduler> scheduler( |
| 157 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), | 157 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), |
| 158 task_runner_.get(), max_frames_pending)); | 158 task_runner_.get(), max_frames_pending)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 } | 236 } |
| 237 | 237 |
| 238 void GpuCompositorFrameSink::OnPrivateConnectionLost() { | 238 void GpuCompositorFrameSink::OnPrivateConnectionLost() { |
| 239 private_connection_lost_ = true; | 239 private_connection_lost_ = true; |
| 240 // Request destruction of |this| only if both connections are lost. | 240 // Request destruction of |this| only if both connections are lost. |
| 241 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( | 241 display_compositor_->OnCompositorFrameSinkPrivateConnectionLost( |
| 242 frame_sink_id_, client_connection_lost_); | 242 frame_sink_id_, client_connection_lost_); |
| 243 } | 243 } |
| 244 | 244 |
| 245 } // namespace ui | 245 } // namespace ui |
| OLD | NEW |