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

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

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