diff -r 000000000000 -r 6474c204b198 gfx/skia/trunk/src/gpu/GrGpuFactory.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gfx/skia/trunk/src/gpu/GrGpuFactory.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,43 @@ + +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + +#include "GrTypes.h" + +#include "gl/GrGLConfig.h" + +#include "GrGpu.h" +#include "gl/GrGpuGL.h" + +GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) { + + const GrGLInterface* glInterface = NULL; + SkAutoTUnref glInterfaceUnref; + + if (kOpenGL_GrBackend == backend) { + glInterface = reinterpret_cast(backendContext); + if (NULL == glInterface) { + glInterface = GrGLDefaultInterface(); + // By calling GrGLDefaultInterface we've taken a ref on the + // returned object. We only want to hold that ref until after + // the GrGpu is constructed and has taken ownership. + glInterfaceUnref.reset(glInterface); + } + if (NULL == glInterface) { +#ifdef SK_DEBUG + GrPrintf("No GL interface provided!\n"); +#endif + return NULL; + } + GrGLContext ctx(glInterface); + if (ctx.isInitialized()) { + return SkNEW_ARGS(GrGpuGL, (ctx, context)); + } + } + return NULL; +}