Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: tools/gpu/GrContextFactory.cpp

Issue 1852733002: Add GrContext::releaseAndAbandonContext() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix no-gpu build, add null check, add unit test" Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/gpu/GrContextFactory.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « tools/gpu/GrContextFactory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698