| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "content/browser/renderer_host/accelerated_plugin_view_mac.h" | 5 #import "content/browser/renderer_host/accelerated_plugin_view_mac.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "content/browser/browser_thread.h" | 9 #include "content/browser/browser_thread.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 LOG(ERROR) << "CGLPixelFormatObj failed"; | 65 LOG(ERROR) << "CGLPixelFormatObj failed"; |
| 66 | 66 |
| 67 // Draw at beam vsync. | 67 // Draw at beam vsync. |
| 68 GLint swapInterval; | 68 GLint swapInterval; |
| 69 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) | 69 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) |
| 70 swapInterval = 0; | 70 swapInterval = 0; |
| 71 else | 71 else |
| 72 swapInterval = 1; | 72 swapInterval = 1; |
| 73 [glContext_ setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; | 73 [glContext_ setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; |
| 74 | 74 |
| 75 handlingGlobalFrameDidChange_ = NO; |
| 75 [[NSNotificationCenter defaultCenter] | 76 [[NSNotificationCenter defaultCenter] |
| 76 addObserver:self | 77 addObserver:self |
| 77 selector:@selector(globalFrameDidChange:) | 78 selector:@selector(globalFrameDidChange:) |
| 78 name:NSViewGlobalFrameDidChangeNotification | 79 name:NSViewGlobalFrameDidChangeNotification |
| 79 object:self]; | 80 object:self]; |
| 80 } | 81 } |
| 81 return self; | 82 return self; |
| 82 } | 83 } |
| 83 | 84 |
| 84 - (void)dealloc { | 85 - (void)dealloc { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 - (void)rightMouseDown:(NSEvent*)event { | 145 - (void)rightMouseDown:(NSEvent*)event { |
| 145 // The NSResponder documentation: "Note: The NSView implementation of this | 146 // The NSResponder documentation: "Note: The NSView implementation of this |
| 146 // method does not pass the message up the responder chain, it handles it | 147 // method does not pass the message up the responder chain, it handles it |
| 147 // directly." | 148 // directly." |
| 148 // That's bad, we want the next responder (RWHVMac) to handle this event to | 149 // That's bad, we want the next responder (RWHVMac) to handle this event to |
| 149 // dispatch it to the renderer. | 150 // dispatch it to the renderer. |
| 150 [[self nextResponder] rightMouseDown:event]; | 151 [[self nextResponder] rightMouseDown:event]; |
| 151 } | 152 } |
| 152 | 153 |
| 153 - (void)globalFrameDidChange:(NSNotification*)notification { | 154 - (void)globalFrameDidChange:(NSNotification*)notification { |
| 155 // Short-circuit recursive calls. |
| 156 if (handlingGlobalFrameDidChange_) |
| 157 return; |
| 158 |
| 159 handlingGlobalFrameDidChange_ = YES; |
| 160 |
| 154 // This call to -update can call -globalFrameDidChange: again, see | 161 // This call to -update can call -globalFrameDidChange: again, see |
| 155 // http://crbug.com/55754 comments 22 and 24. | 162 // http://crbug.com/55754 comments 22 and 24. |
| 156 [glContext_ update]; | 163 [glContext_ update]; |
| 157 | 164 |
| 158 // You would think that -update updates the viewport. You would be wrong. | 165 // You would think that -update updates the viewport. You would be wrong. |
| 159 CGLSetCurrentContext(cglContext_); | 166 CGLSetCurrentContext(cglContext_); |
| 160 NSSize size = [self frame].size; | 167 NSSize size = [self frame].size; |
| 161 glViewport(0, 0, size.width, size.height); | 168 glViewport(0, 0, size.width, size.height); |
| 162 CGLSetCurrentContext(0); | 169 CGLSetCurrentContext(0); |
| 170 |
| 171 handlingGlobalFrameDidChange_ = NO; |
| 163 } | 172 } |
| 164 | 173 |
| 165 - (void)prepareForGLRendering { | 174 - (void)prepareForGLRendering { |
| 166 TRACE_EVENT0("browser", "AcceleratedPluginView::prepareForGLRendering"); | 175 TRACE_EVENT0("browser", "AcceleratedPluginView::prepareForGLRendering"); |
| 167 | 176 |
| 168 // If we're using OpenGL, make sure it is connected. | 177 // If we're using OpenGL, make sure it is connected. |
| 169 if ([glContext_ view] != self) { | 178 if ([glContext_ view] != self) { |
| 170 [glContext_ setView:self]; | 179 [glContext_ setView:self]; |
| 171 } | 180 } |
| 172 } | 181 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return YES; | 247 return YES; |
| 239 } | 248 } |
| 240 | 249 |
| 241 - (void)viewDidMoveToSuperview { | 250 - (void)viewDidMoveToSuperview { |
| 242 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidMoveToSuperview"); | 251 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidMoveToSuperview"); |
| 243 if (![self superview]) | 252 if (![self superview]) |
| 244 [self onRenderWidgetHostViewGone]; | 253 [self onRenderWidgetHostViewGone]; |
| 245 } | 254 } |
| 246 @end | 255 @end |
| 247 | 256 |
| OLD | NEW |