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

Side by Side Diff: mojo/services/view_manager/window_tree_host_impl.cc

Issue 478103002: Revert of Mojo multiple command buffer support and sample (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « mojo/services/view_manager/window_tree_host_impl.h ('k') | mojo/shell/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/root_node_manager.h"
6 #include "mojo/services/view_manager/window_tree_host_impl.h" 6 #include "mojo/services/view_manager/window_tree_host_impl.h"
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/public/cpp/input_events/input_events_type_converters.h" 9 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
10 #include "mojo/services/view_manager/context_factory_impl.h" 10 #include "mojo/services/view_manager/context_factory_impl.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void RootLayoutManager::SetChildBounds(aura::Window* child, 60 void RootLayoutManager::SetChildBounds(aura::Window* child,
61 const gfx::Rect& requested_bounds) { 61 const gfx::Rect& requested_bounds) {
62 SetChildBoundsDirect(child, gfx::Rect(requested_bounds.size())); 62 SetChildBoundsDirect(child, gfx::Rect(requested_bounds.size()));
63 } 63 }
64 64
65 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
66 // WindowTreeHostImpl, public: 66 // WindowTreeHostImpl, public:
67 67
68 WindowTreeHostImpl::WindowTreeHostImpl( 68 WindowTreeHostImpl::WindowTreeHostImpl(
69 NativeViewportPtr viewport, 69 NativeViewportPtr viewport,
70 GpuPtr gpu_service,
71 const gfx::Rect& bounds, 70 const gfx::Rect& bounds,
72 const Callback<void()>& compositor_created_callback, 71 const Callback<void()>& compositor_created_callback,
73 const Callback<void()>& native_viewport_closed_callback, 72 const Callback<void()>& native_viewport_closed_callback,
74 const Callback<void(EventPtr)>& event_received_callback) 73 const Callback<void(EventPtr)>& event_received_callback)
75 : native_viewport_(viewport.Pass()), 74 : native_viewport_(viewport.Pass()),
76 gpu_service_(gpu_service.Pass()),
77 widget_(gfx::kNullAcceleratedWidget),
78 compositor_created_callback_(compositor_created_callback), 75 compositor_created_callback_(compositor_created_callback),
79 native_viewport_closed_callback_(native_viewport_closed_callback), 76 native_viewport_closed_callback_(native_viewport_closed_callback),
80 event_received_callback_(event_received_callback), 77 event_received_callback_(event_received_callback),
81 bounds_(bounds) { 78 bounds_(bounds) {
82 native_viewport_.set_client(this); 79 native_viewport_.set_client(this);
83 native_viewport_->Create(Rect::From(bounds)); 80 native_viewport_->Create(Rect::From(bounds));
84 native_viewport_->Show(); 81
82 MessagePipe pipe;
83 native_viewport_->CreateGLES2Context(
84 MakeRequest<CommandBuffer>(pipe.handle0.Pass()));
85
86 // The ContextFactory must exist before any Compositors are created.
87 if (context_factory_) {
88 delete context_factory_;
89 context_factory_ = NULL;
90 }
91 context_factory_ = new ContextFactoryImpl(pipe.handle1.Pass());
92 aura::Env::GetInstance()->set_context_factory(context_factory_);
85 93
86 window()->SetLayoutManager(new RootLayoutManager()); 94 window()->SetLayoutManager(new RootLayoutManager());
87 } 95 }
88 96
89 WindowTreeHostImpl::~WindowTreeHostImpl() { 97 WindowTreeHostImpl::~WindowTreeHostImpl() {
90 DestroyCompositor(); 98 DestroyCompositor();
91 DestroyDispatcher(); 99 DestroyDispatcher();
92 } 100 }
93 101
94 //////////////////////////////////////////////////////////////////////////////// 102 ////////////////////////////////////////////////////////////////////////////////
95 // WindowTreeHostImpl, aura::WindowTreeHost implementation: 103 // WindowTreeHostImpl, aura::WindowTreeHost implementation:
96 104
97 ui::EventSource* WindowTreeHostImpl::GetEventSource() { 105 ui::EventSource* WindowTreeHostImpl::GetEventSource() {
98 return this; 106 return this;
99 } 107 }
100 108
101 gfx::AcceleratedWidget WindowTreeHostImpl::GetAcceleratedWidget() { 109 gfx::AcceleratedWidget WindowTreeHostImpl::GetAcceleratedWidget() {
102 return widget_; 110 NOTIMPLEMENTED() << "GetAcceleratedWidget";
111 return gfx::kNullAcceleratedWidget;
103 } 112 }
104 113
105 void WindowTreeHostImpl::Show() { 114 void WindowTreeHostImpl::Show() {
106 window()->Show(); 115 window()->Show();
116 native_viewport_->Show();
107 } 117 }
108 118
109 void WindowTreeHostImpl::Hide() { 119 void WindowTreeHostImpl::Hide() {
110 native_viewport_->Hide(); 120 native_viewport_->Hide();
111 window()->Hide(); 121 window()->Hide();
112 } 122 }
113 123
114 gfx::Rect WindowTreeHostImpl::GetBounds() const { 124 gfx::Rect WindowTreeHostImpl::GetBounds() const {
115 return bounds_; 125 return bounds_;
116 } 126 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 //////////////////////////////////////////////////////////////////////////////// 161 ////////////////////////////////////////////////////////////////////////////////
152 // WindowTreeHostImpl, ui::EventSource implementation: 162 // WindowTreeHostImpl, ui::EventSource implementation:
153 163
154 ui::EventProcessor* WindowTreeHostImpl::GetEventProcessor() { 164 ui::EventProcessor* WindowTreeHostImpl::GetEventProcessor() {
155 return dispatcher(); 165 return dispatcher();
156 } 166 }
157 167
158 //////////////////////////////////////////////////////////////////////////////// 168 ////////////////////////////////////////////////////////////////////////////////
159 // WindowTreeHostImpl, NativeViewportClient implementation: 169 // WindowTreeHostImpl, NativeViewportClient implementation:
160 170
161 void WindowTreeHostImpl::OnCreated(uint64_t native_viewport_id) { 171 void WindowTreeHostImpl::OnCreated() {
162 LOG(ERROR) << "OnCreated " << native_viewport_id; 172 CreateCompositor(GetAcceleratedWidget());
163 CommandBufferPtr cb;
164 gpu_service_->CreateOnscreenGLES2Context(
165 native_viewport_id, Size::From(bounds_.size()), Get(&cb));
166 widget_ = reinterpret_cast<gfx::AcceleratedWidget>(native_viewport_id);
167
168 // The ContextFactory must exist before any Compositors are created.
169 if (context_factory_) {
170 delete context_factory_;
171 context_factory_ = NULL;
172 }
173 context_factory_ = new ContextFactoryImpl(cb.PassMessagePipe());
174 aura::Env::GetInstance()->set_context_factory(context_factory_);
175
176 CreateCompositor(gfx::kNullAcceleratedWidget);
177 compositor_created_callback_.Run(); 173 compositor_created_callback_.Run();
178 } 174 }
179 175
180 void WindowTreeHostImpl::OnBoundsChanged(RectPtr bounds) { 176 void WindowTreeHostImpl::OnBoundsChanged(RectPtr bounds) {
181 bounds_ = bounds.To<gfx::Rect>(); 177 bounds_ = bounds.To<gfx::Rect>();
182 if (context_factory_) 178 OnHostResized(bounds_.size());
183 OnHostResized(bounds_.size());
184 } 179 }
185 180
186 void WindowTreeHostImpl::OnDestroyed() { 181 void WindowTreeHostImpl::OnDestroyed(const mojo::Callback<void()>& callback) {
187 DestroyCompositor(); 182 DestroyCompositor();
188 native_viewport_closed_callback_.Run(); 183 native_viewport_closed_callback_.Run();
189 // TODO(beng): quit the message loop once we are on our own thread. 184 // TODO(beng): quit the message loop once we are on our own thread.
185 callback.Run();
190 } 186 }
191 187
192 void WindowTreeHostImpl::OnEvent(EventPtr event, 188 void WindowTreeHostImpl::OnEvent(EventPtr event,
193 const mojo::Callback<void()>& callback) { 189 const mojo::Callback<void()>& callback) {
194 event_received_callback_.Run(event.Pass()); 190 event_received_callback_.Run(event.Pass());
195 callback.Run(); 191 callback.Run();
196 }; 192 };
197 193
198 } // namespace service 194 } // namespace service
199 } // namespace mojo 195 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/window_tree_host_impl.h ('k') | mojo/shell/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698