Index: gpu/command_buffer/client/gl_in_process_context.cc |
diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc |
index 99e4b786a0bdcbe9312bddc259358f093c175a9c..21d8924c8dff052716de382decb2c6aa146847bf 100644 |
--- a/gpu/command_buffer/client/gl_in_process_context.cc |
+++ b/gpu/command_buffer/client/gl_in_process_context.cc |
@@ -49,6 +49,7 @@ const unsigned int kDefaultMaxTransferBufferSize = 16 * 1024 * 1024; |
class GLInProcessContextImpl |
: public GLInProcessContext, |
+ public GpuControlClient, |
public base::SupportsWeakPtr<GLInProcessContextImpl> { |
public: |
explicit GLInProcessContextImpl( |
@@ -67,12 +68,16 @@ class GLInProcessContextImpl |
GpuMemoryBufferManager* gpu_memory_buffer_manager, |
ImageFactory* image_factory); |
- // GLInProcessContext implementation: |
- void SetContextLostCallback(const base::Closure& callback) override; |
+ // GLInProcessContext implementation. |
gles2::GLES2Implementation* GetImplementation() override; |
size_t GetMappedMemoryLimit() override; |
void SetLock(base::Lock* lock) override; |
+ // GpuControlClient implementation. These methods are called on the GPU thread |
danakj
2016/04/06 02:14:15
It all gets quite hairy in here. The InProcessComm
danakj
2016/04/06 02:19:58
Oh no I realized this class should not be calling
danakj
2016/04/06 02:25:44
It seems like what's weird here (or different) is
|
+ // by the in-process GpuControl. |
+ void OnGpuControlErrorMessage(const char* message, int32_t id) override {} |
+ void OnGpuControlLostContext() override; |
+ |
#if defined(OS_ANDROID) |
scoped_refptr<gfx::SurfaceTexture> GetSurfaceTexture( |
uint32_t stream_id) override; |
@@ -81,7 +86,7 @@ class GLInProcessContextImpl |
private: |
void Destroy(); |
- void OnContextLost(); |
+ bool IsContextLost() const; |
void OnSignalSyncPoint(const base::Closure& callback); |
scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; |
@@ -90,9 +95,8 @@ class GLInProcessContextImpl |
scoped_ptr<InProcessCommandBuffer> command_buffer_; |
const GLInProcessContextSharedMemoryLimits mem_limits_; |
+ mutable base::Lock context_lost_lock_; |
danakj
2016/04/06 02:14:15
We used to wrap callbacks inside callbacks to get
|
bool context_lost_; |
- base::Closure context_lost_callback_; |
- base::Lock* lock_; |
DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl); |
}; |
@@ -104,8 +108,7 @@ base::LazyInstance<std::set<GLInProcessContextImpl*> > g_all_shared_contexts = |
GLInProcessContextImpl::GLInProcessContextImpl( |
const GLInProcessContextSharedMemoryLimits& mem_limits) |
- : mem_limits_(mem_limits), context_lost_(false), lock_(nullptr) { |
-} |
+ : mem_limits_(mem_limits) {} |
GLInProcessContextImpl::~GLInProcessContextImpl() { |
{ |
@@ -124,23 +127,19 @@ size_t GLInProcessContextImpl::GetMappedMemoryLimit() { |
} |
void GLInProcessContextImpl::SetLock(base::Lock* lock) { |
+ // TODO(danakj): This isn't used... remove from the GLInProcessContext api? |
command_buffer_->SetLock(lock); |
- lock_ = lock; |
} |
-void GLInProcessContextImpl::SetContextLostCallback( |
- const base::Closure& callback) { |
- context_lost_callback_ = callback; |
+void GLInProcessContextImpl::OnGpuControlLostContext() { |
+ // This is called on the GPU thread. |
+ base::AutoLock lock(context_lost_lock_); |
+ context_lost_ = true; |
} |
-void GLInProcessContextImpl::OnContextLost() { |
- scoped_ptr<base::AutoLock> lock; |
- if (lock_) |
- lock.reset(new base::AutoLock(*lock_)); |
- context_lost_ = true; |
- if (!context_lost_callback_.is_null()) { |
- context_lost_callback_.Run(); |
- } |
+bool GLInProcessContextImpl::IsContextLost() const { |
+ base::AutoLock lock(context_lost_lock_); |
+ return context_lost_; |
} |
bool GLInProcessContextImpl::Initialize( |
@@ -161,8 +160,6 @@ bool GLInProcessContextImpl::Initialize( |
std::vector<int32_t> attrib_vector; |
attribs.Serialize(&attrib_vector); |
- base::Closure wrapped_callback = |
- base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); |
command_buffer_.reset(new InProcessCommandBuffer(service)); |
scoped_ptr<base::AutoLock> scoped_shared_context_lock; |
@@ -176,7 +173,7 @@ bool GLInProcessContextImpl::Initialize( |
it != g_all_shared_contexts.Get().end(); |
it++) { |
const GLInProcessContextImpl* context = *it; |
- if (!context->context_lost_) { |
+ if (!context->IsContextLost()) { |
share_group = context->gles2_implementation_->share_group(); |
share_command_buffer = context->command_buffer_.get(); |
DCHECK(share_group.get()); |
@@ -193,13 +190,14 @@ bool GLInProcessContextImpl::Initialize( |
DCHECK(share_command_buffer); |
} |
+ command_buffer_->SetGpuControlClient(this); |
+ |
if (!command_buffer_->Initialize(surface, |
is_offscreen, |
window, |
size, |
attrib_vector, |
gpu_preference, |
- wrapped_callback, |
share_command_buffer, |
gpu_memory_buffer_manager, |
image_factory)) { |