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