skia2/tests/GLInterfaceValidationTest.cpp
kkinnunen 30bc88ccd5 Refactor SkGLContext to be actually extendable
Refactor SkGLContext to be actually extendable. Before, non-trivial subclass
would need to destroy the GL connection upon running the destructor. However,
the base class would run GL commands in its own destructor (with destroyed GL
connection)

Refactor so that SkGLContext subclass object creation is completely done by
the factory function. If the factory function returns a non-NULL ptr, it means the context
is usable.

The destruction is done with the destructor instead of virtual function called
upon destruction. Make the destructors not to call virtual functions, for
clarity.

Remove custom 1x1 FBO setup code from the base class. It appears not to be used
anymore.

BUG=skia:2992

Review URL: https://codereview.chromium.org/640283004
2014-10-15 23:03:54 -07:00

40 lines
1.3 KiB
C++
Executable File

/*
* 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 "Test.h"
// This is a GPU-backend specific test
#if SK_SUPPORT_GPU
#include "GrContextFactory.h"
DEF_GPUTEST(GLInterfaceValidation, reporter, factory) {
for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) {
GrContextFactory::GLContextType glCtxType = (GrContextFactory::GLContextType)i;
// this forces the factory to make the context if it hasn't yet
factory->get(glCtxType);
SkGLContext* glCtx = factory->getGLContext(glCtxType);
// We're supposed to fail the NVPR context type when we the native context that does not
// support the NVPR extension.
if (GrContextFactory::kNVPR_GLContextType == glCtxType &&
factory->getGLContext(GrContextFactory::kNative_GLContextType) &&
!factory->getGLContext(GrContextFactory::kNative_GLContextType)->gl()->hasExtension("GL_NV_path_rendering")) {
REPORTER_ASSERT(reporter, NULL == glCtx);
continue;
}
REPORTER_ASSERT(reporter, glCtx);
if (glCtx) {
const GrGLInterface* interface = glCtx->gl();
REPORTER_ASSERT(reporter, interface->validate());
}
}
}
#endif