OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrContextFactory_DEFINED | 8 #ifndef GrContextFactory_DEFINED |
9 #define GrContextFactory_DEFINED | 9 #define GrContextFactory_DEFINED |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 /** | 131 /** |
132 * Get a GrContext initialized with a type of GL context. It also makes the
GL context current. | 132 * Get a GrContext initialized with a type of GL context. It also makes the
GL context current. |
133 */ | 133 */ |
134 GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLSta
ndard) { | 134 GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLSta
ndard) { |
135 if (ContextInfo* info = this->getContextInfo(type, forcedGpuAPI)) { | 135 if (ContextInfo* info = this->getContextInfo(type, forcedGpuAPI)) { |
136 return info->fGrContext; | 136 return info->fGrContext; |
137 } | 137 } |
138 return nullptr; | 138 return nullptr; |
139 } | 139 } |
140 | |
141 // Returns the GLContext of the given type. If it has not been created yet, | |
142 // nullptr is returned instead. | |
143 SkGLContext* getGLContext(GLContextType type) { | |
144 for (int i = 0; i < fContexts.count(); ++i) { | |
145 if (fContexts[i]->fType == type) { | |
146 return fContexts[i]->fGLContext; | |
147 } | |
148 } | |
149 | |
150 return nullptr; | |
151 } | |
152 | |
153 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } | 140 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } |
154 | 141 |
155 private: | 142 private: |
156 SkTArray<SkAutoTDelete<ContextInfo>, true> fContexts; | 143 SkTArray<SkAutoTDelete<ContextInfo>, true> fContexts; |
157 const GrContextOptions fGlobalOptions; | 144 const GrContextOptions fGlobalOptions; |
158 }; | 145 }; |
159 | 146 |
160 #endif | 147 #endif |
OLD | NEW |