diff options
author | bsalomon <bsalomon@google.com> | 2016-01-22 08:16:09 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-22 08:16:09 -0800 |
commit | 1aa202935ff698f1f35c5435455073fd9f1d08de (patch) | |
tree | 95d9e78ffa25f80fe54b40ad6cc36eae96e1a85b /src/gpu/gl/GrGLCaps.cpp | |
parent | 6a377e629dc93e9d2cede4082a43e9f723f968e4 (diff) |
Add ability to query read pixels support without a render target.
Add more checks to onGetReadPixelsInfo.
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1615023003
Review URL: https://codereview.chromium.org/1615023003
Diffstat (limited to 'src/gpu/gl/GrGLCaps.cpp')
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index ae6e6132b1..5c6d59fbb6 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -10,6 +10,7 @@ #include "GrContextOptions.h" #include "GrGLContext.h" +#include "GrGLRenderTarget.h" #include "glsl/GrGLSLCaps.h" #include "SkTSearch.h" #include "SkTSort.h" @@ -17,6 +18,8 @@ GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterface) : INHERITED(contextOptions) { + fStandard = ctxInfo.standard(); + fStencilFormats.reset(); fMSFBOType = kNone_MSFBOType; fInvalidateFBType = kNone_InvalidateFBType; @@ -648,47 +651,52 @@ bool GrGLCaps::hasPathRenderingSupport(const GrGLContextInfo& ctxInfo, const GrG } return true; } -bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, + +bool GrGLCaps::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConfig, - GrPixelConfig currFBOConfig) const { - SkASSERT(this->isConfigRenderable(currFBOConfig, false)); + std::function<void (GrGLenum, GrGLint*)> getIntegerv, + std::function<bool ()> bindRenderTarget) const { + SkASSERT(this->isConfigRenderable(rtConfig, false)); GrGLenum readFormat; GrGLenum readType; - if (!this->getReadPixelsFormat(currFBOConfig, readConfig, &readFormat, &readType)) { + if (!this->getReadPixelsFormat(rtConfig, readConfig, &readFormat, &readType)) { return false; } - if (kGL_GrGLStandard == intf->fStandard) { + if (kGL_GrGLStandard == fStandard) { // All of our renderable configs can be converted to each other by glReadPixels in OpenGL. return true; } // See Section 16.1.2 in the ES 3.2 specification. - if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatType) { + if (kNormalizedFixedPoint_FormatType == fConfigTable[rtConfig].fFormatType) { if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { return true; } } else { - SkASSERT(kFloat_FormatType == fConfigTable[currFBOConfig].fFormatType); + SkASSERT(kFloat_FormatType == fConfigTable[rtConfig].fFormatType); if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) { return true; } } - if (0 == fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fFormat) { + if (0 == fConfigTable[rtConfig].fSecondReadPixelsFormat.fFormat) { ReadPixelsFormat* rpFormat = - const_cast<ReadPixelsFormat*>(&fConfigTable[currFBOConfig].fSecondReadPixelsFormat); + const_cast<ReadPixelsFormat*>(&fConfigTable[rtConfig].fSecondReadPixelsFormat); GrGLint format = 0, type = 0; - GR_GL_GetIntegerv(intf, GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format); - GR_GL_GetIntegerv(intf, GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, &type); + if (!bindRenderTarget()) { + return false; + } + getIntegerv(GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT, &format); + getIntegerv(GR_GL_IMPLEMENTATION_COLOR_READ_TYPE, &type); rpFormat->fFormat = format; rpFormat->fType = type; } - return fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fFormat == readFormat && - fConfigTable[currFBOConfig].fSecondReadPixelsFormat.fType == readType; + return fConfigTable[rtConfig].fSecondReadPixelsFormat.fFormat == readFormat && + fConfigTable[rtConfig].fSecondReadPixelsFormat.fType == readType; } void GrGLCaps::initFSAASupport(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { |