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

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

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