| Index: cc/output/context_provider.h
|
| diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h
|
| index aa4367d97ff68d515b22121b7cb89b25fba4ad57..bfc1d4f5cf640e25fc1e8e489300b8a283896cc0 100644
|
| --- a/cc/output/context_provider.h
|
| +++ b/cc/output/context_provider.h
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "base/callback.h"
|
| #include "base/memory/ref_counted.h"
|
| +#include "base/synchronization/lock.h"
|
| #include "cc/base/cc_export.h"
|
| #include "gpu/command_buffer/common/capabilities.h"
|
|
|
| @@ -26,6 +27,27 @@ struct ManagedMemoryPolicy;
|
|
|
| class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
|
| public:
|
| + class ScopedContextGL {
|
| + public:
|
| + explicit ScopedContextGL(ContextProvider* context_provider)
|
| + : context_provider_(context_provider),
|
| + context_lock_(*context_provider_->GetLock()) {
|
| + // Allow current thread to bind to |context_provider|.
|
| + context_provider_->DetachFromThread();
|
| + }
|
| + ~ScopedContextGL() {
|
| + // Allow a different thread to bind to |context_provider|.
|
| + context_provider_->DetachFromThread();
|
| + }
|
| +
|
| + gpu::gles2::GLES2Interface* ContextGL() {
|
| + return context_provider_->ContextGL();
|
| + }
|
| +
|
| + private:
|
| + ContextProvider* const context_provider_;
|
| + base::AutoLock context_lock_;
|
| + };
|
| // Bind the 3d context to the current thread. This should be called before
|
| // accessing the contexts. Calling it more than once should have no effect.
|
| // Once this function has been called, the class should only be accessed
|
|
|