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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.cpp ('k') | no next file » | 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 2011 Google Inc. 2 * Copyright 2011 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 #include "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 2275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2286 // Note that we're assuming that 0 rowBytes has already been handled and tha t the width has been 2286 // Note that we're assuming that 0 rowBytes has already been handled and tha t the width has been
2287 // clipped. 2287 // clipped.
2288 return caps.packRowLengthSupport() || GrBytesPerPixel(config) * width == row Bytes; 2288 return caps.packRowLengthSupport() || GrBytesPerPixel(config) * width == row Bytes;
2289 } 2289 }
2290 2290
2291 bool GrGLGpu::readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConf ig) { 2291 bool GrGLGpu::readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConf ig) {
2292 auto bindRenderTarget = [this, target]() -> bool { 2292 auto bindRenderTarget = [this, target]() -> bool {
2293 this->flushRenderTarget(static_cast<GrGLRenderTarget*>(target), &SkIRect ::EmptyIRect()); 2293 this->flushRenderTarget(static_cast<GrGLRenderTarget*>(target), &SkIRect ::EmptyIRect());
2294 return true; 2294 return true;
2295 }; 2295 };
2296 auto unbindRenderTarget = []{};
2297 auto getIntegerv = [this](GrGLenum query, GrGLint* value) {
2298 GR_GL_GetIntegerv(this->glInterface(), query, value);
2299 };
2300 GrPixelConfig rtConfig = target->config();
2301 return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget,
2302 unbindRenderTarget);
2303 }
2304
2305 bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf ig) {
2306 sk_sp<GrTexture> temp;
2307 auto bindRenderTarget = [this, rtConfig, &temp]() -> bool {
2308 GrTextureDesc desc;
2309 desc.fConfig = rtConfig;
2310 desc.fWidth = desc.fHeight = 16;
2311 if (this->glCaps().isConfigRenderable(rtConfig, false)) {
2312 desc.fFlags = kRenderTarget_GrSurfaceFlag;
2313 temp.reset(this->createTexture(desc, SkBudgeted::kNo));
2314 if (!temp) {
2315 return false;
2316 }
2317 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(temp->asRend erTarget());
2318 this->flushRenderTarget(glrt, &SkIRect::EmptyIRect());
2319 return true;
2320 } else if (this->glCaps().canConfigBeFBOColorAttachment(rtConfig)) {
2321 temp.reset(this->createTexture(desc, SkBudgeted::kNo));
2322 if (!temp) {
2323 return false;
2324 }
2325 GrGLIRect vp;
2326 this->bindSurfaceFBOForPixelOps(temp.get(), GR_GL_FRAMEBUFFER, &vp, kDst_TempFBOTarget);
2327 fHWBoundRenderTargetUniqueID = 0;
2328 return true;
2329 }
2330 return false;
2331 };
2332 auto unbindRenderTarget = [this, &temp]() {
2333 this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, temp.get());
2334 };
2296 auto getIntegerv = [this](GrGLenum query, GrGLint* value) { 2335 auto getIntegerv = [this](GrGLenum query, GrGLint* value) {
2297 GR_GL_GetIntegerv(this->glInterface(), query, value); 2336 GR_GL_GetIntegerv(this->glInterface(), query, value);
2298 }; 2337 };
2299 GrPixelConfig rtConfig = target->config(); 2338 return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget,
2300 return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget); 2339 unbindRenderTarget);
2301 }
2302
2303 bool GrGLGpu::readPixelsSupported(GrPixelConfig rtConfig, GrPixelConfig readConf ig) {
2304 auto bindRenderTarget = [this, rtConfig]() -> bool {
2305 GrTextureDesc desc;
2306 desc.fConfig = rtConfig;
2307 desc.fWidth = desc.fHeight = 16;
2308 desc.fFlags = kRenderTarget_GrSurfaceFlag;
2309 sk_sp<GrTexture> temp(this->createTexture(desc, SkBudgeted::kNo));
2310 if (!temp) {
2311 return false;
2312 }
2313 GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(temp->asRenderTa rget());
2314 this->flushRenderTarget(glrt, &SkIRect::EmptyIRect());
2315 return true;
2316 };
2317 auto getIntegerv = [this](GrGLenum query, GrGLint* value) {
2318 GR_GL_GetIntegerv(this->glInterface(), query, value);
2319 };
2320 return this->glCaps().readPixelsSupported(rtConfig, readConfig, getIntegerv, bindRenderTarget);
2321 } 2340 }
2322 2341
2323 bool GrGLGpu::readPixelsSupported(GrSurface* surfaceForConfig, GrPixelConfig rea dConfig) { 2342 bool GrGLGpu::readPixelsSupported(GrSurface* surfaceForConfig, GrPixelConfig rea dConfig) {
2324 if (GrRenderTarget* rt = surfaceForConfig->asRenderTarget()) { 2343 if (GrRenderTarget* rt = surfaceForConfig->asRenderTarget()) {
2325 return this->readPixelsSupported(rt, readConfig); 2344 return this->readPixelsSupported(rt, readConfig);
2326 } else { 2345 } else {
2327 GrPixelConfig config = surfaceForConfig->config(); 2346 GrPixelConfig config = surfaceForConfig->config();
2328 return this->readPixelsSupported(config, readConfig); 2347 return this->readPixelsSupported(config, readConfig);
2329 } 2348 }
2330 } 2349 }
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
4650 4669
4651 bool GrGLGpu::waitFence(GrFence fence, uint64_t timeout) const { 4670 bool GrGLGpu::waitFence(GrFence fence, uint64_t timeout) const {
4652 GrGLenum result; 4671 GrGLenum result;
4653 GL_CALL_RET(result, ClientWaitSync((GrGLsync)fence, GR_GL_SYNC_FLUSH_COMMAND S_BIT, timeout)); 4672 GL_CALL_RET(result, ClientWaitSync((GrGLsync)fence, GR_GL_SYNC_FLUSH_COMMAND S_BIT, timeout));
4654 return (GR_GL_CONDITION_SATISFIED == result); 4673 return (GR_GL_CONDITION_SATISFIED == result);
4655 } 4674 }
4656 4675
4657 void GrGLGpu::deleteFence(GrFence fence) const { 4676 void GrGLGpu::deleteFence(GrFence fence) const {
4658 GL_CALL(DeleteSync((GrGLsync)fence)); 4677 GL_CALL(DeleteSync((GrGLsync)fence));
4659 } 4678 }
OLDNEW
« 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