#if SK_SUPPORT_GPU
#include "gl/GrGLDefines.h"
#include "GrContextFactory.h"
- GrContextFactory gGrFactory;
+ SkAutoTDelete<GrContextFactory> gGrFactory;
#endif
__SK_FORCE_IMAGE_DECODER_LINKING;
if (!is_cpu_config_allowed(name)) {
return false;
}
- if (const GrContext* ctx = gGrFactory.get(ctxType)) {
+ if (const GrContext* ctx = gGrFactory->get(ctxType)) {
return sampleCnt <= ctx->getMaxSampleCount();
}
return false;
}
#if SK_SUPPORT_GPU
else if (Benchmark::kGPU_Backend == config.backend) {
- target->surface.reset(SkSurface::NewRenderTarget(gGrFactory.get(config.ctxType), info,
+ target->surface.reset(SkSurface::NewRenderTarget(gGrFactory->get(config.ctxType), info,
config.samples));
- target->gl = gGrFactory.getGLContext(config.ctxType);
+ target->gl = gGrFactory->getGLContext(config.ctxType);
}
#endif
SetupCrashHandler();
SkAutoGraphics ag;
+#if SK_SUPPORT_GPU
+ gGrFactory.reset(SkNEW_ARGS(GrContextFactory, (GrContext::Options())));
+#endif
+
if (kAutoTuneLoops != FLAGS_loops) {
FLAGS_samples = 1;
FLAGS_gpuFrameLag = 0;
#if SK_SUPPORT_GPU
if (FLAGS_abandonGpuContext) {
- gGrFactory.abandonContexts();
+ gGrFactory->abandonContexts();
}
if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) {
- gGrFactory.destroyContexts();
+ gGrFactory->destroyContexts();
}
#endif
}
SkTDArray<SkScalar> tileGridReplayScales;
#if SK_SUPPORT_GPU
GrGLStandard gpuAPI = kNone_GrGLStandard;
- GrContextFactory* grFactory = new GrContextFactory;
+ GrContextFactory* grFactory = new GrContextFactory(GrContext::Options());
#else
GrGLStandard gpuAPI = 0;
GrContextFactory* grFactory = NULL;
}
}
+ explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(opts) { }
GrContextFactory() { }
~GrContextFactory() { this->destroyContexts(); }
glCtx->makeCurrent();
GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
- grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx));
+ grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, &fGlobalOptions));
if (!grCtx.get()) {
return NULL;
}
SkGLContextHelper* fGLContext;
GrContext* fGrContext;
};
- SkTArray<GPUContext, true> fContexts;
+ SkTArray<GPUContext, true> fContexts;
+ const GrContext::Options fGlobalOptions;
};
#endif