| OLD | NEW |
| 1 |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 4 | 5 |
| 5 #include "ui/aura/window_tree_host.h" | 6 #include "ui/aura/window_tree_host.h" |
| 6 | 7 |
| 7 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 8 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 9 #include "ui/aura/client/capture_client.h" | 10 #include "ui/aura/client/capture_client.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
| 11 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 13 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 14 #include "ui/aura/window_targeter.h" | 15 #include "ui/aura/window_targeter.h" |
| 15 #include "ui/aura/window_tree_host_observer.h" | 16 #include "ui/aura/window_tree_host_observer.h" |
| 16 #include "ui/base/ime/input_method.h" | 17 #include "ui/base/ime/input_method.h" |
| 17 #include "ui/base/ime/input_method_factory.h" | 18 #include "ui/base/ime/input_method_factory.h" |
| 18 #include "ui/base/view_prop.h" | 19 #include "ui/base/view_prop.h" |
| 19 #include "ui/compositor/dip_util.h" | 20 #include "ui/compositor/dip_util.h" |
| 20 #include "ui/compositor/layer.h" | 21 #include "ui/compositor/layer.h" |
| 21 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
| 22 #include "ui/gfx/geometry/insets.h" | 23 #include "ui/gfx/geometry/insets.h" |
| 23 #include "ui/gfx/geometry/point.h" | 24 #include "ui/gfx/geometry/point.h" |
| 24 #include "ui/gfx/geometry/point3_f.h" | 25 #include "ui/gfx/geometry/point3_f.h" |
| 25 #include "ui/gfx/geometry/point_conversions.h" | 26 #include "ui/gfx/geometry/point_conversions.h" |
| 26 #include "ui/gfx/geometry/size_conversions.h" | 27 #include "ui/gfx/geometry/size_conversions.h" |
| 27 #include "ui/gfx/screen.h" | 28 #include "ui/gfx/screen.h" |
| 28 | 29 |
| 30 #if defined(OS_WIN) |
| 31 #include "ui/base/window_resize_helper.h" |
| 32 #endif |
| 33 |
| 29 namespace aura { | 34 namespace aura { |
| 30 | 35 |
| 31 const char kWindowTreeHostForAcceleratedWidget[] = | 36 const char kWindowTreeHostForAcceleratedWidget[] = |
| 32 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; | 37 "__AURA_WINDOW_TREE_HOST_ACCELERATED_WIDGET__"; |
| 33 | 38 |
| 34 float GetDeviceScaleFactorFromDisplay(Window* window) { | 39 float GetDeviceScaleFactorFromDisplay(Window* window) { |
| 35 gfx::Display display = gfx::Screen::GetScreenFor(window)-> | 40 gfx::Display display = gfx::Screen::GetScreenFor(window)-> |
| 36 GetDisplayNearestWindow(window); | 41 GetDisplayNearestWindow(window); |
| 37 DCHECK(display.is_valid()); | 42 DCHECK(display.is_valid()); |
| 38 return display.device_scale_factor(); | 43 return display.device_scale_factor(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // ~Window, but by that time any calls to virtual methods overriden here (such | 241 // ~Window, but by that time any calls to virtual methods overriden here (such |
| 237 // as GetRootWindow()) result in Window's implementation. By destroying here | 242 // as GetRootWindow()) result in Window's implementation. By destroying here |
| 238 // we ensure GetRootWindow() still returns this. | 243 // we ensure GetRootWindow() still returns this. |
| 239 //window()->RemoveOrDestroyChildren(); | 244 //window()->RemoveOrDestroyChildren(); |
| 240 } | 245 } |
| 241 | 246 |
| 242 void WindowTreeHost::CreateCompositor() { | 247 void WindowTreeHost::CreateCompositor() { |
| 243 DCHECK(Env::GetInstance()); | 248 DCHECK(Env::GetInstance()); |
| 244 ui::ContextFactory* context_factory = Env::GetInstance()->context_factory(); | 249 ui::ContextFactory* context_factory = Env::GetInstance()->context_factory(); |
| 245 DCHECK(context_factory); | 250 DCHECK(context_factory); |
| 246 compositor_.reset( | 251 #if defined(OS_WIN) |
| 247 new ui::Compositor(context_factory, base::ThreadTaskRunnerHandle::Get())); | 252 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 253 ui::WindowResizeHelper::Get()->task_runner(); |
| 254 #else |
| 255 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 256 base::ThreadTaskRunnerHandle::Get(); |
| 257 #endif |
| 258 compositor_.reset(new ui::Compositor(context_factory, task_runner)); |
| 248 if (!dispatcher()) { | 259 if (!dispatcher()) { |
| 249 window()->Init(ui::LAYER_NOT_DRAWN); | 260 window()->Init(ui::LAYER_NOT_DRAWN); |
| 250 window()->set_host(this); | 261 window()->set_host(this); |
| 251 window()->SetName("RootWindow"); | 262 window()->SetName("RootWindow"); |
| 252 window()->SetEventTargeter( | 263 window()->SetEventTargeter( |
| 253 scoped_ptr<ui::EventTargeter>(new WindowTargeter())); | 264 scoped_ptr<ui::EventTargeter>(new WindowTargeter())); |
| 254 dispatcher_.reset(new WindowEventDispatcher(this)); | 265 dispatcher_.reset(new WindowEventDispatcher(this)); |
| 255 } | 266 } |
| 256 } | 267 } |
| 257 | 268 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 client::CursorClient* cursor_client = client::GetCursorClient(window()); | 325 client::CursorClient* cursor_client = client::GetCursorClient(window()); |
| 315 if (cursor_client) { | 326 if (cursor_client) { |
| 316 const gfx::Display& display = | 327 const gfx::Display& display = |
| 317 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); | 328 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); |
| 318 cursor_client->SetDisplay(display); | 329 cursor_client->SetDisplay(display); |
| 319 } | 330 } |
| 320 dispatcher()->OnCursorMovedToRootLocation(root_location); | 331 dispatcher()->OnCursorMovedToRootLocation(root_location); |
| 321 } | 332 } |
| 322 | 333 |
| 323 } // namespace aura | 334 } // namespace aura |
| OLD | NEW |