| 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 "components/mus/gles2/mojo_gpu_memory_buffer_manager.h" | 13 #include "components/mus/gles2/mojo_gpu_memory_buffer_manager.h" |
| 14 #include "components/mus/surfaces/buffer_queue.h" | 14 #include "components/mus/surfaces/buffer_queue.h" |
| 15 #include "components/mus/surfaces/surfaces_context_provider.h" | 15 #include "components/mus/surfaces/surfaces_context_provider.h" |
| 16 #include "gpu/command_buffer/client/context_support.h" | 16 #include "gpu/command_buffer/client/context_support.h" |
| 17 #include "gpu/command_buffer/client/gles2_interface.h" | 17 #include "gpu/command_buffer/client/gles2_interface.h" |
| 18 | 18 |
| 19 namespace mus { | 19 namespace mus { |
| 20 | 20 |
| 21 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( | 21 DirectOutputSurfaceOzone::DirectOutputSurfaceOzone( |
| 22 const scoped_refptr<SurfacesContextProvider>& context_provider, | 22 const scoped_refptr<SurfacesContextProvider>& context_provider, |
| 23 gfx::AcceleratedWidget widget, | 23 gfx::AcceleratedWidget widget, |
| 24 base::SingleThreadTaskRunner* task_runner, |
| 24 uint32_t target, | 25 uint32_t target, |
| 25 uint32_t internalformat) | 26 uint32_t internalformat) |
| 26 : cc::OutputSurface(context_provider), | 27 : cc::OutputSurface(context_provider), |
| 27 output_surface_( | 28 output_surface_( |
| 28 new BufferQueue(context_provider, target, internalformat, widget)), | 29 new BufferQueue(context_provider, target, internalformat, widget)), |
| 30 synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( |
| 31 task_runner, |
| 32 cc::BeginFrameArgs::DefaultInterval())), |
| 29 weak_ptr_factory_(this) { | 33 weak_ptr_factory_(this) { |
| 30 capabilities_.uses_default_gl_framebuffer = false; | 34 capabilities_.uses_default_gl_framebuffer = false; |
| 31 capabilities_.flipped_output_surface = true; | 35 capabilities_.flipped_output_surface = true; |
| 32 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling | 36 // Set |max_frames_pending| to 2 for surfaceless, which aligns scheduling |
| 33 // more closely with the previous surfaced behavior. | 37 // more closely with the previous surfaced behavior. |
| 34 // With a surface, swap buffer ack used to return early, before actually | 38 // With a surface, swap buffer ack used to return early, before actually |
| 35 // presenting the back buffer, enabling the browser compositor to run ahead. | 39 // presenting the back buffer, enabling the browser compositor to run ahead. |
| 36 // Surfaceless implementation acks at the time of actual buffer swap, which | 40 // Surfaceless implementation acks at the time of actual buffer swap, which |
| 37 // shifts the start of the new frame forward relative to the old | 41 // shifts the start of the new frame forward relative to the old |
| 38 // implementation. | 42 // implementation. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 gpu::SyncToken sync_token; | 85 gpu::SyncToken sync_token; |
| 82 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 86 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 83 | 87 |
| 84 client_->DidSwapBuffers(); | 88 client_->DidSwapBuffers(); |
| 85 } | 89 } |
| 86 | 90 |
| 87 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { | 91 bool DirectOutputSurfaceOzone::BindToClient(cc::OutputSurfaceClient* client) { |
| 88 if (!cc::OutputSurface::BindToClient(client)) | 92 if (!cc::OutputSurface::BindToClient(client)) |
| 89 return false; | 93 return false; |
| 90 | 94 |
| 95 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); |
| 96 |
| 91 if (capabilities_.uses_default_gl_framebuffer) { | 97 if (capabilities_.uses_default_gl_framebuffer) { |
| 92 capabilities_.flipped_output_surface = | 98 capabilities_.flipped_output_surface = |
| 93 context_provider()->ContextCapabilities().gpu.flips_vertically; | 99 context_provider()->ContextCapabilities().gpu.flips_vertically; |
| 94 } | 100 } |
| 95 return true; | 101 return true; |
| 96 } | 102 } |
| 97 | 103 |
| 98 // TODO(rjkroege): Plumb vsync properties. | |
| 99 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( | 104 void DirectOutputSurfaceOzone::OnUpdateVSyncParametersFromGpu( |
| 100 base::TimeTicks timebase, | 105 base::TimeTicks timebase, |
| 101 base::TimeDelta interval) { | 106 base::TimeDelta interval) { |
| 102 DCHECK(HasClient()); | 107 DCHECK(HasClient()); |
| 103 CommitVSyncParameters(timebase, interval); | 108 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
| 104 // vsync_manager_->UpdateVSyncParameters(timebase, interval); | |
| 105 } | 109 } |
| 106 | 110 |
| 107 void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted( | 111 void DirectOutputSurfaceOzone::OnGpuSwapBuffersCompleted( |
| 108 gfx::SwapResult result) { | 112 gfx::SwapResult result) { |
| 109 DCHECK(output_surface_); | 113 DCHECK(output_surface_); |
| 110 bool force_swap = false; | 114 bool force_swap = false; |
| 111 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { | 115 if (result == gfx::SwapResult::SWAP_NAK_RECREATE_BUFFERS) { |
| 112 // Even through the swap failed, this is a fixable error so we can pretend | 116 // Even through the swap failed, this is a fixable error so we can pretend |
| 113 // it succeeded to the rest of the system. | 117 // it succeeded to the rest of the system. |
| 114 result = gfx::SwapResult::SWAP_ACK; | 118 result = gfx::SwapResult::SWAP_ACK; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 135 // must create the native window in the size that the hardware reports. | 139 // must create the native window in the size that the hardware reports. |
| 136 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, | 140 void DirectOutputSurfaceOzone::Reshape(const gfx::Size& size, |
| 137 float scale_factor, | 141 float scale_factor, |
| 138 bool alpha) { | 142 bool alpha) { |
| 139 OutputSurface::Reshape(size, scale_factor, alpha); | 143 OutputSurface::Reshape(size, scale_factor, alpha); |
| 140 DCHECK(output_surface_); | 144 DCHECK(output_surface_); |
| 141 output_surface_->Reshape(SurfaceSize(), scale_factor); | 145 output_surface_->Reshape(SurfaceSize(), scale_factor); |
| 142 } | 146 } |
| 143 | 147 |
| 144 } // namespace mus | 148 } // namespace mus |
| OLD | NEW |