Index: content/common/gpu/client/context_provider_command_buffer.cc |
diff --git a/content/common/gpu/client/context_provider_command_buffer.cc b/content/common/gpu/client/context_provider_command_buffer.cc |
index 9436732c0d48e2a367ffd8347a5168d4b0d57b2d..7b16a0278cfcb824c4e4dda2eb05307b204f612b 100644 |
--- a/content/common/gpu/client/context_provider_command_buffer.cc |
+++ b/content/common/gpu/client/context_provider_command_buffer.cc |
@@ -21,11 +21,11 @@ |
public: |
explicit LostContextCallbackProxy(ContextProviderCommandBuffer* provider) |
: provider_(provider) { |
- provider_->WebContext3DNoChecks()->setContextLostCallback(this); |
+ provider_->context3d_->setContextLostCallback(this); |
} |
~LostContextCallbackProxy() override { |
- provider_->WebContext3DNoChecks()->setContextLostCallback(NULL); |
+ provider_->context3d_->setContextLostCallback(NULL); |
} |
void onContextLost() override { provider_->OnLostContext(); } |
@@ -47,12 +47,11 @@ |
ContextProviderCommandBuffer::ContextProviderCommandBuffer( |
scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context3d, |
CommandBufferContextType type) |
- : context_type_(type), |
+ : context3d_(context3d.Pass()), |
+ context_type_(type), |
debug_name_(CommandBufferContextTypeToString(type)) { |
- gr_interface_ = skia::AdoptRef(new GrGLInterfaceForWebGraphicsContext3D( |
- context3d.Pass())); |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
- DCHECK(gr_interface_->WebContext3D()); |
+ DCHECK(context3d_); |
context_thread_checker_.DetachFromThread(); |
} |
@@ -61,52 +60,41 @@ |
context_thread_checker_.CalledOnValidThread()); |
// Destroy references to the context3d_ before leaking it. |
- if (WebContext3DNoChecks()->GetCommandBufferProxy()) |
- WebContext3DNoChecks()->GetCommandBufferProxy()->SetLock(nullptr); |
+ if (context3d_->GetCommandBufferProxy()) |
+ context3d_->GetCommandBufferProxy()->SetLock(nullptr); |
lost_context_callback_proxy_.reset(); |
} |
CommandBufferProxyImpl* ContextProviderCommandBuffer::GetCommandBufferProxy() { |
- return WebContext3D()->GetCommandBufferProxy(); |
+ return context3d_->GetCommandBufferProxy(); |
} |
WebGraphicsContext3DCommandBufferImpl* |
ContextProviderCommandBuffer::WebContext3D() { |
- DCHECK(gr_interface_); |
- DCHECK(gr_interface_->WebContext3D()); |
+ DCHECK(context3d_); |
DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
DCHECK(context_thread_checker_.CalledOnValidThread()); |
- return WebContext3DNoChecks(); |
-} |
- |
-WebGraphicsContext3DCommandBufferImpl* |
- ContextProviderCommandBuffer::WebContext3DNoChecks() { |
- DCHECK(gr_interface_); |
- return static_cast<WebGraphicsContext3DCommandBufferImpl*>( |
- gr_interface_->WebContext3D()); |
+ return context3d_.get(); |
} |
bool ContextProviderCommandBuffer::BindToCurrentThread() { |
// This is called on the thread the context will be used. |
DCHECK(context_thread_checker_.CalledOnValidThread()); |
- DCHECK(gr_interface_ && gr_interface_->WebContext3D()); |
if (lost_context_callback_proxy_) |
return true; |
- WebContext3DNoChecks()->SetContextType(context_type_); |
- if (!WebContext3DNoChecks()->InitializeOnCurrentThread()) |
+ context3d_->SetContextType(context_type_); |
+ if (!context3d_->InitializeOnCurrentThread()) |
return false; |
- gr_interface_->BindToCurrentThread(); |
InitializeCapabilities(); |
std::string unique_context_name = |
- base::StringPrintf("%s-%p", debug_name_.c_str(), WebContext3DNoChecks()); |
- WebContext3DNoChecks()->traceBeginCHROMIUM("gpu_toplevel", |
- unique_context_name.c_str()); |
+ base::StringPrintf("%s-%p", debug_name_.c_str(), context3d_.get()); |
+ context3d_->traceBeginCHROMIUM("gpu_toplevel", unique_context_name.c_str()); |
lost_context_callback_proxy_.reset(new LostContextCallbackProxy(this)); |
return true; |
@@ -117,13 +105,15 @@ |
} |
gpu::gles2::GLES2Interface* ContextProviderCommandBuffer::ContextGL() { |
+ DCHECK(context3d_); |
DCHECK(lost_context_callback_proxy_); // Is bound to thread. |
+ DCHECK(context_thread_checker_.CalledOnValidThread()); |
- return WebContext3D()->GetImplementation(); |
+ return context3d_->GetImplementation(); |
} |
gpu::ContextSupport* ContextProviderCommandBuffer::ContextSupport() { |
- return WebContext3D()->GetContextSupport(); |
+ return context3d_->GetContextSupport(); |
} |
class GrContext* ContextProviderCommandBuffer::GrContext() { |
@@ -133,7 +123,7 @@ |
if (gr_context_) |
return gr_context_->get(); |
- gr_context_.reset(new GrContextForWebGraphicsContext3D(gr_interface_)); |
+ gr_context_.reset(new GrContextForWebGraphicsContext3D(context3d_.get())); |
// If GlContext is already lost, also abandon the new GrContext. |
if (gr_context_->get() && |
@@ -152,7 +142,8 @@ |
} |
void ContextProviderCommandBuffer::SetupLock() { |
- WebContext3D()->GetCommandBufferProxy()->SetLock(&context_lock_); |
+ DCHECK(context3d_); |
+ context3d_->GetCommandBufferProxy()->SetLock(&context_lock_); |
} |
base::Lock* ContextProviderCommandBuffer::GetLock() { |
@@ -185,9 +176,9 @@ |
void ContextProviderCommandBuffer::InitializeCapabilities() { |
Capabilities caps; |
- caps.gpu = WebContext3DNoChecks()->GetImplementation()->capabilities(); |
+ caps.gpu = context3d_->GetImplementation()->capabilities(); |
- size_t mapped_memory_limit = WebContext3DNoChecks()->GetMappedMemoryLimit(); |
+ size_t mapped_memory_limit = context3d_->GetMappedMemoryLimit(); |
caps.max_transfer_buffer_usage_bytes = |
mapped_memory_limit == WebGraphicsContext3DCommandBufferImpl::kNoLimit |
? std::numeric_limits<size_t>::max() : mapped_memory_limit; |