Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: src/gpu/gl/GrGLCaps.cpp

Issue 1584563002: Make A8 readback work in more cases and improve testing. (Closed) Base URL: https://skia.googlesource.com/skia.git@outputswiz
Patch Set: fix test for ios Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/gl/GrGLGpu.cpp » ('j') | tests/ReadWriteAlphaTest.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL. 640 // Some OpenGL implementations allow GL_ALPHA as a format to glReadPixel s. However,
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.
641 return true; 656 return true;
642 } 657 }
643 658
644 // See Section 16.1.2 in the ES 3.2 specification. 659 // See Section 16.1.2 in the ES 3.2 specification.
645 660
646 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT ype) { 661 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT ype) {
647 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { 662 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) {
648 return true; 663 return true;
649 } 664 }
650 } else { 665 } else {
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 1059
1045 // We don't currently support moving RGBA data into and out of ALPHA surface s. It could be 1060 // We don't currently support moving RGBA data into and out of ALPHA surface s. It could be
1046 // made to work in many cases using glPixelStore and what not but is not nee ded currently. 1061 // made to work in many cases using glPixelStore and what not but is not nee ded currently.
1047 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) { 1062 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) {
1048 return false; 1063 return false;
1049 } 1064 }
1050 1065
1051 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage] ; 1066 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage] ;
1052 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType; 1067 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType;
1053 1068
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
1054 return true; 1080 return true;
1055 } 1081 }
1056 1082
1057 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli, 1083 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli,
1058 GrGLSLCaps* glslCaps) { 1084 GrGLSLCaps* glslCaps) {
1059 /* 1085 /*
1060 Comments on renderability of configs on various GL versions. 1086 Comments on renderability of configs on various GL versions.
1061 OpenGL < 3.0: 1087 OpenGL < 3.0:
1062 no built in support for render targets. 1088 no built in support for render targets.
1063 GL_EXT_framebuffer_object adds possible support for any sized format with base internal 1089 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
1572 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { 1598 for (int j = 0; j < kExternalFormatUsageCnt; ++j) {
1573 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != 1599 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] !=
1574 fConfigTable[i].fFormats.fExternalFormat[j]); 1600 fConfigTable[i].fFormats.fExternalFormat[j]);
1575 } 1601 }
1576 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType); 1602 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType);
1577 } 1603 }
1578 #endif 1604 #endif
1579 } 1605 }
1580 1606
1581 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1607 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
OLDNEW
« no previous file with comments | « no previous file | src/gpu/gl/GrGLGpu.cpp » ('j') | tests/ReadWriteAlphaTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698