| 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/direct_output_surface_ozone.h" | 5 #include "components/mus/surfaces/direct_output_surface_ozone.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
| 12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
| 13 #include "cc/output/output_surface_client.h" | 13 #include "cc/output/output_surface_client.h" |
| 14 #include "cc/scheduler/delay_based_time_source.h" | 14 #include "cc/scheduler/begin_frame_source.h" |
| 15 #include "components/display_compositor/buffer_queue.h" | 15 #include "components/display_compositor/buffer_queue.h" |
| 16 #include "components/mus/common/gpu_service.h" | 16 #include "components/mus/common/gpu_service.h" |
| 17 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h" | 17 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h" |
| 18 #include "components/mus/gpu/mus_gpu_memory_buffer_manager.h" | 18 #include "components/mus/gpu/mus_gpu_memory_buffer_manager.h" |
| 19 #include "components/mus/surfaces/surfaces_context_provider.h" | 19 #include "components/mus/surfaces/surfaces_context_provider.h" |
| 20 #include "gpu/command_buffer/client/context_support.h" | 20 #include "gpu/command_buffer/client/context_support.h" |
| 21 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
| 22 | 22 |
| 23 using display_compositor::BufferQueue; | 23 using display_compositor::BufferQueue; |
| 24 | 24 |
| 25 namespace mus { | 25 namespace mus { |
| 26 | 26 |
| 27 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( | 27 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( |
| 28 scoped_refptr<SurfacesContextProvider> context_provider, | 28 scoped_refptr<SurfacesContextProvider> context_provider, |
| 29 gfx::AcceleratedWidget widget, | 29 gfx::AcceleratedWidget widget, |
| 30 base::SingleThreadTaskRunner* task_runner, | 30 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source, |
| 31 uint32_t target, | 31 uint32_t target, |
| 32 uint32_t internalformat) | 32 uint32_t internalformat) |
| 33 : cc::OutputSurface(context_provider, nullptr, nullptr), | 33 : cc::OutputSurface(context_provider, nullptr, nullptr), |
| 34 gl_helper_(context_provider->ContextGL(), | 34 gl_helper_(context_provider->ContextGL(), |
| 35 context_provider->ContextSupport()), | 35 context_provider->ContextSupport()), |
| 36 synthetic_begin_frame_source_(new cc::DelayBasedBeginFrameSource( | 36 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 37 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))), | |
| 38 weak_ptr_factory_(this) { | 37 weak_ptr_factory_(this) { |
| 39 if (!GpuService::UseChromeGpuCommandBuffer()) { | 38 if (!GpuService::UseChromeGpuCommandBuffer()) { |
| 40 ozone_gpu_memory_buffer_manager_.reset(new OzoneGpuMemoryBufferManager()); | 39 ozone_gpu_memory_buffer_manager_.reset(new OzoneGpuMemoryBufferManager()); |
| 41 buffer_queue_.reset(new BufferQueue( | 40 buffer_queue_.reset(new BufferQueue( |
| 42 context_provider->ContextGL(), target, internalformat, &gl_helper_, | 41 context_provider->ContextGL(), target, internalformat, &gl_helper_, |
| 43 ozone_gpu_memory_buffer_manager_.get(), widget)); | 42 ozone_gpu_memory_buffer_manager_.get(), widget)); |
| 44 } else { | 43 } else { |
| 45 buffer_queue_.reset(new BufferQueue( | 44 buffer_queue_.reset(new BufferQueue( |
| 46 context_provider->ContextGL(), target, internalformat, &gl_helper_, | 45 context_provider->ContextGL(), target, internalformat, &gl_helper_, |
| 47 MusGpuMemoryBufferManager::current(), widget)); | 46 MusGpuMemoryBufferManager::current(), widget)); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 gpu::SyncToken sync_token; | 100 gpu::SyncToken sync_token; |
| 102 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 101 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 103 | 102 |
| 104 client_->DidSwapBuffers(); | 103 client_->DidSwapBuffers(); |
| 105 } | 104 } |
| 106 | 105 |
| 107 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { | 106 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { |
| 108 if (!cc::OutputSurface::BindToClient(client)) | 107 if (!cc::OutputSurface::BindToClient(client)) |
| 109 return false; | 108 return false; |
| 110 | 109 |
| 111 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); | |
| 112 | |
| 113 if (capabilities_.uses_default_gl_framebuffer) { | 110 if (capabilities_.uses_default_gl_framebuffer) { |
| 114 capabilities_.flipped_output_surface = | 111 capabilities_.flipped_output_surface = |
| 115 context_provider()->ContextCapabilities().flips_vertically; | 112 context_provider()->ContextCapabilities().flips_vertically; |
| 116 } | 113 } |
| 117 return true; | 114 return true; |
| 118 } | 115 } |
| 119 | 116 |
| 120 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( | 117 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( |
| 121 base::TimeTicks timebase, | 118 base::TimeTicks timebase, |
| 122 base::TimeDelta interval) { | 119 base::TimeDelta interval) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // must create the native window in the size that the hardware reports. | 152 // must create the native window in the size that the hardware reports. |
| 156 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, | 153 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, |
| 157 float scale_factor, | 154 float scale_factor, |
| 158 bool alpha) { | 155 bool alpha) { |
| 159 OutputSurface::Reshape(size, scale_factor, alpha); | 156 OutputSurface::Reshape(size, scale_factor, alpha); |
| 160 DCHECK(buffer_queue_); | 157 DCHECK(buffer_queue_); |
| 161 buffer_queue_->Reshape(SurfaceSize(), scale_factor); | 158 buffer_queue_->Reshape(SurfaceSize(), scale_factor); |
| 162 } | 159 } |
| 163 | 160 |
| 164 } // namespace mus | 161 } // namespace mus |
| OLD | NEW |