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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 | 50 |
| 51 gpu::gles2::GLES2Interface* ContextGL() { | 51 gpu::gles2::GLES2Interface* ContextGL() { |
| 52 return context_provider_->ContextGL(); | 52 return context_provider_->ContextGL(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 private: | 55 private: |
| 56 ContextProvider* const context_provider_; | 56 ContextProvider* const context_provider_; |
| 57 base::AutoLock context_lock_; | 57 base::AutoLock context_lock_; |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 // Bind the 3d context to the current thread. This should be called before | 60 // This Factory API is how to create a context provider in a deferred way (ie. |
| 61 // accessing the contexts. Calling it more than once should have no effect. | 61 // on another thread than the main thread). |
| 62 // Once this function has been called, the class should only be accessed | 62 class DeferredCreate { |
|
piman
2016/05/17 03:41:40
naming-wise, how about Factory? It's shorter, and
danakj
2016/05/17 19:53:32
Ya it does. I was like ContextProvider::Factory is
| |
| 63 // from the same thread unless the function has some explicitly specified | 63 public: |
| 64 // rules for access on a different thread. See SetupLockOnMainThread(), which | 64 // Creates and returns a new context provider. The context provider may only |
| 65 // can be used to provide access from multiple threads. | 65 // be used on the thread it is created on unless it supports locking (via |
| 66 virtual bool BindToCurrentThread() = 0; | 66 // the ScopedContextLock class). |
| 67 virtual scoped_refptr<ContextProvider> CreateContext() = 0; | |
| 68 | |
| 69 protected: | |
| 70 DeferredCreate() {} | |
| 71 | |
| 72 private: | |
| 73 DISALLOW_COPY_AND_ASSIGN(DeferredCreate); | |
| 74 }; | |
| 67 | 75 |
| 68 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; | 76 virtual gpu::gles2::GLES2Interface* ContextGL() = 0; |
| 69 virtual gpu::ContextSupport* ContextSupport() = 0; | 77 virtual gpu::ContextSupport* ContextSupport() = 0; |
| 70 virtual class GrContext* GrContext() = 0; | 78 virtual class GrContext* GrContext() = 0; |
| 71 | 79 |
| 72 // Invalidates the cached OpenGL state in GrContext. | 80 // Invalidates the cached OpenGL state in GrContext. |
| 73 // See skia GrContext::resetContext for details. | 81 // See skia GrContext::resetContext for details. |
| 74 virtual void InvalidateGrContext(uint32_t state) = 0; | 82 virtual void InvalidateGrContext(uint32_t state) = 0; |
| 75 | 83 |
| 76 // Returns the capabilities of the currently bound 3d context. | 84 // Returns the capabilities of the currently bound 3d context. |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 97 virtual base::Lock* GetLock() = 0; | 105 virtual base::Lock* GetLock() = 0; |
| 98 | 106 |
| 99 protected: | 107 protected: |
| 100 friend class base::RefCountedThreadSafe<ContextProvider>; | 108 friend class base::RefCountedThreadSafe<ContextProvider>; |
| 101 virtual ~ContextProvider() {} | 109 virtual ~ContextProvider() {} |
| 102 }; | 110 }; |
| 103 | 111 |
| 104 } // namespace cc | 112 } // namespace cc |
| 105 | 113 |
| 106 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ | 114 #endif // CC_OUTPUT_CONTEXT_PROVIDER_H_ |
| OLD | NEW |