From 8382394bf260af223d5217ff8c45961f149bf1cf Mon Sep 17 00:00:00 2001 From: "tomhudson@google.com" Date: Fri, 28 Oct 2011 14:59:07 +0000 Subject: Instead of using fixed size for GPU context in benchmain, walk list of benchmarks and find the largest size required. codereview.appspot.com/5330045/ git-svn-id: http://skia.googlecode.com/svn/trunk@2551 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/benchmain.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index 5debfee925..7800abccb0 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -216,6 +216,22 @@ static int findConfig(const char config[]) { return -1; } +static void determine_gpu_context_size(SkTDict& defineDict, + int* contextWidth, + int* contextHeight) { + Iter iter(&defineDict); + SkBenchmark* bench; + while ((bench = iter.next()) != NULL) { + SkIPoint dim = bench->getSize(); + if (*contextWidth < dim.fX) { + *contextWidth = dim.fX; + } + if (*contextHeight < dim.fY) { + *contextHeight = dim.fY; + } + } +} + int main (int argc, char * const argv[]) { SkAutoGraphics ag; @@ -426,7 +442,10 @@ int main (int argc, char * const argv[]) { } else { glctx.reset(new SkNativeGLContext); } - if (glctx.get()->init(1024, 1024)) { + int contextWidth = 1024; + int contextHeight = 1024; + determine_gpu_context_size(defineDict, &contextWidth, &contextHeight); + if (glctx.get()->init(contextWidth, contextHeight)) { GrPlatform3DContext ctx = reinterpret_cast(glctx.get()->gl()); context = GrContext::Create(kOpenGL_Shaders_GrEngine, ctx); @@ -434,8 +453,8 @@ int main (int argc, char * const argv[]) { GrPlatformSurfaceDesc desc; desc.reset(); desc.fConfig = kRGBA_8888_GrPixelConfig; - desc.fWidth = 1024; - desc.fHeight = 1024; + desc.fWidth = contextWidth; + desc.fHeight = contextHeight; desc.fStencilBits = 8; desc.fPlatformRenderTarget = glctx.get()->getFBOID(); desc.fSurfaceType = kRenderTarget_GrPlatformSurfaceType; -- cgit v1.2.3