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 | 8 |
9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 2385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 desc->fConfig = src->config(); | 2396 desc->fConfig = src->config(); |
2397 desc->fOrigin = src->origin(); | 2397 desc->fOrigin = src->origin(); |
2398 desc->fFlags = kNone_GrSurfaceFlags; | 2398 desc->fFlags = kNone_GrSurfaceFlags; |
2399 } | 2399 } |
2400 } | 2400 } |
2401 | 2401 |
2402 bool GrGpuGL::onCopySurface(GrSurface* dst, | 2402 bool GrGpuGL::onCopySurface(GrSurface* dst, |
2403 GrSurface* src, | 2403 GrSurface* src, |
2404 const SkIRect& srcRect, | 2404 const SkIRect& srcRect, |
2405 const SkIPoint& dstPoint) { | 2405 const SkIPoint& dstPoint) { |
| 2406 bool inheritedCouldCopy = INHERITED::onCanCopySurface(dst, src, srcRect, dst
Point); |
2406 bool copied = false; | 2407 bool copied = false; |
2407 if (can_copy_texsubimage(dst, src, this)) { | 2408 bool wouldNeedTempFBO = false; |
| 2409 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && |
| 2410 (!wouldNeedTempFBO || !inheritedCouldCopy)) { |
2408 GrGLuint srcFBO; | 2411 GrGLuint srcFBO; |
2409 GrGLIRect srcVP; | 2412 GrGLIRect srcVP; |
2410 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP); | 2413 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP); |
2411 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); | 2414 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); |
2412 SkASSERT(dstTex); | 2415 SkASSERT(dstTex); |
2413 // We modified the bound FBO | 2416 // We modified the bound FBO |
2414 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 2417 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
2415 GrGLIRect srcGLRect; | 2418 GrGLIRect srcGLRect; |
2416 srcGLRect.setRelativeTo(srcVP, | 2419 srcGLRect.setRelativeTo(srcVP, |
2417 srcRect.fLeft, | 2420 srcRect.fLeft, |
(...skipping 11 matching lines...) Expand all Loading... |
2429 dstY = dstPoint.fY; | 2432 dstY = dstPoint.fY; |
2430 } | 2433 } |
2431 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, | 2434 GL_CALL(CopyTexSubImage2D(GR_GL_TEXTURE_2D, 0, |
2432 dstPoint.fX, dstY, | 2435 dstPoint.fX, dstY, |
2433 srcGLRect.fLeft, srcGLRect.fBottom, | 2436 srcGLRect.fLeft, srcGLRect.fBottom, |
2434 srcGLRect.fWidth, srcGLRect.fHeight)); | 2437 srcGLRect.fWidth, srcGLRect.fHeight)); |
2435 copied = true; | 2438 copied = true; |
2436 if (srcFBO) { | 2439 if (srcFBO) { |
2437 GL_CALL(DeleteFramebuffers(1, &srcFBO)); | 2440 GL_CALL(DeleteFramebuffers(1, &srcFBO)); |
2438 } | 2441 } |
2439 } else if (can_blit_framebuffer(dst, src, this)) { | 2442 } else if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && |
| 2443 (!wouldNeedTempFBO || !inheritedCouldCopy)) { |
2440 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 2444 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
2441 srcRect.width(), srcRect.height()); | 2445 srcRect.width(), srcRect.height()); |
2442 bool selfOverlap = false; | 2446 bool selfOverlap = false; |
2443 if (dst->surfacePriv().isSameAs(src)) { | 2447 if (dst->surfacePriv().isSameAs(src)) { |
2444 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); | 2448 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); |
2445 } | 2449 } |
2446 | 2450 |
2447 if (!selfOverlap) { | 2451 if (!selfOverlap) { |
2448 GrGLuint dstFBO; | 2452 GrGLuint dstFBO; |
2449 GrGLuint srcFBO; | 2453 GrGLuint srcFBO; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2492 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); | 2496 GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); |
2493 if (dstFBO) { | 2497 if (dstFBO) { |
2494 GL_CALL(DeleteFramebuffers(1, &dstFBO)); | 2498 GL_CALL(DeleteFramebuffers(1, &dstFBO)); |
2495 } | 2499 } |
2496 if (srcFBO) { | 2500 if (srcFBO) { |
2497 GL_CALL(DeleteFramebuffers(1, &srcFBO)); | 2501 GL_CALL(DeleteFramebuffers(1, &srcFBO)); |
2498 } | 2502 } |
2499 copied = true; | 2503 copied = true; |
2500 } | 2504 } |
2501 } | 2505 } |
| 2506 if (!copied && inheritedCouldCopy) { |
| 2507 copied = INHERITED::onCopySurface(dst, src, srcRect, dstPoint); |
| 2508 SkASSERT(copied); |
| 2509 } |
2502 return copied; | 2510 return copied; |
2503 } | 2511 } |
2504 | 2512 |
2505 bool GrGpuGL::onCanCopySurface(GrSurface* dst, | 2513 bool GrGpuGL::onCanCopySurface(GrSurface* dst, |
2506 GrSurface* src, | 2514 GrSurface* src, |
2507 const SkIRect& srcRect, | 2515 const SkIRect& srcRect, |
2508 const SkIPoint& dstPoint) { | 2516 const SkIPoint& dstPoint) { |
2509 // This mirrors the logic in onCopySurface. We prefer our base makes the co
py if we need to | 2517 // This mirrors the logic in onCopySurface. |
2510 // create a temp fbo | 2518 if (can_copy_texsubimage(dst, src, this)) { |
2511 // TODO verify this assumption, it may not be true at all | |
2512 bool wouldNeedTempFBO = false; | |
2513 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem
pFBO) { | |
2514 return true; | 2519 return true; |
2515 } | 2520 } |
2516 if (can_blit_framebuffer(dst, src, this, &wouldNeedTempFBO) && !wouldNeedTem
pFBO) { | 2521 if (can_blit_framebuffer(dst, src, this)) { |
2517 if (dst->surfacePriv().isSameAs(src)) { | 2522 if (dst->surfacePriv().isSameAs(src)) { |
2518 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, | 2523 SkIRect dstRect = SkIRect::MakeXYWH(dstPoint.fX, dstPoint.fY, |
2519 srcRect.width(), srcRect.height(
)); | 2524 srcRect.width(), srcRect.height(
)); |
2520 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { | 2525 if(!SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect)) { |
2521 return true; | 2526 return true; |
2522 } | 2527 } |
2523 } else { | 2528 } else { |
2524 return true; | 2529 return true; |
2525 } | 2530 } |
2526 } | 2531 } |
2527 return false; | 2532 return INHERITED::onCanCopySurface(dst, src, srcRect, dstPoint); |
2528 } | 2533 } |
2529 | 2534 |
2530 void GrGpuGL::didAddGpuTraceMarker() { | 2535 void GrGpuGL::didAddGpuTraceMarker() { |
2531 if (this->caps()->gpuTracingSupport()) { | 2536 if (this->caps()->gpuTracingSupport()) { |
2532 const GrTraceMarkerSet& markerArray = this->getActiveTraceMarkers(); | 2537 const GrTraceMarkerSet& markerArray = this->getActiveTraceMarkers(); |
2533 SkString markerString = markerArray.toStringLast(); | 2538 SkString markerString = markerArray.toStringLast(); |
2534 GL_CALL(PushGroupMarker(0, markerString.c_str())); | 2539 GL_CALL(PushGroupMarker(0, markerString.c_str())); |
2535 } | 2540 } |
2536 } | 2541 } |
2537 | 2542 |
(...skipping 29 matching lines...) Expand all Loading... |
2567 this->setVertexArrayID(gpu, 0); | 2572 this->setVertexArrayID(gpu, 0); |
2568 } | 2573 } |
2569 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2574 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2570 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2575 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2571 fDefaultVertexArrayAttribState.resize(attrCount); | 2576 fDefaultVertexArrayAttribState.resize(attrCount); |
2572 } | 2577 } |
2573 attribState = &fDefaultVertexArrayAttribState; | 2578 attribState = &fDefaultVertexArrayAttribState; |
2574 } | 2579 } |
2575 return attribState; | 2580 return attribState; |
2576 } | 2581 } |
OLD | NEW |