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

Unified Diff: src/gpu/GrContextFactory.h

Issue 1446453003: Generate list of GPU contexts outside SurfaceTest tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: msvc fixes Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dm/DM.cpp ('k') | src/gpu/GrContextFactory.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContextFactory.h
diff --git a/src/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h
index 130c333dd0f066c0e9fce39fca1e680944c4f94b..6d174323180b2a3eb651445549b2ec54c0dfeb32 100644
--- a/src/gpu/GrContextFactory.h
+++ b/src/gpu/GrContextFactory.h
@@ -98,39 +98,52 @@ public:
void destroyContexts() {
for (int i = 0; i < fContexts.count(); ++i) {
- if (fContexts[i].fGLContext) { // could be abandoned.
- fContexts[i].fGLContext->makeCurrent();
- }
- fContexts[i].fGrContext->unref();
- if (fContexts[i].fGLContext) {
- fContexts[i].fGLContext->unref();
+ if (fContexts[i]->fGLContext) { // could be abandoned.
+ fContexts[i]->fGLContext->makeCurrent();
}
+ fContexts[i]->fGrContext->unref();
+ SkSafeUnref(fContexts[i]->fGLContext);
}
fContexts.reset();
}
void abandonContexts() {
for (int i = 0; i < fContexts.count(); ++i) {
- if (fContexts[i].fGLContext) {
- fContexts[i].fGLContext->testAbandon();
- SkSafeSetNull(fContexts[i].fGLContext);
+ if (fContexts[i]->fGLContext) {
+ fContexts[i]->fGLContext->testAbandon();
+ SkSafeSetNull(fContexts[i]->fGLContext);
}
- fContexts[i].fGrContext->abandonContext();
+ fContexts[i]->fGrContext->abandonContext();
}
}
+ struct ContextInfo {
+ GLContextType fType;
+ SkGLContext* fGLContext;
+ GrContext* fGrContext;
+ };
/**
- * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
+ * Get a context initialized with a type of GL context. It also makes the GL context current.
+ * Pointer is valid until destroyContexts() is called.
*/
- GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard);
+ ContextInfo* getContextInfo(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard);
+ /**
+ * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
+ */
+ GrContext* get(GLContextType type, GrGLStandard forcedGpuAPI = kNone_GrGLStandard) {
+ if (ContextInfo* info = this->getContextInfo(type, forcedGpuAPI)) {
+ return info->fGrContext;
+ }
+ return nullptr;
+ }
// Returns the GLContext of the given type. If it has not been created yet,
// nullptr is returned instead.
SkGLContext* getGLContext(GLContextType type) {
for (int i = 0; i < fContexts.count(); ++i) {
- if (fContexts[i].fType == type) {
- return fContexts[i].fGLContext;
+ if (fContexts[i]->fType == type) {
+ return fContexts[i]->fGLContext;
}
}
@@ -140,12 +153,7 @@ public:
const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
private:
- struct GPUContext {
- GLContextType fType;
- SkGLContext* fGLContext;
- GrContext* fGrContext;
- };
- SkTArray<GPUContext, true> fContexts;
+ SkTArray<SkAutoTDelete<ContextInfo>, true> fContexts;
const GrContextOptions fGlobalOptions;
};
« no previous file with comments | « dm/DM.cpp ('k') | src/gpu/GrContextFactory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698