diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 03:12:17 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-21 03:12:17 +0000 |
commit | 2f47fc457801054fb68055b4649e21af609f81dc (patch) | |
tree | cb31f77630a7465c4001baf2794d25989c20e457 | |
parent | 21ee224e0862f56ce9d88f2c91950a40cfae6aa0 (diff) | |
download | chromium_src-2f47fc457801054fb68055b4649e21af609f81dc.zip chromium_src-2f47fc457801054fb68055b4649e21af609f81dc.tar.gz chromium_src-2f47fc457801054fb68055b4649e21af609f81dc.tar.bz2 |
compositor_unittests target is unimplmented on Mac
Adds necessary pieces to get the WebKit compositor working with
compositor_unittests target on Mac. Required gyp build flags are:
'use_aura': 1,
'use_webkit_compositor': 1,
'use_skia': 1,
BUG=104390, 104555
TEST=compositor_unittests --gtest_filter=LayerWithRealCompositorTest.* passes and shows correct visual results.
Review URL: http://codereview.chromium.org/8486020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110875 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base.gypi | 2 | ||||
-rw-r--r-- | printing/printed_document.h | 2 | ||||
-rw-r--r-- | printing/printing.gyp | 8 | ||||
-rw-r--r-- | ui/base/animation/tween.cc | 5 | ||||
-rw-r--r-- | ui/base/animation/tween.h | 5 | ||||
-rw-r--r-- | ui/gfx/compositor/compositor.gyp | 9 | ||||
-rw-r--r-- | ui/gfx/compositor/test/test_compositor_host.h | 4 | ||||
-rw-r--r-- | ui/gfx/compositor/test/test_compositor_host_mac.mm | 146 | ||||
-rw-r--r-- | ui/gfx/compositor/test/test_suite.cc | 4 | ||||
-rw-r--r-- | ui/gfx/compositor/test/test_suite.h | 2 | ||||
-rw-r--r-- | ui/gfx/gl/gl.gyp | 10 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_mac.mm (renamed from ui/gfx/gl/gl_context_mac.cc) | 22 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_nsview.h | 48 | ||||
-rw-r--r-- | ui/gfx/gl/gl_context_nsview.mm | 92 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_mac.cc | 26 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_nsview.h | 46 | ||||
-rw-r--r-- | ui/gfx/gl/gl_surface_nsview.mm | 46 | ||||
-rw-r--r-- | ui/gfx/native_widget_types.h | 10 | ||||
-rw-r--r-- | ui/gfx/path.h | 2 | ||||
-rw-r--r-- | webkit/glue/webkit_glue.gypi | 4 | ||||
-rw-r--r-- | webkit/plugins/npapi/webplugin_delegate_impl.h | 8 |
21 files changed, 467 insertions, 34 deletions
diff --git a/base/base.gypi b/base/base.gypi index 5449329..fcf014a 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -424,7 +424,7 @@ [ 'toolkit_uses_gtk==0', { 'sources!': [ 'message_pump_gtk.cc', ], }], - [ '(touchui==0 and use_aura==0) or OS == "win"', { + [ '(touchui==0 and use_aura==0) or OS == "win" or OS == "mac"', { 'sources!' : [ 'message_pump_x.cc', ], }, { 'sources!' : [ 'message_pump_gtk.cc', ], diff --git a/printing/printed_document.h b/printing/printed_document.h index 7233df5..3e3217a 100644 --- a/printing/printed_document.h +++ b/printing/printed_document.h @@ -51,7 +51,7 @@ class PRINTING_EXPORT PrintedDocument // Draws the page in the context. // Note: locks for a short amount of time in debug only. -#if defined(OS_WIN) || defined(OS_MACOSX) +#if defined(OS_WIN) || defined(OS_MACOSX) && !defined(USE_AURA) void RenderPrintedPage(const PrintedPage& page, gfx::NativeDrawingContext context) const; #elif defined(OS_POSIX) diff --git a/printing/printing.gyp b/printing/printing.gyp index 34e3b4e..495fc73 100644 --- a/printing/printing.gyp +++ b/printing/printing.gyp @@ -111,6 +111,14 @@ ['exclude', 'metafile_skia_wrapper\\.(cc|h)$'], ], }], + # Mac-Aura does not support printing. + ['OS=="mac" and use_aura==1',{ + 'sources!': [ + 'printed_document_mac.cc', + 'printing_context_mac.mm', + 'printing_context_mac.h', + ], + }], ['OS=="mac" and use_aura==0',{ 'sources': [ 'printing_context_mac.mm', diff --git a/ui/base/animation/tween.cc b/ui/base/animation/tween.cc index 3d57aef..b8f4385 100644 --- a/ui/base/animation/tween.cc +++ b/ui/base/animation/tween.cc @@ -11,10 +11,7 @@ #endif #include "base/logging.h" - -#if !defined(OS_MACOSX) #include "ui/gfx/interpolated_transform.h" -#endif namespace ui { @@ -86,7 +83,6 @@ gfx::Rect Tween::ValueBetween(double value, target_bounds.height())); } -#if !defined(OS_MACOSX) // static Transform Tween::ValueBetween(double value, const Transform& start_transform, @@ -127,6 +123,5 @@ Transform Tween::ValueBetween(double value, return to_return; } -#endif } // namespace ui diff --git a/ui/base/animation/tween.h b/ui/base/animation/tween.h index 02c08c5..b1641b5 100644 --- a/ui/base/animation/tween.h +++ b/ui/base/animation/tween.h @@ -9,10 +9,7 @@ #include "base/basictypes.h" #include "ui/base/ui_export.h" #include "ui/gfx/rect.h" - -#if !defined(OS_MACOSX) #include "ui/gfx/transform.h" -#endif namespace ui { @@ -37,11 +34,9 @@ class UI_EXPORT Tween { static gfx::Rect ValueBetween(double value, const gfx::Rect& start_bounds, const gfx::Rect& target_bounds); -#if !defined(OS_MACOSX) static Transform ValueBetween(double value, const Transform& start_transform, const Transform& target_transform); -#endif private: Tween(); diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp index 71ac245..4b4c8b0 100644 --- a/ui/gfx/compositor/compositor.gyp +++ b/ui/gfx/compositor/compositor.gyp @@ -46,8 +46,8 @@ 'compositor_switches.cc', 'compositor_switches.h', 'compositor_win.cc', - 'debug_utils.cc', - 'debug_utils.h', + 'debug_utils.cc', + 'debug_utils.h', 'layer.cc', 'layer.h', 'layer_animation_delegate.h', @@ -62,7 +62,7 @@ 'screen_rotation.h', ], 'conditions': [ - ['os_posix == 1 and OS != "mac"', { + ['os_posix == 1', { 'sources!': [ 'compositor_stub.cc', ], @@ -92,7 +92,7 @@ }], ['use_webkit_compositor == 1', { 'sources/': [ - ['exclude', '^compositor_(gl|win|stub).(h|cc)$'], + ['exclude', '^compositor_(gl|mac|win|stub).(h|cc|mm)$'], ], 'dependencies': [ '<(DEPTH)/third_party/WebKit/Source/WebKit/chromium/WebKit.gyp:webkit', @@ -162,6 +162,7 @@ 'run_all_unittests.cc', 'test/test_compositor_host.h', 'test/test_compositor_host_linux.cc', + 'test/test_compositor_host_mac.mm', 'test/test_compositor_host_win.cc', 'test/test_layer_animation_delegate.cc', 'test/test_layer_animation_delegate.h', diff --git a/ui/gfx/compositor/test/test_compositor_host.h b/ui/gfx/compositor/test/test_compositor_host.h index 92650cb..ea15ba0 100644 --- a/ui/gfx/compositor/test/test_compositor_host.h +++ b/ui/gfx/compositor/test/test_compositor_host.h @@ -16,7 +16,11 @@ namespace ui { class Compositor; +#if defined (OS_MACOSX) +class TestCompositorHost { +#else class TestCompositorHost : public MessageLoop::Dispatcher { +#endif public: virtual ~TestCompositorHost() {} diff --git a/ui/gfx/compositor/test/test_compositor_host_mac.mm b/ui/gfx/compositor/test/test_compositor_host_mac.mm new file mode 100644 index 0000000..4cd1ee2 --- /dev/null +++ b/ui/gfx/compositor/test/test_compositor_host_mac.mm @@ -0,0 +1,146 @@ +// Copyright (c) 2011 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 "ui/gfx/compositor/test/test_compositor_host.h" + +#import <AppKit/NSApplication.h> +#import <AppKit/NSOpenGL.h> +#import <AppKit/NSView.h> +#import <AppKit/NSWindow.h> +#import <Foundation/NSAutoreleasePool.h> + +#include "base/compiler_specific.h" +#include "ui/gfx/compositor/compositor.h" +#include "ui/gfx/rect.h" + +// AcceleratedTestView provides an NSView class that delegates drawing to a +// ui::Compositor delegate, setting up the NSOpenGLContext as required. +@interface AcceleratedTestView : NSView { + scoped_refptr<ui::Compositor> compositor_; +} +// Designated initializer. +-(id)init; +-(void)setCompositor:(scoped_refptr<ui::Compositor>)compositor; +@end + +@implementation AcceleratedTestView +-(id)init { + // The frame will be resized when reparented into the window's view hierarchy. + self = [super initWithFrame:NSZeroRect]; + return self; +} + +-(void)setCompositor:(scoped_refptr<ui::Compositor>)compositor { + compositor_ = compositor; +} + +- (void)drawRect:(NSRect)rect { + DCHECK(compositor_) << "Drawing with no compositor set."; + compositor_->Draw(false); +} +@end + +namespace ui { + +// Tests that use Objective-C memory semantics need to have a top-level +// NSAutoreleasePool set up and initialized prior to execution and drained upon +// exit. The tests will leak otherwise. +class FoundationHost { + protected: + FoundationHost() { + pool_ = [[NSAutoreleasePool alloc] init]; + } + virtual ~FoundationHost() { + [pool_ drain]; + } + + private: + NSAutoreleasePool* pool_; + DISALLOW_COPY_AND_ASSIGN(FoundationHost); +}; + +// Tests that use the AppKit framework need to have the NSApplication +// initialized prior to doing anything with display objects such as windows, +// views, or controls. +class AppKitHost : public FoundationHost { + protected: + AppKitHost() { + [NSApplication sharedApplication]; + } + virtual ~AppKitHost() { + } + private: + DISALLOW_COPY_AND_ASSIGN(AppKitHost); +}; + +// TestCompositorHostMac provides a window surface and a coordinated compositor +// for use in the compositor unit tests. +class TestCompositorHostMac : public TestCompositorHost, + public CompositorDelegate, + public AppKitHost { + public: + TestCompositorHostMac(const gfx::Rect& bounds); + virtual ~TestCompositorHostMac(); + + private: + // TestCompositorHost: + virtual void Show() OVERRIDE; + virtual ui::Compositor* GetCompositor() OVERRIDE; + + // CompositorDelegate: + virtual void ScheduleDraw() OVERRIDE; + + gfx::Rect bounds_; + scoped_refptr<ui::Compositor> compositor_; + + // Owned. Released when window is closed. + NSWindow* window_; + + DISALLOW_COPY_AND_ASSIGN(TestCompositorHostMac); +}; + +TestCompositorHostMac::TestCompositorHostMac(const gfx::Rect& bounds) + : bounds_(bounds), window_(nil) { +} + +TestCompositorHostMac::~TestCompositorHostMac() { + [window_ orderOut:nil]; + [window_ close]; +} + +void TestCompositorHostMac::Show() { + DCHECK(!window_); + window_ = [[NSWindow alloc] + initWithContentRect:NSMakeRect(bounds_.x(), + bounds_.y(), + bounds_.width(), + bounds_.height()) + styleMask:NSBorderlessWindowMask + backing:NSBackingStoreBuffered + defer:NO]; + AcceleratedTestView* view = [[[AcceleratedTestView alloc] init] autorelease]; + compositor_ = ui::Compositor::Create(this, view, bounds_.size()); + [view setCompositor:compositor_]; + [window_ setContentView:view]; + [window_ orderFront:nil]; +} + +ui::Compositor* TestCompositorHostMac::GetCompositor() { + return compositor_; +} + +void TestCompositorHostMac::ScheduleDraw() { + if (!compositor_) + return; + + // Force display now. + [window_ display]; +} + +// static +TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { + return new TestCompositorHostMac(bounds); +} + +} // namespace ui diff --git a/ui/gfx/compositor/test/test_suite.cc b/ui/gfx/compositor/test/test_suite.cc index c1d76cd..4164d46 100644 --- a/ui/gfx/compositor/test/test_suite.cc +++ b/ui/gfx/compositor/test/test_suite.cc @@ -30,10 +30,6 @@ void CompositorTestSuite::Initialize() { gfx::RegisterPathProvider(); ui::RegisterPathProvider(); - // Force unittests to run using en-US so if we test against string - // output, it'll pass regardless of the system language. - ui::ResourceBundle::InitSharedInstance("en-US"); - message_loop_.reset(new MessageLoop(MessageLoop::TYPE_UI)); ui::CompositorTestSupport::Initialize(); } diff --git a/ui/gfx/compositor/test/test_suite.h b/ui/gfx/compositor/test/test_suite.h index d4760ce..140cd47 100644 --- a/ui/gfx/compositor/test/test_suite.h +++ b/ui/gfx/compositor/test/test_suite.h @@ -15,7 +15,7 @@ class MessageLoop; class CompositorTestSuite : public base::TestSuite { public: CompositorTestSuite(int argc, char** argv); - ~CompositorTestSuite(); + virtual ~CompositorTestSuite(); protected: // base::TestSuite: diff --git a/ui/gfx/gl/gl.gyp b/ui/gfx/gl/gl.gyp index 22e40b9..9850533 100644 --- a/ui/gfx/gl/gl.gyp +++ b/ui/gfx/gl/gl.gyp @@ -41,7 +41,7 @@ 'gl_context.cc', 'gl_context.h', 'gl_context_linux.cc', - 'gl_context_mac.cc', + 'gl_context_mac.mm', 'gl_context_osmesa.cc', 'gl_context_osmesa.h', 'gl_context_stub.cc', @@ -172,6 +172,14 @@ ], }, }], + ['OS=="mac" and use_aura == 1', { + 'sources': [ + 'gl_context_nsview.mm', + 'gl_context_nsview.h', + 'gl_surface_nsview.mm', + 'gl_surface_nsview.h', + ], + }], ], }, ], diff --git a/ui/gfx/gl/gl_context_mac.cc b/ui/gfx/gl/gl_context_mac.mm index 0c870e2..508ccf9 100644 --- a/ui/gfx/gl/gl_context_mac.cc +++ b/ui/gfx/gl/gl_context_mac.mm @@ -13,8 +13,11 @@ #include "ui/gfx/gl/gl_context_osmesa.h" #include "ui/gfx/gl/gl_context_stub.h" #include "ui/gfx/gl/gl_implementation.h" -#include "ui/gfx/gl/gl_surface_cgl.h" -#include "ui/gfx/gl/gl_surface_osmesa.h" +#include "ui/gfx/gl/gl_surface.h" + +#if defined(USE_AURA) +#include "ui/gfx/gl/gl_context_nsview.h" +#endif namespace { @@ -38,9 +41,18 @@ scoped_refptr<GLContext> GLContext::CreateGLContext( GpuPreference gpu_preference) { switch (GetGLImplementation()) { case kGLImplementationDesktopGL: { - scoped_refptr<GLContext> context(new GLContextCGL(share_group)); - if (!context->Initialize(compatible_surface, gpu_preference)) - return NULL; + scoped_refptr<GLContext> context; + if (compatible_surface->IsOffscreen()) { + context = new GLContextCGL(share_group); + if (!context->Initialize(compatible_surface, gpu_preference)) + return NULL; + } else { +#if defined(USE_AURA) + context = new GLContextNSView(share_group); + if (!context->Initialize(compatible_surface, gpu_preference)) + return NULL; +#endif + } return context; } diff --git a/ui/gfx/gl/gl_context_nsview.h b/ui/gfx/gl/gl_context_nsview.h new file mode 100644 index 0000000..674df63 --- /dev/null +++ b/ui/gfx/gl/gl_context_nsview.h @@ -0,0 +1,48 @@ +// Copyright (c) 2011 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 UI_GFX_GL_GL_CONTEXT_NSVIEW_H_ +#define UI_GFX_GL_GL_CONTEXT_NSVIEW_H_ +#pragma once + +#import <AppKit/NSOpenGL.h> + +#include "base/compiler_specific.h" +#include "base/memory/scoped_nsobject.h" +#include "ui/gfx/gl/gl_context.h" + +namespace gfx { + +class GLSurface; + +// GLContextNSView encapsulates an NSView-based GLContext. This is paired with +// the GLSurfaceNSView class. +class GLContextNSView : public GLContext { + public: + explicit GLContextNSView(GLShareGroup* group); + virtual ~GLContextNSView(); + + // GLContext: + virtual bool Initialize(GLSurface* surface, + GpuPreference gpu_preference) OVERRIDE; + virtual void Destroy() OVERRIDE; + virtual bool MakeCurrent(GLSurface* surface) OVERRIDE; + virtual void ReleaseCurrent(GLSurface* surface) OVERRIDE; + virtual bool IsCurrent(GLSurface* surface) OVERRIDE; + virtual void* GetHandle() OVERRIDE; + virtual void SetSwapInterval(int interval) OVERRIDE; + + // Flush the |context_|. Swaps buffers. + void FlushBuffer(); + + private: + scoped_nsobject<NSOpenGLContext> context_; + GpuPreference gpu_preference_; + + DISALLOW_COPY_AND_ASSIGN(GLContextNSView); +}; + +} // namespace gfx + +#endif // UI_GFX_GL_GL_CONTEXT_NSVIEW_H_ diff --git a/ui/gfx/gl/gl_context_nsview.mm b/ui/gfx/gl/gl_context_nsview.mm new file mode 100644 index 0000000..a3aa7aa --- /dev/null +++ b/ui/gfx/gl/gl_context_nsview.mm @@ -0,0 +1,92 @@ +// Copyright (c) 2011 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 "ui/gfx/gl/gl_context_nsview.h" + +#include <vector> + +#import <AppKit/NSOpenGL.h> +#import <AppKit/NSView.h> + +#include "base/logging.h" +#include "ui/gfx/gl/gl_surface_nsview.h" + +namespace gfx { + +GLContextNSView::GLContextNSView(GLShareGroup* group) + : GLContext(group) { +} + +GLContextNSView::~GLContextNSView() { +} + +bool GLContextNSView::Initialize(GLSurface* surface, + GpuPreference gpu_preference) { + DCHECK(!context_) << "NSGLContext was previously initialized."; + gpu_preference_ = gpu_preference; + + std::vector<NSOpenGLPixelFormatAttribute> attributes; + attributes.push_back(NSOpenGLPFAAccelerated); + attributes.push_back(NSOpenGLPFADoubleBuffer); + attributes.push_back(0); + + scoped_nsobject<NSOpenGLPixelFormat> pixel_format; + pixel_format.reset([[NSOpenGLPixelFormat alloc] + initWithAttributes:&attributes.front()]); + if (!pixel_format) { + LOG(ERROR) << "NSOpenGLPixelFormat initWithAttributes failed."; + return false; + } + + context_.reset([[NSOpenGLContext alloc] initWithFormat:pixel_format + shareContext:nil]); + if (!context_) { + LOG(ERROR) << "NSOpenGLContext initWithFormat failed"; + return false; + } + + // Allow the surface to call back when in need of |FlushBuffer|. + static_cast<GLSurfaceNSView*>(surface)->SetGLContext(this); + + return true; +} + +void GLContextNSView::Destroy() { + context_.reset(nil); +} + +bool GLContextNSView::MakeCurrent(GLSurface* surface) { + PluginWindowHandle view = + static_cast<PluginWindowHandle>(surface->GetHandle()); + // Only set the context's view if the view is parented. + // I.e. it is a valid drawable. + if ([view window]) + [context_ setView:view]; + [context_ makeCurrentContext]; + return true; +} + +void GLContextNSView::ReleaseCurrent(GLSurface* surface) { + [NSOpenGLContext clearCurrentContext]; +} + +bool GLContextNSView::IsCurrent(GLSurface* surface) { + return context_ == [NSOpenGLContext currentContext]; +} + +void* GLContextNSView::GetHandle() { + return context_; +} + +void GLContextNSView::SetSwapInterval(int interval) { + DCHECK(interval == 0 || interval == 1); + GLint swap = interval; + [context_ setValues:&swap forParameter:NSOpenGLCPSwapInterval]; +} + +void GLContextNSView::FlushBuffer() { + [context_ flushBuffer]; +} + +} // namespace gfx diff --git a/ui/gfx/gl/gl_surface_mac.cc b/ui/gfx/gl/gl_surface_mac.cc index 0f6cdd4..ebe3cc3 100644 --- a/ui/gfx/gl/gl_surface_mac.cc +++ b/ui/gfx/gl/gl_surface_mac.cc @@ -13,6 +13,10 @@ #include "ui/gfx/gl/gl_surface_osmesa.h" #include "ui/gfx/gl/gl_surface_stub.h" +#if defined(USE_AURA) +#include "ui/gfx/gl/gl_surface_nsview.h" +#endif + namespace gfx { bool GLSurface::InitializeOneOffInternal() { @@ -32,7 +36,27 @@ bool GLSurface::InitializeOneOffInternal() { scoped_refptr<GLSurface> GLSurface::CreateViewGLSurface( bool software, gfx::PluginWindowHandle window) { - return CreateOffscreenGLSurface(software, gfx::Size(1, 1)); +#if defined(USE_AURA) + if (software) + return NULL; + + switch (GetGLImplementation()) { + case kGLImplementationDesktopGL: { + scoped_refptr<GLSurface> surface(new GLSurfaceNSView(window)); + if (!surface->Initialize()) + return NULL; + + return surface; + } + case kGLImplementationMockGL: + return new GLSurfaceStub; + default: + NOTREACHED(); + return NULL; + } +#else + return CreateOffscreenGLSurface(software, gfx::Size(1,1)); +#endif } scoped_refptr<GLSurface> GLSurface::CreateOffscreenGLSurface( diff --git a/ui/gfx/gl/gl_surface_nsview.h b/ui/gfx/gl/gl_surface_nsview.h new file mode 100644 index 0000000..58e1344 --- /dev/null +++ b/ui/gfx/gl/gl_surface_nsview.h @@ -0,0 +1,46 @@ +// Copyright (c) 2011 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 UI_GFX_GL_GL_SURFACE_NSVIEW_H_ +#define UI_GFX_GL_GL_SURFACE_NSVIEW_H_ + +#include "base/compiler_specific.h" +#include "ui/gfx/gl/gl_surface.h" +#include "ui/gfx/size.h" + +namespace gfx { + +class GLContextNSView; + +// GLSurfaceNSView provides an implementation of the the GLSurface interface +// that is backed by an NSView. This interface pairs with the GLContextNSView +// class, and the NSView is expected to use this context for drawing. +class GLSurfaceNSView : public GLSurface { + public: + explicit GLSurfaceNSView(PluginWindowHandle view); + virtual ~GLSurfaceNSView(); + + // GLSurface: + virtual void Destroy() OVERRIDE; + virtual bool IsOffscreen() OVERRIDE; + virtual bool SwapBuffers() OVERRIDE; + virtual gfx::Size GetSize() OVERRIDE; + virtual void* GetHandle() OVERRIDE; + + // Allow the surface to call back to context when in need of |FlushBuffer|. + void SetGLContext(GLContextNSView* context); + + private: + // Weak. An |NSView*|. + PluginWindowHandle view_; + + // Weak. Associated context. + GLContextNSView* context_; + + DISALLOW_COPY_AND_ASSIGN(GLSurfaceNSView); +}; + +} // namespace gfx + +#endif // UI_GFX_GL_GL_SURFACE_NSVIEW_H_ diff --git a/ui/gfx/gl/gl_surface_nsview.mm b/ui/gfx/gl/gl_surface_nsview.mm new file mode 100644 index 0000000..0c7f3aa --- /dev/null +++ b/ui/gfx/gl/gl_surface_nsview.mm @@ -0,0 +1,46 @@ +// Copyright (c) 2011 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 "ui/gfx/gl/gl_surface_nsview.h" + +#import <AppKit/NSOpenGL.h> +#import <AppKit/NSView.h> + +#include "ui/gfx/gl/gl_context_nsview.h" + +namespace gfx { + +GLSurfaceNSView::GLSurfaceNSView(PluginWindowHandle view) + : view_(view), + context_(NULL) { +} + +GLSurfaceNSView::~GLSurfaceNSView() { +} + +void GLSurfaceNSView::Destroy() { +} + +bool GLSurfaceNSView::IsOffscreen() { + return false; +} + +bool GLSurfaceNSView::SwapBuffers() { + context_->FlushBuffer(); + return true; +} + +gfx::Size GLSurfaceNSView::GetSize() { + return gfx::Size(NSSizeToCGSize([view_ bounds].size)); +} + +void* GLSurfaceNSView::GetHandle() { + return view_; +} + +void GLSurfaceNSView::SetGLContext(GLContextNSView* context) { + context_ = context; +} + +} // namespace gfx diff --git a/ui/gfx/native_widget_types.h b/ui/gfx/native_widget_types.h index 70c6e49..1f40cc2 100644 --- a/ui/gfx/native_widget_types.h +++ b/ui/gfx/native_widget_types.h @@ -226,6 +226,11 @@ static inline NativeView NativeViewFromIdInBrowser(NativeViewId id) { #elif defined(USE_X11) typedef unsigned long PluginWindowHandle; const PluginWindowHandle kNullPluginWindow = 0; +#elif defined(USE_AURA) && defined(OS_MACOSX) + // Mac-Aura uses NSView-backed GLSurface. Regular Mac does not. + // TODO(dhollowa): Rationalize these two definitions. http://crbug.com/104551. + typedef NSView* PluginWindowHandle; + const PluginWindowHandle kNullPluginWindow = 0; #else // On OS X we don't have windowed plugins. // We use a NULL/0 PluginWindowHandle in shared code to indicate there @@ -251,6 +256,11 @@ const AcceleratedWidget kNullAcceleratedWidget = NULL; #elif defined(USE_X11) typedef unsigned long AcceleratedWidget; const AcceleratedWidget kNullAcceleratedWidget = 0; +#elif defined(USE_AURA) && defined(OS_MACOSX) +// Mac-Aura uses NSView-backed GLSurface. Regular Mac does not. +// TODO(dhollowa): Rationalize these two definitions. http://crbug.com/104551. +typedef NSView* AcceleratedWidget; +const AcceleratedWidget kNullAcceleratedWidget = 0; #else typedef void* AcceleratedWidget; const AcceleratedWidget kNullAcceleratedWidget = NULL; diff --git a/ui/gfx/path.h b/ui/gfx/path.h index d0b32bb..c00443d 100644 --- a/ui/gfx/path.h +++ b/ui/gfx/path.h @@ -28,7 +28,7 @@ class UI_EXPORT Path : public SkPath { ~Path(); -#if defined(OS_WIN) || defined(USE_X11) +#if defined(USE_AURA) || defined(OS_WIN) || defined(USE_X11) // Creates a NativeRegion from the path. The caller is responsible for freeing // resources used by this region. This only supports polygon paths. NativeRegion CreateNativeRegion() const; diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi index ceb2aeb..95a7f84 100644 --- a/webkit/glue/webkit_glue.gypi +++ b/webkit/glue/webkit_glue.gypi @@ -454,9 +454,11 @@ }], ['use_aura==1', { 'sources/': [ - ['exclude', '^../plugins/npapi/webplugin_delegate_impl_win.cc'], + ['exclude', '^\\.\\./plugins/npapi/webplugin_delegate_impl_mac.mm'], + ['exclude', '^\\.\\./plugins/npapi/webplugin_delegate_impl_win.cc'], ], 'sources!': [ + 'webcursor_mac.mm', 'webcursor_win.cc', ], }], diff --git a/webkit/plugins/npapi/webplugin_delegate_impl.h b/webkit/plugins/npapi/webplugin_delegate_impl.h index 6f57a97..97fde32 100644 --- a/webkit/plugins/npapi/webplugin_delegate_impl.h +++ b/webkit/plugins/npapi/webplugin_delegate_impl.h @@ -163,7 +163,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { bool GetIMEStatus(int* input_type, gfx::Rect* caret_rect); #endif -#if defined(OS_MACOSX) +#if defined(OS_MACOSX) && !defined(USE_AURA) // Informs the plugin that the geometry has changed, as with UpdateGeometry, // but also includes the new buffer context for that new geometry. void UpdateGeometryAndContext(const gfx::Rect& window_rect, @@ -211,7 +211,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { void CGPaint(CGContextRef context, const gfx::Rect& rect); bool AllowBufferFlipping(); -#endif // OS_MACOSX +#endif // OS_MACOSX && !USE_AURA gfx::PluginWindowHandle windowed_handle() const { return windowed_handle_; @@ -424,7 +424,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { // Calls SetCapture/ReleaseCapture based on the message type. static void HandleCaptureForMessage(HWND window, UINT message); -#elif defined(OS_MACOSX) +#elif defined(OS_MACOSX) && !defined(USE_AURA) // Sets window_rect_ to |rect| void SetPluginRect(const gfx::Rect& rect); // Sets content_area_origin to |origin| @@ -493,7 +493,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { int keyup_ignore_count_; scoped_ptr<ExternalDragTracker> external_drag_tracker_; -#endif // OS_MACOSX +#endif // OS_MACOSX && !USE_AURA // Called by the message filter hook when the plugin enters a modal loop. void OnModalLoopEntered(); |