| Index: src/gpu/GrContextFactory.h
|
| diff --git a/src/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h
|
| index 1df99d6ff1f88d1e516ac024c302eafcc25b9159..7afa3108c69d8984e0d63cd76350570dc764d4be 100644
|
| --- a/src/gpu/GrContextFactory.h
|
| +++ b/src/gpu/GrContextFactory.h
|
| @@ -98,59 +98,47 @@ public:
|
| }
|
| }
|
|
|
| - explicit GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opts) { }
|
| - GrContextFactory() { }
|
| + explicit GrContextFactory(const GrContextOptions& opts);
|
| + GrContextFactory();
|
|
|
| - ~GrContextFactory() { this->destroyContexts(); }
|
| + ~GrContextFactory();
|
|
|
| - 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();
|
| - 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);
|
| - }
|
| - fContexts[i]->fGrContext->abandonContext();
|
| - }
|
| - }
|
| + void destroyContexts();
|
| + void abandonContexts();
|
|
|
| struct ContextInfo {
|
| - GLContextType fType;
|
| - GLContextOptions fOptions;
|
| - SkGLContext* fGLContext;
|
| - GrContext* fGrContext;
|
| + ContextInfo()
|
| + : fGrContext(nullptr), fGLContext(nullptr) { }
|
| + ContextInfo(GrContext* grContext, SkGLContext* glContext)
|
| + : fGrContext(grContext), fGLContext(glContext) { }
|
| + GrContext* fGrContext;
|
| + SkGLContext* fGLContext; //! Valid until the factory destroys it via abandonContexts() or
|
| + //! destroyContexts().
|
| };
|
| +
|
| /**
|
| * Get a context initialized with a type of GL context. It also makes the GL context current.
|
| - * Pointer is valid until destroyContexts() is called.
|
| */
|
| - ContextInfo* getContextInfo(GLContextType type,
|
| - GLContextOptions options = kNone_GLContextOptions);
|
| -
|
| + ContextInfo getContextInfo(GLContextType type,
|
| + GLContextOptions options = kNone_GLContextOptions);
|
| /**
|
| * Get a GrContext initialized with a type of GL context. It also makes the GL context current.
|
| */
|
| - GrContext* get(GLContextType type, GLContextOptions options = kNone_GLContextOptions) {
|
| - if (ContextInfo* info = this->getContextInfo(type, options)) {
|
| - return info->fGrContext;
|
| - }
|
| - return nullptr;
|
| + GrContext* get(GLContextType type,
|
| + GLContextOptions options = kNone_GLContextOptions) {
|
| + return this->getContextInfo(type, options).fGrContext;
|
| }
|
| const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
|
|
|
| private:
|
| - SkTArray<SkAutoTDelete<ContextInfo>, true> fContexts;
|
| - const GrContextOptions fGlobalOptions;
|
| + struct Context {
|
| + GLContextType fType;
|
| + GLContextOptions fOptions;
|
| + SkGLContext* fGLContext;
|
| + GrContext* fGrContext;
|
| + };
|
| + SkTArray<Context, true> fContexts;
|
| + const GrContextOptions fGlobalOptions;
|
| };
|
|
|
| #endif
|
|
|