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

Side by Side Diff: mojo/services/native_viewport/native_viewport_service.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 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/native_viewport/native_viewport_service.h" 5 #include "mojo/services/native_viewport/native_viewport_service.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "mojo/services/gles2/gles2_impl.h" 9 #include "mojo/services/gles2/gles2_impl.h"
10 #include "mojo/services/native_viewport/geometry_conversions.h" 10 #include "mojo/services/native_viewport/geometry_conversions.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 DCHECK_EQ(event.time_stamp(), pending_event_timestamp_); 72 DCHECK_EQ(event.time_stamp(), pending_event_timestamp_);
73 waiting_for_event_ack_ = false; 73 waiting_for_event_ack_ = false;
74 } 74 }
75 75
76 void CreateGLES2ContextIfNeeded() { 76 void CreateGLES2ContextIfNeeded() {
77 if (created_context_) 77 if (created_context_)
78 return; 78 return;
79 if (widget_ == gfx::kNullAcceleratedWidget || !gles2_) 79 if (widget_ == gfx::kNullAcceleratedWidget || !gles2_)
80 return; 80 return;
81 gfx::Size size = native_viewport_->GetSize(); 81 gfx::Size size = native_viewport_->GetSize();
82 if (size.width() == 0 || size.height() == 0) 82 if (size.IsEmpty())
83 return; 83 return;
84 gles2_->CreateContext(widget_, size); 84 gles2_->CreateContext(widget_, size);
85 created_context_ = true; 85 created_context_ = true;
86 } 86 }
87 87
88 virtual bool OnEvent(ui::Event* ui_event) MOJO_OVERRIDE { 88 virtual bool OnEvent(ui::Event* ui_event) MOJO_OVERRIDE {
89 // Must not return early before updating capture. 89 // Must not return early before updating capture.
90 switch (ui_event->type()) { 90 switch (ui_event->type()) {
91 case ui::ET_MOUSE_PRESSED: 91 case ui::ET_MOUSE_PRESSED:
92 case ui::ET_TOUCH_PRESSED: 92 case ui::ET_TOUCH_PRESSED:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 virtual void OnAcceleratedWidgetAvailable( 141 virtual void OnAcceleratedWidgetAvailable(
142 gfx::AcceleratedWidget widget) MOJO_OVERRIDE { 142 gfx::AcceleratedWidget widget) MOJO_OVERRIDE {
143 widget_ = widget; 143 widget_ = widget;
144 CreateGLES2ContextIfNeeded(); 144 CreateGLES2ContextIfNeeded();
145 } 145 }
146 146
147 virtual void OnBoundsChanged(const gfx::Rect& bounds) MOJO_OVERRIDE { 147 virtual void OnBoundsChanged(const gfx::Rect& bounds) MOJO_OVERRIDE {
148 CreateGLES2ContextIfNeeded(); 148 CreateGLES2ContextIfNeeded();
149 AllocationScope allocation;
149 client_->OnBoundsChanged(bounds); 150 client_->OnBoundsChanged(bounds);
150 } 151 }
151 152
152 virtual void OnDestroyed() MOJO_OVERRIDE { 153 virtual void OnDestroyed() MOJO_OVERRIDE {
153 // TODO(beng): 154 // TODO(beng):
154 // Destroying |gles2_| on the shell thread here hits thread checker 155 // Destroying |gles2_| on the shell thread here hits thread checker
155 // asserts. All code must stop touching the AcceleratedWidget at this 156 // asserts. All code must stop touching the AcceleratedWidget at this
156 // point as it is dead after this call stack. jamesr said we probably 157 // point as it is dead after this call stack. jamesr said we probably
157 // should make our own GLSurface and simply tell it to stop touching the 158 // should make our own GLSurface and simply tell it to stop touching the
158 // AcceleratedWidget via Destroy() but we have no good way of doing that 159 // AcceleratedWidget via Destroy() but we have no good way of doing that
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 extern "C" MOJO_NATIVE_VIEWPORT_EXPORT MojoResult MojoMain( 207 extern "C" MOJO_NATIVE_VIEWPORT_EXPORT MojoResult MojoMain(
207 const MojoHandle shell_handle) { 208 const MojoHandle shell_handle) {
208 base::MessageLoopForUI loop; 209 base::MessageLoopForUI loop;
209 mojo::services::NativeViewportService app( 210 mojo::services::NativeViewportService app(
210 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass()); 211 mojo::MakeScopedHandle(mojo::MessagePipeHandle(shell_handle)).Pass());
211 base::MessageLoop::current()->Run(); 212 base::MessageLoop::current()->Run();
212 return MOJO_RESULT_OK; 213 return MOJO_RESULT_OK;
213 } 214 }
214 215
215 #endif // !OS_ANDROID 216 #endif // !OS_ANDROID
OLDNEW
« no previous file with comments | « mojo/services/native_viewport/native_viewport_mac.mm ('k') | mojo/services/native_viewport/native_viewport_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698