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

Side by Side 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, 4 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 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H
6 #define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H 6 #define CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #import <QuartzCore/CVDisplayLink.h>
9 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
10 11
11 #include "base/mac/scoped_cftyperef.h" 12 #include "base/mac/scoped_cftyperef.h"
12 #include "base/memory/scoped_nsobject.h" 13 #include "base/memory/scoped_nsobject.h"
14 #include "base/synchronization/lock.h"
15 #include "base/time.h"
16 #include "base/timer.h"
13 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/size.h" 18 #include "ui/gfx/size.h"
15 19
16 class IOSurfaceSupport; 20 class IOSurfaceSupport;
17 21
18 namespace content { 22 namespace content {
19 23
20 // This class manages an OpenGL context and IOSurface for the accelerated 24 // This class manages an OpenGL context and IOSurface for the accelerated
21 // compositing code path. The GL context is attached to 25 // compositing code path. The GL context is attached to
22 // RenderWidgetHostViewCocoa for blitting the IOSurface. 26 // RenderWidgetHostViewCocoa for blitting the IOSurface.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bool HasIOSurface() { return !!io_surface_.get(); } 58 bool HasIOSurface() { return !!io_surface_.get(); }
55 59
56 const gfx::Size& pixel_io_surface_size() const { 60 const gfx::Size& pixel_io_surface_size() const {
57 return pixel_io_surface_size_; 61 return pixel_io_surface_size_;
58 } 62 }
59 // In cocoa view units / DIPs. 63 // In cocoa view units / DIPs.
60 const gfx::Size& io_surface_size() const { return io_surface_size_; } 64 const gfx::Size& io_surface_size() const { return io_surface_size_; }
61 65
62 bool is_vsync_disabled() const { return is_vsync_disabled_; } 66 bool is_vsync_disabled() const { return is_vsync_disabled_; }
63 67
68 // Get vsync scheduling parameters.
69 void GetVSyncParameters(base::TimeTicks* timebase,
70 uint32* interval_numerator,
71 uint32* interval_denominator);
72
64 private: 73 private:
74 friend CVReturn DisplayLinkCallback(CVDisplayLinkRef,
75 const CVTimeStamp*,
76 const CVTimeStamp*,
77 CVOptionFlags,
78 CVOptionFlags*,
79 void*);
80
65 // Vertex structure for use in glDraw calls. 81 // Vertex structure for use in glDraw calls.
66 struct SurfaceVertex { 82 struct SurfaceVertex {
67 SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { } 83 SurfaceVertex() : x_(0.0f), y_(0.0f), tx_(0.0f), ty_(0.0f) { }
68 // Currently the texture coords are always the same as vertex coords. 84 // Currently the texture coords are always the same as vertex coords.
69 void set(float x, float y, float tx, float ty) { 85 void set(float x, float y, float tx, float ty) {
70 x_ = x; 86 x_ = x;
71 y_ = y; 87 y_ = y;
72 tx_ = tx; 88 tx_ = tx;
73 ty_ = ty; 89 ty_ = ty;
74 } 90 }
(...skipping 29 matching lines...) Expand all
104 } 120 }
105 SurfaceVertex verts_[4]; 121 SurfaceVertex verts_[4];
106 }; 122 };
107 123
108 CompositingIOSurfaceMac(IOSurfaceSupport* io_surface_support, 124 CompositingIOSurfaceMac(IOSurfaceSupport* io_surface_support,
109 NSOpenGLContext* glContext, 125 NSOpenGLContext* glContext,
110 CGLContextObj cglContext, 126 CGLContextObj cglContext,
111 GLuint shader_program_blit_rgb, 127 GLuint shader_program_blit_rgb,
112 GLint blit_rgb_sampler_location, 128 GLint blit_rgb_sampler_location,
113 GLuint shader_program_white, 129 GLuint shader_program_white,
114 bool is_vsync_disabled); 130 bool is_vsync_disabled,
131 CVDisplayLinkRef display_link);
115 132
116 // Returns true if IOSurface is ready to render. False otherwise. 133 // Returns true if IOSurface is ready to render. False otherwise.
117 bool MapIOSurfaceToTexture(uint64 io_surface_handle); 134 bool MapIOSurfaceToTexture(uint64 io_surface_handle);
118 135
119 void UnrefIOSurfaceWithContextCurrent(); 136 void UnrefIOSurfaceWithContextCurrent();
120 137
121 void DrawQuad(const SurfaceQuad& quad); 138 void DrawQuad(const SurfaceQuad& quad);
122 139
140 // Called on display-link thread.
141 void DisplayLinkTick(CVDisplayLinkRef display_link,
142 const CVTimeStamp* output_time);
143
144 void CalculateVsyncParametersLockHeld(const CVTimeStamp* time);
145
146 // Prevent from spinning on CGLFlushDrawable when it fails to throttle to
147 // VSync frequency.
148 void RateLimitDraws();
149
150 void StartOrContinueDisplayLink();
151 void StopDisplayLink();
152
123 // Cached pointer to IOSurfaceSupport Singleton. 153 // Cached pointer to IOSurfaceSupport Singleton.
124 IOSurfaceSupport* io_surface_support_; 154 IOSurfaceSupport* io_surface_support_;
125 155
126 // GL context 156 // GL context
127 scoped_nsobject<NSOpenGLContext> glContext_; 157 scoped_nsobject<NSOpenGLContext> glContext_;
128 CGLContextObj cglContext_; // weak, backed by |glContext_|. 158 CGLContextObj cglContext_; // weak, backed by |glContext_|.
129 159
130 // IOSurface data. 160 // IOSurface data.
131 uint64 io_surface_handle_; 161 uint64 io_surface_handle_;
132 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_; 162 base::mac::ScopedCFTypeRef<CFTypeRef> io_surface_;
(...skipping 10 matching lines...) Expand all
143 GLuint texture_; 173 GLuint texture_;
144 174
145 // Shader parameters. 175 // Shader parameters.
146 GLuint shader_program_blit_rgb_; 176 GLuint shader_program_blit_rgb_;
147 GLint blit_rgb_sampler_location_; 177 GLint blit_rgb_sampler_location_;
148 GLuint shader_program_white_; 178 GLuint shader_program_white_;
149 179
150 SurfaceQuad quad_; 180 SurfaceQuad quad_;
151 181
152 bool is_vsync_disabled_; 182 bool is_vsync_disabled_;
183
184 // CVDisplayLink for querying Vsync timing info and throttling swaps.
185 CVDisplayLinkRef display_link_;
186
187 // Timer for stopping display link after a timeout with no swaps.
188 base::DelayTimer<CompositingIOSurfaceMac> display_link_stop_timer_;
189
190 // Lock for sharing data between UI thread and display-link thread.
191 base::Lock lock_;
192
193 // Counts for throttling swaps.
194 int64 vsync_count_;
195 int64 swap_count_;
196
197 // Vsync timing data.
198 base::TimeTicks vsync_timebase_;
199 uint32 vsync_interval_numerator_;
200 uint32 vsync_interval_denominator_;
153 }; 201 };
154 202
155 } // namespace content 203 } // namespace content
156 204
157 #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H 205 #endif // CONTENT_BROWSER_RENDERER_HOST_ACCELERATED_COMPOSITING_VIEW_MAC_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698