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

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

Issue 1584473002: Swizzle shader output and blend when using GL_RED to implement kAlpha_8_GrPixelConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@hideformats
Patch Set: Address comments 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 | « src/gpu/GrSwizzle.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »
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 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 } 1541 }
1542 1542
1543 // If we don't have texture swizzle support then the shader generator must i nsert the 1543 // If we don't have texture swizzle support then the shader generator must i nsert the
1544 // swizzle into shader code. 1544 // swizzle into shader code.
1545 if (!this->textureSwizzleSupport()) { 1545 if (!this->textureSwizzleSupport()) {
1546 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1546 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1547 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle; 1547 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle;
1548 } 1548 }
1549 } 1549 }
1550 1550
1551 // Shader output swizzles will default to RGBA. When we've use GL_RED instea d of GL_ALPHA to
1552 // implement kAlpha_8_GrPixelConfig we need to swizzle the shader outputs so the alpha channel
1553 // gets written to the single component.
1554 if (this->textureRedSupport()) {
1555 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1556 GrPixelConfig config = static_cast<GrPixelConfig>(i);
1557 if (GrPixelConfigIsAlphaOnly(config) &&
1558 fConfigTable[i].fFormats.fBaseInternalFormat == GR_GL_RED) {
1559 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA();
1560 }
1561 }
1562 }
1563
1551 #ifdef SK_DEBUG 1564 #ifdef SK_DEBUG
1552 // Make sure we initialized everything. 1565 // Make sure we initialized everything.
1553 ConfigInfo defaultEntry; 1566 ConfigInfo defaultEntry;
1554 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1567 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1555 SkASSERT(defaultEntry.fFormats.fBaseInternalFormat != 1568 SkASSERT(defaultEntry.fFormats.fBaseInternalFormat !=
1556 fConfigTable[i].fFormats.fBaseInternalFormat); 1569 fConfigTable[i].fFormats.fBaseInternalFormat);
1557 SkASSERT(defaultEntry.fFormats.fSizedInternalFormat != 1570 SkASSERT(defaultEntry.fFormats.fSizedInternalFormat !=
1558 fConfigTable[i].fFormats.fSizedInternalFormat); 1571 fConfigTable[i].fFormats.fSizedInternalFormat);
1559 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { 1572 for (int j = 0; j < kExternalFormatUsageCnt; ++j) {
1560 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != 1573 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] !=
1561 fConfigTable[i].fFormats.fExternalFormat[j]); 1574 fConfigTable[i].fFormats.fExternalFormat[j]);
1562 } 1575 }
1563 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType); 1576 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType);
1564 } 1577 }
1565 #endif 1578 #endif
1566 } 1579 }
1567 1580
1568 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1581 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
OLDNEW
« no previous file with comments | « src/gpu/GrSwizzle.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698