| 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> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 [NSApplication sharedApplication]; | 71 [NSApplication sharedApplication]; |
| 72 } | 72 } |
| 73 virtual ~AppKitHost() { | 73 virtual ~AppKitHost() { |
| 74 } | 74 } |
| 75 private: | 75 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(AppKitHost); | 76 DISALLOW_COPY_AND_ASSIGN(AppKitHost); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 // TestCompositorHostMac provides a window surface and a coordinated compositor | 79 // TestCompositorHostMac provides a window surface and a coordinated compositor |
| 80 // for use in the compositor unit tests. | 80 // for use in the compositor unit tests. |
| 81 class TestCompositorHostMac : public TestCompositorHost | 81 class TestCompositorHostMac : public TestCompositorHost, |
| 82 public AppKitHost { | 82 public AppKitHost { |
| 83 public: | 83 public: |
| 84 TestCompositorHostMac(const gfx::Rect& bounds); | 84 TestCompositorHostMac(const gfx::Rect& bounds); |
| 85 virtual ~TestCompositorHostMac(); | 85 virtual ~TestCompositorHostMac(); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 // TestCompositorHost: | 88 // TestCompositorHost: |
| 89 virtual void Show() OVERRIDE; | 89 virtual void Show() OVERRIDE; |
| 90 virtual ui::Compositor* GetCompositor() OVERRIDE; | 90 virtual ui::Compositor* GetCompositor() OVERRIDE; |
| 91 | 91 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 117 window_ = [[NSWindow alloc] | 117 window_ = [[NSWindow alloc] |
| 118 initWithContentRect:NSMakeRect(bounds_.x(), | 118 initWithContentRect:NSMakeRect(bounds_.x(), |
| 119 bounds_.y(), | 119 bounds_.y(), |
| 120 bounds_.width(), | 120 bounds_.width(), |
| 121 bounds_.height()) | 121 bounds_.height()) |
| 122 styleMask:NSBorderlessWindowMask | 122 styleMask:NSBorderlessWindowMask |
| 123 backing:NSBackingStoreBuffered | 123 backing:NSBackingStoreBuffered |
| 124 defer:NO]; | 124 defer:NO]; |
| 125 base::scoped_nsobject<AcceleratedTestView> view( | 125 base::scoped_nsobject<AcceleratedTestView> view( |
| 126 [[AcceleratedTestView alloc] init]); | 126 [[AcceleratedTestView alloc] init]); |
| 127 compositor_.reset(new ui::Compositor(view, bounds_.size())); | 127 compositor_.reset(new ui::Compositor(view)); |
| 128 compositor_->SetScaleAndSize(1.0f, bounds_.size()); |
| 128 [view setCompositor:compositor_.get()]; | 129 [view setCompositor:compositor_.get()]; |
| 129 [window_ setContentView:view]; | 130 [window_ setContentView:view]; |
| 130 [window_ orderFront:nil]; | 131 [window_ orderFront:nil]; |
| 131 } | 132 } |
| 132 | 133 |
| 133 ui::Compositor* TestCompositorHostMac::GetCompositor() { | 134 ui::Compositor* TestCompositorHostMac::GetCompositor() { |
| 134 return compositor_.get(); | 135 return compositor_.get(); |
| 135 } | 136 } |
| 136 | 137 |
| 137 // static | 138 // static |
| 138 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { | 139 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { |
| 139 return new TestCompositorHostMac(bounds); | 140 return new TestCompositorHostMac(bounds); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace ui | 143 } // namespace ui |
| OLD | NEW |