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 97f171514897e1634c62be1118acaeebbb5ea57b..be3ace62f03a1aa3be398f9e688aee8c83828151 100644 |
--- a/gpu/command_buffer/client/gl_in_process_context.cc |
+++ b/gpu/command_buffer/client/gl_in_process_context.cc |
@@ -53,16 +53,17 @@ class GLInProcessContextImpl |
explicit GLInProcessContextImpl(); |
virtual ~GLInProcessContextImpl(); |
- bool Initialize(bool is_offscreen, |
+ bool Initialize(scoped_refptr<gfx::GLSurface> surface, |
+ bool is_offscreen, |
bool share_resources, |
gfx::AcceleratedWidget window, |
const gfx::Size& size, |
const char* allowed_extensions, |
const int32* attrib_list, |
- gfx::GpuPreference gpu_preference, |
- const base::Closure& context_lost_callback); |
+ gfx::GpuPreference gpu_preference); |
// GLInProcessContext implementation: |
+ virtual void SetContextLostCallback(const base::Closure& callback) OVERRIDE; |
virtual void SignalSyncPoint(unsigned sync_point, |
const base::Closure& callback) OVERRIDE; |
virtual void SignalQuery(unsigned query, const base::Closure& callback) |
@@ -79,7 +80,7 @@ class GLInProcessContextImpl |
void Destroy(); |
void PollQueryCallbacks(); |
void CallQueryCallback(size_t index); |
- void OnContextLost(const base::Closure& callback); |
+ void OnContextLost(); |
void OnSignalSyncPoint(const base::Closure& callback); |
scoped_ptr<gles2::GLES2CmdHelper> gles2_helper_; |
@@ -92,6 +93,7 @@ class GLInProcessContextImpl |
unsigned int share_group_id_; |
bool context_lost_; |
+ base::Closure context_lost_callback_; |
DISALLOW_COPY_AND_ASSIGN(GLInProcessContextImpl); |
}; |
@@ -147,9 +149,16 @@ gles2::GLES2Implementation* GLInProcessContextImpl::GetImplementation() { |
return gles2_implementation_.get(); |
} |
-void GLInProcessContextImpl::OnContextLost(const base::Closure& callback) { |
+void GLInProcessContextImpl::SetContextLostCallback( |
+ const base::Closure& callback) { |
+ context_lost_callback_ = callback; |
+} |
+ |
+void GLInProcessContextImpl::OnContextLost() { |
context_lost_ = true; |
- callback.Run(); |
+ if (!context_lost_callback_.is_null()) { |
+ context_lost_callback_.Run(); |
+ } |
} |
void GLInProcessContextImpl::OnSignalSyncPoint(const base::Closure& callback) { |
@@ -159,14 +168,14 @@ void GLInProcessContextImpl::OnSignalSyncPoint(const base::Closure& callback) { |
} |
bool GLInProcessContextImpl::Initialize( |
+ scoped_refptr<gfx::GLSurface> surface, |
bool is_offscreen, |
bool share_resources, |
gfx::AcceleratedWidget window, |
const gfx::Size& size, |
const char* allowed_extensions, |
const int32* attrib_list, |
- gfx::GpuPreference gpu_preference, |
- const base::Closure& context_lost_callback) { |
+ gfx::GpuPreference gpu_preference) { |
DCHECK(size.width() >= 0 && size.height() >= 0); |
std::vector<int32> attribs; |
@@ -197,9 +206,7 @@ bool GLInProcessContextImpl::Initialize( |
} |
base::Closure wrapped_callback = |
- base::Bind(&GLInProcessContextImpl::OnContextLost, |
- AsWeakPtr(), |
- context_lost_callback); |
+ base::Bind(&GLInProcessContextImpl::OnContextLost, AsWeakPtr()); |
command_buffer_.reset(new InProcessCommandBuffer()); |
scoped_ptr<base::AutoLock> scoped_shared_context_lock; |
@@ -223,15 +230,16 @@ bool GLInProcessContextImpl::Initialize( |
if (!share_group && !++share_group_id_) |
++share_group_id_; |
} |
- if (!command_buffer_->Initialize(is_offscreen, |
- share_resources, |
- window, |
- size, |
- allowed_extensions, |
- attribs, |
- gpu_preference, |
- wrapped_callback, |
- share_group_id_)) { |
+ if (!command_buffer_->Initialize(surface, |
+ is_offscreen, |
+ share_resources, |
+ window, |
+ size, |
+ allowed_extensions, |
+ attribs, |
+ gpu_preference, |
+ wrapped_callback, |
+ share_group_id_)) { |
LOG(INFO) << "Failed to initialize InProcessCommmandBuffer"; |
return false; |
} |
@@ -345,19 +353,43 @@ GLInProcessContext* GLInProcessContext::CreateContext( |
bool share_resources, |
const char* allowed_extensions, |
const int32* attrib_list, |
- gfx::GpuPreference gpu_preference, |
- const base::Closure& callback) { |
+ gfx::GpuPreference gpu_preference) { |
scoped_ptr<GLInProcessContextImpl> context( |
new GLInProcessContextImpl()); |
if (!context->Initialize( |
+ NULL /* surface */, |
is_offscreen, |
share_resources, |
window, |
size, |
allowed_extensions, |
attrib_list, |
- gpu_preference, |
- callback)) |
+ gpu_preference)) |
+ return NULL; |
+ |
+ return context.release(); |
+} |
+ |
+// static |
+GLInProcessContext* GLInProcessContext::CreateWithSurface( |
+ scoped_refptr<gfx::GLSurface> surface, |
+ bool is_offscreen, |
+ const gfx::Size& size, |
+ bool share_resources, |
+ const char* allowed_extensions, |
+ const int32* attrib_list, |
+ gfx::GpuPreference gpu_preference) { |
+ scoped_ptr<GLInProcessContextImpl> context( |
+ new GLInProcessContextImpl()); |
+ if (!context->Initialize( |
+ surface, |
+ is_offscreen, |
+ share_resources, |
+ NULL /* window */, |
+ size, |
+ allowed_extensions, |
+ attrib_list, |
+ gpu_preference)) |
return NULL; |
return context.release(); |