1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/gpu/GrGpuFactory.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,43 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "GrTypes.h" 1.14 + 1.15 +#include "gl/GrGLConfig.h" 1.16 + 1.17 +#include "GrGpu.h" 1.18 +#include "gl/GrGpuGL.h" 1.19 + 1.20 +GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) { 1.21 + 1.22 + const GrGLInterface* glInterface = NULL; 1.23 + SkAutoTUnref<const GrGLInterface> glInterfaceUnref; 1.24 + 1.25 + if (kOpenGL_GrBackend == backend) { 1.26 + glInterface = reinterpret_cast<const GrGLInterface*>(backendContext); 1.27 + if (NULL == glInterface) { 1.28 + glInterface = GrGLDefaultInterface(); 1.29 + // By calling GrGLDefaultInterface we've taken a ref on the 1.30 + // returned object. We only want to hold that ref until after 1.31 + // the GrGpu is constructed and has taken ownership. 1.32 + glInterfaceUnref.reset(glInterface); 1.33 + } 1.34 + if (NULL == glInterface) { 1.35 +#ifdef SK_DEBUG 1.36 + GrPrintf("No GL interface provided!\n"); 1.37 +#endif 1.38 + return NULL; 1.39 + } 1.40 + GrGLContext ctx(glInterface); 1.41 + if (ctx.isInitialized()) { 1.42 + return SkNEW_ARGS(GrGpuGL, (ctx, context)); 1.43 + } 1.44 + } 1.45 + return NULL; 1.46 +}