diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 21:59:18 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-30 21:59:18 +0000 |
commit | 4699f1faf715bc2714e0d6b0ca8b939b6cefcef7 (patch) | |
tree | 3af19f9757aa4bacc4fe877e5a4d3245d2ef7818 | |
parent | 7510d108021bc6b0efeb42ea18f29c266bf9e780 (diff) | |
download | chromium_src-4699f1faf715bc2714e0d6b0ca8b939b6cefcef7.zip chromium_src-4699f1faf715bc2714e0d6b0ca8b939b6cefcef7.tar.gz chromium_src-4699f1faf715bc2714e0d6b0ca8b939b6cefcef7.tar.bz2 |
Mac content shell: fix GPU acceleration
BUG=120772
TEST=site in bug works in content shell on Mac.
Review URL: https://chromiumcodereview.appspot.com/9969010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@129961 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/cocoa/chrome_browser_window.h | 4 | ||||
-rw-r--r-- | content/browser/renderer_host/accelerated_plugin_view_mac.h | 9 | ||||
-rw-r--r-- | content/browser/renderer_host/accelerated_plugin_view_mac.mm | 20 | ||||
-rw-r--r-- | content/browser/renderer_host/accelerated_plugin_view_mac_unittest.mm | 5 | ||||
-rw-r--r-- | content/content_browser.gypi | 1 | ||||
-rw-r--r-- | content/public/browser/accelerated_window_interface.h | 16 | ||||
-rw-r--r-- | content/shell/shell_mac.mm | 50 |
7 files changed, 79 insertions, 26 deletions
diff --git a/chrome/browser/ui/cocoa/chrome_browser_window.h b/chrome/browser/ui/cocoa/chrome_browser_window.h index 6ea2f86..59114a2 100644 --- a/chrome/browser/ui/cocoa/chrome_browser_window.h +++ b/chrome/browser/ui/cocoa/chrome_browser_window.h @@ -8,11 +8,13 @@ #import <Cocoa/Cocoa.h> +#import "content/public/browser/accelerated_window_interface.h" #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" // Common base class for chrome browser windows. Contains methods relating to // hole punching that are shared between framed and fullscreen windows. -@interface ChromeBrowserWindow : ChromeEventProcessingWindow { +@interface ChromeBrowserWindow + : ChromeEventProcessingWindow<UnderlayableSurface> { @private int underlaySurfaceCount_; } diff --git a/content/browser/renderer_host/accelerated_plugin_view_mac.h b/content/browser/renderer_host/accelerated_plugin_view_mac.h index 4f8c0ba..0d3de79 100644 --- a/content/browser/renderer_host/accelerated_plugin_view_mac.h +++ b/content/browser/renderer_host/accelerated_plugin_view_mac.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,13 +13,6 @@ class RenderWidgetHostViewMac; -// Informal protocol implemented by windows that need to be informed explicitly -// about underlay surfaces. -@interface NSObject (UnderlayableSurface) -- (void)underlaySurfaceAdded; -- (void)underlaySurfaceRemoved; -@end - // This subclass of NSView hosts the output of accelerated plugins on // the page. @interface AcceleratedPluginView : NSView { diff --git a/content/browser/renderer_host/accelerated_plugin_view_mac.mm b/content/browser/renderer_host/accelerated_plugin_view_mac.mm index c499046..3571ae0 100644 --- a/content/browser/renderer_host/accelerated_plugin_view_mac.mm +++ b/content/browser/renderer_host/accelerated_plugin_view_mac.mm @@ -9,6 +9,7 @@ #include "base/command_line.h" #include "base/debug/trace_event.h" #include "content/browser/renderer_host/render_widget_host_view_mac.h" +#import "content/public/browser/accelerated_window_interface.h" #include "content/public/browser/browser_thread.h" #include "ui/gfx/gl/gl_context.h" #include "ui/gfx/gl/gl_switches.h" @@ -185,10 +186,12 @@ using content::BrowserThread; // Inform the window hosting this accelerated view that it needs to be // transparent. if (![self isHiddenOrHasHiddenAncestor]) { - if ([[self window] respondsToSelector:@selector(underlaySurfaceRemoved)]) - [static_cast<id>([self window]) underlaySurfaceRemoved]; - if ([newWindow respondsToSelector:@selector(underlaySurfaceAdded)]) - [static_cast<id>(newWindow) underlaySurfaceAdded]; + if ([[self window] conformsToProtocol:@protocol(UnderlayableSurface)]) { + [static_cast<id<UnderlayableSurface> >([self window]) + underlaySurfaceRemoved]; + } + if ([newWindow conformsToProtocol:@protocol(UnderlayableSurface)]) + [static_cast<id<UnderlayableSurface> >(newWindow) underlaySurfaceAdded]; } } @@ -196,8 +199,9 @@ using content::BrowserThread; TRACE_EVENT0("browser", "AcceleratedPluginView::viewDidHide"); [super viewDidHide]; - if ([[self window] respondsToSelector:@selector(underlaySurfaceRemoved)]) { - [static_cast<id>([self window]) underlaySurfaceRemoved]; + if ([[self window] conformsToProtocol:@protocol(UnderlayableSurface)]) { + [static_cast<id<UnderlayableSurface> >([self window]) + underlaySurfaceRemoved]; } } @@ -210,8 +214,8 @@ using content::BrowserThread; [self initOpenGLContext]; } - if ([[self window] respondsToSelector:@selector(underlaySurfaceRemoved)]) { - [static_cast<id>([self window]) underlaySurfaceAdded]; + if ([[self window] conformsToProtocol:@protocol(UnderlayableSurface)]) { + [static_cast<id<UnderlayableSurface> >([self window]) underlaySurfaceAdded]; } } diff --git a/content/browser/renderer_host/accelerated_plugin_view_mac_unittest.mm b/content/browser/renderer_host/accelerated_plugin_view_mac_unittest.mm index 4d902d2..8ad3334 100644 --- a/content/browser/renderer_host/accelerated_plugin_view_mac_unittest.mm +++ b/content/browser/renderer_host/accelerated_plugin_view_mac_unittest.mm @@ -1,14 +1,15 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/browser/renderer_host/accelerated_plugin_view_mac.h" #include "base/logging.h" +#import "content/public/browser/accelerated_window_interface.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -@interface UnderlayCountingWindow : NSWindow { +@interface UnderlayCountingWindow : NSWindow<UnderlayableSurface> { @private int underlayCount_; } diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 32bdc65..4425a07 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -28,6 +28,7 @@ ], 'sources': [ 'port/browser/render_widget_host_view_port.h', + 'public/browser/accelerated_window_interface.h', 'public/browser/access_token_store.h', 'public/browser/browser_accessibility_state.h', 'public/browser/browser_child_process_host.h', diff --git a/content/public/browser/accelerated_window_interface.h b/content/public/browser/accelerated_window_interface.h new file mode 100644 index 0000000..7a6a2bc --- /dev/null +++ b/content/public/browser/accelerated_window_interface.h @@ -0,0 +1,16 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_BROWSER_ACCELERATED_WINDOW_INTERFACE_H_ +#define CONTENT_PUBLIC_BROWSER_ACCELERATED_WINDOW_INTERFACE_H_ +#pragma once + +// Protocol implemented by windows that need to be informed explicitly about +// underlay surfaces. +@protocol UnderlayableSurface +- (void)underlaySurfaceAdded; +- (void)underlaySurfaceRemoved; +@end + +#endif // CONTENT_PUBLIC_BROWSER_ACCELERATED_WINDOW_INTERFACE_H_ diff --git a/content/shell/shell_mac.mm b/content/shell/shell_mac.mm index 63e6211..6e55a9e 100644 --- a/content/shell/shell_mac.mm +++ b/content/shell/shell_mac.mm @@ -11,12 +11,47 @@ #import "base/memory/scoped_nsobject.h" #include "base/string_piece.h" #include "base/sys_string_conversions.h" +#import "content/public/browser/accelerated_window_interface.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_view.h" #include "content/shell/resource.h" #include "googleurl/src/gurl.h" +@interface ShellWindow : NSWindow<UnderlayableSurface> { + @private + int underlaySurfaceCount_; +} + +// Informs the window that an underlay surface has been added/removed. The +// window is non-opaque while underlay surfaces are present. +- (void)underlaySurfaceAdded; +- (void)underlaySurfaceRemoved; + +@end + +@implementation ShellWindow + +- (void)underlaySurfaceAdded { + DCHECK_GE(underlaySurfaceCount_, 0); + ++underlaySurfaceCount_; + + // We're having the OpenGL surface render under the window, so the window + // needs to be not opaque. + if (underlaySurfaceCount_ == 1) + [self setOpaque:NO]; +} + +- (void)underlaySurfaceRemoved { + --underlaySurfaceCount_; + DCHECK_GE(underlaySurfaceCount_, 0); + + if (underlaySurfaceCount_ == 0) + [self setOpaque:YES]; +} + +@end + // Receives notification that the window is closing so that it can start the // tear-down process. Is responsible for deleting itself when done. @interface ContentShellWindowDelegate : NSObject<NSWindowDelegate> { @@ -142,13 +177,14 @@ void Shell::PlatformSetIsLoading(bool loading) { void Shell::PlatformCreateWindow(int width, int height) { NSRect initial_window_bounds = NSMakeRect(0, 0, width, height); - window_ = [[NSWindow alloc] initWithContentRect:initial_window_bounds - styleMask:(NSTitledWindowMask | - NSClosableWindowMask | - NSMiniaturizableWindowMask | - NSResizableWindowMask ) - backing:NSBackingStoreBuffered - defer:NO]; + window_ = + [[ShellWindow alloc] initWithContentRect:initial_window_bounds + styleMask:(NSTitledWindowMask | + NSClosableWindowMask | + NSMiniaturizableWindowMask | + NSResizableWindowMask ) + backing:NSBackingStoreBuffered + defer:NO]; [window_ setTitle:kWindowTitle]; NSView* content = [window_ contentView]; |