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

Unified Diff: src/gpu/GrContextFactory.cpp

Issue 1555053003: Revert of Make SkGLContext lifetime more well-defined (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrContextFactory.h ('k') | tests/EGLImageTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrContextFactory.cpp
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index b7e48254c881af6835b8c6e195b3a8c2ee1a69a7..4814e7870e8f0f16e118e824d526abea7122f0a7 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -23,56 +23,16 @@
#include "gl/GrGLGpu.h"
#include "GrCaps.h"
-GrContextFactory::GrContextFactory() { }
-
-GrContextFactory::GrContextFactory(const GrContextOptions& opts)
- : fGlobalOptions(opts) {
-}
-
-GrContextFactory::~GrContextFactory() {
- this->destroyContexts();
-}
-
-void GrContextFactory::destroyContexts() {
- for (Context& context : fContexts) {
- if (context.fGLContext) {
- context.fGLContext->makeCurrent();
- }
- if (!context.fGrContext->unique()) {
- context.fGrContext->abandonContext();
- }
- context.fGrContext->unref();
- delete(context.fGLContext);
- }
- fContexts.reset();
-}
-
-void GrContextFactory::abandonContexts() {
- for (Context& context : fContexts) {
- if (context.fGLContext) {
- context.fGLContext->makeCurrent();
- context.fGLContext->testAbandon();
- delete(context.fGLContext);
- context.fGLContext = nullptr;
- }
- context.fGrContext->abandonContext();
- }
-}
-
-GrContextFactory::ContextInfo GrContextFactory::getContextInfo(GLContextType type,
- GLContextOptions options) {
+GrContextFactory::ContextInfo* GrContextFactory::getContextInfo(GLContextType type,
+ GLContextOptions options) {
for (int i = 0; i < fContexts.count(); ++i) {
- Context& context = fContexts[i];
- if (!context.fGLContext) {
- continue;
- }
- if (context.fType == type &&
- context.fOptions == options) {
- context.fGLContext->makeCurrent();
- return ContextInfo(context.fGrContext, context.fGLContext);
+ if (fContexts[i]->fType == type &&
+ fContexts[i]->fOptions == options) {
+ fContexts[i]->fGLContext->makeCurrent();
+ return fContexts[i];
}
}
- SkAutoTDelete<SkGLContext> glCtx;
+ SkAutoTUnref<SkGLContext> glCtx;
SkAutoTUnref<GrContext> grCtx;
switch (type) {
case kNative_GLContextType:
@@ -112,7 +72,7 @@
break;
}
if (nullptr == glCtx.get()) {
- return ContextInfo();
+ return nullptr;
}
SkASSERT(glCtx->isValid());
@@ -122,7 +82,7 @@
if (!(kEnableNVPR_GLContextOptions & options)) {
glInterface.reset(GrGLInterfaceRemoveNVPR(glInterface));
if (!glInterface) {
- return ContextInfo();
+ return nullptr;
}
}
@@ -134,18 +94,18 @@
grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
#endif
if (!grCtx.get()) {
- return ContextInfo();
+ return nullptr;
}
if (kEnableNVPR_GLContextOptions & options) {
if (!grCtx->caps()->shaderCaps()->pathRenderingSupport()) {
- return ContextInfo();
+ return nullptr;
}
}
- Context& context = fContexts.push_back();
- context.fGLContext = glCtx.detach();
- context.fGrContext = SkRef(grCtx.get());
- context.fType = type;
- context.fOptions = options;
- return ContextInfo(context.fGrContext, context.fGLContext);
+ ContextInfo* ctx = fContexts.emplace_back(new ContextInfo);
+ ctx->fGLContext = SkRef(glCtx.get());
+ ctx->fGrContext = SkRef(grCtx.get());
+ ctx->fType = type;
+ ctx->fOptions = options;
+ return ctx;
}
« no previous file with comments | « src/gpu/GrContextFactory.h ('k') | tests/EGLImageTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698