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

Unified Diff: content/browser/renderer_host/compositing_iosurface_mac.mm

Issue 16845005: Don't use a sleep in the browser's main thread to throttle swapbuffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Resolve against head Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/compositing_iosurface_mac.mm
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.mm b/content/browser/renderer_host/compositing_iosurface_mac.mm
index 300c1cd24bfb41030af4d6645bdc49df2f9feb6c..dea809b9f54814c0fb797667ffd0f91457a42a5a 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.mm
+++ b/content/browser/renderer_host/compositing_iosurface_mac.mm
@@ -280,8 +280,6 @@ CompositingIOSurfaceMac::CompositingIOSurfaceMac(
display_link_(0),
display_link_stop_timer_(FROM_HERE, base::TimeDelta::FromSeconds(1),
this, &CompositingIOSurfaceMac::StopDisplayLink),
- vsync_count_(0),
- swap_count_(0),
vsync_interval_numerator_(0),
vsync_interval_denominator_(0),
initialized_is_intel_(false),
@@ -565,9 +563,6 @@ void CompositingIOSurfaceMac::DrawIOSurface(
copy_done_callbacks[i].Run();
StartOrContinueDisplayLink();
-
- if (!is_vsync_disabled())
- RateLimitDraws();
}
void CompositingIOSurfaceMac::CopyTo(
@@ -740,9 +735,6 @@ void CompositingIOSurfaceMac::DisplayLinkTick(CVDisplayLinkRef display_link,
const CVTimeStamp* time) {
TRACE_EVENT0("gpu", "CompositingIOSurfaceMac::DisplayLinkTick");
base::AutoLock lock(lock_);
- // Increment vsync_count but don't let it get ahead of swap_count.
- vsync_count_ = std::min(vsync_count_ + 1, swap_count_);
-
CalculateVsyncParametersLockHeld(time);
}
@@ -758,39 +750,11 @@ void CompositingIOSurfaceMac::CalculateVsyncParametersLockHeld(
base::TimeTicks::FromInternalValue(time->hostTime / 1000);
}
-void CompositingIOSurfaceMac::RateLimitDraws() {
- int64 vsync_count;
- int64 swap_count;
-
- {
- base::AutoLock lock(lock_);
- vsync_count = vsync_count_;
- swap_count = ++swap_count_;
- }
-
- // It's OK for swap_count to get 2 ahead of vsync_count, but any more
- // indicates that it has become unthrottled. This happens when, for example,
- // the window is obscured by another opaque window.
- if (swap_count > vsync_count + 2) {
- TRACE_EVENT0("gpu", "CompositingIOSurfaceMac::RateLimitDraws");
- // Sleep for one vsync interval. This will prevent spinning while the window
- // is not visible, but will also allow quick recovery when the window
- // becomes visible again.
- int64 sleep_us = 16666; // default to 60hz if display link API fails.
- if (vsync_interval_denominator_ > 0) {
- sleep_us = (static_cast<int64>(vsync_interval_numerator_) * 1000000) /
- vsync_interval_denominator_;
- }
- base::PlatformThread::Sleep(base::TimeDelta::FromMicroseconds(sleep_us));
- }
-}
-
void CompositingIOSurfaceMac::StartOrContinueDisplayLink() {
if (display_link_ == NULL)
return;
if (!CVDisplayLinkIsRunning(display_link_)) {
- vsync_count_ = swap_count_ = 0;
CVDisplayLinkStart(display_link_);
}
display_link_stop_timer_.Reset();

Powered by Google App Engine
This is Rietveld 408576698