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

Side by Side Diff: cc/output/context_provider.h

Issue 1356463002: Revert of cc: Implement shared worker contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « cc/layers/ui_resource_layer_impl_unittest.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_OUTPUT_CONTEXT_PROVIDER_H_ 5 #ifndef CC_OUTPUT_CONTEXT_PROVIDER_H_
6 #define CC_OUTPUT_CONTEXT_PROVIDER_H_ 6 #define CC_OUTPUT_CONTEXT_PROVIDER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 14 matching lines...) Expand all
25 namespace cc { 25 namespace cc {
26 struct ManagedMemoryPolicy; 26 struct ManagedMemoryPolicy;
27 27
28 class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { 28 class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> {
29 public: 29 public:
30 class ScopedContextLock { 30 class ScopedContextLock {
31 public: 31 public:
32 explicit ScopedContextLock(ContextProvider* context_provider) 32 explicit ScopedContextLock(ContextProvider* context_provider)
33 : context_provider_(context_provider), 33 : context_provider_(context_provider),
34 context_lock_(*context_provider_->GetLock()) { 34 context_lock_(*context_provider_->GetLock()) {
35 // Allow current thread to use |context_provider_|. 35 // Allow current thread to bind to |context_provider|.
36 context_provider_->DetachFromThread(); 36 context_provider_->DetachFromThread();
37 } 37 }
38 ~ScopedContextLock() { 38 ~ScopedContextLock() {
39 // Allow usage by thread for which |context_provider_| is bound to. 39 // Allow a different thread to bind to |context_provider|.
40 context_provider_->DetachFromThread(); 40 context_provider_->DetachFromThread();
41 } 41 }
42 42
43 gpu::gles2::GLES2Interface* ContextGL() { 43 gpu::gles2::GLES2Interface* ContextGL() {
44 return context_provider_->ContextGL(); 44 return context_provider_->ContextGL();
45 } 45 }
46 46
47 private: 47 private:
48 ContextProvider* const context_provider_; 48 ContextProvider* const context_provider_;
49 base::AutoLock context_lock_; 49 base::AutoLock context_lock_;
50 }; 50 };
51 // Bind the 3d context to the current thread. This should be called before 51 // Bind the 3d context to the current thread. This should be called before
52 // accessing the contexts. Calling it more than once should have no effect. 52 // accessing the contexts. Calling it more than once should have no effect.
53 // Once this function has been called, the class should only be accessed 53 // Once this function has been called, the class should only be accessed
54 // from the same thread unless the function has some explicitly specified 54 // from the same thread.
55 // rules for access on a different thread. See SetupLockOnMainThread(), which
56 // can be used to provide access from multiple threads.
57 virtual bool BindToCurrentThread() = 0; 55 virtual bool BindToCurrentThread() = 0;
58 virtual void DetachFromThread() {} 56 virtual void DetachFromThread() {}
59 57
60 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; 58 virtual gpu::gles2::GLES2Interface* ContextGL() = 0;
61 virtual gpu::ContextSupport* ContextSupport() = 0; 59 virtual gpu::ContextSupport* ContextSupport() = 0;
62 virtual class GrContext* GrContext() = 0; 60 virtual class GrContext* GrContext() = 0;
63 61
64 struct Capabilities { 62 struct Capabilities {
65 gpu::Capabilities gpu; 63 gpu::Capabilities gpu;
66 size_t max_transfer_buffer_usage_bytes; 64 size_t max_transfer_buffer_usage_bytes;
67 65
68 CC_EXPORT Capabilities(); 66 CC_EXPORT Capabilities();
69 }; 67 };
70 68
71 // Invalidates the cached OpenGL state in GrContext. 69 // Invalidates the cached OpenGL state in GrContext.
72 // See skia GrContext::resetContext for details. 70 // See skia GrContext::resetContext for details.
73 virtual void InvalidateGrContext(uint32_t state) = 0; 71 virtual void InvalidateGrContext(uint32_t state) = 0;
74 72
75 // Sets up a lock so this context can be used from multiple threads. After 73 // Sets up a lock so this context can be used from multiple threads.
76 // calling this, all functions without explicit thread usage constraints can
77 // be used on any thread while the lock returned by GetLock() is acquired.
78 virtual void SetupLock() = 0; 74 virtual void SetupLock() = 0;
79 75
80 // Returns the lock that should be held if using this context from multiple 76 // Returns the lock that should be held if using this context from multiple
81 // threads. This can be called on any thread. 77 // threads.
82 virtual base::Lock* GetLock() = 0; 78 virtual base::Lock* GetLock() = 0;
83 79
84 // Returns the capabilities of the currently bound 3d context. 80 // Returns the capabilities of the currently bound 3d context.
85 virtual Capabilities ContextCapabilities() = 0; 81 virtual Capabilities ContextCapabilities() = 0;
86 82
87 // Ask the provider to check if the contexts are valid or lost. If they are, 83 // Ask the provider to check if the contexts are valid or lost. If they are,
88 // this should invalidate the provider so that it can be replaced with a new 84 // this should invalidate the provider so that it can be replaced with a new
89 // one. 85 // one.
90 virtual void VerifyContexts() = 0; 86 virtual void VerifyContexts() = 0;
91 87
(...skipping 20 matching lines...) Expand all
112 const MemoryPolicyChangedCallback& memory_policy_changed_callback) = 0; 108 const MemoryPolicyChangedCallback& memory_policy_changed_callback) = 0;
113 109
114 protected: 110 protected:
115 friend class base::RefCountedThreadSafe<ContextProvider>; 111 friend class base::RefCountedThreadSafe<ContextProvider>;
116 virtual ~ContextProvider() {} 112 virtual ~ContextProvider() {}
117 }; 113 };
118 114
119 } // namespace cc 115 } // namespace cc
120 116
121 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ 117 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_
OLDNEW
« no previous file with comments | « cc/layers/ui_resource_layer_impl_unittest.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698