| 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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { | 636 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { |
| 637 return false; | 637 return false; |
| 638 } | 638 } |
| 639 return true; | 639 return true; |
| 640 } | 640 } |
| 641 | 641 |
| 642 bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig, | 642 bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig, |
| 643 GrPixelConfig readConfig, | 643 GrPixelConfig readConfig, |
| 644 std::function<void (GrGLenum, GrGLint*)> getI
ntegerv, | 644 std::function<void (GrGLenum, GrGLint*)> getI
ntegerv, |
| 645 std::function<bool ()> bindRenderTarget) cons
t { | 645 std::function<bool ()> bindRenderTarget) cons
t { |
| 646 SkASSERT(this->isConfigRenderable(rtConfig, false)); | 646 // If it's not possible to even have a render target of rtConfig then read p
ixels is |
| 647 // not supported regardless of readConfig. |
| 648 if (!this->isConfigRenderable(rtConfig, false)) { |
| 649 return false; |
| 650 } |
| 647 | 651 |
| 648 GrGLenum readFormat; | 652 GrGLenum readFormat; |
| 649 GrGLenum readType; | 653 GrGLenum readType; |
| 650 if (!this->getReadPixelsFormat(rtConfig, readConfig, &readFormat, &readType)
) { | 654 if (!this->getReadPixelsFormat(rtConfig, readConfig, &readFormat, &readType)
) { |
| 651 return false; | 655 return false; |
| 652 } | 656 } |
| 653 | 657 |
| 654 if (kGL_GrGLStandard == fStandard) { | 658 if (kGL_GrGLStandard == fStandard) { |
| 655 // All of our renderable configs can be converted to each other by glRea
dPixels in OpenGL. | 659 // Some OpenGL implementations allow GL_ALPHA as a format to glReadPixel
s. However, |
| 660 // the manual (https://www.opengl.org/sdk/docs/man/) says only these for
mats are allowed: |
| 661 // GL_STENCIL_INDEX, GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL, GL_RED, GL_GR
EEN, GL_BLUE, |
| 662 // GL_RGB, GL_BGR, GL_RGBA, and GL_BGRA. We check for the subset that we
would use. |
| 663 if (readFormat != GR_GL_RED && readFormat != GR_GL_RGB && readFormat !=
GR_GL_RGBA && |
| 664 readFormat != GR_GL_BGRA) { |
| 665 return false; |
| 666 } |
| 667 // There is also a set of allowed types, but all the types we use are in
the set: |
| 668 // GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_UNSIGNED_I
NT, GL_INT, |
| 669 // GL_HALF_FLOAT, GL_FLOAT, GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3
_3_REV, |
| 670 // GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_5_6_5_REV, GL_UNSIGNED_SHO
RT_4_4_4_4, |
| 671 // GL_UNSIGNED_SHORT_4_4_4_4_REV, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED
_SHORT_1_5_5_5_REV, |
| 672 // GL_UNSIGNED_INT_8_8_8_8, GL_UNSIGNED_INT_8_8_8_8_REV,GL_UNSIGNED_INT_
10_10_10_2, |
| 673 // GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_INT
_10F_11F_11F_REV, |
| 674 // GL_UNSIGNED_INT_5_9_9_9_REV, or GL_FLOAT_32_UNSIGNED_INT_24_8_REV. |
| 656 return true; | 675 return true; |
| 657 } | 676 } |
| 658 | 677 |
| 659 // See Section 16.1.2 in the ES 3.2 specification. | 678 // See Section 16.1.2 in the ES 3.2 specification. |
| 660 | 679 |
| 661 if (kNormalizedFixedPoint_FormatType == fConfigTable[rtConfig].fFormatType)
{ | 680 if (kNormalizedFixedPoint_FormatType == fConfigTable[rtConfig].fFormatType)
{ |
| 662 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { | 681 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { |
| 663 return true; | 682 return true; |
| 664 } | 683 } |
| 665 } else { | 684 } else { |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 | 1082 |
| 1064 // We don't currently support moving RGBA data into and out of ALPHA surface
s. It could be | 1083 // We don't currently support moving RGBA data into and out of ALPHA surface
s. It could be |
| 1065 // made to work in many cases using glPixelStore and what not but is not nee
ded currently. | 1084 // made to work in many cases using glPixelStore and what not but is not nee
ded currently. |
| 1066 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) { | 1085 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) { |
| 1067 return false; | 1086 return false; |
| 1068 } | 1087 } |
| 1069 | 1088 |
| 1070 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage]
; | 1089 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage]
; |
| 1071 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType; | 1090 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType; |
| 1072 | 1091 |
| 1092 // When GL_RED is supported as a texture format, our alpha-only textures are
stored using |
| 1093 // GL_RED and we swizzle in order to map all components to 'r'. However, in
this case the |
| 1094 // surface is not alpha-only and we want alpha to really mean the alpha comp
onent of the |
| 1095 // texture, not the red component. |
| 1096 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) { |
| 1097 if (this->textureRedSupport()) { |
| 1098 SkASSERT(GR_GL_RED == *externalFormat); |
| 1099 *externalFormat = GR_GL_ALPHA; |
| 1100 } |
| 1101 } |
| 1102 |
| 1073 return true; | 1103 return true; |
| 1074 } | 1104 } |
| 1075 | 1105 |
| 1076 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, | 1106 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli, |
| 1077 GrGLSLCaps* glslCaps) { | 1107 GrGLSLCaps* glslCaps) { |
| 1078 /* | 1108 /* |
| 1079 Comments on renderability of configs on various GL versions. | 1109 Comments on renderability of configs on various GL versions. |
| 1080 OpenGL < 3.0: | 1110 OpenGL < 3.0: |
| 1081 no built in support for render targets. | 1111 no built in support for render targets. |
| 1082 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal | 1112 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... |
| 1591 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { | 1621 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { |
| 1592 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != | 1622 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != |
| 1593 fConfigTable[i].fFormats.fExternalFormat[j]); | 1623 fConfigTable[i].fFormats.fExternalFormat[j]); |
| 1594 } | 1624 } |
| 1595 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats
.fExternalType); | 1625 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats
.fExternalType); |
| 1596 } | 1626 } |
| 1597 #endif | 1627 #endif |
| 1598 } | 1628 } |
| 1599 | 1629 |
| 1600 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} | 1630 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} |
| OLD | NEW |