OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrContextFactory.h" | 9 #include "GrContextFactory.h" |
10 #include "gl/GLTestContext.h" | 10 #include "gl/GLTestContext.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (context.fGLContext) { | 56 if (context.fGLContext) { |
57 context.fGLContext->makeCurrent(); | 57 context.fGLContext->makeCurrent(); |
58 context.fGLContext->testAbandon(); | 58 context.fGLContext->testAbandon(); |
59 delete(context.fGLContext); | 59 delete(context.fGLContext); |
60 context.fGLContext = nullptr; | 60 context.fGLContext = nullptr; |
61 } | 61 } |
62 context.fGrContext->abandonContext(); | 62 context.fGrContext->abandonContext(); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
| 66 void GrContextFactory::releaseResourcesAndAbandonContexts() { |
| 67 for (Context& context : fContexts) { |
| 68 if (context.fGLContext) { |
| 69 context.fGLContext->makeCurrent(); |
| 70 context.fGrContext->releaseResourcesAndAbandonContext(); |
| 71 delete(context.fGLContext); |
| 72 context.fGLContext = nullptr; |
| 73 } |
| 74 } |
| 75 } |
| 76 |
66 GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
e, | 77 GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType typ
e, |
67 GLContextOptions
options) { | 78 GLContextOptions
options) { |
68 for (int i = 0; i < fContexts.count(); ++i) { | 79 for (int i = 0; i < fContexts.count(); ++i) { |
69 Context& context = fContexts[i]; | 80 Context& context = fContexts[i]; |
70 if (!context.fGLContext) { | 81 if (!context.fGLContext) { |
71 continue; | 82 continue; |
72 } | 83 } |
73 if (context.fType == type && | 84 if (context.fType == type && |
74 context.fOptions == options) { | 85 context.fOptions == options) { |
75 context.fGLContext->makeCurrent(); | 86 context.fGLContext->makeCurrent(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 } | 168 } |
158 | 169 |
159 Context& context = fContexts.push_back(); | 170 Context& context = fContexts.push_back(); |
160 context.fGLContext = glCtx.release(); | 171 context.fGLContext = glCtx.release(); |
161 context.fGrContext = SkRef(grCtx.get()); | 172 context.fGrContext = SkRef(grCtx.get()); |
162 context.fType = type; | 173 context.fType = type; |
163 context.fOptions = options; | 174 context.fOptions = options; |
164 return ContextInfo(context.fGrContext, context.fGLContext); | 175 return ContextInfo(context.fGrContext, context.fGLContext); |
165 } | 176 } |
166 } // namespace sk_gpu_test | 177 } // namespace sk_gpu_test |
OLD | NEW |