Index: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h |
diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h |
index a50c9d50d8317ff5914f8534c66a73e9f5002b4d..faaf944bfda5726684aead0c7b2854876d09ac8e 100644 |
--- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h |
+++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h |
@@ -11,6 +11,7 @@ |
#include "base/callback.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/synchronization/lock.h" |
#include "content/common/content_export.h" |
#include "content/common/gpu/client/command_buffer_proxy_impl.h" |
#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
@@ -79,7 +80,8 @@ class WebGraphicsContext3DCommandBufferImpl |
GpuChannelHost* host, |
const Attributes& attributes, |
bool bind_generates_resources, |
- const SharedMemoryLimits& limits); |
+ const SharedMemoryLimits& limits, |
+ WebGraphicsContext3DCommandBufferImpl* share_context); |
virtual ~WebGraphicsContext3DCommandBufferImpl(); |
@@ -108,7 +110,8 @@ class WebGraphicsContext3DCommandBufferImpl |
GpuChannelHost* host, |
const WebGraphicsContext3D::Attributes& attributes, |
const GURL& active_url, |
- const SharedMemoryLimits& limits); |
+ const SharedMemoryLimits& limits, |
+ WebGraphicsContext3D* share_context); |
size_t GetMappedMemoryLimit() { |
return mem_limits_.mapped_memory_reclaim_limit; |
@@ -658,13 +661,58 @@ class WebGraphicsContext3DCommandBufferImpl |
}; |
friend class WebGraphicsContext3DErrorMessageCallback; |
+ class ShareGroup : public base::RefCountedThreadSafe<ShareGroup> { |
+ public: |
+ ShareGroup(); |
+ |
+ WebGraphicsContext3DCommandBufferImpl* GetAnyContext() { |
piman
2013/12/12 23:56:39
nit: maybe append "Locked" to these functions to m
|
+ // In order to ensure that the context returned is not removed while |
+ // in use the share group's lock should be aquired before calling this |
+ // function. |
+ lock_.AssertAcquired(); |
+ if (contexts_.empty()) |
+ return NULL; |
+ return contexts_.front(); |
+ } |
+ |
+ void AddContext(WebGraphicsContext3DCommandBufferImpl* context) { |
+ lock_.AssertAcquired(); |
+ contexts_.push_back(context); |
+ } |
+ |
+ void RemoveContext(WebGraphicsContext3DCommandBufferImpl* context) { |
+ base::AutoLock auto_lock(lock_); |
+ contexts_.erase(std::remove(contexts_.begin(), contexts_.end(), context), |
+ contexts_.end()); |
+ } |
+ |
+ void RemoveAllContexts() { |
+ base::AutoLock auto_lock(lock_); |
+ contexts_.clear(); |
+ } |
+ |
+ base::Lock& lock() { |
+ return lock_; |
+ } |
+ |
+ private: |
+ friend class base::RefCountedThreadSafe<ShareGroup>; |
+ ~ShareGroup(); |
+ |
+ std::vector<WebGraphicsContext3DCommandBufferImpl*> contexts_; |
+ base::Lock lock_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ShareGroup); |
+ }; |
+ |
// Initialize the underlying GL context. May be called multiple times; second |
// and subsequent calls are ignored. Must be called from the thread that is |
// going to use this object to issue GL commands (which might not be the main |
// thread). |
bool MaybeInitializeGL(); |
- bool InitializeCommandBuffer(bool onscreen); |
+ bool InitializeCommandBuffer(bool onscreen, |
+ WebGraphicsContext3DCommandBufferImpl* share_context); |
void Destroy(); |
@@ -723,6 +771,7 @@ class WebGraphicsContext3DCommandBufferImpl |
SharedMemoryLimits mem_limits_; |
uint32_t flush_id_; |
+ scoped_refptr<ShareGroup> share_group_; |
}; |
} // namespace content |