| OLD | NEW |
| 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 3484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3495 if (srcTexture && srcTexture->target() != GR_GL_TEXTURE_2D) { | 3495 if (srcTexture && srcTexture->target() != GR_GL_TEXTURE_2D) { |
| 3496 // Not supported for FBO blit or CopyTexSubImage | 3496 // Not supported for FBO blit or CopyTexSubImage |
| 3497 return false; | 3497 return false; |
| 3498 } | 3498 } |
| 3499 | 3499 |
| 3500 // We look for opportunities to use CopyTexSubImage, or fbo blit. If neither
are | 3500 // We look for opportunities to use CopyTexSubImage, or fbo blit. If neither
are |
| 3501 // possible and we return false to fallback to creating a render target dst
for render-to- | 3501 // possible and we return false to fallback to creating a render target dst
for render-to- |
| 3502 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger
ing temporary fbo | 3502 // texture. This code prefers CopyTexSubImage to fbo blit and avoids trigger
ing temporary fbo |
| 3503 // creation. It isn't clear that avoiding temporary fbo creation is actually
optimal. | 3503 // creation. It isn't clear that avoiding temporary fbo creation is actually
optimal. |
| 3504 | 3504 |
| 3505 GrSurfaceOrigin originForBlitFramebuffer = kDefault_GrSurfaceOrigin; |
| 3506 if (this->glCaps().blitFramebufferSupport() == |
| 3507 GrGLCaps::kNoScalingNoMirroring_BlitFramebufferSupport) { |
| 3508 originForBlitFramebuffer = src->origin(); |
| 3509 } |
| 3510 |
| 3505 // Check for format issues with glCopyTexSubImage2D | 3511 // Check for format issues with glCopyTexSubImage2D |
| 3506 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && | 3512 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && |
| 3507 kBGRA_8888_GrPixelConfig == src->config()) { | 3513 kBGRA_8888_GrPixelConfig == src->config()) { |
| 3508 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be
used with fbo blit | 3514 // glCopyTexSubImage2D doesn't work with this config. If the bgra can be
used with fbo blit |
| 3509 // then we set up for that, otherwise fail. | 3515 // then we set up for that, otherwise fail. |
| 3510 if (this->caps()->isConfigRenderable(kBGRA_8888_GrPixelConfig, false)) { | 3516 if (this->caps()->isConfigRenderable(kBGRA_8888_GrPixelConfig, false)) { |
| 3511 desc->fOrigin = kDefault_GrSurfaceOrigin; | 3517 desc->fOrigin = originForBlitFramebuffer; |
| 3512 desc->fFlags = kRenderTarget_GrSurfaceFlag; | 3518 desc->fFlags = kRenderTarget_GrSurfaceFlag; |
| 3513 desc->fConfig = kBGRA_8888_GrPixelConfig; | 3519 desc->fConfig = kBGRA_8888_GrPixelConfig; |
| 3514 return true; | 3520 return true; |
| 3515 } | 3521 } |
| 3516 return false; | 3522 return false; |
| 3517 } else if (nullptr == src->asRenderTarget()) { | 3523 } else if (nullptr == src->asRenderTarget()) { |
| 3518 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t
he src. | 3524 // CopyTexSubImage2D or fbo blit would require creating a temp fbo for t
he src. |
| 3519 return false; | 3525 return false; |
| 3520 } | 3526 } |
| 3521 | 3527 |
| 3522 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as
RenderTarget()); | 3528 const GrGLRenderTarget* srcRT = static_cast<const GrGLRenderTarget*>(src->as
RenderTarget()); |
| 3523 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { | 3529 if (srcRT && srcRT->renderFBOID() != srcRT->textureFBOID()) { |
| 3524 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up
for FBO blit or | 3530 // It's illegal to call CopyTexSubImage2D on a MSAA renderbuffer. Set up
for FBO blit or |
| 3525 // fail. | 3531 // fail. |
| 3526 if (this->caps()->isConfigRenderable(src->config(), false)) { | 3532 if (this->caps()->isConfigRenderable(src->config(), false)) { |
| 3527 desc->fOrigin = kDefault_GrSurfaceOrigin; | 3533 desc->fOrigin = originForBlitFramebuffer; |
| 3528 desc->fFlags = kRenderTarget_GrSurfaceFlag; | 3534 desc->fFlags = kRenderTarget_GrSurfaceFlag; |
| 3529 desc->fConfig = src->config(); | 3535 desc->fConfig = src->config(); |
| 3530 return true; | 3536 return true; |
| 3531 } | 3537 } |
| 3532 return false; | 3538 return false; |
| 3533 } | 3539 } |
| 3534 | 3540 |
| 3535 // We'll do a CopyTexSubImage. Make the dst a plain old texture. | 3541 // We'll do a CopyTexSubImage. Make the dst a plain old texture. |
| 3536 desc->fConfig = src->config(); | 3542 desc->fConfig = src->config(); |
| 3537 desc->fOrigin = src->origin(); | 3543 desc->fOrigin = src->origin(); |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4247 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4253 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
| 4248 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4254 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
| 4249 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4255 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
| 4250 copyParams->fWidth = texture->width(); | 4256 copyParams->fWidth = texture->width(); |
| 4251 copyParams->fHeight = texture->height(); | 4257 copyParams->fHeight = texture->height(); |
| 4252 return true; | 4258 return true; |
| 4253 } | 4259 } |
| 4254 } | 4260 } |
| 4255 return false; | 4261 return false; |
| 4256 } | 4262 } |
| OLD | NEW |