michael@0: michael@0: /* michael@0: * Copyright 2011 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "GrTypes.h" michael@0: michael@0: #include "gl/GrGLConfig.h" michael@0: michael@0: #include "GrGpu.h" michael@0: #include "gl/GrGpuGL.h" michael@0: michael@0: GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) { michael@0: michael@0: const GrGLInterface* glInterface = NULL; michael@0: SkAutoTUnref glInterfaceUnref; michael@0: michael@0: if (kOpenGL_GrBackend == backend) { michael@0: glInterface = reinterpret_cast(backendContext); michael@0: if (NULL == glInterface) { michael@0: glInterface = GrGLDefaultInterface(); michael@0: // By calling GrGLDefaultInterface we've taken a ref on the michael@0: // returned object. We only want to hold that ref until after michael@0: // the GrGpu is constructed and has taken ownership. michael@0: glInterfaceUnref.reset(glInterface); michael@0: } michael@0: if (NULL == glInterface) { michael@0: #ifdef SK_DEBUG michael@0: GrPrintf("No GL interface provided!\n"); michael@0: #endif michael@0: return NULL; michael@0: } michael@0: GrGLContext ctx(glInterface); michael@0: if (ctx.isInitialized()) { michael@0: return SkNEW_ARGS(GrGpuGL, (ctx, context)); michael@0: } michael@0: } michael@0: return NULL; michael@0: }