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

Unified Diff: mojo/examples/sample_app/gles2_client_impl.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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/examples/sample_app/gles2_client_impl.h ('k') | mojo/examples/sample_app/sample_app.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/examples/sample_app/gles2_client_impl.cc
diff --git a/mojo/examples/sample_app/gles2_client_impl.cc b/mojo/examples/sample_app/gles2_client_impl.cc
index b3f2003aac81498c26044a27cf04d86541b4173a..eb7f47b3cd8ba12fac697a846b1fb05e93316800 100644
--- a/mojo/examples/sample_app/gles2_client_impl.cc
+++ b/mojo/examples/sample_app/gles2_client_impl.cc
@@ -22,7 +22,8 @@ float CalculateDragDistance(const gfx::PointF& start, const Point& end) {
}
GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe)
- : getting_animation_frames_(false) {
+ : getting_animation_frames_(false),
+ context_created_(false) {
context_ = MojoGLES2CreateContext(
pipe.release().value(),
&DidCreateContextThunk,
@@ -35,6 +36,11 @@ GLES2ClientImpl::~GLES2ClientImpl() {
MojoGLES2DestroyContext(context_);
}
+void GLES2ClientImpl::SetSize(const Size& size) {
+ size_ = gfx::Size(size.width(), size.height());
+ InitializeCubeIfNeeded();
+}
+
void GLES2ClientImpl::HandleInputEvent(const Event& event) {
switch (event.action()) {
case ui::ET_MOUSE_PRESSED:
@@ -75,19 +81,21 @@ void GLES2ClientImpl::HandleInputEvent(const Event& event) {
}
}
-void GLES2ClientImpl::DidCreateContext(uint32_t width,
- uint32_t height) {
+void GLES2ClientImpl::DidCreateContext() {
MojoGLES2MakeCurrent(context_);
+ context_created_ = true;
+ InitializeCubeIfNeeded();
+}
- cube_.Init(width, height);
+void GLES2ClientImpl::InitializeCubeIfNeeded() {
+ if (size_.IsEmpty() || !context_created_)
+ return;
+ cube_.Init(size_.width(), size_.height());
RequestAnimationFrames();
}
-void GLES2ClientImpl::DidCreateContextThunk(
- void* closure,
- uint32_t width,
- uint32_t height) {
- static_cast<GLES2ClientImpl*>(closure)->DidCreateContext(width, height);
+void GLES2ClientImpl::DidCreateContextThunk(void* closure) {
+ static_cast<GLES2ClientImpl*>(closure)->DidCreateContext();
}
void GLES2ClientImpl::ContextLost() {
« no previous file with comments | « mojo/examples/sample_app/gles2_client_impl.h ('k') | mojo/examples/sample_app/sample_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698