| 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 "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 "gpu/command_buffer/client/context_support.h" | 14 #include "gpu/command_buffer/client/context_support.h" |
| 14 #include "gpu/command_buffer/client/gles2_interface.h" | 15 #include "gpu/command_buffer/client/gles2_interface.h" |
| 15 | 16 |
| 16 namespace mus { | 17 namespace mus { |
| 17 | 18 |
| 18 DirectOutputSurface::DirectOutputSurface( | 19 DirectOutputSurface::DirectOutputSurface( |
| 19 scoped_refptr<SurfacesContextProvider> context_provider, | 20 scoped_refptr<SurfacesContextProvider> context_provider, |
| 20 base::SingleThreadTaskRunner* task_runner) | 21 cc::SyntheticBeginFrameSource* synthetic_begin_frame_source) |
| 21 : cc::OutputSurface(context_provider, nullptr, nullptr), | 22 : cc::OutputSurface(context_provider, nullptr, nullptr), |
| 22 synthetic_begin_frame_source_(new cc::SyntheticBeginFrameSource( | 23 synthetic_begin_frame_source_(synthetic_begin_frame_source), |
| 23 task_runner, | |
| 24 cc::BeginFrameArgs::DefaultInterval())), | |
| 25 weak_ptr_factory_(this) { | 24 weak_ptr_factory_(this) { |
| 26 context_provider->SetDelegate(this); | 25 context_provider->SetDelegate(this); |
| 27 } | 26 } |
| 28 | 27 |
| 29 DirectOutputSurface::~DirectOutputSurface() {} | 28 DirectOutputSurface::~DirectOutputSurface() = default; |
| 30 | 29 |
| 31 bool DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { | 30 bool DirectOutputSurface::BindToClient(cc::OutputSurfaceClient* client) { |
| 32 if (!cc::OutputSurface::BindToClient(client)) | 31 if (!cc::OutputSurface::BindToClient(client)) |
| 33 return false; | 32 return false; |
| 34 | 33 |
| 35 client->SetBeginFrameSource(synthetic_begin_frame_source_.get()); | |
| 36 | |
| 37 if (capabilities_.uses_default_gl_framebuffer) { | 34 if (capabilities_.uses_default_gl_framebuffer) { |
| 38 capabilities_.flipped_output_surface = | 35 capabilities_.flipped_output_surface = |
| 39 context_provider()->ContextCapabilities().flips_vertically; | 36 context_provider()->ContextCapabilities().flips_vertically; |
| 40 } | 37 } |
| 41 return true; | 38 return true; |
| 42 } | 39 } |
| 43 | 40 |
| 44 void DirectOutputSurface::OnVSyncParametersUpdated(int64_t timebase, | 41 void DirectOutputSurface::OnVSyncParametersUpdated(int64_t timebase, |
| 45 int64_t interval) { | 42 int64_t interval) { |
| 46 auto timebase_time_ticks = base::TimeTicks::FromInternalValue(timebase); | 43 auto timebase_time_ticks = base::TimeTicks::FromInternalValue(timebase); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 73 gpu::SyncToken sync_token; | 70 gpu::SyncToken sync_token; |
| 74 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 71 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 75 | 72 |
| 76 context_provider_->ContextSupport()->SignalSyncToken( | 73 context_provider_->ContextSupport()->SignalSyncToken( |
| 77 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, | 74 sync_token, base::Bind(&OutputSurface::OnSwapBuffersComplete, |
| 78 weak_ptr_factory_.GetWeakPtr())); | 75 weak_ptr_factory_.GetWeakPtr())); |
| 79 client_->DidSwapBuffers(); | 76 client_->DidSwapBuffers(); |
| 80 } | 77 } |
| 81 | 78 |
| 82 } // namespace mus | 79 } // namespace mus |
| OLD | NEW |