| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.h" | 5 #include "components/mus/surfaces/direct_output_surface.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 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 "gpu/command_buffer/client/context_support.h" | 15 #include "gpu/command_buffer/client/context_support.h" |
| 16 #include "gpu/command_buffer/client/gles2_interface.h" | 16 #include "gpu/command_buffer/client/gles2_interface.h" |
| 17 | 17 |
| 18 namespace mus { | 18 namespace mus { |
| 19 | 19 |
| 20 DirectOutputSurface::DirectOutputSurface( | 20 DirectOutputSurface::DirectOutputSurface( |
| 21 scoped_refptr<SurfacesContextProvider> context_provider, | 21 scoped_refptr<SurfacesContextProvider> context_provider, |
| 22 base::SingleThreadTaskRunner* task_runner) | 22 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) |
| 23 : cc::OutputSurface(context_provider, nullptr, nullptr), | 23 : cc::OutputSurface(context_provider, nullptr, nullptr), |
| 24 synthetic_begin_frame_source_(new cc::DelayBasedBeginFrameSource( | 24 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 25 base::MakeUnique<cc::DelayBasedTimeSource>(task_runner))), | |
| 26 weak_ptr_factory_(this) { | 25 weak_ptr_factory_(this) { |
| 27 context_provider->SetDelegate(this); | 26 context_provider->SetDelegate(this); |
| 28 } | 27 } |
| 29 | 28 |
| 30 DirectOutputSurface::~DirectOutputSurface() {} | 29 DirectOutputSurface::~DirectOutputSurface() = default; |
| 31 | 30 |
| 32 bool DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | 31 bool DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { |
| 33 if (!cc::OutputSurface::BindToClient(client)) | 32 if (!cc::OutputSurface::BindToClient(client)) |
| 34 return false; | 33 return false; |
| 35 | 34 |
| 36 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); | |
| 37 | |
| 38 if (capabilities_.uses_default_gl_framebuffer) { | 35 if (capabilities_.uses_default_gl_framebuffer) { |
| 39 capabilities_.flipped_output_surface = | 36 capabilities_.flipped_output_surface = |
| 40 context_provider()->ContextCapabilities().flips_vertically; | 37 context_provider()->ContextCapabilities().flips_vertically; |
| 41 } | 38 } |
| 42 return true; | 39 return true; |
| 43 } | 40 } |
| 44 | 41 |
| 45 void DirectOutputSurface::OnVSyncParametersUpdated( | 42 void DirectOutputSurface::OnVSyncParametersUpdated( |
| 46 const base::TimeTicks& timebase, | 43 const base::TimeTicks& timebase, |
| 47 const base::TimeDelta& interval) { | 44 const base::TimeDelta& interval) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 gpu::SyncToken sync_token; | 66 gpu::SyncToken sync_token; |
| 70 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 67 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 71 | 68 |
| 72 context_provider_->ContextSupport()->SignalSyncToken( | 69 context_provider_->ContextSupport()->SignalSyncToken( |
| 73 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, | 70 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, |
| 74 weak_ptr_factory_.GetWeakPtr())); | 71 weak_ptr_factory_.GetWeakPtr())); |
| 75 client_->DidSwapBuffers(); | 72 client_->DidSwapBuffers(); |
| 76 } | 73 } |
| 77 | 74 |
| 78 } // namespace mus | 75 } // namespace mus |
| OLD | NEW |