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

Side by Side Diff: mojo/examples/aura_demo/root_window_host_mojo.cc

Issue 131153007: Send size to NativeViewportClient::OnCreated instead of GLES2Client::DidCreateContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix various issues Created 6 years, 10 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
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 "mojo/examples/aura_demo/root_window_host_mojo.h" 5 #include "mojo/examples/aura_demo/root_window_host_mojo.h"
6 6
7 #include "mojo/examples/aura_demo/demo_context_factory.h" 7 #include "mojo/examples/aura_demo/demo_context_factory.h"
8 #include "mojo/examples/compositor_app/gles2_client_impl.h" 8 #include "mojo/examples/compositor_app/gles2_client_impl.h"
9 #include "mojo/public/gles2/gles2.h" 9 #include "mojo/public/gles2/gles2.h"
10 #include "mojo/services/native_viewport/geometry_conversions.h" 10 #include "mojo/services/native_viewport/geometry_conversions.h"
(...skipping 12 matching lines...) Expand all
23 // static 23 // static
24 ui::ContextFactory* WindowTreeHostMojo::context_factory_ = NULL; 24 ui::ContextFactory* WindowTreeHostMojo::context_factory_ = NULL;
25 25
26 //////////////////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////////////////
27 // WindowTreeHostMojo, public: 27 // WindowTreeHostMojo, public:
28 28
29 WindowTreeHostMojo::WindowTreeHostMojo( 29 WindowTreeHostMojo::WindowTreeHostMojo(
30 ScopedMessagePipeHandle viewport_handle, 30 ScopedMessagePipeHandle viewport_handle,
31 const gfx::Rect& bounds, 31 const gfx::Rect& bounds,
32 const base::Callback<void()>& compositor_created_callback) 32 const base::Callback<void()>& compositor_created_callback)
33 : native_viewport_(viewport_handle.Pass(), this), 33 : context_created_(false),
34 native_viewport_(viewport_handle.Pass(), this),
34 compositor_created_callback_(compositor_created_callback) { 35 compositor_created_callback_(compositor_created_callback) {
35 AllocationScope scope; 36 AllocationScope scope;
36 native_viewport_->Create(bounds); 37 native_viewport_->Create(bounds);
37 38
38 ScopedMessagePipeHandle gles2_handle; 39 ScopedMessagePipeHandle gles2_handle;
39 ScopedMessagePipeHandle gles2_client_handle; 40 ScopedMessagePipeHandle gles2_client_handle;
40 CreateMessagePipe(&gles2_handle, &gles2_client_handle); 41 CreateMessagePipe(&gles2_handle, &gles2_client_handle);
41 42
42 // The ContextFactory must exist before any Compositors are created. 43 // The ContextFactory must exist before any Compositors are created.
43 if (!context_factory_) { 44 if (!context_factory_) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 153
153 //////////////////////////////////////////////////////////////////////////////// 154 ////////////////////////////////////////////////////////////////////////////////
154 // WindowTreeHostMojo, NativeViewportClient implementation: 155 // WindowTreeHostMojo, NativeViewportClient implementation:
155 156
156 void WindowTreeHostMojo::OnCreated() { 157 void WindowTreeHostMojo::OnCreated() {
157 } 158 }
158 159
159 void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) { 160 void WindowTreeHostMojo::OnBoundsChanged(const Rect& bounds) {
160 bounds_ = gfx::Rect(bounds.position().x(), bounds.position().y(), 161 bounds_ = gfx::Rect(bounds.position().x(), bounds.position().y(),
161 bounds.size().width(), bounds.size().height()); 162 bounds.size().width(), bounds.size().height());
162 window()->SetBounds(gfx::Rect(bounds_.size())); 163 if (delegate_)
164 window()->SetBounds(gfx::Rect(bounds_.size()));
165 CreateCompositorIfNeeded();
163 } 166 }
164 167
165 void WindowTreeHostMojo::OnDestroyed() { 168 void WindowTreeHostMojo::OnDestroyed() {
166 base::MessageLoop::current()->Quit(); 169 base::MessageLoop::current()->Quit();
167 } 170 }
168 171
169 void WindowTreeHostMojo::OnEvent(const Event& event) { 172 void WindowTreeHostMojo::OnEvent(const Event& event) {
170 if (!event.location().is_null()) 173 if (!event.location().is_null())
171 native_viewport_->AckEvent(event); 174 native_viewport_->AckEvent(event);
172 175
(...skipping 19 matching lines...) Expand all
192 delegate_->OnHostKeyEvent(&ev); 195 delegate_->OnHostKeyEvent(&ev);
193 break; 196 break;
194 } 197 }
195 // TODO(beng): touch, etc. 198 // TODO(beng): touch, etc.
196 } 199 }
197 }; 200 };
198 201
199 //////////////////////////////////////////////////////////////////////////////// 202 ////////////////////////////////////////////////////////////////////////////////
200 // WindowTreeHostMojo, private: 203 // WindowTreeHostMojo, private:
201 204
202 void WindowTreeHostMojo::DidCreateContext(gfx::Size viewport_size) { 205 void WindowTreeHostMojo::DidCreateContext() {
206 context_created_ = true;
207 CreateCompositorIfNeeded();
208 }
209
210 void WindowTreeHostMojo::CreateCompositorIfNeeded() {
211 if (bounds_.IsEmpty() || !context_created_)
212 return;
203 CreateCompositor(GetAcceleratedWidget()); 213 CreateCompositor(GetAcceleratedWidget());
204 compositor_created_callback_.Run(); 214 compositor_created_callback_.Run();
205 NotifyHostResized(viewport_size); 215 NotifyHostResized(bounds_.size());
206 } 216 }
207 217
208 } // namespace examples 218 } // namespace examples
209 } // namespace mojo 219 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/examples/aura_demo/root_window_host_mojo.h ('k') | mojo/examples/compositor_app/compositor_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698