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

Side by Side Diff: include/gpu/GrContextFactory.h

Issue 422903002: Test abandoning GL context in dm/nanobench. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix build Created 6 years, 4 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 | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | 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 * 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 SkFAIL("Unknown GL Context type."); 87 SkFAIL("Unknown GL Context type.");
88 } 88 }
89 } 89 }
90 90
91 GrContextFactory() { } 91 GrContextFactory() { }
92 92
93 ~GrContextFactory() { this->destroyContexts(); } 93 ~GrContextFactory() { this->destroyContexts(); }
94 94
95 void destroyContexts() { 95 void destroyContexts() {
96 for (int i = 0; i < fContexts.count(); ++i) { 96 for (int i = 0; i < fContexts.count(); ++i) {
97 fContexts[i].fGLContext->makeCurrent(); 97 if (NULL != fContexts[i].fGLContext) { // could be abandoned.
98 fContexts[i].fGLContext->makeCurrent();
99 }
98 fContexts[i].fGrContext->unref(); 100 fContexts[i].fGrContext->unref();
99 fContexts[i].fGLContext->unref(); 101 if (NULL != fContexts[i].fGLContext) {
102 fContexts[i].fGLContext->unref();
103 }
100 } 104 }
101 fContexts.reset(); 105 fContexts.reset();
102 } 106 }
103 107
108 void abandonContexts() {
109 for (int i = 0; i < fContexts.count(); ++i) {
110 SkSafeSetNull(fContexts[i].fGLContext);
111 fContexts[i].fGrContext->abandonContext();
112 }
113 }
114
104 /** 115 /**
105 * Get a GrContext initialized with a type of GL context. It also makes the GL context current. 116 * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
106 */ 117 */
107 GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLSta ndard) { 118 GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLSta ndard) {
108 for (int i = 0; i < fContexts.count(); ++i) { 119 for (int i = 0; i < fContexts.count(); ++i) {
109 if (forcedGpuAPI != kNone_GrGLStandard && 120 if (forcedGpuAPI != kNone_GrGLStandard &&
110 forcedGpuAPI != fContexts[i].fGLContext->gl()->fStandard) 121 forcedGpuAPI != fContexts[i].fGLContext->gl()->fStandard)
111 continue; 122 continue;
112 123
113 if (fContexts[i].fType == type) { 124 if (fContexts[i].fType == type) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 private: 201 private:
191 struct GPUContext { 202 struct GPUContext {
192 GLContextType fType; 203 GLContextType fType;
193 SkGLContextHelper* fGLContext; 204 SkGLContextHelper* fGLContext;
194 GrContext* fGrContext; 205 GrContext* fGrContext;
195 }; 206 };
196 SkTArray<GPUContext, true> fContexts; 207 SkTArray<GPUContext, true> fContexts;
197 }; 208 };
198 209
199 #endif 210 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/gpu/GrContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698