Fail to create GrContext when we get a NULL for a GL/GLSL version string
BUG=368107 R=jvanverth@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/254083002 git-svn-id: http://skia.googlecode.com/svn/trunk@14452 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
359e4f0a5d
commit
f4e67e3e5e
@ -27,7 +27,7 @@ const GrGLInterface* GrGLAssembleGLInterface(void* ctx, GrGLGetProc get) {
|
|||||||
const char* versionString = (const char*) GetString(GR_GL_VERSION);
|
const char* versionString = (const char*) GetString(GR_GL_VERSION);
|
||||||
GrGLVersion glVer = GrGLGetVersionFromString(versionString);
|
GrGLVersion glVer = GrGLGetVersionFromString(versionString);
|
||||||
|
|
||||||
if (glVer < GR_GL_VER(1,5)) {
|
if (glVer < GR_GL_VER(1,5) || GR_GL_INVALID_VER == glVer) {
|
||||||
// We must have array and element_array buffer objects.
|
// We must have array and element_array buffer objects.
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,11 @@ GrGLCaps& GrGLCaps::operator= (const GrGLCaps& caps) {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
bool GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
||||||
|
|
||||||
this->reset();
|
this->reset();
|
||||||
if (!ctxInfo.isInitialized()) {
|
if (!ctxInfo.isInitialized()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGLStandard standard = ctxInfo.standard();
|
GrGLStandard standard = ctxInfo.standard();
|
||||||
@ -353,6 +353,8 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->initConfigRenderableTable(ctxInfo);
|
this->initConfigRenderableTable(ctxInfo);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
|
void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
* Initializes the GrGLCaps to the set of features supported in the current
|
* Initializes the GrGLCaps to the set of features supported in the current
|
||||||
* OpenGL context accessible via ctxInfo.
|
* OpenGL context accessible via ctxInfo.
|
||||||
*/
|
*/
|
||||||
void init(const GrGLContextInfo& ctxInfo, const GrGLInterface* interface);
|
bool init(const GrGLContextInfo& ctxInfo, const GrGLInterface* interface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call to note that a color config has been verified as a valid color
|
* Call to note that a color config has been verified as a valid color
|
||||||
|
@ -37,8 +37,13 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
|
|||||||
if (interface->validate()) {
|
if (interface->validate()) {
|
||||||
|
|
||||||
fGLVersion = GrGLGetVersionFromString(ver);
|
fGLVersion = GrGLGetVersionFromString(ver);
|
||||||
|
if (GR_GL_INVALID_VER == fGLVersion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
fGLSLGeneration = GrGetGLSLGeneration(interface);
|
if (!GrGetGLSLGeneration(interface, &fGLSLGeneration)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
fVendor = GrGLGetVendor(interface);
|
fVendor = GrGLGetVendor(interface);
|
||||||
|
|
||||||
@ -51,9 +56,7 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
|
|||||||
// This must occur before caps init.
|
// This must occur before caps init.
|
||||||
fInterface.reset(SkRef(interface));
|
fInterface.reset(SkRef(interface));
|
||||||
|
|
||||||
fGLCaps->init(*this, interface);
|
return fGLCaps->init(*this, interface);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -54,10 +54,11 @@ bool GrGLExtensions::init(GrGLStandard standard,
|
|||||||
|
|
||||||
// glGetStringi and indexed extensions were added in version 3.0 of desktop GL and ES.
|
// glGetStringi and indexed extensions were added in version 3.0 of desktop GL and ES.
|
||||||
const GrGLubyte* verString = getString(GR_GL_VERSION);
|
const GrGLubyte* verString = getString(GR_GL_VERSION);
|
||||||
if (NULL == verString) {
|
GrGLVersion version = GrGLGetVersionFromString((const char*) verString);
|
||||||
|
if (GR_GL_INVALID_VER == version) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
GrGLVersion version = GrGLGetVersionFromString((const char*) verString);
|
|
||||||
bool indexed = version >= GR_GL_VER(3, 0);
|
bool indexed = version >= GR_GL_VER(3, 0);
|
||||||
|
|
||||||
if (indexed) {
|
if (indexed) {
|
||||||
|
@ -227,6 +227,9 @@ bool GrGLInterface::validate() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrGLVersion glVer = GrGLGetVersion(this);
|
GrGLVersion glVer = GrGLGetVersion(this);
|
||||||
|
if (GR_GL_INVALID_VER == glVer) {
|
||||||
|
RETURN_FALSE_INTERFACE
|
||||||
|
}
|
||||||
|
|
||||||
// Now check that baseline ES/Desktop fns not covered above are present
|
// Now check that baseline ES/Desktop fns not covered above are present
|
||||||
// and that we have fn pointers for any advertised fExtensions that we will
|
// and that we have fn pointers for any advertised fExtensions that we will
|
||||||
|
@ -9,27 +9,33 @@
|
|||||||
#include "GrGLShaderVar.h"
|
#include "GrGLShaderVar.h"
|
||||||
#include "SkString.h"
|
#include "SkString.h"
|
||||||
|
|
||||||
GrGLSLGeneration GrGetGLSLGeneration(const GrGLInterface* gl) {
|
bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation) {
|
||||||
|
SkASSERT(NULL != generation);
|
||||||
GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
|
GrGLSLVersion ver = GrGLGetGLSLVersion(gl);
|
||||||
|
if (GR_GLSL_INVALID_VER == ver) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (gl->fStandard) {
|
switch (gl->fStandard) {
|
||||||
case kGL_GrGLStandard:
|
case kGL_GrGLStandard:
|
||||||
SkASSERT(ver >= GR_GLSL_VER(1,10));
|
SkASSERT(ver >= GR_GLSL_VER(1,10));
|
||||||
if (ver >= GR_GLSL_VER(1,50)) {
|
if (ver >= GR_GLSL_VER(1,50)) {
|
||||||
return k150_GrGLSLGeneration;
|
*generation = k150_GrGLSLGeneration;
|
||||||
} else if (ver >= GR_GLSL_VER(1,40)) {
|
} else if (ver >= GR_GLSL_VER(1,40)) {
|
||||||
return k140_GrGLSLGeneration;
|
*generation = k140_GrGLSLGeneration;
|
||||||
} else if (ver >= GR_GLSL_VER(1,30)) {
|
} else if (ver >= GR_GLSL_VER(1,30)) {
|
||||||
return k130_GrGLSLGeneration;
|
*generation = k130_GrGLSLGeneration;
|
||||||
} else {
|
} else {
|
||||||
return k110_GrGLSLGeneration;
|
*generation = k110_GrGLSLGeneration;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
case kGLES_GrGLStandard:
|
case kGLES_GrGLStandard:
|
||||||
// version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL
|
// version 1.00 of ES GLSL based on ver 1.20 of desktop GLSL
|
||||||
SkASSERT(ver >= GR_GL_VER(1,00));
|
SkASSERT(ver >= GR_GL_VER(1,00));
|
||||||
return k110_GrGLSLGeneration;
|
*generation = k110_GrGLSLGeneration;
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
GrCrash("Unknown GL Standard");
|
GrCrash("Unknown GL Standard");
|
||||||
return k110_GrGLSLGeneration; // suppress warning
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ enum GrGLSLGeneration {
|
|||||||
/**
|
/**
|
||||||
* Gets the most recent GLSL Generation compatible with the OpenGL context.
|
* Gets the most recent GLSL Generation compatible with the OpenGL context.
|
||||||
*/
|
*/
|
||||||
GrGLSLGeneration GrGetGLSLGeneration(const GrGLInterface* gl);
|
bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a string to include at the beginning of a shader to declare the GLSL
|
* Returns a string to include at the beginning of a shader to declare the GLSL
|
||||||
|
@ -140,7 +140,7 @@ bool GrGLIsChromiumFromRendererString(const char* rendererString) {
|
|||||||
GrGLVersion GrGLGetVersionFromString(const char* versionString) {
|
GrGLVersion GrGLGetVersionFromString(const char* versionString) {
|
||||||
if (NULL == versionString) {
|
if (NULL == versionString) {
|
||||||
SkDEBUGFAIL("NULL GL version string.");
|
SkDEBUGFAIL("NULL GL version string.");
|
||||||
return 0;
|
return GR_GL_INVALID_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int major, minor;
|
int major, minor;
|
||||||
@ -152,7 +152,7 @@ GrGLVersion GrGLGetVersionFromString(const char* versionString) {
|
|||||||
if (get_gl_version_for_mesa(mesaMajor, &major, &minor)) {
|
if (get_gl_version_for_mesa(mesaMajor, &major, &minor)) {
|
||||||
return GR_GL_VER(major, minor);
|
return GR_GL_VER(major, minor);
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return GR_GL_INVALID_VER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,13 +173,13 @@ GrGLVersion GrGLGetVersionFromString(const char* versionString) {
|
|||||||
return GR_GL_VER(major, minor);
|
return GR_GL_VER(major, minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return GR_GL_INVALID_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) {
|
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) {
|
||||||
if (NULL == versionString) {
|
if (NULL == versionString) {
|
||||||
SkDEBUGFAIL("NULL GLSL version string.");
|
SkDEBUGFAIL("NULL GLSL version string.");
|
||||||
return 0;
|
return GR_GLSL_INVALID_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int major, minor;
|
int major, minor;
|
||||||
@ -202,7 +202,7 @@ GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return GR_GLSL_INVALID_VER;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGLVendor GrGLGetVendorFromString(const char* vendorString) {
|
GrGLVendor GrGLGetVendorFromString(const char* vendorString) {
|
||||||
|
@ -18,6 +18,14 @@ class SkMatrix;
|
|||||||
typedef uint32_t GrGLVersion;
|
typedef uint32_t GrGLVersion;
|
||||||
typedef uint32_t GrGLSLVersion;
|
typedef uint32_t GrGLSLVersion;
|
||||||
|
|
||||||
|
#define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
||||||
|
static_cast<int>(minor))
|
||||||
|
#define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
||||||
|
static_cast<int>(minor))
|
||||||
|
|
||||||
|
#define GR_GL_INVALID_VER GR_GL_VER(0, 0)
|
||||||
|
#define GR_GLSL_INVALID_VER GR_GL_VER(0, 0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Vendor and Renderer enum values are lazily updated as required.
|
* The Vendor and Renderer enum values are lazily updated as required.
|
||||||
*/
|
*/
|
||||||
@ -37,11 +45,6 @@ enum GrGLRenderer {
|
|||||||
kOther_GrGLRenderer
|
kOther_GrGLRenderer
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GR_GL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
|
||||||
static_cast<int>(minor))
|
|
||||||
#define GR_GLSL_VER(major, minor) ((static_cast<int>(major) << 16) | \
|
|
||||||
static_cast<int>(minor))
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user