| 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 #include "ui/compositor/test/test_compositor_host.h" | 5 #include "ui/compositor/test/test_compositor_host.h" |
| 6 | 6 |
| 7 #import <AppKit/NSApplication.h> | 7 #import <AppKit/NSApplication.h> |
| 8 #import <AppKit/NSOpenGL.h> | 8 #import <AppKit/NSOpenGL.h> |
| 9 #import <AppKit/NSView.h> | 9 #import <AppKit/NSView.h> |
| 10 #import <AppKit/NSWindow.h> | 10 #import <AppKit/NSWindow.h> |
| 11 #import <Foundation/NSAutoreleasePool.h> | 11 #import <Foundation/NSAutoreleasePool.h> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "ui/compositor/compositor.h" | 16 #include "ui/compositor/compositor.h" |
| 17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 18 | 18 |
| 19 // AcceleratedTestView provides an NSView class that delegates drawing to a | 19 // AcceleratedTestView provides an NSView class that delegates drawing to a |
| 20 // ui::Compositor delegate, setting up the NSOpenGLContext as required. | 20 // ui::Compositor delegate, setting up the NSOpenGLContext as required. |
| 21 @interface AcceleratedTestView : NSView { | 21 @interface AcceleratedTestView : NSView { |
| 22 ui::Compositor* compositor_; | 22 ui::Compositor* compositor_; |
| 23 } | 23 } |
| 24 // Designated initializer. | 24 // Designated initializer. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 void TestCompositorHostMac::Show() { | 119 void TestCompositorHostMac::Show() { |
| 120 DCHECK(!window_); | 120 DCHECK(!window_); |
| 121 window_ = [[NSWindow alloc] | 121 window_ = [[NSWindow alloc] |
| 122 initWithContentRect:NSMakeRect(bounds_.x(), | 122 initWithContentRect:NSMakeRect(bounds_.x(), |
| 123 bounds_.y(), | 123 bounds_.y(), |
| 124 bounds_.width(), | 124 bounds_.width(), |
| 125 bounds_.height()) | 125 bounds_.height()) |
| 126 styleMask:NSBorderlessWindowMask | 126 styleMask:NSBorderlessWindowMask |
| 127 backing:NSBackingStoreBuffered | 127 backing:NSBackingStoreBuffered |
| 128 defer:NO]; | 128 defer:NO]; |
| 129 scoped_nsobject<AcceleratedTestView> view([[AcceleratedTestView alloc] init]); | 129 base::scoped_nsobject<AcceleratedTestView> view( |
| 130 [[AcceleratedTestView alloc] init]); |
| 130 compositor_.reset(new ui::Compositor(this, view, bounds_.size())); | 131 compositor_.reset(new ui::Compositor(this, view, bounds_.size())); |
| 131 [view setCompositor:compositor_.get()]; | 132 [view setCompositor:compositor_.get()]; |
| 132 [window_ setContentView:view]; | 133 [window_ setContentView:view]; |
| 133 [window_ orderFront:nil]; | 134 [window_ orderFront:nil]; |
| 134 } | 135 } |
| 135 | 136 |
| 136 ui::Compositor* TestCompositorHostMac::GetCompositor() { | 137 ui::Compositor* TestCompositorHostMac::GetCompositor() { |
| 137 return compositor_.get(); | 138 return compositor_.get(); |
| 138 } | 139 } |
| 139 | 140 |
| 140 void TestCompositorHostMac::ScheduleDraw() { | 141 void TestCompositorHostMac::ScheduleDraw() { |
| 141 DCHECK(!ui::Compositor::WasInitializedWithThread()); | 142 DCHECK(!ui::Compositor::WasInitializedWithThread()); |
| 142 if (!compositor_.get()) | 143 if (!compositor_.get()) |
| 143 return; | 144 return; |
| 144 | 145 |
| 145 // Force display now. | 146 // Force display now. |
| 146 [window_ display]; | 147 [window_ display]; |
| 147 } | 148 } |
| 148 | 149 |
| 149 // static | 150 // static |
| 150 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { | 151 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { |
| 151 return new TestCompositorHostMac(bounds); | 152 return new TestCompositorHostMac(bounds); |
| 152 } | 153 } |
| 153 | 154 |
| 154 } // namespace ui | 155 } // namespace ui |
| OLD | NEW |