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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(o
pts) { } | 91 explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(o
pts) { } |
92 GrContextFactory() { } | 92 GrContextFactory() { } |
93 | 93 |
94 ~GrContextFactory() { this->destroyContexts(); } | 94 ~GrContextFactory() { this->destroyContexts(); } |
95 | 95 |
96 void destroyContexts() { | 96 void destroyContexts() { |
97 for (int i = 0; i < fContexts.count(); ++i) { | 97 for (int i = 0; i < fContexts.count(); ++i) { |
98 if (NULL != fContexts[i].fGLContext) { // could be abandoned. | 98 if (fContexts[i].fGLContext) { // could be abandoned. |
99 fContexts[i].fGLContext->makeCurrent(); | 99 fContexts[i].fGLContext->makeCurrent(); |
100 } | 100 } |
101 fContexts[i].fGrContext->unref(); | 101 fContexts[i].fGrContext->unref(); |
102 if (NULL != fContexts[i].fGLContext) { | 102 if (fContexts[i].fGLContext) { |
103 fContexts[i].fGLContext->unref(); | 103 fContexts[i].fGLContext->unref(); |
104 } | 104 } |
105 } | 105 } |
106 fContexts.reset(); | 106 fContexts.reset(); |
107 } | 107 } |
108 | 108 |
109 void abandonContexts() { | 109 void abandonContexts() { |
110 for (int i = 0; i < fContexts.count(); ++i) { | 110 for (int i = 0; i < fContexts.count(); ++i) { |
111 if (NULL != fContexts[i].fGLContext) { | 111 if (fContexts[i].fGLContext) { |
112 fContexts[i].fGLContext->testAbandon(); | 112 fContexts[i].fGLContext->testAbandon(); |
113 SkSafeSetNull(fContexts[i].fGLContext); | 113 SkSafeSetNull(fContexts[i].fGLContext); |
114 } | 114 } |
115 fContexts[i].fGrContext->abandonContext(); | 115 fContexts[i].fGrContext->abandonContext(); |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 /** | 119 /** |
120 * Get a GrContext initialized with a type of GL context. It also makes the
GL context current. | 120 * Get a GrContext initialized with a type of GL context. It also makes the
GL context current. |
121 */ | 121 */ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 struct GPUContext { | 208 struct GPUContext { |
209 GLContextType fType; | 209 GLContextType fType; |
210 SkGLContextHelper* fGLContext; | 210 SkGLContextHelper* fGLContext; |
211 GrContext* fGrContext; | 211 GrContext* fGrContext; |
212 }; | 212 }; |
213 SkTArray<GPUContext, true> fContexts; | 213 SkTArray<GPUContext, true> fContexts; |
214 const GrContext::Options fGlobalOptions; | 214 const GrContext::Options fGlobalOptions; |
215 }; | 215 }; |
216 | 216 |
217 #endif | 217 #endif |
OLD | NEW |