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

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

Issue 749903003: some cleanup around GrGpu/GrDrawTarget copySurface (Closed) Base URL: https://skia.googlesource.com/skia.git@isSameAs
Patch Set: fix regression Created 6 years 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/GrGpuGL.h ('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 8
9 #include "GrGpuGL.h" 9 #include "GrGpuGL.h"
10 #include "GrGLStencilBuffer.h" 10 #include "GrGLStencilBuffer.h"
(...skipping 2344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2355 viewport->fHeight = surface->height(); 2355 viewport->fHeight = surface->height();
2356 } else { 2356 } else {
2357 tempFBOID = 0; 2357 tempFBOID = 0;
2358 fGPUStats.incRenderTargetBinds(); 2358 fGPUStats.incRenderTargetBinds();
2359 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID())); 2359 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO ID()));
2360 *viewport = rt->getViewport(); 2360 *viewport = rt->getViewport();
2361 } 2361 }
2362 return tempFBOID; 2362 return tempFBOID;
2363 } 2363 }
2364 2364
2365 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) { 2365 bool GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) {
2366 // In here we look for opportunities to use CopyTexSubImage, or fbo blit. If neither are
2367 // possible and we return false to fallback to creating a render target dst for render-to-
2368 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger ing temporary fbo
2369 // creation. It isn't clear that avoiding temporary fbo creation is actually optimal.
2370
2366 // Check for format issues with glCopyTexSubImage2D 2371 // Check for format issues with glCopyTexSubImage2D
2367 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() && 2372 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna lFormat() &&
2368 kBGRA_8888_GrPixelConfig == src->config()) { 2373 kBGRA_8888_GrPixelConfig == src->config()) {
2369 // glCopyTexSubImage2D doesn't work with this config. We'll want to make it a render target 2374 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be used with fbo blit
2370 // in order to call glBlitFramebuffer or to copy to it by rendering. 2375 // then we set up for that, otherwise fail.
2371 INHERITED::initCopySurfaceDstDesc(src, desc); 2376 if (this->caps()->isConfigRenderable(kBGRA_8888_GrPixelConfig, false)) {
2372 return; 2377 desc->fOrigin = kDefault_GrSurfaceOrigin;
2378 desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFla g;
2379 desc->fConfig = kBGRA_8888_GrPixelConfig;
2380 return true;
2381 }
2382 return false;
2373 } else if (NULL == src->asRenderTarget()) { 2383 } else if (NULL == src->asRenderTarget()) {
2374 // We don't want to have to create an FBO just to use glCopyTexSubImage2 D. Let the base 2384 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t he src.
2375 // class handle it by rendering. 2385 return false;
2376 INHERITED::initCopySurfaceDstDesc(src, desc);
2377 return;
2378 } 2386 }
2379 2387
2380 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget()); 2388 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as RenderTarget());
2381 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { 2389 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) {
2382 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. 2390 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up for FBO blit or
2383 INHERITED::initCopySurfaceDstDesc(src, desc); 2391 // fail.
2384 } else { 2392 if (this->caps()->isConfigRenderable(src->config(), false)) {
2385 desc->fConfig = src->config(); 2393 desc->fOrigin = kDefault_GrSurfaceOrigin;
2386 desc->fOrigin = src->origin(); 2394 desc->fFlags = kRenderTarget_GrSurfaceFlag | kNoStencil_GrSurfaceFla g;
2387 desc->fFlags = kNone_GrSurfaceFlags; 2395 desc->fConfig = src->config();
2396 return true;
2397 }
2398 return false;
2388 } 2399 }
2400
2401 // We'll do a CopyTexSubImage. Make the dst a plain old texture.
2402 desc->fConfig = src->config();
2403 desc->fOrigin = src->origin();
2404 desc->fFlags = kNone_GrSurfaceFlags;
2405 return true;
2389 } 2406 }
2390 2407
2391 bool GrGpuGL::copySurface(GrSurface* dst, 2408 bool GrGpuGL::copySurface(GrSurface* dst,
2392 GrSurface* src, 2409 GrSurface* src,
2393 const SkIRect& srcRect, 2410 const SkIRect& srcRect,
2394 const SkIPoint& dstPoint) { 2411 const SkIPoint& dstPoint) {
2395 bool copied = false; 2412 bool copied = false;
2396 if (can_copy_texsubimage(dst, src, this)) { 2413 if (can_copy_texsubimage(dst, src, this)) {
2397 GrGLuint srcFBO; 2414 GrGLuint srcFBO;
2398 GrGLIRect srcVP; 2415 GrGLIRect srcVP;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
2489 } 2506 }
2490 } 2507 }
2491 return copied; 2508 return copied;
2492 } 2509 }
2493 2510
2494 bool GrGpuGL::canCopySurface(const GrSurface* dst, 2511 bool GrGpuGL::canCopySurface(const GrSurface* dst,
2495 const GrSurface* src, 2512 const GrSurface* src,
2496 const SkIRect& srcRect, 2513 const SkIRect& srcRect,
2497 const SkIPoint& dstPoint) { 2514 const SkIPoint& dstPoint) {
2498 // This mirrors the logic in onCopySurface. We prefer our base makes the co py if we need to 2515 // This mirrors the logic in onCopySurface. We prefer our base makes the co py if we need to
2499 // create a temp fbo 2516 // create a temp fbo. TODO verify the assumption that temp fbos are expensiv e; it may not be
2500 // TODO verify this assumption, it may not be true at all 2517 // true at all.
2501 bool wouldNeedTempFBO = false; 2518 bool wouldNeedTempFBO = false;
2502 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem pFBO) { 2519 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem pFBO) {
2503 return true; 2520 return true;
2504 } 2521 }
2505 if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem pFBO) { 2522 if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem pFBO) {
2506 if (dst == src) { 2523 if (dst == src) {
2507 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, 2524 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY,
2508 srcRect.width(), srcRect.height( )); 2525 srcRect.width(), srcRect.height( ));
2509 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { 2526 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) {
2510 return true; 2527 return true;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 this->setVertexArrayID(gpu, 0); 2573 this->setVertexArrayID(gpu, 0);
2557 } 2574 }
2558 int attrCount = gpu->glCaps().maxVertexAttributes(); 2575 int attrCount = gpu->glCaps().maxVertexAttributes();
2559 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2576 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2560 fDefaultVertexArrayAttribState.resize(attrCount); 2577 fDefaultVertexArrayAttribState.resize(attrCount);
2561 } 2578 }
2562 attribState = &fDefaultVertexArrayAttribState; 2579 attribState = &fDefaultVertexArrayAttribState;
2563 } 2580 }
2564 return attribState; 2581 return attribState;
2565 } 2582 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698