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

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

Issue 1615023003: Add ability to query read pixels support without a render target. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixsupp
Patch Set: squash with prev cl in series 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/gl/GrGLCaps.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
11 #include "GrContextOptions.h" 11 #include "GrContextOptions.h"
12 #include "GrGLContext.h" 12 #include "GrGLContext.h"
13 #include "GrGLRenderTarget.h"
13 #include "glsl/GrGLSLCaps.h" 14 #include "glsl/GrGLSLCaps.h"
14 #include "SkTSearch.h" 15 #include "SkTSearch.h"
15 #include "SkTSort.h" 16 #include "SkTSort.h"
16 17
17 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, 18 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
18 const GrGLContextInfo& ctxInfo, 19 const GrGLContextInfo& ctxInfo,
19 const GrGLInterface* glInterface) : INHERITED(contextOptions) { 20 const GrGLInterface* glInterface) : INHERITED(contextOptions) {
21 fStandard = ctxInfo.standard();
22
20 fStencilFormats.reset(); 23 fStencilFormats.reset();
21 fMSFBOType = kNone_MSFBOType; 24 fMSFBOType = kNone_MSFBOType;
22 fInvalidateFBType = kNone_InvalidateFBType; 25 fInvalidateFBType = kNone_InvalidateFBType;
23 fMapBufferType = kNone_MapBufferType; 26 fMapBufferType = kNone_MapBufferType;
24 fTransferBufferType = kNone_TransferBufferType; 27 fTransferBufferType = kNone_TransferBufferType;
25 fMaxFragmentUniformVectors = 0; 28 fMaxFragmentUniformVectors = 0;
26 fMaxVertexAttributes = 0; 29 fMaxVertexAttributes = 0;
27 fMaxFragmentTextureUnits = 0; 30 fMaxFragmentTextureUnits = 0;
28 fUnpackRowLengthSupport = false; 31 fUnpackRowLengthSupport = false;
29 fUnpackFlipYSupport = false; 32 fUnpackFlipYSupport = false;
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 // them for consistency. 644 // them for consistency.
642 if (nullptr == gli->fFunctions.fStencilThenCoverFillPath || 645 if (nullptr == gli->fFunctions.fStencilThenCoverFillPath ||
643 nullptr == gli->fFunctions.fStencilThenCoverStrokePath || 646 nullptr == gli->fFunctions.fStencilThenCoverStrokePath ||
644 nullptr == gli->fFunctions.fStencilThenCoverFillPathInstanced || 647 nullptr == gli->fFunctions.fStencilThenCoverFillPathInstanced ||
645 nullptr == gli->fFunctions.fStencilThenCoverStrokePathInstanced || 648 nullptr == gli->fFunctions.fStencilThenCoverStrokePathInstanced ||
646 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { 649 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) {
647 return false; 650 return false;
648 } 651 }
649 return true; 652 return true;
650 } 653 }
651 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, 654
655 bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig,
652 GrPixelConfig readConfig, 656 GrPixelConfig readConfig,
653 GrPixelConfig currFBOConfig) const { 657 std::function<void (GrGLenum, GrGLint*)> getI ntegerv,
654 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); 658 std::function<bool ()> bindRenderTarget) cons t {
659 SkASSERT(this->isConfigRenderable(rtConfig, false));
655 660
656 GrGLenum readFormat; 661 GrGLenum readFormat;
657 GrGLenum readType; 662 GrGLenum readType;
658 if (!this->getReadPixelsFormat(currFBOConfig, readConfig, &readFormat, &read Type)) { 663 if (!this->getReadPixelsFormat(rtConfig, readConfig, &readFormat, &readType) ) {
659 return false; 664 return false;
660 } 665 }
661 666
662 if (kGL_GrGLStandard == intf->fStandard) { 667 if (kGL_GrGLStandard == fStandard) {
663 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL. 668 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL.
664 return true; 669 return true;
665 } 670 }
666 671
667 // See Section 16.1.2 in the ES 3.2 specification. 672 // See Section 16.1.2 in the ES 3.2 specification.
668 673
669 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT ype) { 674 if (kNormalizedFixedPoint_FormatType == fConfigTable[rtConfig].fFormatType) {
670 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { 675 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) {
671 return true; 676 return true;
672 } 677 }
673 } else { 678 } else {
674 SkASSERT(kFloat_FormatType == fConfigTable[currFBOConfig].fFormatType); 679 SkASSERT(kFloat_FormatType == fConfigTable[rtConfig].fFormatType);
675 if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) { 680 if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) {
676 return true; 681 return true;
677 } 682 }
678 } 683 }
679 684
680 if (0 == fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fFormat) { 685 if (0 == fConfigTable[rtConfig].fSecondReadPixelsFormat.fFormat) {
681 ReadPixelsFormat* rpFormat = 686 ReadPixelsFormat* rpFormat =
682 const_cast<ReadPixelsFormat*>(&fConfigTable[currFBOConfig].fSecondRe adPixelsFormat); 687 const_cast<ReadPixelsFormat*>(&fConfigTable[rtConfig].fSecondReadPix elsFormat);
683 GrGLint format = 0, type = 0; 688 GrGLint format = 0, type = 0;
684 GR_GL_GetIntegerv(intf, GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format) ; 689 if (!bindRenderTarget()) {
685 GR_GL_GetIntegerv(intf, GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, &type); 690 return false;
691 }
692 getIntegerv(GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format);
693 getIntegerv(GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, &type);
686 rpFormat->fFormat = format; 694 rpFormat->fFormat = format;
687 rpFormat->fType = type; 695 rpFormat->fType = type;
688 } 696 }
689 697
690 return fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fFormat == readFo rmat && 698 return fConfigTable[rtConfig].fSecondReadPixelsFormat.fFormat == readFormat &&
691 fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fType == readType ; 699 fConfigTable[rtConfig].fSecondReadPixelsFormat.fType == readType;
692 } 700 }
693 701
694 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli) { 702 void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli) {
695 703
696 fMSFBOType = kNone_MSFBOType; 704 fMSFBOType = kNone_MSFBOType;
697 if (kGL_GrGLStandard != ctxInfo.standard()) { 705 if (kGL_GrGLStandard != ctxInfo.standard()) {
698 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed 706 // We prefer the EXT/IMG extension over ES3 MSAA because we've observed
699 // ES3 driver bugs on at least one device with a tiled GPU (N10). 707 // ES3 driver bugs on at least one device with a tiled GPU (N10).
700 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) { 708 if (ctxInfo.hasExtension("GL_EXT_multisampled_render_to_texture")) {
701 fMSFBOType = kES_EXT_MsToTexture_MSFBOType; 709 fMSFBOType = kES_EXT_MsToTexture_MSFBOType;
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 for (int j = 0; j < kExternalFormatUsageCnt; ++j) { 1604 for (int j = 0; j < kExternalFormatUsageCnt; ++j) {
1597 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] != 1605 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] !=
1598 fConfigTable[i].fFormats.fExternalFormat[j]); 1606 fConfigTable[i].fFormats.fExternalFormat[j]);
1599 } 1607 }
1600 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType); 1608 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType);
1601 } 1609 }
1602 #endif 1610 #endif
1603 } 1611 }
1604 1612
1605 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1613 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698