diff options
-rw-r--r-- | bench/nanobench.cpp | 16 | ||||
-rw-r--r-- | gm/gmmain.cpp | 2 | ||||
-rw-r--r-- | include/gpu/GrContextFactory.h | 6 |
3 files changed, 15 insertions, 9 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index a5353aa6e8..3522c4acb2 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -26,7 +26,7 @@ #if SK_SUPPORT_GPU #include "gl/GrGLDefines.h" #include "GrContextFactory.h" - GrContextFactory gGrFactory; + SkAutoTDelete<GrContextFactory> gGrFactory; #endif __SK_FORCE_IMAGE_DECODER_LINKING; @@ -288,7 +288,7 @@ static bool is_gpu_config_allowed(const char* name, GrContextFactory::GLContextT 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; @@ -362,9 +362,9 @@ static Target* is_enabled(Benchmark* bench, const Config& config) { } #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 @@ -528,6 +528,10 @@ int nanobench_main() { 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; @@ -671,10 +675,10 @@ int nanobench_main() { #if SK_SUPPORT_GPU if (FLAGS_abandonGpuContext) { - gGrFactory.abandonContexts(); + gGrFactory->abandonContexts(); } if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) { - gGrFactory.destroyContexts(); + gGrFactory->destroyContexts(); } #endif } diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp index 9b51eb0ad6..eb9147b628 100644 --- a/gm/gmmain.cpp +++ b/gm/gmmain.cpp @@ -2284,7 +2284,7 @@ int tool_main(int argc, char** argv) { 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; diff --git a/include/gpu/GrContextFactory.h b/include/gpu/GrContextFactory.h index e73eb784a9..f6677bbe29 100644 --- a/include/gpu/GrContextFactory.h +++ b/include/gpu/GrContextFactory.h @@ -88,6 +88,7 @@ public: } } + explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(opts) { } GrContextFactory() { } ~GrContextFactory() { this->destroyContexts(); } @@ -176,7 +177,7 @@ public: 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; } @@ -207,7 +208,8 @@ private: SkGLContextHelper* fGLContext; GrContext* fGrContext; }; - SkTArray<GPUContext, true> fContexts; + SkTArray<GPUContext, true> fContexts; + const GrContext::Options fGlobalOptions; }; #endif |