| 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/scoped_ptr.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 "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "third_party/skia/include/core/SkXfermode.h" | 16 #include "third_party/skia/include/core/SkXfermode.h" |
| 17 #include "ui/aura/client/default_capture_client.h" | 17 #include "ui/aura/client/default_capture_client.h" |
| 18 #include "ui/aura/client/window_tree_client.h" | 18 #include "ui/aura/client/window_tree_client.h" |
| 19 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 20 #include "ui/aura/test/test_focus_client.h" | 20 #include "ui/aura/test/test_focus_client.h" |
| 21 #include "ui/aura/test/test_screen.h" | 21 #include "ui/aura/test/test_screen.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!capture_client_) { | 111 if (!capture_client_) { |
| 112 capture_client_.reset( | 112 capture_client_.reset( |
| 113 new aura::client::DefaultCaptureClient(window_->GetRootWindow())); | 113 new aura::client::DefaultCaptureClient(window_->GetRootWindow())); |
| 114 } | 114 } |
| 115 return window_; | 115 return window_; |
| 116 } | 116 } |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 aura::Window* window_; | 119 aura::Window* window_; |
| 120 | 120 |
| 121 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | 121 std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); | 123 DISALLOW_COPY_AND_ASSIGN(DemoWindowTreeClient); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 int DemoMain() { | 126 int DemoMain() { |
| 127 #if defined(USE_X11) | 127 #if defined(USE_X11) |
| 128 // This demo uses InProcessContextFactory which uses X on a separate Gpu | 128 // This demo uses InProcessContextFactory which uses X on a separate Gpu |
| 129 // thread. | 129 // thread. |
| 130 gfx::InitializeThreadedX11(); | 130 gfx::InitializeThreadedX11(); |
| 131 #endif | 131 #endif |
| 132 | 132 |
| 133 gfx::GLSurface::InitializeOneOff(); | 133 gfx::GLSurface::InitializeOneOff(); |
| 134 | 134 |
| 135 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
| 136 gfx::SetDefaultDeviceScaleFactor(1.0f); | 136 gfx::SetDefaultDeviceScaleFactor(1.0f); |
| 137 #endif | 137 #endif |
| 138 | 138 |
| 139 // The ContextFactory must exist before any Compositors are created. | 139 // The ContextFactory must exist before any Compositors are created. |
| 140 bool context_factory_for_test = false; | 140 bool context_factory_for_test = false; |
| 141 scoped_ptr<ui::InProcessContextFactory> context_factory( | 141 std::unique_ptr<ui::InProcessContextFactory> context_factory( |
| 142 new ui::InProcessContextFactory(context_factory_for_test, nullptr)); | 142 new ui::InProcessContextFactory(context_factory_for_test, nullptr)); |
| 143 context_factory->set_use_test_surface(false); | 143 context_factory->set_use_test_surface(false); |
| 144 | 144 |
| 145 // Create the message-loop here before creating the root window. | 145 // Create the message-loop here before creating the root window. |
| 146 base::MessageLoopForUI message_loop; | 146 base::MessageLoopForUI message_loop; |
| 147 | 147 |
| 148 base::PowerMonitor power_monitor(make_scoped_ptr( | 148 base::PowerMonitor power_monitor( |
| 149 new base::PowerMonitorDeviceSource)); | 149 base::WrapUnique(new base::PowerMonitorDeviceSource)); |
| 150 | 150 |
| 151 std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); | 151 std::unique_ptr<aura::Env> env = aura::Env::CreateInstance(); |
| 152 env->set_context_factory(context_factory.get()); | 152 env->set_context_factory(context_factory.get()); |
| 153 scoped_ptr<aura::TestScreen> test_screen( | 153 std::unique_ptr<aura::TestScreen> test_screen( |
| 154 aura::TestScreen::Create(gfx::Size())); | 154 aura::TestScreen::Create(gfx::Size())); |
| 155 gfx::Screen::SetScreenInstance(test_screen.get()); | 155 gfx::Screen::SetScreenInstance(test_screen.get()); |
| 156 scoped_ptr<aura::WindowTreeHost> host( | 156 std::unique_ptr<aura::WindowTreeHost> host( |
| 157 test_screen->CreateHostForPrimaryDisplay()); | 157 test_screen->CreateHostForPrimaryDisplay()); |
| 158 scoped_ptr<DemoWindowTreeClient> window_tree_client( | 158 std::unique_ptr<DemoWindowTreeClient> window_tree_client( |
| 159 new DemoWindowTreeClient(host->window())); | 159 new DemoWindowTreeClient(host->window())); |
| 160 aura::test::TestFocusClient focus_client; | 160 aura::test::TestFocusClient focus_client; |
| 161 aura::client::SetFocusClient(host->window(), &focus_client); | 161 aura::client::SetFocusClient(host->window(), &focus_client); |
| 162 | 162 |
| 163 // Create a hierarchy of test windows. | 163 // Create a hierarchy of test windows. |
| 164 gfx::Rect window1_bounds(100, 100, 400, 400); | 164 gfx::Rect window1_bounds(100, 100, 400, 400); |
| 165 DemoWindowDelegate window_delegate1(SK_ColorBLUE); | 165 DemoWindowDelegate window_delegate1(SK_ColorBLUE); |
| 166 aura::Window window1(&window_delegate1); | 166 aura::Window window1(&window_delegate1); |
| 167 window1.set_id(1); | 167 window1.set_id(1); |
| 168 window1.Init(ui::LAYER_TEXTURED); | 168 window1.Init(ui::LAYER_TEXTURED); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 199 int main(int argc, char** argv) { | 199 int main(int argc, char** argv) { |
| 200 base::CommandLine::Init(argc, argv); | 200 base::CommandLine::Init(argc, argv); |
| 201 | 201 |
| 202 // The exit manager is in charge of calling the dtors of singleton objects. | 202 // The exit manager is in charge of calling the dtors of singleton objects. |
| 203 base::AtExitManager exit_manager; | 203 base::AtExitManager exit_manager; |
| 204 | 204 |
| 205 base::i18n::InitializeICU(); | 205 base::i18n::InitializeICU(); |
| 206 | 206 |
| 207 return DemoMain(); | 207 return DemoMain(); |
| 208 } | 208 } |
| OLD | NEW |