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 "mojo/services/view_manager/root_node_manager.h" | |
5 #include "mojo/services/view_manager/window_tree_host_impl.h" | 6 #include "mojo/services/view_manager/window_tree_host_impl.h" |
6 | |
7 #include "mojo/public/c/gles2/gles2.h" | 7 #include "mojo/public/c/gles2/gles2.h" |
8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" |
9 #include "mojo/services/view_manager/context_factory_impl.h" | 9 #include "mojo/services/view_manager/context_factory_impl.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
12 #include "ui/aura/window_event_dispatcher.h" | 12 #include "ui/aura/window_event_dispatcher.h" |
13 #include "ui/compositor/compositor.h" | 13 #include "ui/compositor/compositor.h" |
14 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
15 #include "ui/events/event_constants.h" | 15 #include "ui/events/event_constants.h" |
16 #include "ui/gfx/geometry/insets.h" | 16 #include "ui/gfx/geometry/insets.h" |
17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
18 | 18 |
19 namespace mojo { | 19 namespace mojo { |
20 namespace view_manager { | 20 namespace view_manager { |
21 namespace service { | 21 namespace service { |
22 | 22 |
23 // TODO(sky): nuke this. It shouldn't be static. | 23 // TODO(sky): nuke this. It shouldn't be static. |
24 // static | 24 // static |
25 ContextFactoryImpl* WindowTreeHostImpl::context_factory_ = NULL; | 25 ContextFactoryImpl* WindowTreeHostImpl::context_factory_ = NULL; |
26 | 26 |
27 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
28 // WindowTreeHostImpl, public: | 28 // WindowTreeHostImpl, public: |
29 | 29 |
30 WindowTreeHostImpl::WindowTreeHostImpl( | 30 WindowTreeHostImpl::WindowTreeHostImpl( |
31 NativeViewportPtr viewport, | 31 NativeViewportPtr viewport, |
32 const gfx::Rect& bounds, | 32 const gfx::Rect& bounds, |
33 RootNodeManager* root_node_manager, | |
33 const base::Callback<void()>& compositor_created_callback) | 34 const base::Callback<void()>& compositor_created_callback) |
34 : native_viewport_(viewport.Pass()), | 35 : native_viewport_(viewport.Pass()), |
35 compositor_created_callback_(compositor_created_callback), | 36 compositor_created_callback_(compositor_created_callback), |
36 bounds_(bounds) { | 37 bounds_(bounds), |
38 root_node_manager_(root_node_manager) { | |
37 native_viewport_.set_client(this); | 39 native_viewport_.set_client(this); |
38 native_viewport_->Create(Rect::From(bounds)); | 40 native_viewport_->Create(Rect::From(bounds)); |
39 | 41 |
40 MessagePipe pipe; | 42 MessagePipe pipe; |
41 native_viewport_->CreateGLES2Context( | 43 native_viewport_->CreateGLES2Context( |
42 MakeRequest<CommandBuffer>(pipe.handle0.Pass())); | 44 MakeRequest<CommandBuffer>(pipe.handle0.Pass())); |
43 | 45 |
44 // The ContextFactory must exist before any Compositors are created. | 46 // The ContextFactory must exist before any Compositors are created. |
45 if (context_factory_) { | 47 if (context_factory_) { |
46 delete context_factory_; | 48 delete context_factory_; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 // WindowTreeHostImpl, NativeViewportClient implementation: | 132 // WindowTreeHostImpl, NativeViewportClient implementation: |
131 | 133 |
132 void WindowTreeHostImpl::OnCreated() { | 134 void WindowTreeHostImpl::OnCreated() { |
133 CreateCompositor(GetAcceleratedWidget()); | 135 CreateCompositor(GetAcceleratedWidget()); |
134 compositor_created_callback_.Run(); | 136 compositor_created_callback_.Run(); |
135 } | 137 } |
136 | 138 |
137 void WindowTreeHostImpl::OnBoundsChanged(RectPtr bounds) { | 139 void WindowTreeHostImpl::OnBoundsChanged(RectPtr bounds) { |
138 bounds_ = bounds.To<gfx::Rect>(); | 140 bounds_ = bounds.To<gfx::Rect>(); |
139 OnHostResized(bounds_.size()); | 141 OnHostResized(bounds_.size()); |
142 | |
143 Node* root_node = root_node_manager_->root(); | |
Ben Goodger (Google)
2014/07/08 15:41:57
Instead of doing this (and adding the root_node_ma
| |
144 if (bounds_ == root_node->bounds()) | |
145 return; | |
146 root_node->window()->SetBounds(bounds_); | |
140 } | 147 } |
141 | 148 |
142 void WindowTreeHostImpl::OnDestroyed() { | 149 void WindowTreeHostImpl::OnDestroyed() { |
143 base::MessageLoop::current()->Quit(); | 150 base::MessageLoop::current()->Quit(); |
144 } | 151 } |
145 | 152 |
146 void WindowTreeHostImpl::OnEvent(EventPtr event, | 153 void WindowTreeHostImpl::OnEvent(EventPtr event, |
147 const mojo::Callback<void()>& callback) { | 154 const mojo::Callback<void()>& callback) { |
148 switch (event->action) { | 155 switch (event->action) { |
149 case ui::ET_MOUSE_PRESSED: | 156 case ui::ET_MOUSE_PRESSED: |
(...skipping 26 matching lines...) Expand all Loading... | |
176 break; | 183 break; |
177 } | 184 } |
178 // TODO(beng): touch, etc. | 185 // TODO(beng): touch, etc. |
179 } | 186 } |
180 callback.Run(); | 187 callback.Run(); |
181 }; | 188 }; |
182 | 189 |
183 } // namespace service | 190 } // namespace service |
184 } // namespace view_manager | 191 } // namespace view_manager |
185 } // namespace mojo | 192 } // namespace mojo |
OLD | NEW |