| 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 "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
| 11 #include "cc/output/context_provider.h" | 11 #include "cc/output/context_provider.h" |
| 12 #include "cc/output/output_surface_client.h" | 12 #include "cc/output/output_surface_client.h" |
| 13 #include "cc/scheduler/begin_frame_source.h" |
| 13 #include "components/display_compositor/buffer_queue.h" | 14 #include "components/display_compositor/buffer_queue.h" |
| 14 #include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h" | 15 #include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h" |
| 15 #include "components/mus/surfaces/surfaces_context_provider.h" | 16 #include "components/mus/surfaces/surfaces_context_provider.h" |
| 16 #include "gpu/command_buffer/client/context_support.h" | 17 #include "gpu/command_buffer/client/context_support.h" |
| 17 #include "gpu/command_buffer/client/gles2_interface.h" | 18 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 | 19 |
| 19 using display_compositor::BufferQueue; | 20 using display_compositor::BufferQueue; |
| 20 | 21 |
| 21 namespace mus { | 22 namespace mus { |
| 22 | 23 |
| 23 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( | 24 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( |
| 24 scoped_refptr<SurfacesContextProvider> context_provider, | 25 scoped_refptr<SurfacesContextProvider> context_provider, |
| 25 gfx::AcceleratedWidget widget, | 26 gfx::AcceleratedWidget widget, |
| 26 base::SingleThreadTaskRunner* task_runner, | 27 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source, |
| 27 uint32_t target, | 28 uint32_t target, |
| 28 uint32_t internalformat) | 29 uint32_t internalformat) |
| 29 : cc::OutputSurface(context_provider, nullptr, nullptr), | 30 : cc::OutputSurface(context_provider, nullptr, nullptr), |
| 30 gl_helper_(context_provider->ContextGL(), | 31 gl_helper_(context_provider->ContextGL(), |
| 31 context_provider->ContextSupport()), | 32 context_provider->ContextSupport()), |
| 32 buffer_queue_(new BufferQueue(context_provider->ContextGL(), | 33 buffer_queue_(new BufferQueue(context_provider->ContextGL(), |
| 33 target, | 34 target, |
| 34 internalformat, | 35 internalformat, |
| 35 &gl_helper_, | 36 &gl_helper_, |
| 36 &gpu_memory_buffer_manager_, | 37 &gpu_memory_buffer_manager_, |
| 37 widget)), | 38 widget)), |
| 38 synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( | 39 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 39 task_runner, | |
| 40 cc::BeginFrameArgs::DefaultInterval())), | |
| 41 weak_ptr_factory_(this) { | 40 weak_ptr_factory_(this) { |
| 42 capabilities_.uses_default_gl_framebuffer = false; | 41 capabilities_.uses_default_gl_framebuffer = false; |
| 43 capabilities_.flipped_output_surface = true; | 42 capabilities_.flipped_output_surface = true; |
| 44 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling | 43 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling |
| 45 // more closely with the previous surfaced behavior. | 44 // more closely with the previous surfaced behavior. |
| 46 // With a surface, swap buffer ack used to return early, before actually | 45 // With a surface, swap buffer ack used to return early, before actually |
| 47 // presenting the back buffer, enabling the browser compositor to run ahead. | 46 // presenting the back buffer, enabling the browser compositor to run ahead. |
| 48 // Surfaceless implementation acks at the time of actual buffer swap, which | 47 // Surfaceless implementation acks at the time of actual buffer swap, which |
| 49 // shifts the start of the new frame forward relative to the old | 48 // shifts the start of the new frame forward relative to the old |
| 50 // implementation. | 49 // implementation. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 gpu::SyncToken sync_token; | 92 gpu::SyncToken sync_token; |
| 94 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 93 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 95 | 94 |
| 96 client_->DidSwapBuffers(); | 95 client_->DidSwapBuffers(); |
| 97 } | 96 } |
| 98 | 97 |
| 99 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { | 98 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { |
| 100 if (!cc::OutputSurface::BindToClient(client)) | 99 if (!cc::OutputSurface::BindToClient(client)) |
| 101 return false; | 100 return false; |
| 102 | 101 |
| 103 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); | |
| 104 | |
| 105 if (capabilities_.uses_default_gl_framebuffer) { | 102 if (capabilities_.uses_default_gl_framebuffer) { |
| 106 capabilities_.flipped_output_surface = | 103 capabilities_.flipped_output_surface = |
| 107 context_provider()->ContextCapabilities().flips_vertically; | 104 context_provider()->ContextCapabilities().flips_vertically; |
| 108 } | 105 } |
| 109 return true; | 106 return true; |
| 110 } | 107 } |
| 111 | 108 |
| 112 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( | 109 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( |
| 113 base::TimeTicks timebase, | 110 base::TimeTicks timebase, |
| 114 base::TimeDelta interval) { | 111 base::TimeDelta interval) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // must create the native window in the size that the hardware reports. | 144 // must create the native window in the size that the hardware reports. |
| 148 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, | 145 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, |
| 149 float scale_factor, | 146 float scale_factor, |
| 150 bool alpha) { | 147 bool alpha) { |
| 151 OutputSurface::Reshape(size, scale_factor, alpha); | 148 OutputSurface::Reshape(size, scale_factor, alpha); |
| 152 DCHECK(buffer_queue_); | 149 DCHECK(buffer_queue_); |
| 153 buffer_queue_->Reshape(SurfaceSize(), scale_factor); | 150 buffer_queue_->Reshape(SurfaceSize(), scale_factor); |
| 154 } | 151 } |
| 155 | 152 |
| 156 } // namespace mus | 153 } // namespace mus |
| OLD | NEW |