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

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

Issue 1151603005: Revert of Store context options on caps. (Closed) Base URL: https://skia.googlesource.com/skia.git@onecaps
Patch Set: Created 5 years, 7 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 | « src/gpu/GrContext.cpp ('k') | src/gpu/GrContextFactory.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
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrContextOptions.h"
13 12
14 #include "gl/SkGLContext.h" 13 #include "gl/SkGLContext.h"
15 #include "SkTArray.h" 14 #include "SkTArray.h"
16 15
17 /** 16 /**
18 * This is a simple class that is useful in test apps that use different 17 * This is a simple class that is useful in test apps that use different
19 * GrContexts backed by different types of GL contexts. It manages creating the 18 * GrContexts backed by different types of GL contexts. It manages creating the
20 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the 19 * GL context and a GrContext that uses it. The GL/Gr contexts persist until the
21 * factory is destroyed (though the caller can always grab a ref on the returned 20 * factory is destroyed (though the caller can always grab a ref on the returned
22 * Gr and GL contexts to make them outlive the factory). 21 * Gr and GL contexts to make them outlive the factory).
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #endif 73 #endif
75 case kNVPR_GLContextType: 74 case kNVPR_GLContextType:
76 return "nvpr"; 75 return "nvpr";
77 case kDebug_GLContextType: 76 case kDebug_GLContextType:
78 return "debug"; 77 return "debug";
79 default: 78 default:
80 SkFAIL("Unknown GL Context type."); 79 SkFAIL("Unknown GL Context type.");
81 } 80 }
82 } 81 }
83 82
84 explicit GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opt s) { } 83 explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(o pts) { }
85 GrContextFactory() { } 84 GrContextFactory() { }
86 85
87 ~GrContextFactory() { this->destroyContexts(); } 86 ~GrContextFactory() { this->destroyContexts(); }
88 87
89 void destroyContexts() { 88 void destroyContexts() {
90 for (int i = 0; i < fContexts.count(); ++i) { 89 for (int i = 0; i < fContexts.count(); ++i) {
91 if (fContexts[i].fGLContext) { // could be abandoned. 90 if (fContexts[i].fGLContext) { // could be abandoned.
92 fContexts[i].fGLContext->makeCurrent(); 91 fContexts[i].fGLContext->makeCurrent();
93 } 92 }
94 fContexts[i].fGrContext->unref(); 93 fContexts[i].fGrContext->unref();
(...skipping 25 matching lines...) Expand all
120 SkGLContext* getGLContext(GLContextType type) { 119 SkGLContext* getGLContext(GLContextType type) {
121 for (int i = 0; i < fContexts.count(); ++i) { 120 for (int i = 0; i < fContexts.count(); ++i) {
122 if (fContexts[i].fType == type) { 121 if (fContexts[i].fType == type) {
123 return fContexts[i].fGLContext; 122 return fContexts[i].fGLContext;
124 } 123 }
125 } 124 }
126 125
127 return NULL; 126 return NULL;
128 } 127 }
129 128
130 const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; } 129 const GrContext::Options& getGlobalOptions() const { return fGlobalOptions; }
131 130
132 private: 131 private:
133 struct GPUContext { 132 struct GPUContext {
134 GLContextType fType; 133 GLContextType fType;
135 SkGLContext* fGLContext; 134 SkGLContext* fGLContext;
136 GrContext* fGrContext; 135 GrContext* fGrContext;
137 }; 136 };
138 SkTArray<GPUContext, true> fContexts; 137 SkTArray<GPUContext, true> fContexts;
139 const GrContextOptions fGlobalOptions; 138 const GrContext::Options fGlobalOptions;
140 }; 139 };
141 140
142 #endif 141 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrContextFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698