Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / mojo / examples / sample_app / gles2_client_impl.cc
index b3f2003..8abff8b 100644 (file)
@@ -25,16 +25,24 @@ GLES2ClientImpl::GLES2ClientImpl(ScopedMessagePipeHandle pipe)
     : getting_animation_frames_(false) {
   context_ = MojoGLES2CreateContext(
       pipe.release().value(),
-      &DidCreateContextThunk,
       &ContextLostThunk,
       &DrawAnimationFrameThunk,
       this);
+  MojoGLES2MakeCurrent(context_);
 }
 
 GLES2ClientImpl::~GLES2ClientImpl() {
   MojoGLES2DestroyContext(context_);
 }
 
+void GLES2ClientImpl::SetSize(const Size& size) {
+  size_ = gfx::Size(size.width(), size.height());
+  if (size_.IsEmpty())
+    return;
+  cube_.Init(size_.width(), size_.height());
+  RequestAnimationFrames();
+}
+
 void GLES2ClientImpl::HandleInputEvent(const Event& event) {
   switch (event.action()) {
   case ui::ET_MOUSE_PRESSED:
@@ -75,21 +83,6 @@ void GLES2ClientImpl::HandleInputEvent(const Event& event) {
   }
 }
 
-void GLES2ClientImpl::DidCreateContext(uint32_t width,
-                                       uint32_t height) {
-  MojoGLES2MakeCurrent(context_);
-
-  cube_.Init(width, height);
-  RequestAnimationFrames();
-}
-
-void GLES2ClientImpl::DidCreateContextThunk(
-    void* closure,
-    uint32_t width,
-    uint32_t height) {
-  static_cast<GLES2ClientImpl*>(closure)->DidCreateContext(width, height);
-}
-
 void GLES2ClientImpl::ContextLost() {
   CancelAnimationFrames();
 }