Hide formats in GrGLCaps and use specific getters for different GL functions.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1580003002 Review URL: https://codereview.chromium.org/1580003002
This commit is contained in:
parent
368342ccb5
commit
76148af6df
@ -630,14 +630,18 @@ bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
|
|||||||
GrPixelConfig currFBOConfig) const {
|
GrPixelConfig currFBOConfig) const {
|
||||||
SkASSERT(this->isConfigRenderable(currFBOConfig, false));
|
SkASSERT(this->isConfigRenderable(currFBOConfig, false));
|
||||||
|
|
||||||
|
GrGLenum readFormat;
|
||||||
|
GrGLenum readType;
|
||||||
|
if (!this->getReadPixelsFormat(currFBOConfig, readConfig, &readFormat, &readType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (kGL_GrGLStandard == intf->fStandard) {
|
if (kGL_GrGLStandard == intf->fStandard) {
|
||||||
// All of our renderable configs can be converted to each other by glReadPixels in OpenGL.
|
// All of our renderable configs can be converted to each other by glReadPixels in OpenGL.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// See Section 16.1.2 in the ES 3.2 specification.
|
|
||||||
|
|
||||||
GrGLenum readFormat = fConfigTable[readConfig].fFormats.fExternalFormat;
|
// See Section 16.1.2 in the ES 3.2 specification.
|
||||||
GrGLenum readType = fConfigTable[readConfig].fFormats.fExternalType;
|
|
||||||
|
|
||||||
if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatType) {
|
if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatType) {
|
||||||
if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) {
|
if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) {
|
||||||
@ -886,15 +890,17 @@ SkString GrGLCaps::dump() const {
|
|||||||
r.append("Configs\n-------\n");
|
r.append("Configs\n-------\n");
|
||||||
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
||||||
r.appendf(" cfg: %d flags: 0x%04x, b_internal: 0x%08x s_internal: 0x%08x, e_format: "
|
r.appendf(" cfg: %d flags: 0x%04x, b_internal: 0x%08x s_internal: 0x%08x, e_format: "
|
||||||
"0x%08x, e_type: 0x%08x, i_for_teximage: 0x%08x, e_for_teximage: 0x%08x\n",
|
"0x%08x, e_format_teximage: 0x%08x, e_type: 0x%08x, i_for_teximage: 0x%08x, "
|
||||||
|
"i_for_renderbuffer: 0x%08x\n",
|
||||||
i,
|
i,
|
||||||
fConfigTable[i].fFlags,
|
fConfigTable[i].fFlags,
|
||||||
fConfigTable[i].fFormats.fBaseInternalFormat,
|
fConfigTable[i].fFormats.fBaseInternalFormat,
|
||||||
fConfigTable[i].fFormats.fSizedInternalFormat,
|
fConfigTable[i].fFormats.fSizedInternalFormat,
|
||||||
fConfigTable[i].fFormats.fExternalFormat,
|
fConfigTable[i].fFormats.fExternalFormat[kOther_ExternalFormatUsage],
|
||||||
|
fConfigTable[i].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage],
|
||||||
fConfigTable[i].fFormats.fExternalType,
|
fConfigTable[i].fFormats.fExternalType,
|
||||||
fConfigTable[i].fFormats.fInternalFormatTexImage,
|
fConfigTable[i].fFormats.fInternalFormatTexImage,
|
||||||
fConfigTable[i].fFormats.fExternalFormatForTexImage);
|
fConfigTable[i].fFormats.fInternalFormatRenderbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
@ -988,6 +994,66 @@ bool GrGLCaps::bgraIsInternalFormat() const {
|
|||||||
return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat == GR_GL_BGRA;
|
return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat == GR_GL_BGRA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GrGLCaps::getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
|
||||||
|
GrGLenum* internalFormat, GrGLenum* externalFormat,
|
||||||
|
GrGLenum* externalType) const {
|
||||||
|
if (!this->getExternalFormat(surfaceConfig, externalConfig, kTexImage_ExternalFormatUsage,
|
||||||
|
externalFormat, externalType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*internalFormat = fConfigTable[surfaceConfig].fFormats.fInternalFormatTexImage;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GrGLCaps::getCompressedTexImageFormats(GrPixelConfig surfaceConfig,
|
||||||
|
GrGLenum* internalFormat) const {
|
||||||
|
if (!GrPixelConfigIsCompressed(surfaceConfig)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*internalFormat = fConfigTable[surfaceConfig].fFormats.fInternalFormatTexImage;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GrGLCaps::getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
|
||||||
|
GrGLenum* externalFormat, GrGLenum* externalType) const {
|
||||||
|
if (!this->getExternalFormat(surfaceConfig, externalConfig, kOther_ExternalFormatUsage,
|
||||||
|
externalFormat, externalType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GrGLCaps::getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const {
|
||||||
|
if (GrPixelConfigIsCompressed(config)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*internalFormat = fConfigTable[config].fFormats.fInternalFormatRenderbuffer;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GrGLCaps::getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
|
||||||
|
ExternalFormatUsage usage, GrGLenum* externalFormat,
|
||||||
|
GrGLenum* externalType) const {
|
||||||
|
SkASSERT(externalFormat && externalType);
|
||||||
|
if (GrPixelConfigIsCompressed(memoryConfig) || GrPixelConfigIsCompressed(memoryConfig)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool surfaceIsAlphaOnly = GrPixelConfigIsAlphaOnly(surfaceConfig);
|
||||||
|
bool memoryIsAlphaOnly = GrPixelConfigIsAlphaOnly(memoryConfig);
|
||||||
|
|
||||||
|
// We don't currently support moving RGBA data into and out of ALPHA surfaces. It could be
|
||||||
|
// made to work in many cases using glPixelStore and what not but is not needed currently.
|
||||||
|
if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage];
|
||||||
|
*externalType = fConfigTable[memoryConfig].fFormats.fExternalType;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli,
|
void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli,
|
||||||
GrGLSLCaps* glslCaps) {
|
GrGLSLCaps* glslCaps) {
|
||||||
/*
|
/*
|
||||||
@ -1069,14 +1135,15 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
|
fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
|
||||||
fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
|
fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
|
||||||
fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0;
|
fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
|
||||||
fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0;
|
fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0;
|
||||||
fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
|
fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
|
||||||
|
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA8;
|
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA8;
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
|
fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
|
||||||
@ -1091,7 +1158,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
}
|
}
|
||||||
fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
|
fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
|
||||||
|
|
||||||
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA;
|
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_BGRA;
|
||||||
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||||
fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
if (kGL_GrGLStandard == standard) {
|
if (kGL_GrGLStandard == standard) {
|
||||||
@ -1152,7 +1220,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8;
|
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_SRGB8_ALPHA8;
|
||||||
// GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the
|
// GL does not do srgb<->rgb conversions when transferring between cpu and gpu. Thus, the
|
||||||
// external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]Image.
|
// external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]Image.
|
||||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
|
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RGBA;
|
||||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
if (srgbSupport) {
|
if (srgbSupport) {
|
||||||
@ -1167,7 +1236,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
} else {
|
} else {
|
||||||
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGB5;
|
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGB5;
|
||||||
}
|
}
|
||||||
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB;
|
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RGB;
|
||||||
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_SHORT_5_6_5;
|
fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_SHORT_5_6_5;
|
||||||
fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
|
fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
|
||||||
@ -1182,7 +1252,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA4;
|
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA4;
|
||||||
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_SHORT_4_4_4_4;
|
fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_SHORT_4_4_4_4;
|
||||||
fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
|
fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
|
||||||
@ -1198,12 +1269,14 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
if (this->textureRedSupport()) {
|
if (this->textureRedSupport()) {
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R8;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R8;
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RED;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RED;
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
|
fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
|
||||||
} else {
|
} else {
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA;
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA8;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA8;
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_ALPHA;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_ALPHA;
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
|
fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
|
||||||
}
|
}
|
||||||
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED_BYTE;
|
||||||
@ -1248,7 +1321,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA32F;
|
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA32F;
|
||||||
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT;
|
fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT;
|
||||||
fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
|
fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
|
||||||
if (hasFPTextures) {
|
if (hasFPTextures) {
|
||||||
@ -1265,12 +1339,14 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
if (this->textureRedSupport()) {
|
if (this->textureRedSupport()) {
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
|
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RED;
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
|
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RED;
|
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage]
|
||||||
|
= GR_GL_RED;
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
|
fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
|
||||||
} else {
|
} else {
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA;
|
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ALPHA;
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
|
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_ALPHA;
|
fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage]
|
||||||
|
= GR_GL_ALPHA;
|
||||||
fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
|
fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
|
||||||
}
|
}
|
||||||
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
|
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
|
||||||
@ -1292,7 +1368,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RGBA;
|
||||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA16F;
|
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_RGBA16F;
|
||||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA;
|
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
GR_GL_RGBA;
|
||||||
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
|
if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER(3, 0)) {
|
||||||
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT;
|
fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HALF_FLOAT;
|
||||||
} else {
|
} else {
|
||||||
@ -1322,7 +1399,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PALETTE8_RGBA8;
|
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PALETTE8_RGBA8;
|
||||||
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_PALETTE8_RGBA8;
|
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_PALETTE8_RGBA8;
|
||||||
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0;
|
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
|
||||||
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0;
|
fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0;
|
||||||
fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
// Disable this for now, while we investigate https://bug.skia.org/4333
|
// Disable this for now, while we investigate https://bug.skia.org/4333
|
||||||
@ -1367,14 +1444,14 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
GR_GL_COMPRESSED_3DC_X;
|
GR_GL_COMPRESSED_3DC_X;
|
||||||
|
|
||||||
}
|
}
|
||||||
fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0;
|
fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
|
||||||
fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
|
fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
|
||||||
fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
|
fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
|
||||||
|
|
||||||
fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_ETC1_RGB8;
|
fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_ETC1_RGB8;
|
||||||
fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMPRESSED_ETC1_RGB8;
|
fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMPRESSED_ETC1_RGB8;
|
||||||
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0;
|
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
|
||||||
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
|
fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
|
||||||
fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
if (kGL_GrGLStandard == standard) {
|
if (kGL_GrGLStandard == standard) {
|
||||||
@ -1394,7 +1471,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_R11_EAC;
|
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPRESSED_R11_EAC;
|
||||||
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMPRESSED_R11_EAC;
|
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMPRESSED_R11_EAC;
|
||||||
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0;
|
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] = 0;
|
||||||
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
|
fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
|
||||||
fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
// Check for R11_EAC. We don't support R11_EAC on desktop, as most cards default to
|
// Check for R11_EAC. We don't support R11_EAC on desktop, as most cards default to
|
||||||
@ -1408,7 +1485,8 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
GR_GL_COMPRESSED_RGBA_ASTC_12x12;
|
GR_GL_COMPRESSED_RGBA_ASTC_12x12;
|
||||||
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat =
|
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat =
|
||||||
GR_GL_COMPRESSED_RGBA_ASTC_12x12;
|
GR_GL_COMPRESSED_RGBA_ASTC_12x12;
|
||||||
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0;
|
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFormatUsage] =
|
||||||
|
0;
|
||||||
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
|
fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
|
||||||
fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_FormatType;
|
||||||
if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
|
if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
|
||||||
@ -1421,13 +1499,21 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
// Bulk populate the texture internal/external formats here and then deal with exceptions below.
|
// Bulk populate the texture internal/external formats here and then deal with exceptions below.
|
||||||
|
|
||||||
// ES 2.0 requires that the internal/external formats match.
|
// ES 2.0 requires that the internal/external formats match.
|
||||||
bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() ||
|
bool useSizedTexFormats = (kGL_GrGLStandard == ctxInfo.standard() ||
|
||||||
ctxInfo.version() >= GR_GL_VER(3,0));
|
ctxInfo.version() >= GR_GL_VER(3,0));
|
||||||
|
// All ES versions (thus far) require sized internal formats for render buffers.
|
||||||
|
// TODO: Always use sized internal format?
|
||||||
|
bool useSizedRbFormats = kGLES_GrGLStandard == ctxInfo.standard();
|
||||||
|
|
||||||
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
||||||
// Almost always we want to pass fExternalFormat as the <format> param to glTex[Sub]Image.
|
// Almost always we want to pass fExternalFormat[kOther_ExternalFormatUsage] as the <format>
|
||||||
fConfigTable[i].fFormats.fExternalFormatForTexImage =
|
// param to glTex[Sub]Image.
|
||||||
fConfigTable[i].fFormats.fExternalFormat;
|
fConfigTable[i].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] =
|
||||||
fConfigTable[i].fFormats.fInternalFormatTexImage = useSizedFormats ?
|
fConfigTable[i].fFormats.fExternalFormat[kOther_ExternalFormatUsage];
|
||||||
|
fConfigTable[i].fFormats.fInternalFormatTexImage = useSizedTexFormats ?
|
||||||
|
fConfigTable[i].fFormats.fSizedInternalFormat :
|
||||||
|
fConfigTable[i].fFormats.fBaseInternalFormat;
|
||||||
|
fConfigTable[i].fFormats.fInternalFormatRenderbuffer = useSizedRbFormats ?
|
||||||
fConfigTable[i].fFormats.fSizedInternalFormat :
|
fConfigTable[i].fFormats.fSizedInternalFormat :
|
||||||
fConfigTable[i].fFormats.fBaseInternalFormat;
|
fConfigTable[i].fFormats.fBaseInternalFormat;
|
||||||
}
|
}
|
||||||
@ -1436,7 +1522,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
// Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param.
|
// Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param.
|
||||||
// On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param to glTexImage.
|
// On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param to glTexImage.
|
||||||
if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_VER(2,0)) {
|
if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_VER(2,0)) {
|
||||||
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormatForTexImage =
|
fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] =
|
||||||
GR_GL_SRGB_ALPHA;
|
GR_GL_SRGB_ALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1450,7 +1536,7 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
// ES 2.0: the extension makes BGRA an external format but not an internal format.
|
// ES 2.0: the extension makes BGRA an external format but not an internal format.
|
||||||
// ES 3.0: the extension explicitly states GL_BGRA8 is not a valid internal format for
|
// ES 3.0: the extension explicitly states GL_BGRA8 is not a valid internal format for
|
||||||
// glTexImage (just for glTexStorage).
|
// glTexImage (just for glTexStorage).
|
||||||
if (useSizedFormats && this->bgraIsInternalFormat()) {
|
if (useSizedTexFormats && this->bgraIsInternalFormat()) {
|
||||||
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA;
|
fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1464,17 +1550,19 @@ void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
|
|||||||
|
|
||||||
#ifdef SK_DEBUG
|
#ifdef SK_DEBUG
|
||||||
// Make sure we initialized everything.
|
// Make sure we initialized everything.
|
||||||
ConfigFormats defaultEntry;
|
ConfigInfo defaultEntry;
|
||||||
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
for (int i = 0; i < kGrPixelConfigCnt; ++i) {
|
||||||
SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fFormats.fBaseInternalFormat);
|
SkASSERT(defaultEntry.fFormats.fBaseInternalFormat !=
|
||||||
SkASSERT(defaultEntry.fSizedInternalFormat !=
|
fConfigTable[i].fFormats.fBaseInternalFormat);
|
||||||
|
SkASSERT(defaultEntry.fFormats.fSizedInternalFormat !=
|
||||||
fConfigTable[i].fFormats.fSizedInternalFormat);
|
fConfigTable[i].fFormats.fSizedInternalFormat);
|
||||||
SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExternalFormat);
|
for (int j = 0; j < kExternalFormatUsageCnt; ++j) {
|
||||||
SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExternalType);
|
SkASSERT(defaultEntry.fFormats.fExternalFormat[j] !=
|
||||||
|
fConfigTable[i].fFormats.fExternalFormat[j]);
|
||||||
|
}
|
||||||
|
SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats.fExternalType);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
|
void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,24 +29,6 @@ class GrGLCaps : public GrCaps {
|
|||||||
public:
|
public:
|
||||||
typedef GrGLStencilAttachment::Format StencilFormat;
|
typedef GrGLStencilAttachment::Format StencilFormat;
|
||||||
|
|
||||||
/** Provides information about the mappiing from GrPixelConfig to GL formats. */
|
|
||||||
struct ConfigFormats {
|
|
||||||
ConfigFormats() {
|
|
||||||
// Inits to known bad GL enum values.
|
|
||||||
memset(this, 0xAB, sizeof(ConfigFormats));
|
|
||||||
}
|
|
||||||
GrGLenum fBaseInternalFormat;
|
|
||||||
GrGLenum fSizedInternalFormat;
|
|
||||||
GrGLenum fExternalFormat;
|
|
||||||
GrGLenum fExternalType;
|
|
||||||
|
|
||||||
// The <format> parameter to use for glTexImage and glTexSubImage.
|
|
||||||
// This is usually the same as fExternalFormat except for kSRGBA on some GL contexts.
|
|
||||||
GrGLenum fExternalFormatForTexImage;
|
|
||||||
// Either the base or sized internal format depending on the GL and config.
|
|
||||||
GrGLenum fInternalFormatTexImage;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of MSAA for FBOs supported. Different extensions have different
|
* The type of MSAA for FBOs supported. Different extensions have different
|
||||||
* semantics of how / when a resolve is performed.
|
* semantics of how / when a resolve is performed.
|
||||||
@ -138,16 +120,22 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns conversions to various GL format parameters for a GrPixelCfonig. */
|
|
||||||
const ConfigFormats& configGLFormats(GrPixelConfig config) const {
|
|
||||||
return fConfigTable[config].fFormats;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the mapping between GrPixelConfig components and GL internal format components. */
|
/** Returns the mapping between GrPixelConfig components and GL internal format components. */
|
||||||
const GrSwizzle& configSwizzle(GrPixelConfig config) const {
|
const GrSwizzle& configSwizzle(GrPixelConfig config) const {
|
||||||
return fConfigTable[config].fSwizzle;
|
return fConfigTable[config].fSwizzle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
|
||||||
|
GrGLenum* internalFormat, GrGLenum* externalFormat,
|
||||||
|
GrGLenum* externalType) const;
|
||||||
|
|
||||||
|
bool getCompressedTexImageFormats(GrPixelConfig surfaceConfig, GrGLenum* internalFormat) const;
|
||||||
|
|
||||||
|
bool getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig externalConfig,
|
||||||
|
GrGLenum* externalFormat, GrGLenum* externalType) const;
|
||||||
|
|
||||||
|
bool getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFormat) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an array of legal stencil formats. These formats are not guaranteed
|
* Gets an array of legal stencil formats. These formats are not guaranteed
|
||||||
* to be supported by the driver but are legal GLenum names given the GL
|
* to be supported by the driver but are legal GLenum names given the GL
|
||||||
@ -290,14 +278,10 @@ public:
|
|||||||
bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
|
bool ES2CompatibilitySupport() const { return fES2CompatibilitySupport; }
|
||||||
|
|
||||||
/// Can we call glDisable(GL_MULTISAMPLE)?
|
/// Can we call glDisable(GL_MULTISAMPLE)?
|
||||||
bool multisampleDisableSupport() const {
|
bool multisampleDisableSupport() const { return fMultisampleDisableSupport; }
|
||||||
return fMultisampleDisableSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
|
/// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
|
||||||
bool useNonVBOVertexAndIndexDynamicData() const {
|
bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
|
||||||
return fUseNonVBOVertexAndIndexDynamicData;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Does ReadPixels support the provided format/type combo?
|
/// Does ReadPixels support the provided format/type combo?
|
||||||
bool readPixelsSupported(const GrGLInterface* intf,
|
bool readPixelsSupported(const GrGLInterface* intf,
|
||||||
@ -334,6 +318,17 @@ public:
|
|||||||
const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
|
const GrGLSLCaps* glslCaps() const { return reinterpret_cast<GrGLSLCaps*>(fShaderCaps.get()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
enum ExternalFormatUsage {
|
||||||
|
kTexImage_ExternalFormatUsage,
|
||||||
|
kOther_ExternalFormatUsage,
|
||||||
|
|
||||||
|
kLast_ExternalFormatUsage = kOther_ExternalFormatUsage
|
||||||
|
};
|
||||||
|
static const int kExternalFormatUsageCnt = kLast_ExternalFormatUsage + 1;
|
||||||
|
bool getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memoryConfig,
|
||||||
|
ExternalFormatUsage usage, GrGLenum* externalFormat,
|
||||||
|
GrGLenum* externalType) const;
|
||||||
|
|
||||||
void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
|
void init(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*);
|
||||||
void initGLSL(const GrGLContextInfo&);
|
void initGLSL(const GrGLContextInfo&);
|
||||||
bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
|
bool hasPathRenderingSupport(const GrGLContextInfo&, const GrGLInterface*);
|
||||||
@ -396,6 +391,29 @@ private:
|
|||||||
GrGLenum fType;
|
GrGLenum fType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ConfigFormats {
|
||||||
|
ConfigFormats() {
|
||||||
|
// Inits to known bad GL enum values.
|
||||||
|
memset(this, 0xAB, sizeof(ConfigFormats));
|
||||||
|
}
|
||||||
|
GrGLenum fBaseInternalFormat;
|
||||||
|
GrGLenum fSizedInternalFormat;
|
||||||
|
|
||||||
|
/** The external format and type are to be used when uploading/downloading data using this
|
||||||
|
config where both the CPU data and GrSurface are the same config. To get the external
|
||||||
|
format and type when converting between configs while copying to/from memory use
|
||||||
|
getExternalFormat().
|
||||||
|
The kTexImage external format is usually the same as kOther except for kSRGBA on some
|
||||||
|
GL contexts. */
|
||||||
|
GrGLenum fExternalFormat[kExternalFormatUsageCnt];
|
||||||
|
GrGLenum fExternalType;
|
||||||
|
|
||||||
|
|
||||||
|
// Either the base or sized internal format depending on the GL and config.
|
||||||
|
GrGLenum fInternalFormatTexImage;
|
||||||
|
GrGLenum fInternalFormatRenderbuffer;
|
||||||
|
};
|
||||||
|
|
||||||
struct ConfigInfo {
|
struct ConfigInfo {
|
||||||
ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
|
ConfigInfo() : fStencilFormatIndex(kUnknown_StencilIndex), fFlags(0) {}
|
||||||
|
|
||||||
|
@ -742,14 +742,14 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Internal format comes from the texture desc.
|
// Internal format comes from the texture desc.
|
||||||
GrGLenum internalFormat =
|
GrGLenum internalFormat;
|
||||||
this->glCaps().configGLFormats(desc.fConfig).fInternalFormatTexImage;
|
|
||||||
|
|
||||||
// External format and type come from the upload data.
|
// External format and type come from the upload data.
|
||||||
GrGLenum externalFormat =
|
GrGLenum externalFormat;
|
||||||
this->glCaps().configGLFormats(dataConfig).fExternalFormatForTexImage;
|
GrGLenum externalType;
|
||||||
GrGLenum externalType = this->glCaps().configGLFormats(dataConfig).fExternalType;
|
if (!this->glCaps().getTexImageFormats(desc.fConfig, dataConfig, &internalFormat,
|
||||||
|
&externalFormat, &externalType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* Check whether to allocate a temporary buffer for flipping y or
|
* Check whether to allocate a temporary buffer for flipping y or
|
||||||
* because our srcData has extra bytes past each row. If so, we need
|
* because our srcData has extra bytes past each row. If so, we need
|
||||||
@ -811,7 +811,7 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc,
|
|||||||
} else {
|
} else {
|
||||||
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
|
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
|
||||||
GL_ALLOC_CALL(this->glInterface(), TexImage2D(target, 0, internalFormat, desc.fWidth,
|
GL_ALLOC_CALL(this->glInterface(), TexImage2D(target, 0, internalFormat, desc.fWidth,
|
||||||
desc.fHeight, 0, externalFormat,
|
desc.fHeight, 0, externalFormat,
|
||||||
externalType, dataOrOffset));
|
externalType, dataOrOffset));
|
||||||
GrGLenum error = check_alloc_error(desc, this->glInterface());
|
GrGLenum error = check_alloc_error(desc, this->glInterface());
|
||||||
if (error != GR_GL_NO_ERROR) {
|
if (error != GR_GL_NO_ERROR) {
|
||||||
@ -878,9 +878,11 @@ bool GrGLGpu::uploadCompressedTexData(const GrSurfaceDesc& desc,
|
|||||||
// is a multiple of the block size.
|
// is a multiple of the block size.
|
||||||
size_t dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height);
|
size_t dataSize = GrCompressedFormatDataSize(desc.fConfig, width, height);
|
||||||
|
|
||||||
// We only need the internal format for compressed 2D textures. There is on
|
// We only need the internal format for compressed 2D textures.
|
||||||
// sized vs base internal format distinction for compressed textures.
|
GrGLenum internalFormat;
|
||||||
GrGLenum internalFormat =this->glCaps().configGLFormats(desc.fConfig).fSizedInternalFormat;
|
if (!this->glCaps().getCompressedTexImageFormats(desc.fConfig, &internalFormat)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (kNewTexture_UploadType == uploadType) {
|
if (kNewTexture_UploadType == uploadType) {
|
||||||
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
|
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
|
||||||
@ -988,12 +990,9 @@ bool GrGLGpu::createRenderTargetObjects(const GrSurfaceDesc& desc,
|
|||||||
!idDesc->fMSColorRenderbufferID) {
|
!idDesc->fMSColorRenderbufferID) {
|
||||||
goto FAILED;
|
goto FAILED;
|
||||||
}
|
}
|
||||||
// All ES versions (thus far) require sized internal formats for render buffers.
|
if (!this->glCaps().getRenderbufferFormat(desc.fConfig, &colorRenderbufferFormat)) {
|
||||||
// TODO: Always use sized internal format?
|
return false;
|
||||||
// If this rule gets more complicated, add a field to ConfigEntry rather than logic here.
|
}
|
||||||
colorRenderbufferFormat = kGLES_GrGLStandard == this->glStandard() ?
|
|
||||||
this->glCaps().configGLFormats(desc.fConfig).fSizedInternalFormat :
|
|
||||||
this->glCaps().configGLFormats(desc.fConfig).fBaseInternalFormat;
|
|
||||||
} else {
|
} else {
|
||||||
idDesc->fRTFBOID = idDesc->fTexFBOID;
|
idDesc->fRTFBOID = idDesc->fTexFBOID;
|
||||||
}
|
}
|
||||||
@ -1267,17 +1266,22 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) {
|
|||||||
GR_GL_TEXTURE_WRAP_T,
|
GR_GL_TEXTURE_WRAP_T,
|
||||||
GR_GL_CLAMP_TO_EDGE));
|
GR_GL_CLAMP_TO_EDGE));
|
||||||
|
|
||||||
const GrGLCaps::ConfigFormats colorFormats = this->glCaps().configGLFormats(config);
|
GrGLenum internalFormat;
|
||||||
|
GrGLenum externalFormat;
|
||||||
|
GrGLenum externalType;
|
||||||
|
if (!this->glCaps().getTexImageFormats(config, config, &internalFormat, &externalFormat,
|
||||||
|
&externalType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
|
CLEAR_ERROR_BEFORE_ALLOC(this->glInterface());
|
||||||
GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
|
GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
colorFormats.fInternalFormatTexImage,
|
internalFormat,
|
||||||
kSize,
|
kSize,
|
||||||
kSize,
|
kSize,
|
||||||
0,
|
0,
|
||||||
colorFormats.fExternalFormatForTexImage,
|
externalFormat,
|
||||||
colorFormats.fExternalType,
|
externalType,
|
||||||
NULL));
|
NULL));
|
||||||
if (GR_GL_NO_ERROR != CHECK_ALLOC_ERROR(this->glInterface())) {
|
if (GR_GL_NO_ERROR != CHECK_ALLOC_ERROR(this->glInterface())) {
|
||||||
GL_CALL(DeleteTextures(1, &colorID));
|
GL_CALL(DeleteTextures(1, &colorID));
|
||||||
@ -2016,8 +2020,12 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GrGLenum format = this->glCaps().configGLFormats(config).fExternalFormat;
|
GrGLenum externalFormat;
|
||||||
GrGLenum type = this->glCaps().configGLFormats(config).fExternalType;
|
GrGLenum externalType;
|
||||||
|
if (!this->glCaps().getReadPixelsFormat(surface->config(), config, &externalFormat,
|
||||||
|
&externalType)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin();
|
bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin();
|
||||||
|
|
||||||
// resolve the render target if necessary
|
// resolve the render target if necessary
|
||||||
@ -2070,7 +2078,7 @@ bool GrGLGpu::onReadPixels(GrSurface* surface,
|
|||||||
|
|
||||||
GL_CALL(ReadPixels(readRect.fLeft, readRect.fBottom,
|
GL_CALL(ReadPixels(readRect.fLeft, readRect.fBottom,
|
||||||
readRect.fWidth, readRect.fHeight,
|
readRect.fWidth, readRect.fHeight,
|
||||||
format, type, readDst));
|
externalFormat, externalType, readDst));
|
||||||
if (readDstRowBytes != tightRowBytes) {
|
if (readDstRowBytes != tightRowBytes) {
|
||||||
SkASSERT(this->glCaps().packRowLengthSupport());
|
SkASSERT(this->glCaps().packRowLengthSupport());
|
||||||
GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
|
GL_CALL(PixelStorei(GR_GL_PACK_ROW_LENGTH, 0));
|
||||||
@ -2443,8 +2451,7 @@ void GrGLGpu::flushBlend(const GrXferProcessor::BlendInfo& blendInfo) {
|
|||||||
GrColor blendConst = blendInfo.fBlendConstant;
|
GrColor blendConst = blendInfo.fBlendConstant;
|
||||||
if ((BlendCoeffReferencesConstant(srcCoeff) ||
|
if ((BlendCoeffReferencesConstant(srcCoeff) ||
|
||||||
BlendCoeffReferencesConstant(dstCoeff)) &&
|
BlendCoeffReferencesConstant(dstCoeff)) &&
|
||||||
(!fHWBlendState.fConstColorValid ||
|
(!fHWBlendState.fConstColorValid || fHWBlendState.fConstColor != blendConst)) {
|
||||||
fHWBlendState.fConstColor != blendConst)) {
|
|
||||||
GrGLfloat c[4];
|
GrGLfloat c[4];
|
||||||
GrColorToRGBAFloat(blendConst, c);
|
GrColorToRGBAFloat(blendConst, c);
|
||||||
GL_CALL(BlendColor(c[0], c[1], c[2], c[3]));
|
GL_CALL(BlendColor(c[0], c[1], c[2], c[3]));
|
||||||
@ -3326,9 +3333,19 @@ GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in
|
|||||||
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE));
|
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_S, GR_GL_CLAMP_TO_EDGE));
|
||||||
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_EDGE));
|
GL_CALL(TexParameteri(info->fTarget, GR_GL_TEXTURE_WRAP_T, GR_GL_CLAMP_TO_EDGE));
|
||||||
|
|
||||||
GrGLenum internalFormat = this->glCaps().configGLFormats(config).fInternalFormatTexImage;
|
GrGLenum internalFormat;
|
||||||
GrGLenum externalFormat = this->glCaps().configGLFormats(config).fExternalFormatForTexImage;
|
GrGLenum externalFormat;
|
||||||
GrGLenum externalType = this->glCaps().configGLFormats(config).fExternalType;
|
GrGLenum externalType;
|
||||||
|
|
||||||
|
if (!this->glCaps().getTexImageFormats(config, config, &internalFormat, &externalFormat,
|
||||||
|
&externalType)) {
|
||||||
|
delete info;
|
||||||
|
#ifdef SK_IGNORE_GL_TEXTURE_TARGET
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return reinterpret_cast<GrBackendObject>(nullptr);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat,
|
GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat,
|
||||||
externalType, pixels));
|
externalType, pixels));
|
||||||
|
Loading…
Reference in New Issue
Block a user