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

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

Issue 11195011: Send vsync timebase updates to the browser compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use the existing output surface mechanism to feed vsync info into the compositor Created 8 years, 1 month 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 | Annotate | Revision Log
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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "content/common/gpu/image_transport_surface.h" 7 #include "content/common/gpu/image_transport_surface.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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 params.route_id = route_id_; 150 params.route_id = route_id_;
151 manager_->Send(new GpuHostMsg_AcceleratedSurfaceRelease(params)); 151 manager_->Send(new GpuHostMsg_AcceleratedSurfaceRelease(params));
152 } 152 }
153 153
154 void ImageTransportHelper::SendResizeView(const gfx::Size& size) { 154 void ImageTransportHelper::SendResizeView(const gfx::Size& size) {
155 manager_->Send(new GpuHostMsg_ResizeView(stub_->surface_id(), 155 manager_->Send(new GpuHostMsg_ResizeView(stub_->surface_id(),
156 route_id_, 156 route_id_,
157 size)); 157 size));
158 } 158 }
159 159
160 void ImageTransportHelper::SendUpdateVSyncParameters(
161 base::TimeTicks timebase, base::TimeDelta interval) {
162 manager_->Send(new GpuHostMsg_UpdateVSyncParameters(timebase,
163 interval));
164 }
165
160 void ImageTransportHelper::SetScheduled(bool is_scheduled) { 166 void ImageTransportHelper::SetScheduled(bool is_scheduled) {
161 gpu::GpuScheduler* scheduler = Scheduler(); 167 gpu::GpuScheduler* scheduler = Scheduler();
162 if (!scheduler) 168 if (!scheduler)
163 return; 169 return;
164 170
165 scheduler->SetScheduled(is_scheduled); 171 scheduler->SetScheduled(is_scheduled);
166 } 172 }
167 173
168 void ImageTransportHelper::DeferToFence(base::Closure task) { 174 void ImageTransportHelper::DeferToFence(base::Closure task) {
169 gpu::GpuScheduler* scheduler = Scheduler(); 175 gpu::GpuScheduler* scheduler = Scheduler();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 return helper_->Initialize(); 269 return helper_->Initialize();
264 } 270 }
265 271
266 void PassThroughImageTransportSurface::Destroy() { 272 void PassThroughImageTransportSurface::Destroy() {
267 helper_->Destroy(); 273 helper_->Destroy();
268 GLSurfaceAdapter::Destroy(); 274 GLSurfaceAdapter::Destroy();
269 } 275 }
270 276
271 bool PassThroughImageTransportSurface::SwapBuffers() { 277 bool PassThroughImageTransportSurface::SwapBuffers() {
272 bool result = gfx::GLSurfaceAdapter::SwapBuffers(); 278 bool result = gfx::GLSurfaceAdapter::SwapBuffers();
279 SendVSyncUpdateIfAvailable();
273 280
274 if (transport_) { 281 if (transport_) {
275 // Round trip to the browser UI thread, for throttling, by sending a dummy 282 // Round trip to the browser UI thread, for throttling, by sending a dummy
276 // SwapBuffers message. 283 // SwapBuffers message.
277 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; 284 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params;
278 params.surface_handle = 0; 285 params.surface_handle = 0;
279 helper_->SendAcceleratedSurfaceBuffersSwapped(params); 286 helper_->SendAcceleratedSurfaceBuffersSwapped(params);
280 287
281 helper_->SetScheduled(false); 288 helper_->SetScheduled(false);
282 } 289 }
283 return result; 290 return result;
284 } 291 }
285 292
286 bool PassThroughImageTransportSurface::PostSubBuffer( 293 bool PassThroughImageTransportSurface::PostSubBuffer(
287 int x, int y, int width, int height) { 294 int x, int y, int width, int height) {
288 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height); 295 bool result = gfx::GLSurfaceAdapter::PostSubBuffer(x, y, width, height);
296 SendVSyncUpdateIfAvailable();
289 297
290 if (transport_) { 298 if (transport_) {
291 // Round trip to the browser UI thread, for throttling, by sending a dummy 299 // Round trip to the browser UI thread, for throttling, by sending a dummy
292 // PostSubBuffer message. 300 // PostSubBuffer message.
293 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params; 301 GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params params;
294 params.surface_handle = 0; 302 params.surface_handle = 0;
295 params.x = x; 303 params.x = x;
296 params.y = y; 304 params.y = y;
297 params.width = width; 305 params.width = width;
298 params.height = height; 306 params.height = height;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 Resize(new_size_); 341 Resize(new_size_);
334 } 342 }
335 } 343 }
336 344
337 gfx::Size PassThroughImageTransportSurface::GetSize() { 345 gfx::Size PassThroughImageTransportSurface::GetSize() {
338 return GLSurfaceAdapter::GetSize(); 346 return GLSurfaceAdapter::GetSize();
339 } 347 }
340 348
341 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {} 349 PassThroughImageTransportSurface::~PassThroughImageTransportSurface() {}
342 350
351 void PassThroughImageTransportSurface::SendVSyncUpdateIfAvailable() {
352 int64 monotonicTime;
353 int64 mediaStreamCounter;
354 int64 swapBufferCounter;
355
356 // TODO: Use glXGetMscRateOML (where available) to get the correct interval
357 // time. If unavailable, we should plumb-in information about when we
358 // clock down.
359 const int64 intervalTime = base::Time::kMicrosecondsPerSecond / 60;
piman 2012/10/24 16:56:54 This sounds like it belongs to GLSurfaceGLX too.
ajuma 2012/10/26 20:12:39 Done.
360
361 if (GetSyncValues(&monotonicTime, &mediaStreamCounter, &swapBufferCounter)) {
362 base::TimeTicks timebase = base::TimeTicks::FromInternalValue(
363 monotonicTime);
364 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(intervalTime);
365 helper_->SendUpdateVSyncParameters(timebase, interval);
366 }
367 }
368
343 } // namespace content 369 } // namespace content
344 370
345 #endif // defined(ENABLE_GPU) 371 #endif // defined(ENABLE_GPU)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698