summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authorabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 23:13:56 +0000
committerabarth@chromium.org <abarth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-02 23:13:56 +0000
commit5ad68f63427c91e30e78d76085842ffa703a6e30 (patch)
treeaa10c5e2600a56235bbe996a2a4a5a65678a4d84 /mojo
parent357edd26b23b7109932e3403b98d03d6785c6b5f (diff)
downloadchromium_src-5ad68f63427c91e30e78d76085842ffa703a6e30.zip
chromium_src-5ad68f63427c91e30e78d76085842ffa703a6e30.tar.gz
chromium_src-5ad68f63427c91e30e78d76085842ffa703a6e30.tar.bz2
[Mojo] Fix race condition in sample_app's SwapBuffers
The in-process command buffer expects all of its callers to be on a single thread. Prior to this CL, we were bouncing back to the shell thread to call swap buffers. Now we call SwapBuffers from sample_app's thread. R=davemoore@chromium.org Review URL: https://codereview.chromium.org/99323005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo')
-rw-r--r--mojo/examples/sample_app/native_viewport_client_impl.cc1
-rw-r--r--mojo/examples/sample_app/sample_gles2_delegate.cc6
-rw-r--r--mojo/examples/sample_app/sample_gles2_delegate.h6
-rw-r--r--mojo/public/bindings/gles2_client/gles2_client_impl.cc13
-rw-r--r--mojo/public/bindings/gles2_client/gles2_client_impl.h10
-rw-r--r--mojo/services/gles2/gles2.mojom2
-rw-r--r--mojo/services/gles2/gles2_impl.cc6
-rw-r--r--mojo/services/gles2/gles2_impl.h2
8 files changed, 25 insertions, 21 deletions
diff --git a/mojo/examples/sample_app/native_viewport_client_impl.cc b/mojo/examples/sample_app/native_viewport_client_impl.cc
index 7701a18..6f10990 100644
--- a/mojo/examples/sample_app/native_viewport_client_impl.cc
+++ b/mojo/examples/sample_app/native_viewport_client_impl.cc
@@ -17,6 +17,7 @@ NativeViewportClientImpl::NativeViewportClientImpl(ScopedMessagePipeHandle pipe)
}
NativeViewportClientImpl::~NativeViewportClientImpl() {
+ service_->Close();
}
void NativeViewportClientImpl::Open() {
diff --git a/mojo/examples/sample_app/sample_gles2_delegate.cc b/mojo/examples/sample_app/sample_gles2_delegate.cc
index 8245ce6..4bac022 100644
--- a/mojo/examples/sample_app/sample_gles2_delegate.cc
+++ b/mojo/examples/sample_app/sample_gles2_delegate.cc
@@ -19,7 +19,7 @@ SampleGLES2Delegate::~SampleGLES2Delegate() {
}
void SampleGLES2Delegate::DidCreateContext(
- GLES2* gl, uint32_t width, uint32_t height) {
+ GLES2ClientImpl* gl, uint32_t width, uint32_t height) {
gl_ = gl;
cube_.Init(width, height);
last_time_ = base::Time::Now();
@@ -36,9 +36,9 @@ void SampleGLES2Delegate::Draw() {
gl_->SwapBuffers();
}
-void SampleGLES2Delegate::ContextLost(GLES2* gl) {
- timer_.Stop();
+void SampleGLES2Delegate::ContextLost(GLES2ClientImpl* gl) {
gl_ = NULL;
+ timer_.Stop();
}
} // namespace examples
diff --git a/mojo/examples/sample_app/sample_gles2_delegate.h b/mojo/examples/sample_app/sample_gles2_delegate.h
index 226b8ac..efd4872 100644
--- a/mojo/examples/sample_app/sample_gles2_delegate.h
+++ b/mojo/examples/sample_app/sample_gles2_delegate.h
@@ -19,15 +19,15 @@ class SampleGLES2Delegate : public GLES2Delegate {
private:
virtual void DidCreateContext(
- GLES2* gl, uint32_t width, uint32_t height) MOJO_OVERRIDE;
- virtual void ContextLost(GLES2* gl) MOJO_OVERRIDE;
+ GLES2ClientImpl* gl, uint32_t width, uint32_t height) MOJO_OVERRIDE;
+ virtual void ContextLost(GLES2ClientImpl* gl) MOJO_OVERRIDE;
void Draw();
base::Time last_time_;
base::RepeatingTimer<SampleGLES2Delegate> timer_;
- GLES2* gl_;
SpinningCube cube_;
+ GLES2ClientImpl* gl_;
};
} // namespace examples
diff --git a/mojo/public/bindings/gles2_client/gles2_client_impl.cc b/mojo/public/bindings/gles2_client/gles2_client_impl.cc
index 1985fea..2fea93c 100644
--- a/mojo/public/bindings/gles2_client/gles2_client_impl.cc
+++ b/mojo/public/bindings/gles2_client/gles2_client_impl.cc
@@ -19,10 +19,10 @@ GLES2Delegate::~GLES2Delegate() {
}
void GLES2Delegate::DidCreateContext(
- GLES2* gl, uint32_t width, uint32_t height) {
+ GLES2ClientImpl* gl, uint32_t width, uint32_t height) {
}
-void GLES2Delegate::ContextLost(GLES2* gl) {
+void GLES2Delegate::ContextLost(GLES2ClientImpl* gl) {
}
GLES2ClientImpl::GLES2ClientImpl(GLES2Delegate* delegate,
@@ -34,6 +34,7 @@ GLES2ClientImpl::GLES2ClientImpl(GLES2Delegate* delegate,
}
GLES2ClientImpl::~GLES2ClientImpl() {
+ gl_->Destroy();
}
void GLES2ClientImpl::Initialize() {
@@ -48,6 +49,10 @@ void GLES2ClientImpl::Terminate() {
g_gles2_initialized = false;
}
+void GLES2ClientImpl::SwapBuffers() {
+ gles2::GetGLContext()->SwapBuffers();
+}
+
void GLES2ClientImpl::DidCreateContext(
uint64_t encoded, uint32_t width, uint32_t height) {
// Ack, Hans! It's the giant hack.
@@ -60,11 +65,11 @@ void GLES2ClientImpl::DidCreateContext(
static_cast<uintptr_t>(encoded));
gles2::SetGLContext(gl_interface);
- delegate_->DidCreateContext(gl(), width, height);
+ delegate_->DidCreateContext(this, width, height);
}
void GLES2ClientImpl::ContextLost() {
- delegate_->ContextLost(gl());
+ delegate_->ContextLost(this);
}
} // mojo
diff --git a/mojo/public/bindings/gles2_client/gles2_client_impl.h b/mojo/public/bindings/gles2_client/gles2_client_impl.h
index 63106ac..9213905 100644
--- a/mojo/public/bindings/gles2_client/gles2_client_impl.h
+++ b/mojo/public/bindings/gles2_client/gles2_client_impl.h
@@ -9,12 +9,14 @@
#include "mojom/gles2.h"
namespace mojo {
+class GLES2ClientImpl;
class GLES2Delegate {
public:
virtual ~GLES2Delegate();
- virtual void DidCreateContext(GLES2* gl, uint32_t width, uint32_t height);
- virtual void ContextLost(GLES2* gl);
+ virtual void DidCreateContext(
+ GLES2ClientImpl* gl, uint32_t width, uint32_t height);
+ virtual void ContextLost(GLES2ClientImpl* gl);
};
class GLES2ClientImpl : public GLES2ClientStub {
@@ -26,9 +28,7 @@ class GLES2ClientImpl : public GLES2ClientStub {
static void Initialize();
static void Terminate();
- GLES2* gl() {
- return gl_.get();
- }
+ void SwapBuffers();
private:
virtual void DidCreateContext(
diff --git a/mojo/services/gles2/gles2.mojom b/mojo/services/gles2/gles2.mojom
index 04fe14b..cb6c1b7 100644
--- a/mojo/services/gles2/gles2.mojom
+++ b/mojo/services/gles2/gles2.mojom
@@ -6,7 +6,7 @@ module mojo {
[Peer=GLES2Client]
interface GLES2 {
- void SwapBuffers();
+ void Destroy();
};
[Peer=GLES2]
diff --git a/mojo/services/gles2/gles2_impl.cc b/mojo/services/gles2/gles2_impl.cc
index ffa5962..f0451f5 100644
--- a/mojo/services/gles2/gles2_impl.cc
+++ b/mojo/services/gles2/gles2_impl.cc
@@ -19,10 +19,8 @@ GLES2Impl::GLES2Impl(ScopedMessagePipeHandle client)
GLES2Impl::~GLES2Impl() {
}
-void GLES2Impl::SwapBuffers() {
- if (!gl_context_)
- return;
- gl_context_->GetImplementation()->SwapBuffers();
+void GLES2Impl::Destroy() {
+ gl_context_.reset();
}
void GLES2Impl::CreateContext(gfx::AcceleratedWidget widget,
diff --git a/mojo/services/gles2/gles2_impl.h b/mojo/services/gles2/gles2_impl.h
index a98a48b..50ca456 100644
--- a/mojo/services/gles2/gles2_impl.h
+++ b/mojo/services/gles2/gles2_impl.h
@@ -24,7 +24,7 @@ class GLES2Impl : public GLES2Stub {
explicit GLES2Impl(ScopedMessagePipeHandle client);
virtual ~GLES2Impl();
- virtual void SwapBuffers() OVERRIDE;
+ virtual void Destroy() OVERRIDE;
void CreateContext(gfx::AcceleratedWidget widget, const gfx::Size& size);