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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 GrPixelConfig currFBOConfig) const { | 630 GrPixelConfig currFBOConfig) const { |
631 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); | 631 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); |
632 | 632 |
633 GrGLenum readFormat; | 633 GrGLenum readFormat; |
634 GrGLenum readType; | 634 GrGLenum readType; |
635 if (!this->getReadPixelsFormat(currFBOConfig, readConfig, &readFormat, &read
Type)) { | 635 if (!this->getReadPixelsFormat(currFBOConfig, readConfig, &readFormat, &read
Type)) { |
636 return false; | 636 return false; |
637 } | 637 } |
638 | 638 |
639 if (kGL_GrGLStandard == intf->fStandard) { | 639 if (kGL_GrGLStandard == intf->fStandard) { |
640 // Some OpenGL implementations allow GL_ALPHA as a format to glReadPixel
s. However, | 640 // All of our renderable configs can be converted to each other by glRea
dPixels in OpenGL. |
641 // the manual (https://www.opengl.org/sdk/docs/man/) says only these for
mats are allowed: | |
642 // GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_RED, GL_GR
EEN, GL_BLUE, | |
643 // GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA. We check for the subset that we
would use. | |
644 if (readFormat != GR_GL_RED && readFormat != GR_GL_RGB && readFormat !=
GR_GL_RGBA && | |
645 readFormat != GR_GL_BGRA) { | |
646 return false; | |
647 } | |
648 // There is also a set of allowed types, but all the types we use are in
the set: | |
649 // GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_I
NT, GL_INT, | |
650 // GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3
_3_REV, | |
651 // GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHO
RT_4_4_4_4, | |
652 // GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED
_SHORT_1_5_5_5_REV, | |
653 // GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,GL_UNSIGNED_INT_
10_10_10_2, | |
654 // GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT
_10F_11F_11F_REV, | |
655 // GL_UNSIGNED_INT_5_9_9_9_REV, or GL_FLOAT_32_UNSIGNED_INT_24_8_REV. | |
656 return true; | 641 return true; |
657 } | 642 } |
658 | 643 |
659 // See Section 16.1.2 in the ES 3.2 specification. | 644 // See Section 16.1.2 in the ES 3.2 specification. |
660 | 645 |
661 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT
ype) { | 646 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT
ype) { |
662 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { | 647 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { |
663 return true; | 648 return true; |
664 } | 649 } |
665 } else { | 650 } else { |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 | 1044 |
1060 // We don't currently support moving RGBA data into and out of ALPHA surface
s. It could be | 1045 // We don't currently support moving RGBA data into and out of ALPHA surface
s. It could be |
1061 // made to work in many cases using glPixelStore and what not but is not nee
ded currently. | 1046 // made to work in many cases using glPixelStore and what not but is not nee
ded currently. |
1062 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) { | 1047 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) { |
1063 return false; | 1048 return false; |
1064 } | 1049 } |
1065 | 1050 |
1066 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage]
; | 1051 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage]
; |
1067 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType; | 1052 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType; |
1068 | 1053 |
1069 // When GL_RED is supported as a texture format, our alpha-only textures are
stored using | |
1070 // GL_RED and we swizzle in order to map all components to 'r'. However, in
this case the | |
1071 // surface is not alpha-only and we want alpha to really mean the alpha comp
onent of the | |
1072 // texture, not the red component. | |
1073 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) { | |
1074 if (this->textureRedSupport()) { | |
1075 SkASSERT(GR_GL_RED == *externalFormat); | |
1076 *externalFormat = GR_GL_ALPHA; | |
1077 } | |
1078 } | |
1079 | |
1080 return true; | 1054 return true; |
1081 } | 1055 } |
1082 | 1056 |
1083 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, | 1057 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, |
1084 GrGLSLCaps* glslCaps) { | 1058 GrGLSLCaps* glslCaps) { |
1085 /* | 1059 /* |
1086 Comments on renderability of configs on various GL versions. | 1060 Comments on renderability of configs on various GL versions. |
1087 OpenGL < 3.0: | 1061 OpenGL < 3.0: |
1088 no built in support for render targets. | 1062 no built in support for render targets. |
1089 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal | 1063 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { | 1572 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { |
1599 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != | 1573 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != |
1600 fConfigTable[i].fFormats.fExternalFormat[j]); | 1574 fConfigTable[i].fFormats.fExternalFormat[j]); |
1601 } | 1575 } |
1602 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats
.fExternalType); | 1576 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats
.fExternalType); |
1603 } | 1577 } |
1604 #endif | 1578 #endif |
1605 } | 1579 } |
1606 | 1580 |
1607 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} | 1581 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} |
OLD | NEW |