OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
10 | 10 |
(...skipping 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1428 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |= | 1428 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |= |
1429 ConfigInfo::kRenderableWithMSAA_Flag; | 1429 ConfigInfo::kRenderableWithMSAA_Flag; |
1430 } | 1430 } |
1431 } | 1431 } |
1432 } | 1432 } |
1433 if (texStorageSupported) { | 1433 if (texStorageSupported) { |
1434 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexS
torage_Flag; | 1434 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTexS
torage_Flag; |
1435 } | 1435 } |
1436 fConfigTable[kBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); | 1436 fConfigTable[kBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); |
1437 | 1437 |
1438 // We only enable srgb support if both textures and FBOs support srgb, | 1438 // We only enable srgb support if both textures and FBOs support srgb. |
1439 // *and* we can disable sRGB decode-on-read, to support "legacy" mode. | 1439 bool srgbSupport = false; |
1440 if (kGL_GrGLStandard == standard) { | 1440 if (kGL_GrGLStandard == standard) { |
1441 if (ctxInfo.version() >= GR_GL_VER(3,0)) { | 1441 if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
1442 fSRGBSupport = true; | 1442 srgbSupport = true; |
1443 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { | 1443 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { |
1444 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || | 1444 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
1445 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { | 1445 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
1446 fSRGBSupport = true; | 1446 srgbSupport = true; |
1447 } | 1447 } |
1448 } | 1448 } |
1449 // All the above srgb extensions support toggling srgb writes | 1449 // All the above srgb extensions support toggling srgb writes |
1450 fSRGBWriteControl = fSRGBSupport; | 1450 fSRGBWriteControl = srgbSupport; |
1451 } else { | 1451 } else { |
1452 // See https://bug.skia.org/4148 for PowerVR issue. | 1452 // See https://bug.skia.org/4148 for PowerVR issue. |
1453 fSRGBSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && | 1453 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && |
1454 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT
_sRGB")); | 1454 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT
_sRGB")); |
1455 // ES through 3.1 requires EXT_srgb_write_control to support toggling | 1455 // ES through 3.1 requires EXT_srgb_write_control to support toggling |
1456 // sRGB writing for destinations. | 1456 // sRGB writing for destinations. |
1457 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); | 1457 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); |
1458 } | 1458 } |
1459 if (!ctxInfo.hasExtension("GL_EXT_texture_sRGB_decode")) { | |
1460 // To support "legacy" L32 mode, we require the ability to turn off sRGB
decode: | |
1461 fSRGBSupport = false; | |
1462 } | |
1463 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; | 1459 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; |
1464 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; | 1460 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; |
1465 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the | 1461 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the |
1466 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. | 1462 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. |
1467 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = | 1463 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = |
1468 GR_GL_RGBA; | 1464 GR_GL_RGBA; |
1469 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1465 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
1470 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; | 1466 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
1471 if (fSRGBSupport) { | 1467 if (srgbSupport) { |
1472 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | | 1468 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | |
1473 allRenderFlags; | 1469 allRenderFlags; |
1474 } | 1470 } |
1475 if (texStorageSupported) { | 1471 if (texStorageSupported) { |
1476 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTex
Storage_Flag; | 1472 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTex
Storage_Flag; |
1477 } | 1473 } |
1478 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); | 1474 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); |
1479 | 1475 |
1480 // sBGRA is not a "real" thing in OpenGL, but GPUs support it, and on platfo
rms where | |
1481 // kN32 == BGRA, we need some way to work with it. (The default framebuffer
on Windows | |
1482 // is in this format, for example). | |
1483 fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; | |
1484 fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; | |
1485 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the | |
1486 // external format is GL_BGRA. | |
1487 fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte
rnalFormatUsage] = | |
1488 GR_GL_BGRA; | |
1489 fConfigTable[kSBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | |
1490 fConfigTable[kSBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; | |
1491 if (fSRGBSupport) { | |
1492 fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | | |
1493 allRenderFlags; | |
1494 } | |
1495 if (texStorageSupported) { | |
1496 fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags |= ConfigInfo::kCanUseTex
Storage_Flag; | |
1497 } | |
1498 fConfigTable[kSBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); | |
1499 | |
1500 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG
B; | 1476 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG
B; |
1501 if (this->ES2CompatibilitySupport()) { | 1477 if (this->ES2CompatibilitySupport()) { |
1502 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB565; | 1478 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB565; |
1503 } else { | 1479 } else { |
1504 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB5; | 1480 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB5; |
1505 } | 1481 } |
1506 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa
lFormatUsage] = | 1482 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa
lFormatUsage] = |
1507 GR_GL_RGB; | 1483 GR_GL_RGB; |
1508 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_SHORT_5_6_5; | 1484 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_SHORT_5_6_5; |
1509 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; | 1485 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 fConfigTable[i].fFormats.fSizedInternalFormat : | 1785 fConfigTable[i].fFormats.fSizedInternalFormat : |
1810 fConfigTable[i].fFormats.fBaseInternalFormat; | 1786 fConfigTable[i].fFormats.fBaseInternalFormat; |
1811 } | 1787 } |
1812 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the <
format> | 1788 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the <
format> |
1813 // param to Tex(Sub)Image. ES 2.0 requires the <internalFormat> and <format>
params to match. | 1789 // param to Tex(Sub)Image. ES 2.0 requires the <internalFormat> and <format>
params to match. |
1814 // Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param. | 1790 // Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param. |
1815 // On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param
to glTexImage. | 1791 // On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param
to glTexImage. |
1816 if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_V
ER(2,0)) { | 1792 if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_V
ER(2,0)) { |
1817 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexIma
ge_ExternalFormatUsage] = | 1793 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexIma
ge_ExternalFormatUsage] = |
1818 GR_GL_SRGB_ALPHA; | 1794 GR_GL_SRGB_ALPHA; |
1819 | |
1820 // Additionally, because we had to "invent" sBGRA, there is no way to ma
ke it work | |
1821 // in ES 2.0, because there is no <internalFormat> we can use. So just m
ake that format | |
1822 // unsupported. (If we have no sRGB support at all, this will get overwr
itten below). | |
1823 fConfigTable[kSBGRA_8888_GrPixelConfig].fFlags = 0; | |
1824 } | 1795 } |
1825 | 1796 |
1826 // If BGRA is supported as an internal format it must always be specified to
glTex[Sub]Image | 1797 // If BGRA is supported as an internal format it must always be specified to
glTex[Sub]Image |
1827 // as a base format. | 1798 // as a base format. |
1828 // GL_EXT_texture_format_BGRA8888: | 1799 // GL_EXT_texture_format_BGRA8888: |
1829 // This extension GL_BGRA as an unsized internal format. However, it is
written against ES | 1800 // This extension GL_BGRA as an unsized internal format. However, it is
written against ES |
1830 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses
unsized internal | 1801 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses
unsized internal |
1831 // formats. | 1802 // formats. |
1832 // GL_APPLE_texture_format_BGRA8888: | 1803 // GL_APPLE_texture_format_BGRA8888: |
1833 // ES 2.0: the extension makes BGRA an external format but not an intern
al format. | 1804 // ES 2.0: the extension makes BGRA an external format but not an intern
al format. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { | 1840 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { |
1870 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != | 1841 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != |
1871 fConfigTable[i].fFormats.fExternalFormat[j]); | 1842 fConfigTable[i].fFormats.fExternalFormat[j]); |
1872 } | 1843 } |
1873 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats
.fExternalType); | 1844 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats
.fExternalType); |
1874 } | 1845 } |
1875 #endif | 1846 #endif |
1876 } | 1847 } |
1877 | 1848 |
1878 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} | 1849 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} |
OLD | NEW |