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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/icu_util.h" | 9 #include "base/i18n/icu_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/power_monitor/power_monitor.h" | 13 #include "base/power_monitor/power_monitor.h" |
14 #include "base/power_monitor/power_monitor_device_source.h" | 14 #include "base/power_monitor/power_monitor_device_source.h" |
15 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "cc/surfaces/surface_manager.h" | 17 #include "cc/surfaces/surface_manager.h" |
18 #include "third_party/skia/include/core/SkXfermode.h" | 18 #include "third_party/skia/include/core/SkXfermode.h" |
19 #include "ui/aura/client/default_capture_client.h" | 19 #include "ui/aura/client/default_capture_client.h" |
20 #include "ui/aura/client/window_tree_client.h" | 20 #include "ui/aura/client/window_parenting_client.h" |
21 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
22 #include "ui/aura/test/test_focus_client.h" | 22 #include "ui/aura/test/test_focus_client.h" |
23 #include "ui/aura/test/test_screen.h" | 23 #include "ui/aura/test/test_screen.h" |
24 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
25 #include "ui/aura/window_delegate.h" | 25 #include "ui/aura/window_delegate.h" |
26 #include "ui/aura/window_tree_host.h" | 26 #include "ui/aura/window_tree_host.h" |
27 #include "ui/base/hit_test.h" | 27 #include "ui/base/hit_test.h" |
28 #include "ui/compositor/paint_recorder.h" | 28 #include "ui/compositor/paint_recorder.h" |
29 #include "ui/compositor/test/in_process_context_factory.h" | 29 #include "ui/compositor/test/in_process_context_factory.h" |
30 #include "ui/events/event.h" | 30 #include "ui/events/event.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 bool HasHitTestMask() const override { return false; } | 89 bool HasHitTestMask() const override { return false; } |
90 void GetHitTestMask(gfx::Path* mask) const override {} | 90 void GetHitTestMask(gfx::Path* mask) const override {} |
91 | 91 |
92 private: | 92 private: |
93 SkColor color_; | 93 SkColor color_; |
94 gfx::Rect window_bounds_; | 94 gfx::Rect window_bounds_; |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); | 96 DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); |
97 }; | 97 }; |
98 | 98 |
99 class DemoWindowTreeClient : public aura::client::WindowTreeClient { | 99 class DemoWindowParentingClient : public aura::client::WindowParentingClient { |
100 public: | 100 public: |
101 explicit DemoWindowTreeClient(aura::Window* window) : window_(window) { | 101 explicit DemoWindowParentingClient(aura::Window* window) : window_(window) { |
102 aura::client::SetWindowTreeClient(window_, this); | 102 aura::client::SetWindowParentingClient(window_, this); |
103 } | 103 } |
104 | 104 |
105 ~DemoWindowTreeClient() override { | 105 ~DemoWindowParentingClient() override { |
106 aura::client::SetWindowTreeClient(window_, nullptr); | 106 aura::client::SetWindowParentingClient(window_, nullptr); |
107 } | 107 } |
108 | 108 |
109 // Overridden from aura::client::WindowTreeClient: | 109 // Overridden from aura::client::WindowParentingClient: |
110 aura::Window* GetDefaultParent(aura::Window* context, | 110 aura::Window* GetDefaultParent(aura::Window* context, |
111 aura::Window* window, | 111 aura::Window* window, |
112 const gfx::Rect& bounds) override { | 112 const gfx::Rect& bounds) override { |
113 if (!capture_client_) { | 113 if (!capture_client_) { |
114 capture_client_.reset( | 114 capture_client_.reset( |
115 new aura::client::DefaultCaptureClient(window_->GetRootWindow())); | 115 new aura::client::DefaultCaptureClient(window_->GetRootWindow())); |
116 } | 116 } |
117 return window_; | 117 return window_; |
118 } | 118 } |
119 | 119 |
120 private: | 120 private: |
121 aura::Window* window_; | 121 aura::Window* window_; |
122 | 122 |
123 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; | 123 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); | 125 DISALLOW_COPY_AND_ASSIGN(DemoWindowParentingClient); |
126 }; | 126 }; |
127 | 127 |
128 int DemoMain() { | 128 int DemoMain() { |
129 #if defined(USE_X11) | 129 #if defined(USE_X11) |
130 // This demo uses InProcessContextFactory which uses X on a separate Gpu | 130 // This demo uses InProcessContextFactory which uses X on a separate Gpu |
131 // thread. | 131 // thread. |
132 gfx::InitializeThreadedX11(); | 132 gfx::InitializeThreadedX11(); |
133 #endif | 133 #endif |
134 | 134 |
135 gl::init::InitializeGLOneOff(); | 135 gl::init::InitializeGLOneOff(); |
(...skipping 16 matching lines...) Expand all Loading... |
152 base::PowerMonitor power_monitor( | 152 base::PowerMonitor power_monitor( |
153 base::WrapUnique(new base::PowerMonitorDeviceSource)); | 153 base::WrapUnique(new base::PowerMonitorDeviceSource)); |
154 | 154 |
155 std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); | 155 std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); |
156 env->set_context_factory(context_factory.get()); | 156 env->set_context_factory(context_factory.get()); |
157 std::unique_ptr<aura::TestScreen> test_screen( | 157 std::unique_ptr<aura::TestScreen> test_screen( |
158 aura::TestScreen::Create(gfx::Size())); | 158 aura::TestScreen::Create(gfx::Size())); |
159 display::Screen::SetScreenInstance(test_screen.get()); | 159 display::Screen::SetScreenInstance(test_screen.get()); |
160 std::unique_ptr<aura::WindowTreeHost> host( | 160 std::unique_ptr<aura::WindowTreeHost> host( |
161 test_screen->CreateHostForPrimaryDisplay()); | 161 test_screen->CreateHostForPrimaryDisplay()); |
162 std::unique_ptr<DemoWindowTreeClient> window_tree_client( | 162 std::unique_ptr<DemoWindowParentingClient> window_parenting_client( |
163 new DemoWindowTreeClient(host->window())); | 163 new DemoWindowParentingClient(host->window())); |
164 aura::test::TestFocusClient focus_client; | 164 aura::test::TestFocusClient focus_client; |
165 aura::client::SetFocusClient(host->window(), &focus_client); | 165 aura::client::SetFocusClient(host->window(), &focus_client); |
166 | 166 |
167 // Create a hierarchy of test windows. | 167 // Create a hierarchy of test windows. |
168 gfx::Rect window1_bounds(100, 100, 400, 400); | 168 gfx::Rect window1_bounds(100, 100, 400, 400); |
169 DemoWindowDelegate window_delegate1(SK_ColorBLUE); | 169 DemoWindowDelegate window_delegate1(SK_ColorBLUE); |
170 aura::Window window1(&window_delegate1); | 170 aura::Window window1(&window_delegate1); |
171 window1.set_id(1); | 171 window1.set_id(1); |
172 window1.Init(ui::LAYER_TEXTURED); | 172 window1.Init(ui::LAYER_TEXTURED); |
173 window1.SetBounds(window1_bounds); | 173 window1.SetBounds(window1_bounds); |
(...skipping 29 matching lines...) Expand all Loading... |
203 int main(int argc, char** argv) { | 203 int main(int argc, char** argv) { |
204 base::CommandLine::Init(argc, argv); | 204 base::CommandLine::Init(argc, argv); |
205 | 205 |
206 // The exit manager is in charge of calling the dtors of singleton objects. | 206 // The exit manager is in charge of calling the dtors of singleton objects. |
207 base::AtExitManager exit_manager; | 207 base::AtExitManager exit_manager; |
208 | 208 |
209 base::i18n::InitializeICU(); | 209 base::i18n::InitializeICU(); |
210 | 210 |
211 return DemoMain(); | 211 return DemoMain(); |
212 } | 212 } |
OLD | NEW |