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

Unified Diff: src/gpu/gl/GrGLGpu.cpp

Issue 2489643002: Fix query for GR_GL_IMPLEMENTATION_COLOR_READ_FORMAT for GrPixelConfigs that aren't renderable (Closed)
Patch Set: fix Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLGpu.cpp
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 838ad5881f1b50317e9a7423584142734791cef7..266f3a8419a253902aa3943fe3836cf5245b4e50 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2293,31 +2293,50 @@ bool GrGLGpu::readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConf
this->flushRenderTarget(static_cast<GrGLRenderTarget*>(target), &SkIRect::EmptyIRect());
return true;
};
+ auto unbindRenderTarget = []{};
auto getIntegerv = [this](GrGLenum query, GrGLint* value) {
GR_GL_GetIntegerv(this->glInterface(), query, value);
};
GrPixelConfig rtConfig = target->config();
- return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget);
+ return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget,
+ unbindRenderTarget);
}
bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConfig) {
- auto bindRenderTarget = [this, rtConfig]() -> bool {
+ sk_sp<GrTexture> temp;
+ auto bindRenderTarget = [this, rtConfig, &temp]() -> bool {
GrTextureDesc desc;
desc.fConfig = rtConfig;
desc.fWidth = desc.fHeight = 16;
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- sk_sp<GrTexture> temp(this->createTexture(desc, SkBudgeted::kNo));
- if (!temp) {
- return false;
+ if (this->glCaps().isConfigRenderable(rtConfig, false)) {
+ desc.fFlags = kRenderTarget_GrSurfaceFlag;
+ temp.reset(this->createTexture(desc, SkBudgeted::kNo));
+ if (!temp) {
+ return false;
+ }
+ GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(temp->asRenderTarget());
+ this->flushRenderTarget(glrt, &SkIRect::EmptyIRect());
+ return true;
+ } else if (this->glCaps().canConfigBeFBOColorAttachment(rtConfig)) {
+ temp.reset(this->createTexture(desc, SkBudgeted::kNo));
+ if (!temp) {
+ return false;
+ }
+ GrGLIRect vp;
+ this->bindSurfaceFBOForPixelOps(temp.get(), GR_GL_FRAMEBUFFER, &vp, kDst_TempFBOTarget);
+ fHWBoundRenderTargetUniqueID = 0;
+ return true;
}
- GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(temp->asRenderTarget());
- this->flushRenderTarget(glrt, &SkIRect::EmptyIRect());
- return true;
+ return false;
+ };
+ auto unbindRenderTarget = [this, &temp]() {
+ this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, temp.get());
};
auto getIntegerv = [this](GrGLenum query, GrGLint* value) {
GR_GL_GetIntegerv(this->glInterface(), query, value);
};
- return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget);
+ return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget,
+ unbindRenderTarget);
}
bool GrGLGpu::readPixelsSupported(GrSurface* surfaceForConfig, GrPixelConfig readConfig) {
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698