summaryrefslogtreecommitdiffstats
path: root/mojo/gles2
diff options
context:
space:
mode:
Diffstat (limited to 'mojo/gles2')
-rw-r--r--mojo/gles2/gles2_client_impl.cc21
-rw-r--r--mojo/gles2/gles2_client_impl.h14
-rw-r--r--mojo/gles2/gles2_support_impl.cc15
-rw-r--r--mojo/gles2/gles2_support_impl.h1
4 files changed, 33 insertions, 18 deletions
diff --git a/mojo/gles2/gles2_client_impl.cc b/mojo/gles2/gles2_client_impl.cc
index eec5019..f776d8e 100644
--- a/mojo/gles2/gles2_client_impl.cc
+++ b/mojo/gles2/gles2_client_impl.cc
@@ -4,23 +4,20 @@
#include "mojo/gles2/gles2_client_impl.h"
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
+#include "mojo/public/bindings/sync_dispatcher.h"
#include "mojo/public/gles2/gles2.h"
+#include "mojo/public/system/core_cpp.h"
namespace mojo {
namespace gles2 {
GLES2ClientImpl::GLES2ClientImpl(MojoAsyncWaiter* async_waiter,
ScopedMessagePipeHandle pipe,
- MojoGLES2ContextCreated created_callback,
MojoGLES2ContextLost lost_callback,
MojoGLES2DrawAnimationFrame animation_callback,
void* closure)
: service_(pipe.Pass(), this, NULL, async_waiter),
implementation_(NULL),
- created_callback_(created_callback),
lost_callback_(lost_callback),
animation_callback_(animation_callback),
closure_(closure) {
@@ -30,6 +27,17 @@ GLES2ClientImpl::~GLES2ClientImpl() {
service_->Destroy();
}
+bool GLES2ClientImpl::Initialize() {
+ MessagePipe sync_pipe;
+ sync_dispatcher_.reset(
+ new SyncDispatcher<GLES2SyncClient>(sync_pipe.handle1.Pass(), this));
+ service_->Initialize(sync_pipe.handle0.Pass());
+ // Wait for DidCreateContext to come on the sync client pipe.
+ if (!sync_dispatcher_->WaitAndDispatchOneMessage())
+ return false;
+ return !!implementation_;
+}
+
void GLES2ClientImpl::RequestAnimationFrames() {
service_->RequestAnimationFrames();
}
@@ -46,7 +54,6 @@ void GLES2ClientImpl::DidCreateContext(uint64_t encoded) {
// still in-process, we just reinterpret_cast the value into a GL interface.
implementation_ = reinterpret_cast<gpu::gles2::GLES2Implementation*>(
static_cast<uintptr_t>(encoded));
- created_callback_(closure_);
}
void GLES2ClientImpl::ContextLost() {
@@ -57,5 +64,5 @@ void GLES2ClientImpl::DrawAnimationFrame() {
animation_callback_(closure_);
}
-} // namespace examples
+} // namespace gles2
} // namespace mojo
diff --git a/mojo/gles2/gles2_client_impl.h b/mojo/gles2/gles2_client_impl.h
index 7c5073f7..45a0f0d 100644
--- a/mojo/gles2/gles2_client_impl.h
+++ b/mojo/gles2/gles2_client_impl.h
@@ -5,6 +5,7 @@
#ifndef MOJO_GLES2_GLES2_CLIENT_IMPL_H_
#define MOJO_GLES2_GLES2_CLIENT_IMPL_H_
+#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "mojo/public/bindings/remote_ptr.h"
#include "mojo/public/gles2/gles2.h"
@@ -13,17 +14,23 @@
struct MojoGLES2ContextPrivate {};
namespace mojo {
+
+template<typename S> class SyncDispatcher;
+
namespace gles2 {
-class GLES2ClientImpl : public GLES2Client, public MojoGLES2ContextPrivate {
+class GLES2ClientImpl : public GLES2Client,
+ public GLES2SyncClient,
+ public MojoGLES2ContextPrivate {
public:
explicit GLES2ClientImpl(MojoAsyncWaiter* async_waiter,
ScopedMessagePipeHandle pipe,
- MojoGLES2ContextCreated created_callback,
MojoGLES2ContextLost lost_callback,
MojoGLES2DrawAnimationFrame animation_callback,
void* closure);
virtual ~GLES2ClientImpl();
+ bool Initialize();
+
gpu::gles2::GLES2Interface* interface() const { return implementation_; }
gpu::ContextSupport* context_support() const { return implementation_; }
void RequestAnimationFrames();
@@ -34,10 +41,11 @@ class GLES2ClientImpl : public GLES2Client, public MojoGLES2ContextPrivate {
virtual void ContextLost() MOJO_OVERRIDE;
virtual void DrawAnimationFrame() MOJO_OVERRIDE;
+ bool WaitForSyncMessageAndDispatch();
RemotePtr<GLES2> service_;
+ scoped_ptr<SyncDispatcher<GLES2SyncClient> > sync_dispatcher_;
gpu::gles2::GLES2Implementation* implementation_;
- MojoGLES2ContextCreated created_callback_;
MojoGLES2ContextLost lost_callback_;
MojoGLES2DrawAnimationFrame animation_callback_;
void* closure_;
diff --git a/mojo/gles2/gles2_support_impl.cc b/mojo/gles2/gles2_support_impl.cc
index 14d99ac..9a90a09 100644
--- a/mojo/gles2/gles2_support_impl.cc
+++ b/mojo/gles2/gles2_support_impl.cc
@@ -60,18 +60,19 @@ void GLES2SupportImpl::Terminate() {
MojoGLES2Context GLES2SupportImpl::CreateContext(
MessagePipeHandle handle,
- MojoGLES2ContextCreated created_callback,
MojoGLES2ContextLost lost_callback,
MojoGLES2DrawAnimationFrame animation_callback,
void* closure) {
mojo::ScopedMessagePipeHandle scoped_handle =
mojo::ScopedMessagePipeHandle(mojo::MessagePipeHandle(handle));
- return new GLES2ClientImpl(async_waiter_,
- scoped_handle.Pass(),
- created_callback,
- lost_callback,
- animation_callback,
- closure);
+ scoped_ptr<GLES2ClientImpl> client(new GLES2ClientImpl(async_waiter_,
+ scoped_handle.Pass(),
+ lost_callback,
+ animation_callback,
+ closure));
+ if (!client->Initialize())
+ client.reset();
+ return client.release();
}
void GLES2SupportImpl::DestroyContext(MojoGLES2Context context) {
diff --git a/mojo/gles2/gles2_support_impl.h b/mojo/gles2/gles2_support_impl.h
index 90d1ea3..a57000d 100644
--- a/mojo/gles2/gles2_support_impl.h
+++ b/mojo/gles2/gles2_support_impl.h
@@ -22,7 +22,6 @@ class MOJO_GLES2_IMPL_EXPORT GLES2SupportImpl : public GLES2Support {
virtual void Terminate() OVERRIDE;
virtual MojoGLES2Context CreateContext(
MessagePipeHandle handle,
- MojoGLES2ContextCreated created_callback,
MojoGLES2ContextLost lost_callback,
MojoGLES2DrawAnimationFrame animation_callback,
void* closure) OVERRIDE;