2011-10-24 21:17:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
|
2012-08-03 15:00:52 +00:00
|
|
|
|
|
|
|
#include "Test.h"
|
2012-08-02 14:03:32 +00:00
|
|
|
// This is a GPU-backend specific test
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
#include "gl/SkANGLEGLContext.h"
|
|
|
|
#endif
|
2012-02-14 15:11:59 +00:00
|
|
|
#include "gl/SkNativeGLContext.h"
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_MESA
|
2012-02-14 15:11:59 +00:00
|
|
|
#include "gl/SkMesaGLContext.h"
|
2012-03-28 16:19:11 +00:00
|
|
|
#endif
|
2011-10-24 21:17:53 +00:00
|
|
|
|
|
|
|
static void GLInterfaceValidationTest(skiatest::Reporter* reporter) {
|
|
|
|
typedef const GrGLInterface* (*interfaceFactory)();
|
|
|
|
struct {
|
|
|
|
interfaceFactory fFactory;
|
|
|
|
const char* fName;
|
|
|
|
} interfaceFactories[] = {
|
2012-03-28 16:19:11 +00:00
|
|
|
#if SK_ANGLE
|
|
|
|
{GrGLCreateANGLEInterface, "ANGLE"},
|
|
|
|
#endif
|
2011-10-24 21:17:53 +00:00
|
|
|
{GrGLCreateNativeInterface, "Native"},
|
|
|
|
#if SK_MESA
|
|
|
|
{GrGLCreateMesaInterface, "Mesa"},
|
|
|
|
#endif
|
2012-03-28 16:19:11 +00:00
|
|
|
{GrGLCreateDebugInterface, "Debug"},
|
2011-10-27 20:44:19 +00:00
|
|
|
{GrGLCreateNullInterface, "Null"},
|
2011-10-24 21:17:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// On some platforms GrGLCreateNativeInterface will fail unless an OpenGL
|
|
|
|
// context has been created. Also, preserve the current context that may
|
|
|
|
// be in use by outer test harness.
|
|
|
|
SkNativeGLContext::AutoContextRestore nglacr;
|
|
|
|
SkNativeGLContext nglctx;
|
|
|
|
static const int gBOGUS_SIZE = 16;
|
|
|
|
bool nativeContextInit = nglctx.init(gBOGUS_SIZE, gBOGUS_SIZE);
|
|
|
|
REPORTER_ASSERT(reporter, nativeContextInit);
|
|
|
|
if (!nativeContextInit) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#if SK_MESA
|
|
|
|
// We must have a current OSMesa context to initialize an OSMesa
|
|
|
|
// GrGLInterface
|
|
|
|
SkMesaGLContext::AutoContextRestore mglacr;
|
|
|
|
SkMesaGLContext mglctx;
|
|
|
|
bool mesaContextInit = mglctx.init(gBOGUS_SIZE, gBOGUS_SIZE);
|
|
|
|
REPORTER_ASSERT(reporter, mesaContextInit);
|
|
|
|
if(!mesaContextInit) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
SkAutoTUnref<const GrGLInterface> iface;
|
|
|
|
for (size_t i = 0; i < SK_ARRAY_COUNT(interfaceFactories); ++i) {
|
|
|
|
iface.reset(interfaceFactories[i].fFactory());
|
|
|
|
REPORTER_ASSERT(reporter, NULL != iface.get());
|
|
|
|
if (iface.get()) {
|
2012-02-10 20:25:36 +00:00
|
|
|
for (GrGLBinding binding = kFirstGrGLBinding;
|
2012-02-10 20:05:18 +00:00
|
|
|
binding <= kLastGrGLBinding;
|
|
|
|
binding = static_cast<GrGLBinding>(binding << 1)) {
|
|
|
|
if (iface.get()->fBindingsExported & binding) {
|
|
|
|
REPORTER_ASSERT(reporter, iface.get()->validate(binding));
|
|
|
|
}
|
|
|
|
}
|
2011-10-24 21:17:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "TestClassDef.h"
|
|
|
|
DEFINE_TESTCLASS("GLInterfaceValidation",
|
|
|
|
GLInterfaceValidationTestClass,
|
|
|
|
GLInterfaceValidationTest)
|
|
|
|
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|