blob: 585f35f6ab22801414db33a6699004a10182f165 [file] [log] [blame]
/*
* 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"
// must be before GrGLConfig.h
#if GR_WIN32_BUILD
// #include "GrGpuD3D9.h"
#endif
#include "gl/GrGLConfig.h"
#include "GrGpu.h"
#include "gl/GrGpuGLShaders.h"
GrGpu* GrGpu::Create(GrEngine engine, GrPlatform3DContext context3D) {
const GrGLInterface* glInterface = NULL;
SkAutoTUnref<const GrGLInterface> glInterfaceUnref;
if (kOpenGL_Shaders_GrEngine == engine) {
glInterface = reinterpret_cast<const GrGLInterface*>(context3D);
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) {
#if GR_DEBUG
GrPrintf("No GL interface provided!\n");
#endif
return NULL;
}
GrGLContextInfo ctxInfo(glInterface);
if (ctxInfo.isInitialized()) {
return new GrGpuGLShaders(ctxInfo);
}
}
return NULL;
}