Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 std::unique_ptr<ContextCacheController::ScopedBusy> busy_; | 50 std::unique_ptr<ContextCacheController::ScopedBusy> busy_; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class CC_EXPORT ScopedContext { | |
|
danakj
2017/05/01 22:57:33
I don't think this class is doing more than if you
sohan
2017/05/03 11:06:35
Done.
| |
| 54 public: | |
| 55 explicit ScopedContext(ContextProvider* context_provider); | |
| 56 ~ScopedContext(); | |
| 57 | |
| 58 gpu::gles2::GLES2Interface* ContextGL() { | |
| 59 return context_provider_->ContextGL(); | |
| 60 } | |
| 61 | |
| 62 private: | |
| 63 ContextProvider* const context_provider_; | |
| 64 std::unique_ptr<ContextCacheController::ScopedBusy> busy_; | |
| 65 }; | |
| 53 // Bind the 3d context to the current thread. This should be called before | 66 // Bind the 3d context to the current thread. This should be called before |
| 54 // accessing the contexts. Calling it more than once should have no effect. | 67 // accessing the contexts. Calling it more than once should have no effect. |
| 55 // Once this function has been called, the class should only be accessed | 68 // Once this function has been called, the class should only be accessed |
| 56 // from the same thread unless the function has some explicitly specified | 69 // from the same thread unless the function has some explicitly specified |
| 57 // rules for access on a different thread. See SetupLockOnMainThread(), which | 70 // rules for access on a different thread. See SetupLockOnMainThread(), which |
| 58 // can be used to provide access from multiple threads. | 71 // can be used to provide access from multiple threads. |
| 59 virtual bool BindToCurrentThread() = 0; | 72 virtual bool BindToCurrentThread() = 0; |
| 60 | 73 |
| 61 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; | 74 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; |
| 62 virtual gpu::ContextSupport* ContextSupport() = 0; | 75 virtual gpu::ContextSupport* ContextSupport() = 0; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 92 virtual base::Lock* GetLock() = 0; | 105 virtual base::Lock* GetLock() = 0; |
| 93 | 106 |
| 94 protected: | 107 protected: |
| 95 friend class base::RefCountedThreadSafe<ContextProvider>; | 108 friend class base::RefCountedThreadSafe<ContextProvider>; |
| 96 virtual ~ContextProvider() {} | 109 virtual ~ContextProvider() {} |
| 97 }; | 110 }; |
| 98 | 111 |
| 99 } // namespace cc | 112 } // namespace cc |
| 100 | 113 |
| 101 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ | 114 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ |
| OLD | NEW |