Add MESA detection to GrContextInfo and use to decide whether to use GL_ALPHA or GL_RED.
Based on yunchao.he@intel.com's original change here: https://codereview.chromium.org/15994006/ R=yunchao.he@intel.com, robertphillips@google.com Author: bsalomon@google.com Review URL: https://chromiumcodereview.appspot.com/16955005 git-svn-id: http://skia.googlecode.com/svn/trunk@9608 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
61c49f357a
commit
459104ceea
@ -164,10 +164,15 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) {
|
||||
ctxInfo.hasExtension("GL_ARB_texture_storage") ||
|
||||
ctxInfo.hasExtension("GL_EXT_texture_storage");
|
||||
|
||||
// ARB_texture_rg is part of OpenGL 3.0
|
||||
// ARB_texture_rg is part of OpenGL 3.0, but mesa doesn't support it if
|
||||
// it doesn't have ARB_texture_rg extension.
|
||||
if (kDesktop_GrGLBinding == binding) {
|
||||
if (ctxInfo.isMesa()) {
|
||||
fTextureRedSupport = ctxInfo.hasExtension("GL_ARB_texture_rg");
|
||||
} else {
|
||||
fTextureRedSupport = version >= GR_GL_VER(3,0) ||
|
||||
ctxInfo.hasExtension("GL_ARB_texture_rg");
|
||||
}
|
||||
} else {
|
||||
fTextureRedSupport = ctxInfo.hasExtension("GL_EXT_texture_rg");
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ GrGLContextInfo& GrGLContextInfo::operator= (const GrGLContextInfo& ctxInfo) {
|
||||
fGLSLGeneration = ctxInfo.fGLSLGeneration;
|
||||
fVendor = ctxInfo.fVendor;
|
||||
fExtensions = ctxInfo.fExtensions;
|
||||
fIsMesa = ctxInfo.fIsMesa;
|
||||
*fGLCaps = *ctxInfo.fGLCaps.get();
|
||||
return *this;
|
||||
}
|
||||
@ -36,6 +37,9 @@ bool GrGLContextInfo::initialize(const GrGLInterface* interface) {
|
||||
fGLSLGeneration = GrGetGLSLGeneration(fBindingInUse, interface);
|
||||
|
||||
fVendor = GrGLGetVendor(interface);
|
||||
|
||||
fIsMesa = GrGLIsMesaFromVersionString(ver);
|
||||
|
||||
fGLCaps->init(*this, interface);
|
||||
return true;
|
||||
}
|
||||
@ -52,6 +56,7 @@ void GrGLContextInfo::reset() {
|
||||
fGLVersion = GR_GL_VER(0, 0);
|
||||
fGLSLGeneration = static_cast<GrGLSLGeneration>(0);
|
||||
fVendor = kOther_GrGLVendor;
|
||||
fIsMesa = false;
|
||||
fExtensions.reset();
|
||||
fGLCaps->reset();
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public:
|
||||
GrGLVersion version() const { return fGLVersion; }
|
||||
GrGLSLGeneration glslGeneration() const { return fGLSLGeneration; }
|
||||
GrGLVendor vendor() const { return fVendor; }
|
||||
/** Is this a mesa-based driver. Does not mean it is the osmesa software rasterizer. */
|
||||
bool isMesa() const { return fIsMesa; }
|
||||
const GrGLCaps* caps() const { return fGLCaps.get(); }
|
||||
GrGLCaps* caps() { return fGLCaps; }
|
||||
const GrGLExtensions& extensions() const { return fExtensions; }
|
||||
@ -73,6 +75,7 @@ private:
|
||||
GrGLSLGeneration fGLSLGeneration;
|
||||
GrGLVendor fVendor;
|
||||
GrGLExtensions fExtensions;
|
||||
bool fIsMesa;
|
||||
SkAutoTUnref<GrGLCaps> fGLCaps;
|
||||
};
|
||||
|
||||
|
@ -121,6 +121,12 @@ GrGLBinding GrGLGetBindingInUseFromString(const char* versionString) {
|
||||
return kNone_GrGLBinding;
|
||||
}
|
||||
|
||||
bool GrGLIsMesaFromVersionString(const char* versionString) {
|
||||
int major, minor, mesaMajor, mesaMinor;
|
||||
int n = sscanf(versionString, "%d.%d Mesa %d.%d", &major, &minor, &mesaMajor, &mesaMinor);
|
||||
return 4 == n;
|
||||
}
|
||||
|
||||
GrGLVersion GrGLGetVersionFromString(const char* versionString) {
|
||||
if (NULL == versionString) {
|
||||
GrAssert(!"NULL GL version string.");
|
||||
|
@ -71,6 +71,7 @@ enum GrGLVendor {
|
||||
GrGLVersion GrGLGetVersionFromString(const char* versionString);
|
||||
GrGLBinding GrGLGetBindingInUseFromString(const char* versionString);
|
||||
GrGLSLVersion GrGLGetGLSLVersionFromString(const char* versionString);
|
||||
bool GrGLIsMesaFromVersionString(const char* versionString);
|
||||
GrGLVendor GrGLGetVendorFromString(const char* vendorString);
|
||||
|
||||
// these variants call glGetString()
|
||||
|
Loading…
Reference in New Issue
Block a user