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

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

Issue 10828104: fix mac frame-rate regression for non-threaded GPU compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove DEPS change Created 8 years, 5 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.h
diff --git a/content/browser/renderer_host/compositing_iosurface_mac.h b/content/browser/renderer_host/compositing_iosurface_mac.h
index 59d6f26c048d179ccdcebb7a3319b9b08adfec1b..d9f415cc0b43ec534a4cb00e302d4fe6713b2f45 100644
--- a/content/browser/renderer_host/compositing_iosurface_mac.h
+++ b/content/browser/renderer_host/compositing_iosurface_mac.h
@@ -6,10 +6,14 @@
#define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H
#import <Cocoa/Cocoa.h>
+#import <QuartzCore/CVDisplayLink.h>
#include <QuartzCore/QuartzCore.h>
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_nsobject.h"
+#include "base/synchronization/lock.h"
+#include "base/time.h"
+#include "base/timer.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/size.h"
@@ -61,7 +65,19 @@ class CompositingIOSurfaceMac {
bool is_vsync_disabled() const { return is_vsync_disabled_; }
+ // Get vsync scheduling parameters.
+ void GetVSyncParameters(base::TimeTicks* timebase,
+ uint32* interval_numerator,
+ uint32* interval_denominator);
+
private:
+ friend CVReturn DisplayLinkCallback(CVDisplayLinkRef,
+ const CVTimeStamp*,
+ const CVTimeStamp*,
+ CVOptionFlags,
+ CVOptionFlags*,
+ void*);
+
// Vertex structure for use in glDraw calls.
struct SurfaceVertex {
SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { }
@@ -111,7 +127,8 @@ class CompositingIOSurfaceMac {
GLuint shader_program_blit_rgb,
GLint blit_rgb_sampler_location,
GLuint shader_program_white,
- bool is_vsync_disabled);
+ bool is_vsync_disabled,
+ CVDisplayLinkRef display_link);
// Returns true if IOSurface is ready to render. False otherwise.
bool MapIOSurfaceToTexture(uint64 io_surface_handle);
@@ -120,6 +137,19 @@ class CompositingIOSurfaceMac {
void DrawQuad(const SurfaceQuad& quad);
+ // Called on display-link thread.
+ void DisplayLinkTick(CVDisplayLinkRef display_link,
+ const CVTimeStamp* output_time);
+
+ void CalculateVsyncParametersLockHeld(const CVTimeStamp* time);
+
+ // Prevent from spinning on CGLFlushDrawable when it fails to throttle to
+ // VSync frequency.
+ void RateLimitDraws();
+
+ void StartOrContinueDisplayLink();
+ void StopDisplayLink();
+
// Cached pointer to IOSurfaceSupport Singleton.
IOSurfaceSupport* io_surface_support_;
@@ -150,6 +180,24 @@ class CompositingIOSurfaceMac {
SurfaceQuad quad_;
bool is_vsync_disabled_;
+
+ // CVDisplayLink for querying Vsync timing info and throttling swaps.
+ CVDisplayLinkRef display_link_;
+
+ // Timer for stopping display link after a timeout with no swaps.
+ base::DelayTimer<CompositingIOSurfaceMac> display_link_stop_timer_;
+
+ // Lock for sharing data between UI thread and display-link thread.
+ base::Lock lock_;
+
+ // Counts for throttling swaps.
+ int64 vsync_count_;
+ int64 swap_count_;
+
+ // Vsync timing data.
+ base::TimeTicks vsync_timebase_;
+ uint32 vsync_interval_numerator_;
+ uint32 vsync_interval_denominator_;
};
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698