Chromium Code Reviews| 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/surfaces_context_provider.h" | 5 #include "components/mus/surfaces/surfaces_context_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 attributes.bind_generates_resource = false; | 53 attributes.bind_generates_resource = false; |
| 54 attributes.lose_context_when_out_of_memory = true; | 54 attributes.lose_context_when_out_of_memory = true; |
| 55 gl::GpuPreference gpu_preference = gl::PreferIntegratedGpu; | 55 gl::GpuPreference gpu_preference = gl::PreferIntegratedGpu; |
| 56 GURL active_url; | 56 GURL active_url; |
| 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 58 base::ThreadTaskRunnerHandle::Get(); | 58 base::ThreadTaskRunnerHandle::Get(); |
| 59 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 59 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
| 60 service->gpu_channel_local(), widget, gfx::Size(), | 60 service->gpu_channel_local(), widget, gfx::Size(), |
| 61 shared_command_buffer, stream_id, stream_priority, attributes, | 61 shared_command_buffer, stream_id, stream_priority, attributes, |
| 62 active_url, gpu_preference, task_runner); | 62 active_url, gpu_preference, task_runner); |
| 63 command_buffer_proxy_impl_->SetSwapBuffersCompletionCallback( | |
| 64 base::Bind(&SurfacesContextProvider::OnGpuSwapBuffersCompleted, | |
| 65 base::Unretained(this))); | |
| 66 command_buffer_proxy_impl_->SetUpdateVSyncParametersCallback( | |
| 67 base::Bind(&SurfacesContextProvider::OnUpdateVSyncParameters, | |
| 68 base::Unretained(this))); | |
| 63 } | 69 } |
| 64 } | 70 } |
| 65 | 71 |
| 66 void SurfacesContextProvider::SetDelegate( | 72 void SurfacesContextProvider::SetDelegate( |
| 67 SurfacesContextProviderDelegate* delegate) { | 73 SurfacesContextProviderDelegate* delegate) { |
| 68 DCHECK(!delegate_); | 74 DCHECK(!delegate_); |
| 69 delegate_ = delegate; | 75 delegate_ = delegate; |
| 70 } | 76 } |
| 71 | 77 |
| 72 // This routine needs to be safe to call more than once. | 78 // This routine needs to be safe to call more than once. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 if (delegate_) | 169 if (delegate_) |
| 164 delegate_->OnVSyncParametersUpdated(timebase, interval); | 170 delegate_->OnVSyncParametersUpdated(timebase, interval); |
| 165 } | 171 } |
| 166 | 172 |
| 167 void SurfacesContextProvider::GpuCompletedSwapBuffers(gfx::SwapResult result) { | 173 void SurfacesContextProvider::GpuCompletedSwapBuffers(gfx::SwapResult result) { |
| 168 if (!swap_buffers_completion_callback_.is_null()) { | 174 if (!swap_buffers_completion_callback_.is_null()) { |
| 169 swap_buffers_completion_callback_.Run(result); | 175 swap_buffers_completion_callback_.Run(result); |
| 170 } | 176 } |
| 171 } | 177 } |
| 172 | 178 |
| 179 void SurfacesContextProvider::OnGpuSwapBuffersCompleted( | |
| 180 const std::vector<ui::LatencyInfo>& latency_info, | |
| 181 gfx::SwapResult result, | |
| 182 const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac) { | |
| 183 if (!swap_buffers_completion_callback_.is_null()) { | |
| 184 swap_buffers_completion_callback_.Run(result); | |
| 185 } | |
| 186 } | |
| 187 | |
| 188 void SurfacesContextProvider::OnUpdateVSyncParameters( | |
| 189 base::TimeTicks timebase, | |
| 190 base::TimeDelta interval) { | |
| 191 if (delegate_) | |
|
piman
2016/06/09 19:31:32
nit: use {} per style.
Peng
2016/06/09 20:32:45
Done.
| |
| 192 delegate_->OnVSyncParametersUpdated(timebase.ToInternalValue(), | |
| 193 interval.ToInternalValue()); | |
| 194 } | |
| 195 | |
| 173 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( | 196 void SurfacesContextProvider::SetSwapBuffersCompletionCallback( |
| 174 gl::GLSurface::SwapCompletionCallback callback) { | 197 gl::GLSurface::SwapCompletionCallback callback) { |
| 175 swap_buffers_completion_callback_ = callback; | 198 swap_buffers_completion_callback_ = callback; |
| 176 } | 199 } |
| 177 | 200 |
| 178 } // namespace mus | 201 } // namespace mus |
| OLD | NEW |