OLD | NEW |
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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 // from the same thread unless the function has some explicitly specified | 57 // from the same thread unless the function has some explicitly specified |
58 // rules for access on a different thread. See SetupLockOnMainThread(), which | 58 // rules for access on a different thread. See SetupLockOnMainThread(), which |
59 // can be used to provide access from multiple threads. | 59 // can be used to provide access from multiple threads. |
60 virtual bool BindToCurrentThread() = 0; | 60 virtual bool BindToCurrentThread() = 0; |
61 virtual void DetachFromThread() {} | 61 virtual void DetachFromThread() {} |
62 | 62 |
63 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; | 63 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; |
64 virtual gpu::ContextSupport* ContextSupport() = 0; | 64 virtual gpu::ContextSupport* ContextSupport() = 0; |
65 virtual class GrContext* GrContext() = 0; | 65 virtual class GrContext* GrContext() = 0; |
66 | 66 |
67 struct Capabilities { | |
68 gpu::Capabilities gpu; | |
69 size_t max_transfer_buffer_usage_bytes; | |
70 | |
71 CC_EXPORT Capabilities(); | |
72 }; | |
73 | |
74 // Invalidates the cached OpenGL state in GrContext. | 67 // Invalidates the cached OpenGL state in GrContext. |
75 // See skia GrContext::resetContext for details. | 68 // See skia GrContext::resetContext for details. |
76 virtual void InvalidateGrContext(uint32_t state) = 0; | 69 virtual void InvalidateGrContext(uint32_t state) = 0; |
77 | 70 |
78 // Sets up a lock so this context can be used from multiple threads. After | 71 // Sets up a lock so this context can be used from multiple threads. After |
79 // calling this, all functions without explicit thread usage constraints can | 72 // calling this, all functions without explicit thread usage constraints can |
80 // be used on any thread while the lock returned by GetLock() is acquired. | 73 // be used on any thread while the lock returned by GetLock() is acquired. |
81 virtual void SetupLock() = 0; | 74 virtual void SetupLock() = 0; |
82 | 75 |
83 // 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 |
84 // threads. This can be called on any thread. | 77 // threads. This can be called on any thread. |
85 virtual base::Lock* GetLock() = 0; | 78 virtual base::Lock* GetLock() = 0; |
86 | 79 |
87 // Returns the capabilities of the currently bound 3d context. | 80 // Returns the capabilities of the currently bound 3d context. |
88 virtual Capabilities ContextCapabilities() = 0; | 81 virtual gpu::Capabilities ContextCapabilities() = 0; |
89 | 82 |
90 // Delete all cached gpu resources. | 83 // Delete all cached gpu resources. |
91 virtual void DeleteCachedResources() = 0; | 84 virtual void DeleteCachedResources() = 0; |
92 | 85 |
93 // Sets a callback to be called when the context is lost. This should be | 86 // Sets a callback to be called when the context is lost. This should be |
94 // called from the same thread that the context is bound to. To avoid races, | 87 // called from the same thread that the context is bound to. To avoid races, |
95 // it should be called before BindToCurrentThread(). | 88 // it should be called before BindToCurrentThread(). |
96 typedef base::Closure LostContextCallback; | 89 typedef base::Closure LostContextCallback; |
97 virtual void SetLostContextCallback( | 90 virtual void SetLostContextCallback( |
98 const LostContextCallback& lost_context_callback) = 0; | 91 const LostContextCallback& lost_context_callback) = 0; |
99 | 92 |
100 protected: | 93 protected: |
101 friend class base::RefCountedThreadSafe<ContextProvider>; | 94 friend class base::RefCountedThreadSafe<ContextProvider>; |
102 virtual ~ContextProvider() {} | 95 virtual ~ContextProvider() {} |
103 }; | 96 }; |
104 | 97 |
105 } // namespace cc | 98 } // namespace cc |
106 | 99 |
107 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ | 100 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ |
OLD | NEW |