Simplify the GL interface validation test.
Review URL: https://codereview.chromium.org/12703003 git-svn-id: http://skia.googlecode.com/svn/trunk@8077 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
8a8fcba5b6
commit
7fa1bb4133
@ -12,76 +12,22 @@
|
|||||||
// This is a GPU-backend specific test
|
// This is a GPU-backend specific test
|
||||||
#if SK_SUPPORT_GPU
|
#if SK_SUPPORT_GPU
|
||||||
|
|
||||||
#if SK_ANGLE
|
#include "GrContextFactory.h"
|
||||||
#include "gl/SkANGLEGLContext.h"
|
|
||||||
#endif
|
|
||||||
#include "gl/SkNativeGLContext.h"
|
|
||||||
#if SK_MESA
|
|
||||||
#include "gl/SkMesaGLContext.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void GLInterfaceValidationTest(skiatest::Reporter* reporter) {
|
static void GLInterfaceValidationTest(skiatest::Reporter* reporter, GrContextFactory* factory) {
|
||||||
typedef const GrGLInterface* (*interfaceFactory)();
|
for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
|
||||||
struct {
|
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
|
||||||
interfaceFactory fFactory;
|
// this forces the factory to make the context if it hasn't yet
|
||||||
const char* fName;
|
factory->get(glCtxType);
|
||||||
} interfaceFactories[] = {
|
SkGLContextHelper* glCtxHelper = factory->getGLContext(glCtxType);
|
||||||
#if SK_ANGLE
|
REPORTER_ASSERT(reporter, NULL != glCtxHelper);
|
||||||
{GrGLCreateANGLEInterface, "ANGLE"},
|
if (NULL != glCtxHelper) {
|
||||||
#endif
|
const GrGLInterface* interface = glCtxHelper->gl();
|
||||||
{GrGLCreateNativeInterface, "Native"},
|
|
||||||
#if SK_MESA
|
|
||||||
{GrGLCreateMesaInterface, "Mesa"},
|
|
||||||
#endif
|
|
||||||
{GrGLCreateDebugInterface, "Debug"},
|
|
||||||
{GrGLCreateNullInterface, "Null"},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int kBogusSize = 16;
|
|
||||||
|
|
||||||
#if SK_ANGLE
|
|
||||||
SkANGLEGLContext::AutoContextRestore angleACR;
|
|
||||||
SkANGLEGLContext angleContext;
|
|
||||||
bool angleContextInit = angleContext.init(kBogusSize, kBogusSize);
|
|
||||||
REPORTER_ASSERT(reporter, angleContextInit);
|
|
||||||
if (!angleContextInit) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
bool nativeContextInit = nglctx.init(kBogusSize, kBogusSize);
|
|
||||||
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(kBogusSize, kBogusSize);
|
|
||||||
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()) {
|
|
||||||
for (GrGLBinding binding = kFirstGrGLBinding;
|
for (GrGLBinding binding = kFirstGrGLBinding;
|
||||||
binding <= kLastGrGLBinding;
|
binding <= kLastGrGLBinding;
|
||||||
binding = static_cast<GrGLBinding>(binding << 1)) {
|
binding = static_cast<GrGLBinding>(binding << 1)) {
|
||||||
if (iface.get()->fBindingsExported & binding) {
|
if (interface->fBindingsExported & binding) {
|
||||||
REPORTER_ASSERT(reporter, iface.get()->validate(binding));
|
REPORTER_ASSERT(reporter, interface->validate(binding));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +36,7 @@ static void GLInterfaceValidationTest(skiatest::Reporter* reporter) {
|
|||||||
|
|
||||||
|
|
||||||
#include "TestClassDef.h"
|
#include "TestClassDef.h"
|
||||||
DEFINE_TESTCLASS("GLInterfaceValidation",
|
DEFINE_GPUTESTCLASS("GLInterfaceValidation",
|
||||||
GLInterfaceValidationTestClass,
|
GLInterfaceValidationTestClass,
|
||||||
GLInterfaceValidationTest)
|
GLInterfaceValidationTest)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user