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

Side by Side Diff: content/browser/renderer_host/accelerated_plugin_view_mac.mm

Issue 8261004: Prevent recursive calls to globalFrameDidChange. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 2 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
« no previous file with comments | « content/browser/renderer_host/accelerated_plugin_view_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 {
154 // This call to -update can call -globalFrameDidChange: again, see 155 // Short-circuit recursive calls.
155 // http://crbug.com/55754 comments 22 and 24. 156 if (!handlingGlobalFrameDidChange_) {
Nico 2011/10/13 02:26:07 nit: early return instead, less nesting that way.
Ken Russell (switch to Gerrit) 2011/10/13 18:41:20 Right, thanks. Done.
156 [glContext_ update]; 157 handlingGlobalFrameDidChange_ = YES;
157 158
158 // You would think that -update updates the viewport. You would be wrong. 159 // This call to -update can call -globalFrameDidChange: again, see
159 CGLSetCurrentContext(cglContext_); 160 // http://crbug.com/55754 comments 22 and 24.
160 NSSize size = [self frame].size; 161 [glContext_ update];
161 glViewport(0, 0, size.width, size.height); 162
162 CGLSetCurrentContext(0); 163 // You would think that -update updates the viewport. You would be wrong.
164 CGLSetCurrentContext(cglContext_);
165 NSSize size = [self frame].size;
166 glViewport(0, 0, size.width, size.height);
167 CGLSetCurrentContext(0);
168
169 handlingGlobalFrameDidChange_ = NO;
170 }
163 } 171 }
164 172
165 - (void)prepareForGLRendering { 173 - (void)prepareForGLRendering {
166 TRACE_EVENT0("browser", "AcceleratedPluginView::prepareForGLRendering"); 174 TRACE_EVENT0("browser", "AcceleratedPluginView::prepareForGLRendering");
167 175
168 // If we're using OpenGL, make sure it is connected. 176 // If we're using OpenGL, make sure it is connected.
169 if ([glContext_ view] != self) { 177 if ([glContext_ view] != self) {
170 [glContext_ setView:self]; 178 [glContext_ setView:self];
171 } 179 }
172 } 180 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 return YES; 246 return YES;
239 } 247 }
240 248
241 - (void)viewDidMoveToSuperview { 249 - (void)viewDidMoveToSuperview {
242 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidMoveToSuperview"); 250 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidMoveToSuperview");
243 if (![self superview]) 251 if (![self superview])
244 [self onRenderWidgetHostViewGone]; 252 [self onRenderWidgetHostViewGone];
245 } 253 }
246 @end 254 @end
247 255
OLDNEW
« no previous file with comments | « content/browser/renderer_host/accelerated_plugin_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698