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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 /////////////////////////////////////////////////////////////////////////////// | 111 /////////////////////////////////////////////////////////////////////////////// |
112 | 112 |
113 static bool gPrintStartupSpew; | 113 static bool gPrintStartupSpew; |
114 | 114 |
115 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) | 115 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) |
116 : GrGpu(context) | 116 : GrGpu(context) |
117 , fGLContext(ctx) { | 117 , fGLContext(ctx) { |
118 | 118 |
| 119 #if GR_GPU_STATS |
| 120 fGPUStats.fBindFrameBufferCalls = 0; |
| 121 fGPUStats.fCompileShaderCalls = 0; |
| 122 #endif |
| 123 |
119 SkASSERT(ctx.isInitialized()); | 124 SkASSERT(ctx.isInitialized()); |
120 fCaps.reset(SkRef(ctx.caps())); | 125 fCaps.reset(SkRef(ctx.caps())); |
121 | 126 |
122 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); | 127 fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits()); |
123 | 128 |
124 GrGLClearErr(fGLContext.interface()); | 129 GrGLClearErr(fGLContext.interface()); |
125 if (gPrintStartupSpew) { | 130 if (gPrintStartupSpew) { |
126 const GrGLubyte* vendor; | 131 const GrGLubyte* vendor; |
127 const GrGLubyte* renderer; | 132 const GrGLubyte* renderer; |
128 const GrGLubyte* version; | 133 const GrGLubyte* version; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 if (desc->fRTFBOID != desc->fTexFBOID) { | 868 if (desc->fRTFBOID != desc->fTexFBOID) { |
864 SkASSERT(desc->fSampleCnt > 0); | 869 SkASSERT(desc->fSampleCnt > 0); |
865 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, | 870 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, |
866 desc->fMSColorRenderbufferID)); | 871 desc->fMSColorRenderbufferID)); |
867 if (!renderbuffer_storage_msaa(fGLContext, | 872 if (!renderbuffer_storage_msaa(fGLContext, |
868 desc->fSampleCnt, | 873 desc->fSampleCnt, |
869 msColorFormat, | 874 msColorFormat, |
870 width, height)) { | 875 width, height)) { |
871 goto FAILED; | 876 goto FAILED; |
872 } | 877 } |
| 878 #if GR_GPU_STATS |
| 879 fGPUStats.fBindFrameBufferCalls++; |
| 880 #endif |
873 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fRTFBOID)); | 881 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fRTFBOID)); |
874 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 882 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
875 GR_GL_COLOR_ATTACHMENT0, | 883 GR_GL_COLOR_ATTACHMENT0, |
876 GR_GL_RENDERBUFFER, | 884 GR_GL_RENDERBUFFER, |
877 desc->fMSColorRenderbufferID)); | 885 desc->fMSColorRenderbufferID)); |
878 if (desc->fCheckAllocation || | 886 if (desc->fCheckAllocation || |
879 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { | 887 !this->glCaps().isConfigVerifiedColorAttachment(desc->fConfig)) { |
880 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 888 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
881 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 889 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
882 goto FAILED; | 890 goto FAILED; |
883 } | 891 } |
884 fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig); | 892 fGLContext.caps()->markConfigAsValidColorAttachment(desc->fConfig); |
885 } | 893 } |
886 } | 894 } |
| 895 #if GR_GPU_STATS |
| 896 fGPUStats.fBindFrameBufferCalls++; |
| 897 #endif |
887 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID)); | 898 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, desc->fTexFBOID)); |
888 | 899 |
889 if (this->glCaps().usesImplicitMSAAResolve() && desc->fSampleCnt > 0) { | 900 if (this->glCaps().usesImplicitMSAAResolve() && desc->fSampleCnt > 0) { |
890 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, | 901 GL_CALL(FramebufferTexture2DMultisample(GR_GL_FRAMEBUFFER, |
891 GR_GL_COLOR_ATTACHMENT0, | 902 GR_GL_COLOR_ATTACHMENT0, |
892 GR_GL_TEXTURE_2D, | 903 GR_GL_TEXTURE_2D, |
893 texID, 0, desc->fSampleCnt)); | 904 texID, 0, desc->fSampleCnt)); |
894 } else { | 905 } else { |
895 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, | 906 GL_CALL(FramebufferTexture2D(GR_GL_FRAMEBUFFER, |
896 GR_GL_COLOR_ATTACHMENT0, | 907 GR_GL_COLOR_ATTACHMENT0, |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1238 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1249 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
1239 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); | 1250 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); |
1240 #endif | 1251 #endif |
1241 } | 1252 } |
1242 return true; | 1253 return true; |
1243 } else { | 1254 } else { |
1244 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); | 1255 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); |
1245 GrGLuint rb = glsb->renderbufferID(); | 1256 GrGLuint rb = glsb->renderbufferID(); |
1246 | 1257 |
1247 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1258 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 1259 #if GR_GPU_STATS |
| 1260 fGPUStats.fBindFrameBufferCalls++; |
| 1261 #endif |
1248 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo)); | 1262 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo)); |
1249 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1263 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
1250 GR_GL_STENCIL_ATTACHMENT, | 1264 GR_GL_STENCIL_ATTACHMENT, |
1251 GR_GL_RENDERBUFFER, rb)); | 1265 GR_GL_RENDERBUFFER, rb)); |
1252 if (glsb->format().fPacked) { | 1266 if (glsb->format().fPacked) { |
1253 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1267 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
1254 GR_GL_DEPTH_ATTACHMENT, | 1268 GR_GL_DEPTH_ATTACHMENT, |
1255 GR_GL_RENDERBUFFER, rb)); | 1269 GR_GL_RENDERBUFFER, rb)); |
1256 } else { | 1270 } else { |
1257 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1271 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 if (NULL == renderTarget) { | 1445 if (NULL == renderTarget) { |
1432 renderTarget = this->drawState()->getRenderTarget(); | 1446 renderTarget = this->drawState()->getRenderTarget(); |
1433 if (NULL == renderTarget) { | 1447 if (NULL == renderTarget) { |
1434 return; | 1448 return; |
1435 } | 1449 } |
1436 } | 1450 } |
1437 | 1451 |
1438 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); | 1452 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); |
1439 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { | 1453 if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) { |
1440 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1454 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
| 1455 #if GR_GPU_STATS |
| 1456 fGPUStats.fBindFrameBufferCalls++; |
| 1457 #endif |
1441 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); | 1458 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); |
1442 } | 1459 } |
1443 switch (this->glCaps().invalidateFBType()) { | 1460 switch (this->glCaps().invalidateFBType()) { |
1444 case GrGLCaps::kNone_InvalidateFBType: | 1461 case GrGLCaps::kNone_InvalidateFBType: |
1445 SkFAIL("Should never get here."); | 1462 SkFAIL("Should never get here."); |
1446 break; | 1463 break; |
1447 case GrGLCaps::kInvalidate_InvalidateFBType: | 1464 case GrGLCaps::kInvalidate_InvalidateFBType: |
1448 if (0 == glRT->renderFBOID()) { | 1465 if (0 == glRT->renderFBOID()) { |
1449 // When rendering to the default framebuffer the legal values f
or attachments | 1466 // When rendering to the default framebuffer the legal values f
or attachments |
1450 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment | 1467 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 switch (tgt->getResolveType()) { | 1611 switch (tgt->getResolveType()) { |
1595 case GrGLRenderTarget::kCantResolve_ResolveType: | 1612 case GrGLRenderTarget::kCantResolve_ResolveType: |
1596 return false; | 1613 return false; |
1597 case GrGLRenderTarget::kAutoResolves_ResolveType: | 1614 case GrGLRenderTarget::kAutoResolves_ResolveType: |
1598 this->flushRenderTarget(static_cast<GrGLRenderTarget*>(target), | 1615 this->flushRenderTarget(static_cast<GrGLRenderTarget*>(target), |
1599 &SkIRect::EmptyIRect()); | 1616 &SkIRect::EmptyIRect()); |
1600 break; | 1617 break; |
1601 case GrGLRenderTarget::kCanResolve_ResolveType: | 1618 case GrGLRenderTarget::kCanResolve_ResolveType: |
1602 this->onResolveRenderTarget(tgt); | 1619 this->onResolveRenderTarget(tgt); |
1603 // we don't track the state of the READ FBO ID. | 1620 // we don't track the state of the READ FBO ID. |
| 1621 #if GR_GPU_STATS |
| 1622 fGPUStats.fBindFrameBufferCalls++; |
| 1623 #endif |
1604 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, | 1624 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, |
1605 tgt->textureFBOID())); | 1625 tgt->textureFBOID())); |
1606 break; | 1626 break; |
1607 default: | 1627 default: |
1608 SkFAIL("Unknown resolve type"); | 1628 SkFAIL("Unknown resolve type"); |
1609 } | 1629 } |
1610 | 1630 |
1611 const GrGLIRect& glvp = tgt->getViewport(); | 1631 const GrGLIRect& glvp = tgt->getViewport(); |
1612 | 1632 |
1613 // the read rect is viewport-relative | 1633 // the read rect is viewport-relative |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1691 } | 1711 } |
1692 return true; | 1712 return true; |
1693 } | 1713 } |
1694 | 1714 |
1695 void GrGpuGL::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ | 1715 void GrGpuGL::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bound)
{ |
1696 | 1716 |
1697 SkASSERT(target); | 1717 SkASSERT(target); |
1698 | 1718 |
1699 uint32_t rtID = target->getUniqueID(); | 1719 uint32_t rtID = target->getUniqueID(); |
1700 if (fHWBoundRenderTargetUniqueID != rtID) { | 1720 if (fHWBoundRenderTargetUniqueID != rtID) { |
| 1721 #if GR_GPU_STATS |
| 1722 fGPUStats.fBindFrameBufferCalls++; |
| 1723 #endif |
1701 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 1724 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
1702 #ifdef SK_DEBUG | 1725 #ifdef SK_DEBUG |
1703 // don't do this check in Chromium -- this is causing | 1726 // don't do this check in Chromium -- this is causing |
1704 // lots of repeated command buffer flushes when the compositor is | 1727 // lots of repeated command buffer flushes when the compositor is |
1705 // rendering with Ganesh, which is really slow; even too slow for | 1728 // rendering with Ganesh, which is really slow; even too slow for |
1706 // Debug mode. | 1729 // Debug mode. |
1707 if (!this->glContext().isChromium()) { | 1730 if (!this->glContext().isChromium()) { |
1708 GrGLenum status; | 1731 GrGLenum status; |
1709 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1732 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
1710 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 1733 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 #endif | 1816 #endif |
1794 #endif | 1817 #endif |
1795 } | 1818 } |
1796 | 1819 |
1797 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { | 1820 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { |
1798 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 1821 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
1799 if (rt->needsResolve()) { | 1822 if (rt->needsResolve()) { |
1800 // Some extensions automatically resolves the texture when it is read. | 1823 // Some extensions automatically resolves the texture when it is read. |
1801 if (this->glCaps().usesMSAARenderBuffers()) { | 1824 if (this->glCaps().usesMSAARenderBuffers()) { |
1802 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); | 1825 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); |
| 1826 #if GR_GPU_STATS |
| 1827 fGPUStats.fBindFrameBufferCalls += 2; |
| 1828 #endif |
1803 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); | 1829 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); |
1804 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; | 1830 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; |
1805 // make sure we go through flushRenderTarget() since we've modified | 1831 // make sure we go through flushRenderTarget() since we've modified |
1806 // the bound DRAW FBO ID. | 1832 // the bound DRAW FBO ID. |
1807 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 1833 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
1808 const GrGLIRect& vp = rt->getViewport(); | 1834 const GrGLIRect& vp = rt->getViewport(); |
1809 const SkIRect dirtyRect = rt->getResolveRect(); | 1835 const SkIRect dirtyRect = rt->getResolveRect(); |
1810 GrGLIRect r; | 1836 GrGLIRect r; |
1811 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, | 1837 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, |
1812 dirtyRect.width(), dirtyRect.height(), target->origi
n()); | 1838 dirtyRect.width(), dirtyRect.height(), target->origi
n()); |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 !GrPixelConfigIsCompressed(src->config())) { | 2382 !GrPixelConfigIsCompressed(src->config())) { |
2357 if (wouldNeedTempFBO) { | 2383 if (wouldNeedTempFBO) { |
2358 *wouldNeedTempFBO = NULL == src->asRenderTarget(); | 2384 *wouldNeedTempFBO = NULL == src->asRenderTarget(); |
2359 } | 2385 } |
2360 return true; | 2386 return true; |
2361 } else { | 2387 } else { |
2362 return false; | 2388 return false; |
2363 } | 2389 } |
2364 } | 2390 } |
2365 | 2391 |
| 2392 } |
| 2393 |
2366 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is | 2394 // If a temporary FBO was created, its non-zero ID is returned. The viewport tha
t the copy rect is |
2367 // relative to is output. | 2395 // relative to is output. |
2368 inline GrGLuint bind_surface_as_fbo(const GrGLInterface* gl, | 2396 GrGLuint GrGpuGL::bindSurfaceAsFBO(GrSurface* surface, GrGLenum fboTarget, GrGLI
Rect* viewport) { |
2369 GrSurface* surface, | |
2370 GrGLenum fboTarget, | |
2371 GrGLIRect* viewport) { | |
2372 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); | 2397 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(surface->asRenderTarge
t()); |
2373 GrGLuint tempFBOID; | 2398 GrGLuint tempFBOID; |
2374 if (NULL == rt) { | 2399 if (NULL == rt) { |
2375 SkASSERT(surface->asTexture()); | 2400 SkASSERT(surface->asTexture()); |
2376 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); | 2401 GrGLuint texID = static_cast<GrGLTexture*>(surface->asTexture())->textur
eID(); |
2377 GR_GL_CALL(gl, GenFramebuffers(1, &tempFBOID)); | 2402 GR_GL_CALL(this->glInterface(), GenFramebuffers(1, &tempFBOID)); |
2378 GR_GL_CALL(gl, BindFramebuffer(fboTarget, tempFBOID)); | 2403 #if GR_GPU_STATS |
2379 GR_GL_CALL(gl, FramebufferTexture2D(fboTarget, | 2404 fGPUStats.fBindFrameBufferCalls++; |
2380 GR_GL_COLOR_ATTACHMENT0, | 2405 #endif |
2381 GR_GL_TEXTURE_2D, | 2406 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, tempFBOID)); |
2382 texID, | 2407 GR_GL_CALL(this->glInterface(), FramebufferTexture2D(fboTarget, |
2383 0)); | 2408 GR_GL_COLOR_ATTACHM
ENT0, |
| 2409 GR_GL_TEXTURE_2D, |
| 2410 texID, |
| 2411 0)); |
2384 viewport->fLeft = 0; | 2412 viewport->fLeft = 0; |
2385 viewport->fBottom = 0; | 2413 viewport->fBottom = 0; |
2386 viewport->fWidth = surface->width(); | 2414 viewport->fWidth = surface->width(); |
2387 viewport->fHeight = surface->height(); | 2415 viewport->fHeight = surface->height(); |
2388 } else { | 2416 } else { |
2389 tempFBOID = 0; | 2417 tempFBOID = 0; |
2390 GR_GL_CALL(gl, BindFramebuffer(fboTarget, rt->renderFBOID())); | 2418 #if GR_GPU_STATS |
| 2419 fGPUStats.fBindFrameBufferCalls++; |
| 2420 #endif |
| 2421 GR_GL_CALL(this->glInterface(), BindFramebuffer(fboTarget, rt->renderFBO
ID())); |
2391 *viewport = rt->getViewport(); | 2422 *viewport = rt->getViewport(); |
2392 } | 2423 } |
2393 return tempFBOID; | 2424 return tempFBOID; |
2394 } | 2425 } |
2395 | 2426 |
2396 } | |
2397 | |
2398 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc)
{ | 2427 void GrGpuGL::initCopySurfaceDstDesc(const GrSurface* src, GrTextureDesc* desc)
{ |
2399 // Check for format issues with glCopyTexSubImage2D | 2428 // Check for format issues with glCopyTexSubImage2D |
2400 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && | 2429 if (kGLES_GrGLStandard == this->glStandard() && this->glCaps().bgraIsInterna
lFormat() && |
2401 kBGRA_8888_GrPixelConfig == src->config()) { | 2430 kBGRA_8888_GrPixelConfig == src->config()) { |
2402 // glCopyTexSubImage2D doesn't work with this config. We'll want to make
it a render target | 2431 // glCopyTexSubImage2D doesn't work with this config. We'll want to make
it a render target |
2403 // in order to call glBlitFramebuffer or to copy to it by rendering. | 2432 // in order to call glBlitFramebuffer or to copy to it by rendering. |
2404 INHERITED::initCopySurfaceDstDesc(src, desc); | 2433 INHERITED::initCopySurfaceDstDesc(src, desc); |
2405 return; | 2434 return; |
2406 } else if (NULL == src->asRenderTarget()) { | 2435 } else if (NULL == src->asRenderTarget()) { |
2407 // We don't want to have to create an FBO just to use glCopyTexSubImage2
D. Let the base | 2436 // We don't want to have to create an FBO just to use glCopyTexSubImage2
D. Let the base |
(...skipping 17 matching lines...) Expand all Loading... |
2425 GrSurface* src, | 2454 GrSurface* src, |
2426 const SkIRect& srcRect, | 2455 const SkIRect& srcRect, |
2427 const SkIPoint& dstPoint) { | 2456 const SkIPoint& dstPoint) { |
2428 bool inheritedCouldCopy = INHERITED::onCanCopySurface(dst, src, srcRect, dst
Point); | 2457 bool inheritedCouldCopy = INHERITED::onCanCopySurface(dst, src, srcRect, dst
Point); |
2429 bool copied = false; | 2458 bool copied = false; |
2430 bool wouldNeedTempFBO = false; | 2459 bool wouldNeedTempFBO = false; |
2431 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && | 2460 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && |
2432 (!wouldNeedTempFBO || !inheritedCouldCopy)) { | 2461 (!wouldNeedTempFBO || !inheritedCouldCopy)) { |
2433 GrGLuint srcFBO; | 2462 GrGLuint srcFBO; |
2434 GrGLIRect srcVP; | 2463 GrGLIRect srcVP; |
2435 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER
, &srcVP); | 2464 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_FRAMEBUFFER, &srcVP); |
2436 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); | 2465 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); |
2437 SkASSERT(dstTex); | 2466 SkASSERT(dstTex); |
2438 // We modified the bound FBO | 2467 // We modified the bound FBO |
2439 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 2468 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
2440 GrGLIRect srcGLRect; | 2469 GrGLIRect srcGLRect; |
2441 srcGLRect.setRelativeTo(srcVP, | 2470 srcGLRect.setRelativeTo(srcVP, |
2442 srcRect.fLeft, | 2471 srcRect.fLeft, |
2443 srcRect.fTop, | 2472 srcRect.fTop, |
2444 srcRect.width(), | 2473 srcRect.width(), |
2445 srcRect.height(), | 2474 srcRect.height(), |
(...skipping 22 matching lines...) Expand all Loading... |
2468 bool selfOverlap = false; | 2497 bool selfOverlap = false; |
2469 if (dst->isSameAs(src)) { | 2498 if (dst->isSameAs(src)) { |
2470 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); | 2499 selfOverlap = SkIRect::IntersectsNoEmptyCheck(dstRect, srcRect); |
2471 } | 2500 } |
2472 | 2501 |
2473 if (!selfOverlap) { | 2502 if (!selfOverlap) { |
2474 GrGLuint dstFBO; | 2503 GrGLuint dstFBO; |
2475 GrGLuint srcFBO; | 2504 GrGLuint srcFBO; |
2476 GrGLIRect dstVP; | 2505 GrGLIRect dstVP; |
2477 GrGLIRect srcVP; | 2506 GrGLIRect srcVP; |
2478 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR
AMEBUFFER, &dstVP); | 2507 dstFBO = this->bindSurfaceAsFBO(dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP)
; |
2479 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR
AMEBUFFER, &srcVP); | 2508 srcFBO = this->bindSurfaceAsFBO(src, GR_GL_READ_FRAMEBUFFER, &srcVP)
; |
2480 // We modified the bound FBO | 2509 // We modified the bound FBO |
2481 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; | 2510 fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID; |
2482 GrGLIRect srcGLRect; | 2511 GrGLIRect srcGLRect; |
2483 GrGLIRect dstGLRect; | 2512 GrGLIRect dstGLRect; |
2484 srcGLRect.setRelativeTo(srcVP, | 2513 srcGLRect.setRelativeTo(srcVP, |
2485 srcRect.fLeft, | 2514 srcRect.fLeft, |
2486 srcRect.fTop, | 2515 srcRect.fTop, |
2487 srcRect.width(), | 2516 srcRect.width(), |
2488 srcRect.height(), | 2517 srcRect.height(), |
2489 src->origin()); | 2518 src->origin()); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 this->setVertexArrayID(gpu, 0); | 2625 this->setVertexArrayID(gpu, 0); |
2597 } | 2626 } |
2598 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2627 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2599 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2628 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2600 fDefaultVertexArrayAttribState.resize(attrCount); | 2629 fDefaultVertexArrayAttribState.resize(attrCount); |
2601 } | 2630 } |
2602 attribState = &fDefaultVertexArrayAttribState; | 2631 attribState = &fDefaultVertexArrayAttribState; |
2603 } | 2632 } |
2604 return attribState; | 2633 return attribState; |
2605 } | 2634 } |
OLD | NEW |