Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(491)

Unified Diff: cc/output/context_provider.h

Issue 1230203007: Re-land: cc: Use worker context for one-copy tile initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | cc/output/output_surface.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/context_provider.h
diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h
index aa4367d97ff68d515b22121b7cb89b25fba4ad57..c024e02328e9a3930b7593e54b986bdff3566ae5 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 ScopedContextLock {
+ public:
+ explicit ScopedContextLock(ContextProvider* context_provider)
+ : context_provider_(context_provider),
+ context_lock_(*context_provider_->GetLock()) {
+ // Allow current thread to bind to |context_provider|.
+ context_provider_->DetachFromThread();
+ }
+ ~ScopedContextLock() {
+ // 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
« no previous file with comments | « no previous file | cc/output/output_surface.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698