Index: chrome/browser/renderer_host/accelerated_plugin_view_mac.mm |
diff --git a/chrome/browser/renderer_host/accelerated_plugin_view_mac.mm b/chrome/browser/renderer_host/accelerated_plugin_view_mac.mm |
index 82638b6ba48ace0e12344a09a76e4b2034a0f8c4..da4f7bb91efce8011cace8e58807675585eec1c1 100644 |
--- a/chrome/browser/renderer_host/accelerated_plugin_view_mac.mm |
+++ b/chrome/browser/renderer_host/accelerated_plugin_view_mac.mm |
@@ -16,6 +16,9 @@ |
@synthesize cachedSize = cachedSize_; |
- (CVReturn)getFrameForTime:(const CVTimeStamp*)outputTime { |
+ TRACE_EVENT2("browser", "AcceleratedPluginView::getFrameForTime", |
+ "swapBuffersCount_", swapBuffersCount_, |
+ "acknowledgedSwapBuffersCount_", acknowledgedSwapBuffersCount_); |
// There is no autorelease pool when this method is called because it will be |
// called from a background thread. |
base::mac::ScopedNSAutoreleasePool pool; |
@@ -40,22 +43,24 @@ |
return kCVReturnSuccess; |
} |
-// This is the renderer output callback function |
-static CVReturn DrawOneAcceleratedPluginCallback( |
- CVDisplayLinkRef displayLink, |
- const CVTimeStamp* now, |
- const CVTimeStamp* outputTime, |
- CVOptionFlags flagsIn, |
- CVOptionFlags* flagsOut, |
- void* displayLinkContext) { |
- CVReturn result = |
- [(AcceleratedPluginView*)displayLinkContext getFrameForTime:outputTime]; |
- return result; |
-} |
+///// This is the renderer output callback function |
+///static CVReturn DrawOneAcceleratedPluginCallback( |
+/// CVDisplayLinkRef displayLink, |
+/// const CVTimeStamp* now, |
+/// const CVTimeStamp* outputTime, |
+/// CVOptionFlags flagsIn, |
+/// CVOptionFlags* flagsOut, |
+/// void* displayLinkContext) { |
+/// CVReturn result = |
+/// [(AcceleratedPluginView*)displayLinkContext getFrameForTime:outputTime]; |
+/// return result; |
+///} |
- (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r |
pluginHandle:(gfx::PluginWindowHandle)pluginHandle { |
if ((self = [super initWithFrame:NSZeroRect])) { |
+ TRACE_EVENT0("browser", |
+ "AcceleratedPluginView::initWithRenderWidgetHostViewMac"); |
renderWidgetHostView_ = r; |
pluginHandle_ = pluginHandle; |
cachedSize_ = NSZeroSize; |
@@ -91,16 +96,28 @@ static CVReturn DrawOneAcceleratedPluginCallback( |
swapInterval = 1; |
[glContext_ setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; |
- // Set up a display link to do OpenGL rendering on a background thread. |
- CVDisplayLinkCreateWithActiveCGDisplays(&displayLink_); |
+/// // Set up a display link to do OpenGL rendering on a background thread. |
+/// CVDisplayLinkCreateWithActiveCGDisplays(&displayLink_); |
} |
return self; |
} |
- (void)dealloc { |
- CVDisplayLinkRelease(displayLink_); |
- if (renderWidgetHostView_) |
+///CVDisplayLinkRelease(displayLink_); |
+ if (renderWidgetHostView_) { |
+ bool sendAck = (rendererId_ != 0 || routeId_ != 0) && |
+ (swapBuffersCount_ != acknowledgedSwapBuffersCount_); |
+ if (sendAck) { |
+ // Prevent deadlock issues if the GPU process is expecting an ack of the |
+ // SwapBuffers. |
+ renderWidgetHostView_->AcknowledgeSwapBuffers( |
+ rendererId_, |
+ routeId_, |
+ gpuHostId_, |
+ swapBuffersCount_); |
+ } |
renderWidgetHostView_->DeallocFakePluginWindowHandle(pluginHandle_); |
+ } |
[[NSNotificationCenter defaultCenter] removeObserver:self]; |
[super dealloc]; |
} |
@@ -130,6 +147,8 @@ static CVReturn DrawOneAcceleratedPluginCallback( |
fromRenderer:(int)rendererId |
routeId:(int32)routeId |
gpuHostId:(int)gpuHostId { |
+ TRACE_EVENT2("browser", "AcceleratedPluginView::updateSwapBuffersCount", |
+ "routeId", routeId, "count", count); |
if (rendererId == 0 && routeId == 0) { |
// This notification is coming from a plugin process, for which we |
// don't have flow control implemented right now. Fake up a swap |
@@ -141,6 +160,7 @@ static CVReturn DrawOneAcceleratedPluginCallback( |
gpuHostId_ = gpuHostId; |
swapBuffersCount_ = count; |
} |
+ [self getFrameForTime:NULL]; |
} |
- (void)onRenderWidgetHostViewGone { |
@@ -218,11 +238,11 @@ static CVReturn DrawOneAcceleratedPluginCallback( |
CGLUnlockContext(cglContext_); |
globalFrameDidChangeCGLLockCount_--; |
- if (globalFrameDidChangeCGLLockCount_ == 0) { |
- // Make sure the view is synchronized with the correct display. |
- CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext( |
- displayLink_, cglContext_, cglPixelFormat_); |
- } |
+///if (globalFrameDidChangeCGLLockCount_ == 0) { |
+/// // Make sure the view is synchronized with the correct display. |
+/// CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext( |
+/// displayLink_, cglContext_, cglPixelFormat_); |
+///} |
} |
- (void)renewGState { |
@@ -245,24 +265,30 @@ static CVReturn DrawOneAcceleratedPluginCallback( |
selector:@selector(globalFrameDidChange:) |
name:NSViewGlobalFrameDidChangeNotification |
object:self]; |
- CVDisplayLinkSetOutputCallback( |
- displayLink_, &DrawOneAcceleratedPluginCallback, self); |
- CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext( |
- displayLink_, cglContext_, cglPixelFormat_); |
- CVDisplayLinkStart(displayLink_); |
+/// CVDisplayLinkSetOutputCallback( |
+/// displayLink_, &DrawOneAcceleratedPluginCallback, self); |
+/// CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext( |
+/// displayLink_, cglContext_, cglPixelFormat_); |
+/// CVDisplayLinkStart(displayLink_); |
} |
[glContext_ makeCurrentContext]; |
} |
- (void)viewWillMoveToWindow:(NSWindow*)newWindow { |
// Stop the display link thread while the view is not visible. |
- if (newWindow) { |
- if (displayLink_ && !CVDisplayLinkIsRunning(displayLink_)) |
- CVDisplayLinkStart(displayLink_); |
- } else { |
- if (displayLink_ && CVDisplayLinkIsRunning(displayLink_)) |
- CVDisplayLinkStop(displayLink_); |
- } |
+ TRACE_EVENT1("renderer", "viewWillMoveToWindow", |
+ "newWindow", newWindow); |
+///if (newWindow) { |
+/// if (displayLink_ && !CVDisplayLinkIsRunning(displayLink_)) { |
+/// TRACE_EVENT0("renderer", "CVDisplayLinkStart"); |
+/// CVDisplayLinkStart(displayLink_); |
+/// } |
+///} else { |
+/// if (displayLink_ && CVDisplayLinkIsRunning(displayLink_)) { |
+/// TRACE_EVENT0("renderer", "CVDisplayLinkStop"); |
+/// CVDisplayLinkStop(displayLink_); |
+/// } |
+///} |
// Inform the window hosting this accelerated view that it needs to be |
// transparent. |