Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(948)

Side by Side Diff: content/common/gpu/image_transport_surface.cc

Issue 781683005: Ozone: Avoid blocking in Swapbuffer Call. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compiler warning. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/gpu/image_transport_surface.h" 5 #include "content/common/gpu/image_transport_surface.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void PassThroughImageTransportSurface::SetLatencyInfo( 206 void PassThroughImageTransportSurface::SetLatencyInfo(
207 const std::vector<ui::LatencyInfo>& latency_info) { 207 const std::vector<ui::LatencyInfo>& latency_info) {
208 for (size_t i = 0; i < latency_info.size(); i++) 208 for (size_t i = 0; i < latency_info.size(); i++)
209 latency_info_.push_back(latency_info[i]); 209 latency_info_.push_back(latency_info[i]);
210 } 210 }
211 211
212 bool PassThroughImageTransportSurface::SwapBuffers() { 212 bool PassThroughImageTransportSurface::SwapBuffers() {
213 // GetVsyncValues before SwapBuffers to work around Mali driver bug: 213 // GetVsyncValues before SwapBuffers to work around Mali driver bug:
214 // crbug.com/223558. 214 // crbug.com/223558.
215 SendVSyncUpdateIfAvailable(); 215 SendVSyncUpdateIfAvailable();
216 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); 216 return gfx::GLSurfaceAdapter::SwapBuffersAsync(
217 for (size_t i = 0; i < latency_info_.size(); i++) { 217 base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack,
218 latency_info_[i].AddLatencyNumber( 218 base::Unretained(this)));
219 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
220 }
221
222 helper_->SwapBuffersCompleted(latency_info_);
223 latency_info_.clear();
224 return result;
225 } 219 }
226 220
227 bool PassThroughImageTransportSurface::PostSubBuffer( 221 bool PassThroughImageTransportSurface::PostSubBuffer(
228 int x, int y, int width, int height) { 222 int x, int y, int width, int height) {
229 SendVSyncUpdateIfAvailable(); 223 SendVSyncUpdateIfAvailable();
230 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); 224 return gfx::GLSurfaceAdapter::PostSubBufferAsync(x, y, width, height,
225 base::Bind(&PassThroughImageTransportSurface::SwapBuffersCallBack,
226 base::Unretained(this)));
227 }
228
229 void PassThroughImageTransportSurface::SwapBuffersCallBack() {
231 for (size_t i = 0; i < latency_info_.size(); i++) { 230 for (size_t i = 0; i < latency_info_.size(); i++) {
232 latency_info_[i].AddLatencyNumber( 231 latency_info_[i].AddLatencyNumber(
233 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0); 232 ui::INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, 0, 0);
234 } 233 }
235 234
236 helper_->SwapBuffersCompleted(latency_info_); 235 helper_->SwapBuffersCompleted(latency_info_);
237 latency_info_.clear(); 236 latency_info_.clear();
238 return result;
239 } 237 }
240 238
241 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) { 239 bool PassThroughImageTransportSurface::OnMakeCurrent(gfx::GLContext* context) {
242 if (!did_set_swap_interval_) { 240 if (!did_set_swap_interval_) {
243 ImageTransportHelper::SetSwapInterval(context); 241 ImageTransportHelper::SetSwapInterval(context);
244 did_set_swap_interval_ = true; 242 did_set_swap_interval_ = true;
245 } 243 }
246 return true; 244 return true;
247 } 245 }
248 246
(...skipping 22 matching lines...) Expand all
271 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() { 269 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() {
272 gfx::VSyncProvider* vsync_provider = GetVSyncProvider(); 270 gfx::VSyncProvider* vsync_provider = GetVSyncProvider();
273 if (vsync_provider) { 271 if (vsync_provider) {
274 vsync_provider->GetVSyncParameters( 272 vsync_provider->GetVSyncParameters(
275 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters, 273 base::Bind(&ImageTransportHelper::SendUpdateVSyncParameters,
276 helper_->AsWeakPtr())); 274 helper_->AsWeakPtr()));
277 } 275 }
278 } 276 }
279 277
280 } // namespace content 278 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698