| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 private: | 77 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(AppKitHost); | 78 DISALLOW_COPY_AND_ASSIGN(AppKitHost); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // TestCompositorHostMac provides a window surface and a coordinated compositor | 81 // TestCompositorHostMac provides a window surface and a coordinated compositor |
| 82 // for use in the compositor unit tests. | 82 // for use in the compositor unit tests. |
| 83 class TestCompositorHostMac : public TestCompositorHost, | 83 class TestCompositorHostMac : public TestCompositorHost, |
| 84 public AppKitHost { | 84 public AppKitHost { |
| 85 public: | 85 public: |
| 86 TestCompositorHostMac(const gfx::Rect& bounds, | 86 TestCompositorHostMac(const gfx::Rect& bounds, |
| 87 ui::ContextFactory* context_factory); | 87 ui::ContextFactory* context_factory, |
| 88 ui::ContextFactoryPrivate* context_factory_private); |
| 88 ~TestCompositorHostMac() override; | 89 ~TestCompositorHostMac() override; |
| 89 | 90 |
| 90 private: | 91 private: |
| 91 // TestCompositorHost: | 92 // TestCompositorHost: |
| 92 void Show() override; | 93 void Show() override; |
| 93 ui::Compositor* GetCompositor() override; | 94 ui::Compositor* GetCompositor() override; |
| 94 | 95 |
| 95 gfx::Rect bounds_; | 96 gfx::Rect bounds_; |
| 96 | 97 |
| 97 ui::Compositor compositor_; | 98 ui::Compositor compositor_; |
| 98 | 99 |
| 99 // Owned. Released when window is closed. | 100 // Owned. Released when window is closed. |
| 100 NSWindow* window_; | 101 NSWindow* window_; |
| 101 | 102 |
| 102 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostMac); | 103 DISALLOW_COPY_AND_ASSIGN(TestCompositorHostMac); |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 TestCompositorHostMac::TestCompositorHostMac( | 106 TestCompositorHostMac::TestCompositorHostMac( |
| 106 const gfx::Rect& bounds, | 107 const gfx::Rect& bounds, |
| 107 ui::ContextFactory* context_factory) | 108 ui::ContextFactory* context_factory, |
| 109 ui::ContextFactoryPrivate* context_factory_private) |
| 108 : bounds_(bounds), | 110 : bounds_(bounds), |
| 109 compositor_(context_factory, base::ThreadTaskRunnerHandle::Get()), | 111 compositor_(context_factory, |
| 110 window_(nil) { | 112 context_factory_private, |
| 111 } | 113 base::ThreadTaskRunnerHandle::Get()), |
| 114 window_(nil) {} |
| 112 | 115 |
| 113 TestCompositorHostMac::~TestCompositorHostMac() { | 116 TestCompositorHostMac::~TestCompositorHostMac() { |
| 114 // Release reference to |compositor_|. Important because the |compositor_| | 117 // Release reference to |compositor_|. Important because the |compositor_| |
| 115 // holds |this| as its delegate, so that reference must be removed here. | 118 // holds |this| as its delegate, so that reference must be removed here. |
| 116 [[window_ contentView] setCompositor:NULL]; | 119 [[window_ contentView] setCompositor:NULL]; |
| 117 { | 120 { |
| 118 base::scoped_nsobject<NSView> new_view( | 121 base::scoped_nsobject<NSView> new_view( |
| 119 [[NSView alloc] initWithFrame:NSZeroRect]); | 122 [[NSView alloc] initWithFrame:NSZeroRect]); |
| 120 [window_ setContentView:new_view.get()]; | 123 [window_ setContentView:new_view.get()]; |
| 121 } | 124 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 143 [window_ orderFront:nil]; | 146 [window_ orderFront:nil]; |
| 144 } | 147 } |
| 145 | 148 |
| 146 ui::Compositor* TestCompositorHostMac::GetCompositor() { | 149 ui::Compositor* TestCompositorHostMac::GetCompositor() { |
| 147 return &compositor_; | 150 return &compositor_; |
| 148 } | 151 } |
| 149 | 152 |
| 150 // static | 153 // static |
| 151 TestCompositorHost* TestCompositorHost::Create( | 154 TestCompositorHost* TestCompositorHost::Create( |
| 152 const gfx::Rect& bounds, | 155 const gfx::Rect& bounds, |
| 153 ui::ContextFactory* context_factory) { | 156 ui::ContextFactory* context_factory, |
| 154 return new TestCompositorHostMac(bounds, context_factory); | 157 ui::ContextFactoryPrivate* context_factory_private) { |
| 158 return new TestCompositorHostMac(bounds, context_factory, |
| 159 context_factory_private); |
| 155 } | 160 } |
| 156 | 161 |
| 157 } // namespace ui | 162 } // namespace ui |
| OLD | NEW |