| OLD | NEW |
| 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 #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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 // TODO(jbates): is lockFocus needed anymore? it seems redundant with | 174 // TODO(jbates): is lockFocus needed anymore? it seems redundant with |
| 175 // setUpGState in traces. | 175 // setUpGState in traces. |
| 176 - (void)lockFocus { | 176 - (void)lockFocus { |
| 177 TRACE_EVENT0("browser", "AcceleratedPluginView::lockFocus"); | 177 TRACE_EVENT0("browser", "AcceleratedPluginView::lockFocus"); |
| 178 [super lockFocus]; | 178 [super lockFocus]; |
| 179 [self prepareForGLRendering]; | 179 [self prepareForGLRendering]; |
| 180 [glContext_ makeCurrentContext]; | 180 [glContext_ makeCurrentContext]; |
| 181 } | 181 } |
| 182 | 182 |
| 183 - (void)viewWillMoveToWindow:(NSWindow*)newWindow { | |
| 184 TRACE_EVENT1("browser", "AcceleratedPluginView::viewWillMoveToWindow", | |
| 185 "newWindow", newWindow); | |
| 186 // Inform the window hosting this accelerated view that it needs to be | |
| 187 // transparent. | |
| 188 if (![self isHiddenOrHasHiddenAncestor]) { | |
| 189 if ([[self window] conformsToProtocol:@protocol(UnderlayableSurface)]) { | |
| 190 [static_cast<id<UnderlayableSurface> >([self window]) | |
| 191 underlaySurfaceRemoved]; | |
| 192 } | |
| 193 if ([newWindow conformsToProtocol:@protocol(UnderlayableSurface)]) | |
| 194 [static_cast<id<UnderlayableSurface> >(newWindow) underlaySurfaceAdded]; | |
| 195 } | |
| 196 } | |
| 197 | |
| 198 - (void)viewDidHide { | |
| 199 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidHide"); | |
| 200 [super viewDidHide]; | |
| 201 | |
| 202 if ([[self window] conformsToProtocol:@protocol(UnderlayableSurface)]) { | |
| 203 [static_cast<id<UnderlayableSurface> >([self window]) | |
| 204 underlaySurfaceRemoved]; | |
| 205 } | |
| 206 } | |
| 207 | |
| 208 - (void)viewDidUnhide { | 183 - (void)viewDidUnhide { |
| 209 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidUnhide"); | 184 TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidUnhide"); |
| 210 [super viewDidUnhide]; | 185 [super viewDidUnhide]; |
| 211 | 186 |
| 212 // Delay context creation until view unhide, see http://crbug.com/109151 | 187 // Delay context creation until view unhide, see http://crbug.com/109151 |
| 213 if (renderWidgetHostView_ && !glContext_) { | 188 if (renderWidgetHostView_ && !glContext_) { |
| 214 [self initOpenGLContext]; | 189 [self initOpenGLContext]; |
| 215 } | 190 } |
| 216 | |
| 217 if ([[self window] conformsToProtocol:@protocol(UnderlayableSurface)]) { | |
| 218 [static_cast<id<UnderlayableSurface> >([self window]) underlaySurfaceAdded]; | |
| 219 } | |
| 220 } | 191 } |
| 221 | 192 |
| 222 - (BOOL)acceptsFirstResponder { | 193 - (BOOL)acceptsFirstResponder { |
| 223 // Accept first responder if the first responder isn't the RWHVMac, and if the | 194 // Accept first responder if the first responder isn't the RWHVMac, and if the |
| 224 // RWHVMac accepts first responder. If the RWHVMac does not accept first | 195 // RWHVMac accepts first responder. If the RWHVMac does not accept first |
| 225 // responder, do not accept on its behalf. | 196 // responder, do not accept on its behalf. |
| 226 return ([[self window] firstResponder] != [self superview] && | 197 return ([[self window] firstResponder] != [self superview] && |
| 227 [[self superview] acceptsFirstResponder]); | 198 [[self superview] acceptsFirstResponder]); |
| 228 } | 199 } |
| 229 | 200 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Draw at beam vsync. | 248 // Draw at beam vsync. |
| 278 GLint swapInterval; | 249 GLint swapInterval; |
| 279 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) | 250 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) |
| 280 swapInterval = 0; | 251 swapInterval = 0; |
| 281 else | 252 else |
| 282 swapInterval = 1; | 253 swapInterval = 1; |
| 283 [glContext_ setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; | 254 [glContext_ setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval]; |
| 284 } | 255 } |
| 285 | 256 |
| 286 @end // @implementation AcceleratedPluginView(Private) | 257 @end // @implementation AcceleratedPluginView(Private) |
| OLD | NEW |