summaryrefslogtreecommitdiffstats
path: root/ppapi/shared_impl/ppb_graphics_3d_shared.h
diff options
context:
space:
mode:
authornfullagar@chromium.org <nfullagar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-15 20:58:17 +0000
committernfullagar@chromium.org <nfullagar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-15 20:58:17 +0000
commit84b44c55d62a90567183ee7145242ad9cce5b96f (patch)
tree9496026d3271c79260e7c2e3d41e471ec080ec41 /ppapi/shared_impl/ppb_graphics_3d_shared.h
parent65448806d1e7873a7fb3fedfdaf1301275fd9554 (diff)
downloadchromium_src-84b44c55d62a90567183ee7145242ad9cce5b96f.zip
chromium_src-84b44c55d62a90567183ee7145242ad9cce5b96f.tar.gz
chromium_src-84b44c55d62a90567183ee7145242ad9cce5b96f.tar.bz2
Put locks around PPB_Graphics3d.
This CL was inherited from dmichael's CL: PPAPI: Lock around GLES2 entry in to the proxy This might not cover all the ways 3D could go wrong in a multithreaded situation (I don't understand it well enough to know). It also probably locks a bit more than is necessary. But so far it works, and makes Var reference counting (and pretty much everything else) usable on background threads. Probably good enough for M23 experimentation. http://codereview.chromium.org/10960046/ BUG=116317, 92909 TEST=build with enable_pepper_threading=1. PPAPI 3D example works. Zombie Track Meat, Tumbler, and other 3d stuff works in the NaCl IPC proxy. Review URL: https://chromiumcodereview.appspot.com/11054024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/shared_impl/ppb_graphics_3d_shared.h')
-rw-r--r--ppapi/shared_impl/ppb_graphics_3d_shared.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/ppapi/shared_impl/ppb_graphics_3d_shared.h b/ppapi/shared_impl/ppb_graphics_3d_shared.h
index 0860945..b6185f8 100644
--- a/ppapi/shared_impl/ppb_graphics_3d_shared.h
+++ b/ppapi/shared_impl/ppb_graphics_3d_shared.h
@@ -56,6 +56,28 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared
void SwapBuffersACK(int32_t pp_error);
protected:
+ // ScopedNoLocking makes sure we don't try to lock again when we already have
+ // the proxy lock. This is used when we need to use the CommandBuffer
+ // (possibly via gles2_impl) but we already have the proxy lock. The
+ // CommandBuffer in the plugin side of the proxy will otherwise try to acquire
+ // the ProxyLock, causing a crash because we already own the lock. (Locks in
+ // Chromium are never recursive).
+ class ScopedNoLocking {
+ public:
+ explicit ScopedNoLocking(PPB_Graphics3D_Shared* graphics3d_shared)
+ : graphics3d_shared_(graphics3d_shared) {
+ graphics3d_shared_->PushAlreadyLocked();
+ }
+ ~ScopedNoLocking() {
+ graphics3d_shared_->PopAlreadyLocked();
+ }
+ private:
+ PPB_Graphics3D_Shared* graphics3d_shared_; // Weak
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedNoLocking);
+ };
+
+
PPB_Graphics3D_Shared(PP_Instance instance);
PPB_Graphics3D_Shared(const HostResource& host_resource);
virtual ~PPB_Graphics3D_Shared();
@@ -70,6 +92,13 @@ class PPAPI_SHARED_EXPORT PPB_Graphics3D_Shared
void DestroyGLES2Impl();
private:
+ // On the plugin side, we need to know that we already have the lock, so that
+ // we don't try to acquire it again. The default implementation does nothing;
+ // the Plugin side of the proxy must implement these.
+ friend class ScopedNoLocking;
+ virtual void PushAlreadyLocked();
+ virtual void PopAlreadyLocked();
+
scoped_ptr<gpu::gles2::GLES2CmdHelper> gles2_helper_;
scoped_ptr<gpu::TransferBuffer> transfer_buffer_;
scoped_ptr<gpu::gles2::GLES2Implementation> gles2_impl_;