| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // 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 | 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/aura/window_tree_host.h" | 5 #include "ui/aura/window_tree_host.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "ui/aura/client/capture_client.h" | 9 #include "ui/aura/client/capture_client.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget)); | 59 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void WindowTreeHost::InitHost() { | 62 void WindowTreeHost::InitHost() { |
| 63 InitCompositor(); | 63 InitCompositor(); |
| 64 UpdateRootWindowSizeInPixels(GetBoundsInPixels().size()); | 64 UpdateRootWindowSizeInPixels(GetBoundsInPixels().size()); |
| 65 Env::GetInstance()->NotifyHostInitialized(this); | 65 Env::GetInstance()->NotifyHostInitialized(this); |
| 66 window()->Show(); | 66 window()->Show(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void WindowTreeHost::InitCompositor() { | |
| 70 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), | |
| 71 GetBoundsInPixels().size()); | |
| 72 compositor_->SetRootLayer(window()->layer()); | |
| 73 compositor_->SetDisplayColorSpace( | |
| 74 GetICCProfileForCurrentDisplay().GetColorSpace()); | |
| 75 } | |
| 76 | |
| 77 void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) { | 69 void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) { |
| 78 observers_.AddObserver(observer); | 70 observers_.AddObserver(observer); |
| 79 } | 71 } |
| 80 | 72 |
| 81 void WindowTreeHost::RemoveObserver(WindowTreeHostObserver* observer) { | 73 void WindowTreeHost::RemoveObserver(WindowTreeHostObserver* observer) { |
| 82 observers_.RemoveObserver(observer); | 74 observers_.RemoveObserver(observer); |
| 83 } | 75 } |
| 84 | 76 |
| 85 ui::EventProcessor* WindowTreeHost::event_processor() { | 77 ui::EventProcessor* WindowTreeHost::event_processor() { |
| 86 return dispatcher(); | 78 return dispatcher(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if (!dispatcher()) { | 254 if (!dispatcher()) { |
| 263 window()->Init(ui::LAYER_NOT_DRAWN); | 255 window()->Init(ui::LAYER_NOT_DRAWN); |
| 264 window()->set_host(this); | 256 window()->set_host(this); |
| 265 window()->SetName("RootWindow"); | 257 window()->SetName("RootWindow"); |
| 266 window()->SetEventTargeter( | 258 window()->SetEventTargeter( |
| 267 std::unique_ptr<ui::EventTargeter>(new WindowTargeter())); | 259 std::unique_ptr<ui::EventTargeter>(new WindowTargeter())); |
| 268 dispatcher_.reset(new WindowEventDispatcher(this)); | 260 dispatcher_.reset(new WindowEventDispatcher(this)); |
| 269 } | 261 } |
| 270 } | 262 } |
| 271 | 263 |
| 264 void WindowTreeHost::InitCompositor() { |
| 265 compositor_->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(window()), |
| 266 GetBoundsInPixels().size()); |
| 267 compositor_->SetRootLayer(window()->layer()); |
| 268 compositor_->SetDisplayColorSpace( |
| 269 GetICCProfileForCurrentDisplay().GetColorSpace()); |
| 270 } |
| 271 |
| 272 void WindowTreeHost::OnAcceleratedWidgetAvailable() { | 272 void WindowTreeHost::OnAcceleratedWidgetAvailable() { |
| 273 compositor_->SetAcceleratedWidget(GetAcceleratedWidget()); | 273 compositor_->SetAcceleratedWidget(GetAcceleratedWidget()); |
| 274 prop_.reset(new ui::ViewProp(GetAcceleratedWidget(), | 274 prop_.reset(new ui::ViewProp(GetAcceleratedWidget(), |
| 275 kWindowTreeHostForAcceleratedWidget, this)); | 275 kWindowTreeHostForAcceleratedWidget, this)); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void WindowTreeHost::OnHostMovedInPixels( | 278 void WindowTreeHost::OnHostMovedInPixels( |
| 279 const gfx::Point& new_location_in_pixels) { | 279 const gfx::Point& new_location_in_pixels) { |
| 280 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMovedInPixels", "origin", | 280 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMovedInPixels", "origin", |
| 281 new_location_in_pixels.ToString()); | 281 new_location_in_pixels.ToString()); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 client::CursorClient* cursor_client = client::GetCursorClient(window()); | 342 client::CursorClient* cursor_client = client::GetCursorClient(window()); |
| 343 if (cursor_client) { | 343 if (cursor_client) { |
| 344 const display::Display& display = | 344 const display::Display& display = |
| 345 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); | 345 display::Screen::GetScreen()->GetDisplayNearestWindow(window()); |
| 346 cursor_client->SetDisplay(display); | 346 cursor_client->SetDisplay(display); |
| 347 } | 347 } |
| 348 dispatcher()->OnCursorMovedToRootLocation(root_location); | 348 dispatcher()->OnCursorMovedToRootLocation(root_location); |
| 349 } | 349 } |
| 350 | 350 |
| 351 } // namespace aura | 351 } // namespace aura |
| OLD | NEW |