Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: ui/aura/window_tree_host.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/thread_task_runner_handle.h" 7 #include "base/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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // WindowTreeHost, public: 42 // WindowTreeHost, public:
43 43
44 WindowTreeHost::~WindowTreeHost() { 44 WindowTreeHost::~WindowTreeHost() {
45 DCHECK(!compositor_) << "compositor must be destroyed before root window"; 45 DCHECK(!compositor_) << "compositor must be destroyed before root window";
46 if (owned_input_method_) { 46 if (owned_input_method_) {
47 delete input_method_; 47 delete input_method_;
48 input_method_ = nullptr; 48 input_method_ = nullptr;
49 } 49 }
50 } 50 }
51 51
52 #if defined(OS_ANDROID)
53 // static
54 WindowTreeHost* WindowTreeHost::Create(const gfx::Rect& bounds) {
55 // This is only hit for tests and ash, right now these aren't an issue so
56 // adding the CHECK.
57 // TODO(sky): decide if we want a factory.
58 CHECK(false);
59 return nullptr;
60 }
61 #endif
62
63 // static 52 // static
64 WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget( 53 WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
65 gfx::AcceleratedWidget widget) { 54 gfx::AcceleratedWidget widget) {
66 return reinterpret_cast<WindowTreeHost*>( 55 return reinterpret_cast<WindowTreeHost*>(
67 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget)); 56 ui::ViewProp::GetValue(widget, kWindowTreeHostForAcceleratedWidget));
68 } 57 }
69 58
70 void WindowTreeHost::InitHost() { 59 void WindowTreeHost::InitHost() {
71 InitCompositor(); 60 InitCompositor();
72 UpdateRootWindowSize(GetBounds().size()); 61 UpdateRootWindowSize(GetBounds().size());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // TODO(beng): this comment is no longer quite valid since this function 221 // TODO(beng): this comment is no longer quite valid since this function
233 // isn't called from WED, and WED isn't a subclass of Window. So it seems 222 // isn't called from WED, and WED isn't a subclass of Window. So it seems
234 // like we could just rely on ~Window now. 223 // like we could just rely on ~Window now.
235 // Destroy child windows while we're still valid. This is also done by 224 // Destroy child windows while we're still valid. This is also done by
236 // ~Window, but by that time any calls to virtual methods overriden here (such 225 // ~Window, but by that time any calls to virtual methods overriden here (such
237 // as GetRootWindow()) result in Window's implementation. By destroying here 226 // as GetRootWindow()) result in Window's implementation. By destroying here
238 // we ensure GetRootWindow() still returns this. 227 // we ensure GetRootWindow() still returns this.
239 //window()->RemoveOrDestroyChildren(); 228 //window()->RemoveOrDestroyChildren();
240 } 229 }
241 230
242 void WindowTreeHost::CreateCompositor( 231 void WindowTreeHost::CreateCompositor() {
243 gfx::AcceleratedWidget accelerated_widget) {
244 DCHECK(Env::GetInstance()); 232 DCHECK(Env::GetInstance());
245 ui::ContextFactory* context_factory = Env::GetInstance()->context_factory(); 233 ui::ContextFactory* context_factory = Env::GetInstance()->context_factory();
246 DCHECK(context_factory); 234 DCHECK(context_factory);
247 compositor_.reset( 235 compositor_.reset(
248 new ui::Compositor(GetAcceleratedWidget(), 236 new ui::Compositor(context_factory, base::ThreadTaskRunnerHandle::Get()));
249 context_factory,
250 base::ThreadTaskRunnerHandle::Get()));
251 // TODO(beng): I think this setup should probably all move to a "accelerated
252 // widget available" function.
253 if (!dispatcher()) { 237 if (!dispatcher()) {
254 window()->Init(ui::LAYER_NOT_DRAWN); 238 window()->Init(ui::LAYER_NOT_DRAWN);
255 window()->set_host(this); 239 window()->set_host(this);
256 window()->SetName("RootWindow"); 240 window()->SetName("RootWindow");
257 window()->SetEventTargeter( 241 window()->SetEventTargeter(
258 scoped_ptr<ui::EventTargeter>(new WindowTargeter())); 242 scoped_ptr<ui::EventTargeter>(new WindowTargeter()));
259 prop_.reset(new ui::ViewProp(GetAcceleratedWidget(),
260 kWindowTreeHostForAcceleratedWidget,
261 this));
262 dispatcher_.reset(new WindowEventDispatcher(this)); 243 dispatcher_.reset(new WindowEventDispatcher(this));
263 } 244 }
264 } 245 }
265 246
247 void WindowTreeHost::OnAcceleratedWidgetAvailable() {
248 compositor_->OnAcceleratedWidgetAvailable(GetAcceleratedWidget());
249 prop_.reset(new ui::ViewProp(GetAcceleratedWidget(),
250 kWindowTreeHostForAcceleratedWidget,
251 this));
252 }
253
266 void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) { 254 void WindowTreeHost::OnHostMoved(const gfx::Point& new_location) {
267 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMoved", 255 TRACE_EVENT1("ui", "WindowTreeHost::OnHostMoved",
268 "origin", new_location.ToString()); 256 "origin", new_location.ToString());
269 257
270 FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_, 258 FOR_EACH_OBSERVER(WindowTreeHostObserver, observers_,
271 OnHostMoved(this, new_location)); 259 OnHostMoved(this, new_location));
272 } 260 }
273 261
274 void WindowTreeHost::OnHostResized(const gfx::Size& new_size) { 262 void WindowTreeHost::OnHostResized(const gfx::Size& new_size) {
275 // The compositor should have the same size as the native root window host. 263 // The compositor should have the same size as the native root window host.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 client::CursorClient* cursor_client = client::GetCursorClient(window()); 301 client::CursorClient* cursor_client = client::GetCursorClient(window());
314 if (cursor_client) { 302 if (cursor_client) {
315 const gfx::Display& display = 303 const gfx::Display& display =
316 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window()); 304 gfx::Screen::GetScreenFor(window())->GetDisplayNearestWindow(window());
317 cursor_client->SetDisplay(display); 305 cursor_client->SetDisplay(display);
318 } 306 }
319 dispatcher()->OnCursorMovedToRootLocation(root_location); 307 dispatcher()->OnCursorMovedToRootLocation(root_location);
320 } 308 }
321 309
322 } // namespace aura 310 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698