| 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 "GrGLNameAllocator.h" | 10 #include "GrGLNameAllocator.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 static bool gPrintStartupSpew; | 114 static bool gPrintStartupSpew; |
| 115 | 115 |
| 116 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) | 116 GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context) |
| 117 : GrGpu(context) | 117 : GrGpu(context) |
| 118 , fGLContext(ctx) { | 118 , fGLContext(ctx) { |
| 119 | 119 |
| 120 SkASSERT(ctx.isInitialized()); | 120 SkASSERT(ctx.isInitialized()); |
| 121 fCaps.reset(SkRef(ctx.caps())); | 121 fCaps.reset(SkRef(ctx.caps())); |
| 122 | 122 |
| 123 fHWBoundTextures.reset(this->glCaps().maxFragmentTextureUnits()); | 123 fHWBoundTextureInstanceIDs.reset(this->glCaps().maxFragmentTextureUnits()); |
| 124 fHWPathTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords()); | 124 fHWPathTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords()); |
| 125 | 125 |
| 126 GrGLClearErr(fGLContext.interface()); | 126 GrGLClearErr(fGLContext.interface()); |
| 127 if (gPrintStartupSpew) { | 127 if (gPrintStartupSpew) { |
| 128 const GrGLubyte* vendor; | 128 const GrGLubyte* vendor; |
| 129 const GrGLubyte* renderer; | 129 const GrGLubyte* renderer; |
| 130 const GrGLubyte* version; | 130 const GrGLubyte* version; |
| 131 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); | 131 GL_CALL_RET(vendor, GetString(GR_GL_VENDOR)); |
| 132 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); | 132 GL_CALL_RET(renderer, GetString(GR_GL_RENDERER)); |
| 133 GL_CALL_RET(version, GetString(GR_GL_VERSION)); | 133 GL_CALL_RET(version, GetString(GR_GL_VERSION)); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 GL_CALL(LineWidth(1)); | 266 GL_CALL(LineWidth(1)); |
| 267 } | 267 } |
| 268 | 268 |
| 269 if (resetBits & kAA_GrGLBackendState) { | 269 if (resetBits & kAA_GrGLBackendState) { |
| 270 fHWAAState.invalidate(); | 270 fHWAAState.invalidate(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 fHWActiveTextureUnitIdx = -1; // invalid | 273 fHWActiveTextureUnitIdx = -1; // invalid |
| 274 | 274 |
| 275 if (resetBits & kTextureBinding_GrGLBackendState) { | 275 if (resetBits & kTextureBinding_GrGLBackendState) { |
| 276 for (int s = 0; s < fHWBoundTextures.count(); ++s) { | 276 for (int s = 0; s < fHWBoundTextureInstanceIDs.count(); ++s) { |
| 277 fHWBoundTextures[s] = NULL; | 277 fHWBoundTextureInstanceIDs[s] = 0; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 if (resetBits & kBlend_GrGLBackendState) { | 281 if (resetBits & kBlend_GrGLBackendState) { |
| 282 fHWBlendState.invalidate(); | 282 fHWBlendState.invalidate(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 if (resetBits & kView_GrGLBackendState) { | 285 if (resetBits & kView_GrGLBackendState) { |
| 286 fHWScissorSettings.invalidate(); | 286 fHWScissorSettings.invalidate(); |
| 287 fHWViewport.invalidate(); | 287 fHWViewport.invalidate(); |
| 288 } | 288 } |
| 289 | 289 |
| 290 if (resetBits & kStencil_GrGLBackendState) { | 290 if (resetBits & kStencil_GrGLBackendState) { |
| 291 fHWStencilSettings.invalidate(); | 291 fHWStencilSettings.invalidate(); |
| 292 fHWStencilTestEnabled = kUnknown_TriState; | 292 fHWStencilTestEnabled = kUnknown_TriState; |
| 293 } | 293 } |
| 294 | 294 |
| 295 // Vertex | 295 // Vertex |
| 296 if (resetBits & kVertex_GrGLBackendState) { | 296 if (resetBits & kVertex_GrGLBackendState) { |
| 297 fHWGeometryState.invalidate(); | 297 fHWGeometryState.invalidate(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 if (resetBits & kRenderTarget_GrGLBackendState) { | 300 if (resetBits & kRenderTarget_GrGLBackendState) { |
| 301 fHWBoundRenderTarget = NULL; | 301 fHWBoundRenderTargetInstanceID = 0; |
| 302 } | 302 } |
| 303 | 303 |
| 304 if (resetBits & kPathRendering_GrGLBackendState) { | 304 if (resetBits & kPathRendering_GrGLBackendState) { |
| 305 if (this->caps()->pathRenderingSupport()) { | 305 if (this->caps()->pathRenderingSupport()) { |
| 306 fHWProjectionMatrixState.invalidate(); | 306 fHWProjectionMatrixState.invalidate(); |
| 307 // we don't use the model view matrix. | 307 // we don't use the model view matrix. |
| 308 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); | 308 GL_CALL(MatrixLoadIdentity(GR_GL_MODELVIEW)); |
| 309 | 309 |
| 310 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords();
++i) { | 310 for (int i = 0; i < this->glCaps().maxFixedFunctionTextureCoords();
++i) { |
| 311 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); | 311 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 &msColorFormat, | 859 &msColorFormat, |
| 860 NULL, | 860 NULL, |
| 861 NULL)) { | 861 NULL)) { |
| 862 goto FAILED; | 862 goto FAILED; |
| 863 } | 863 } |
| 864 } else { | 864 } else { |
| 865 desc->fRTFBOID = desc->fTexFBOID; | 865 desc->fRTFBOID = desc->fTexFBOID; |
| 866 } | 866 } |
| 867 | 867 |
| 868 // below here we may bind the FBO | 868 // below here we may bind the FBO |
| 869 fHWBoundRenderTarget = NULL; | 869 fHWBoundRenderTargetInstanceID = 0; |
| 870 if (desc->fRTFBOID != desc->fTexFBOID) { | 870 if (desc->fRTFBOID != desc->fTexFBOID) { |
| 871 SkASSERT(desc->fSampleCnt > 0); | 871 SkASSERT(desc->fSampleCnt > 0); |
| 872 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, | 872 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, |
| 873 desc->fMSColorRenderbufferID)); | 873 desc->fMSColorRenderbufferID)); |
| 874 if (!renderbuffer_storage_msaa(fGLContext, | 874 if (!renderbuffer_storage_msaa(fGLContext, |
| 875 desc->fSampleCnt, | 875 desc->fSampleCnt, |
| 876 msColorFormat, | 876 msColorFormat, |
| 877 width, height)) { | 877 width, height)) { |
| 878 goto FAILED; | 878 goto FAILED; |
| 879 } | 879 } |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 GrGLenum status; | 1244 GrGLenum status; |
| 1245 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1245 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
| 1246 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); | 1246 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); |
| 1247 #endif | 1247 #endif |
| 1248 } | 1248 } |
| 1249 return true; | 1249 return true; |
| 1250 } else { | 1250 } else { |
| 1251 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); | 1251 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); |
| 1252 GrGLuint rb = glsb->renderbufferID(); | 1252 GrGLuint rb = glsb->renderbufferID(); |
| 1253 | 1253 |
| 1254 fHWBoundRenderTarget = NULL; | 1254 fHWBoundRenderTargetInstanceID = 0; |
| 1255 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo)); | 1255 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo)); |
| 1256 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1256 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
| 1257 GR_GL_STENCIL_ATTACHMENT, | 1257 GR_GL_STENCIL_ATTACHMENT, |
| 1258 GR_GL_RENDERBUFFER, rb)); | 1258 GR_GL_RENDERBUFFER, rb)); |
| 1259 if (glsb->format().fPacked) { | 1259 if (glsb->format().fPacked) { |
| 1260 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1260 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
| 1261 GR_GL_DEPTH_ATTACHMENT, | 1261 GR_GL_DEPTH_ATTACHMENT, |
| 1262 GR_GL_RENDERBUFFER, rb)); | 1262 GR_GL_RENDERBUFFER, rb)); |
| 1263 } else { | 1263 } else { |
| 1264 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1264 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1450 return; | 1450 return; |
| 1451 } | 1451 } |
| 1452 if (NULL == renderTarget) { | 1452 if (NULL == renderTarget) { |
| 1453 renderTarget = this->drawState()->getRenderTarget(); | 1453 renderTarget = this->drawState()->getRenderTarget(); |
| 1454 if (NULL == renderTarget) { | 1454 if (NULL == renderTarget) { |
| 1455 return; | 1455 return; |
| 1456 } | 1456 } |
| 1457 } | 1457 } |
| 1458 | 1458 |
| 1459 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); | 1459 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); |
| 1460 if (renderTarget != fHWBoundRenderTarget) { | 1460 if (renderTarget->getInstanceID() != fHWBoundRenderTargetInstanceID) { |
| 1461 fHWBoundRenderTarget = NULL; | 1461 fHWBoundRenderTargetInstanceID = NULL; |
| 1462 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); | 1462 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); |
| 1463 } | 1463 } |
| 1464 switch (this->glCaps().invalidateFBType()) { | 1464 switch (this->glCaps().invalidateFBType()) { |
| 1465 case GrGLCaps::kNone_FBFetchType: | 1465 case GrGLCaps::kNone_FBFetchType: |
| 1466 SkFAIL("Should never get here."); | 1466 SkFAIL("Should never get here."); |
| 1467 break; | 1467 break; |
| 1468 case GrGLCaps::kInvalidate_InvalidateFBType: | 1468 case GrGLCaps::kInvalidate_InvalidateFBType: |
| 1469 if (0 == glRT->renderFBOID()) { | 1469 if (0 == glRT->renderFBOID()) { |
| 1470 // When rendering to the default framebuffer the legal values f
or attachments | 1470 // When rendering to the default framebuffer the legal values f
or attachments |
| 1471 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment | 1471 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 } | 1714 } |
| 1715 return true; | 1715 return true; |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 void GrGpuGL::flushRenderTarget(const SkIRect* bound) { | 1718 void GrGpuGL::flushRenderTarget(const SkIRect* bound) { |
| 1719 | 1719 |
| 1720 GrGLRenderTarget* rt = | 1720 GrGLRenderTarget* rt = |
| 1721 static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget()); | 1721 static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget()); |
| 1722 SkASSERT(NULL != rt); | 1722 SkASSERT(NULL != rt); |
| 1723 | 1723 |
| 1724 if (fHWBoundRenderTarget != rt) { | 1724 uint32_t rtID = rt->getInstanceID(); |
| 1725 if (fHWBoundRenderTargetInstanceID != rtID) { |
| 1725 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID())); | 1726 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID())); |
| 1726 #ifdef SK_DEBUG | 1727 #ifdef SK_DEBUG |
| 1727 // don't do this check in Chromium -- this is causing | 1728 // don't do this check in Chromium -- this is causing |
| 1728 // lots of repeated command buffer flushes when the compositor is | 1729 // lots of repeated command buffer flushes when the compositor is |
| 1729 // rendering with Ganesh, which is really slow; even too slow for | 1730 // rendering with Ganesh, which is really slow; even too slow for |
| 1730 // Debug mode. | 1731 // Debug mode. |
| 1731 if (!this->glContext().isChromium()) { | 1732 if (!this->glContext().isChromium()) { |
| 1732 GrGLenum status; | 1733 GrGLenum status; |
| 1733 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1734 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
| 1734 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 1735 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
| 1735 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x
\n", status); | 1736 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x
\n", status); |
| 1736 } | 1737 } |
| 1737 } | 1738 } |
| 1738 #endif | 1739 #endif |
| 1739 fHWBoundRenderTarget = rt; | 1740 fHWBoundRenderTargetInstanceID = rtID; |
| 1740 const GrGLIRect& vp = rt->getViewport(); | 1741 const GrGLIRect& vp = rt->getViewport(); |
| 1741 if (fHWViewport != vp) { | 1742 if (fHWViewport != vp) { |
| 1742 vp.pushToGLViewport(this->glInterface()); | 1743 vp.pushToGLViewport(this->glInterface()); |
| 1743 fHWViewport = vp; | 1744 fHWViewport = vp; |
| 1744 } | 1745 } |
| 1745 } | 1746 } |
| 1746 if (NULL == bound || !bound->isEmpty()) { | 1747 if (NULL == bound || !bound->isEmpty()) { |
| 1747 rt->flagAsNeedingResolve(bound); | 1748 rt->flagAsNeedingResolve(bound); |
| 1748 } | 1749 } |
| 1749 | 1750 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { | 1997 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { |
| 1997 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 1998 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
| 1998 if (rt->needsResolve()) { | 1999 if (rt->needsResolve()) { |
| 1999 // Some extensions automatically resolves the texture when it is read. | 2000 // Some extensions automatically resolves the texture when it is read. |
| 2000 if (this->glCaps().usesMSAARenderBuffers()) { | 2001 if (this->glCaps().usesMSAARenderBuffers()) { |
| 2001 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); | 2002 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); |
| 2002 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); | 2003 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); |
| 2003 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; | 2004 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; |
| 2004 // make sure we go through flushRenderTarget() since we've modified | 2005 // make sure we go through flushRenderTarget() since we've modified |
| 2005 // the bound DRAW FBO ID. | 2006 // the bound DRAW FBO ID. |
| 2006 fHWBoundRenderTarget = NULL; | 2007 fHWBoundRenderTargetInstanceID = 0; |
| 2007 const GrGLIRect& vp = rt->getViewport(); | 2008 const GrGLIRect& vp = rt->getViewport(); |
| 2008 const SkIRect dirtyRect = rt->getResolveRect(); | 2009 const SkIRect dirtyRect = rt->getResolveRect(); |
| 2009 GrGLIRect r; | 2010 GrGLIRect r; |
| 2010 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, | 2011 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, |
| 2011 dirtyRect.width(), dirtyRect.height(), target->origi
n()); | 2012 dirtyRect.width(), dirtyRect.height(), target->origi
n()); |
| 2012 | 2013 |
| 2013 GrAutoTRestore<ScissorState> asr; | 2014 GrAutoTRestore<ScissorState> asr; |
| 2014 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { | 2015 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { |
| 2015 // Apple's extension uses the scissor as the blit bounds. | 2016 // Apple's extension uses the scissor as the blit bounds. |
| 2016 asr.reset(&fScissorState); | 2017 asr.reset(&fScissorState); |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 SkASSERT(NULL != texture); | 2291 SkASSERT(NULL != texture); |
| 2291 | 2292 |
| 2292 // If we created a rt/tex and rendered to it without using a texture and now
we're texturing | 2293 // If we created a rt/tex and rendered to it without using a texture and now
we're texturing |
| 2293 // from the rt it will still be the last bound texture, but it needs resolvi
ng. So keep this | 2294 // from the rt it will still be the last bound texture, but it needs resolvi
ng. So keep this |
| 2294 // out of the "last != next" check. | 2295 // out of the "last != next" check. |
| 2295 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT
arget()); | 2296 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT
arget()); |
| 2296 if (NULL != texRT) { | 2297 if (NULL != texRT) { |
| 2297 this->onResolveRenderTarget(texRT); | 2298 this->onResolveRenderTarget(texRT); |
| 2298 } | 2299 } |
| 2299 | 2300 |
| 2300 if (fHWBoundTextures[unitIdx] != texture) { | 2301 uint32_t textureID = texture->getInstanceID(); |
| 2302 if (fHWBoundTextureInstanceIDs[unitIdx] != textureID) { |
| 2301 this->setTextureUnit(unitIdx); | 2303 this->setTextureUnit(unitIdx); |
| 2302 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); | 2304 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); |
| 2303 fHWBoundTextures[unitIdx] = texture; | 2305 fHWBoundTextureInstanceIDs[unitIdx] = textureID; |
| 2304 } | 2306 } |
| 2305 | 2307 |
| 2306 ResetTimestamp timestamp; | 2308 ResetTimestamp timestamp; |
| 2307 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); | 2309 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); |
| 2308 bool setAll = timestamp < this->getResetTimestamp(); | 2310 bool setAll = timestamp < this->getResetTimestamp(); |
| 2309 GrGLTexture::TexParams newTexParams; | 2311 GrGLTexture::TexParams newTexParams; |
| 2310 | 2312 |
| 2311 static GrGLenum glMinFilterModes[] = { | 2313 static GrGLenum glMinFilterModes[] = { |
| 2312 GR_GL_NEAREST, | 2314 GR_GL_NEAREST, |
| 2313 GR_GL_LINEAR, | 2315 GR_GL_LINEAR, |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2521 case GrDrawState::kBoth_DrawFace: | 2523 case GrDrawState::kBoth_DrawFace: |
| 2522 GL_CALL(Disable(GR_GL_CULL_FACE)); | 2524 GL_CALL(Disable(GR_GL_CULL_FACE)); |
| 2523 break; | 2525 break; |
| 2524 default: | 2526 default: |
| 2525 SkFAIL("Unknown draw face."); | 2527 SkFAIL("Unknown draw face."); |
| 2526 } | 2528 } |
| 2527 fHWDrawFace = drawState.getDrawFace(); | 2529 fHWDrawFace = drawState.getDrawFace(); |
| 2528 } | 2530 } |
| 2529 } | 2531 } |
| 2530 | 2532 |
| 2531 void GrGpuGL::notifyRenderTargetDelete(GrRenderTarget* renderTarget) { | |
| 2532 SkASSERT(NULL != renderTarget); | |
| 2533 if (fHWBoundRenderTarget == renderTarget) { | |
| 2534 fHWBoundRenderTarget = NULL; | |
| 2535 } | |
| 2536 } | |
| 2537 | |
| 2538 void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) { | |
| 2539 for (int s = 0; s < fHWBoundTextures.count(); ++s) { | |
| 2540 if (fHWBoundTextures[s] == texture) { | |
| 2541 // deleting bound texture does implied bind to 0 | |
| 2542 fHWBoundTextures[s] = NULL; | |
| 2543 } | |
| 2544 } | |
| 2545 } | |
| 2546 | |
| 2547 | |
| 2548 GrGLuint GrGpuGL::createGLPathObject() { | 2533 GrGLuint GrGpuGL::createGLPathObject() { |
| 2549 if (NULL == fPathNameAllocator.get()) { | 2534 if (NULL == fPathNameAllocator.get()) { |
| 2550 static const int range = 65536; | 2535 static const int range = 65536; |
| 2551 GrGLuint firstName; | 2536 GrGLuint firstName; |
| 2552 GL_CALL_RET(firstName, GenPaths(range)); | 2537 GL_CALL_RET(firstName, GenPaths(range)); |
| 2553 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first
Name + range))); | 2538 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first
Name + range))); |
| 2554 } | 2539 } |
| 2555 | 2540 |
| 2556 GrGLuint name = fPathNameAllocator->allocateName(); | 2541 GrGLuint name = fPathNameAllocator->allocateName(); |
| 2557 if (0 == name) { | 2542 if (0 == name) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2697 case kR11_EAC_GrPixelConfig: | 2682 case kR11_EAC_GrPixelConfig: |
| 2698 *internalFormat = GR_GL_COMPRESSED_R11; | 2683 *internalFormat = GR_GL_COMPRESSED_R11; |
| 2699 break; | 2684 break; |
| 2700 default: | 2685 default: |
| 2701 return false; | 2686 return false; |
| 2702 } | 2687 } |
| 2703 return true; | 2688 return true; |
| 2704 } | 2689 } |
| 2705 | 2690 |
| 2706 void GrGpuGL::setTextureUnit(int unit) { | 2691 void GrGpuGL::setTextureUnit(int unit) { |
| 2707 SkASSERT(unit >= 0 && unit < fHWBoundTextures.count()); | 2692 SkASSERT(unit >= 0 && unit < fHWBoundTextureInstanceIDs.count()); |
| 2708 if (unit != fHWActiveTextureUnitIdx) { | 2693 if (unit != fHWActiveTextureUnitIdx) { |
| 2709 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); | 2694 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); |
| 2710 fHWActiveTextureUnitIdx = unit; | 2695 fHWActiveTextureUnitIdx = unit; |
| 2711 } | 2696 } |
| 2712 } | 2697 } |
| 2713 | 2698 |
| 2714 void GrGpuGL::setScratchTextureUnit() { | 2699 void GrGpuGL::setScratchTextureUnit() { |
| 2715 // Bind the last texture unit since it is the least likely to be used by GrG
LProgram. | 2700 // Bind the last texture unit since it is the least likely to be used by GrG
LProgram. |
| 2716 int lastUnitIdx = fHWBoundTextures.count() - 1; | 2701 int lastUnitIdx = fHWBoundTextureInstanceIDs.count() - 1; |
| 2717 if (lastUnitIdx != fHWActiveTextureUnitIdx) { | 2702 if (lastUnitIdx != fHWActiveTextureUnitIdx) { |
| 2718 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); | 2703 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); |
| 2719 fHWActiveTextureUnitIdx = lastUnitIdx; | 2704 fHWActiveTextureUnitIdx = lastUnitIdx; |
| 2720 } | 2705 } |
| 2721 // clear out the this field so that if a program does use this unit it will
rebind the correct | 2706 // clear out the this field so that if a program does use this unit it will
rebind the correct |
| 2722 // texture. | 2707 // texture. |
| 2723 fHWBoundTextures[lastUnitIdx] = NULL; | 2708 fHWBoundTextureInstanceIDs[lastUnitIdx] = 0; |
| 2724 } | 2709 } |
| 2725 | 2710 |
| 2726 namespace { | 2711 namespace { |
| 2727 // Determines whether glBlitFramebuffer could be used between src and dst. | 2712 // Determines whether glBlitFramebuffer could be used between src and dst. |
| 2728 inline bool can_blit_framebuffer(const GrSurface* dst, | 2713 inline bool can_blit_framebuffer(const GrSurface* dst, |
| 2729 const GrSurface* src, | 2714 const GrSurface* src, |
| 2730 const GrGpuGL* gpu, | 2715 const GrGpuGL* gpu, |
| 2731 bool* wouldNeedTempFBO = NULL) { | 2716 bool* wouldNeedTempFBO = NULL) { |
| 2732 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && | 2717 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && |
| 2733 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 2718 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2850 bool copied = false; | 2835 bool copied = false; |
| 2851 bool wouldNeedTempFBO = false; | 2836 bool wouldNeedTempFBO = false; |
| 2852 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && | 2837 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && |
| 2853 (!wouldNeedTempFBO || !inheritedCouldCopy)) { | 2838 (!wouldNeedTempFBO || !inheritedCouldCopy)) { |
| 2854 GrGLuint srcFBO; | 2839 GrGLuint srcFBO; |
| 2855 GrGLIRect srcVP; | 2840 GrGLIRect srcVP; |
| 2856 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER
, &srcVP); | 2841 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER
, &srcVP); |
| 2857 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); | 2842 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); |
| 2858 SkASSERT(NULL != dstTex); | 2843 SkASSERT(NULL != dstTex); |
| 2859 // We modified the bound FBO | 2844 // We modified the bound FBO |
| 2860 fHWBoundRenderTarget = NULL; | 2845 fHWBoundRenderTargetInstanceID = 0; |
| 2861 GrGLIRect srcGLRect; | 2846 GrGLIRect srcGLRect; |
| 2862 srcGLRect.setRelativeTo(srcVP, | 2847 srcGLRect.setRelativeTo(srcVP, |
| 2863 srcRect.fLeft, | 2848 srcRect.fLeft, |
| 2864 srcRect.fTop, | 2849 srcRect.fTop, |
| 2865 srcRect.width(), | 2850 srcRect.width(), |
| 2866 srcRect.height(), | 2851 srcRect.height(), |
| 2867 src->origin()); | 2852 src->origin()); |
| 2868 | 2853 |
| 2869 this->setScratchTextureUnit(); | 2854 this->setScratchTextureUnit(); |
| 2870 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); | 2855 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2892 } | 2877 } |
| 2893 | 2878 |
| 2894 if (!selfOverlap) { | 2879 if (!selfOverlap) { |
| 2895 GrGLuint dstFBO; | 2880 GrGLuint dstFBO; |
| 2896 GrGLuint srcFBO; | 2881 GrGLuint srcFBO; |
| 2897 GrGLIRect dstVP; | 2882 GrGLIRect dstVP; |
| 2898 GrGLIRect srcVP; | 2883 GrGLIRect srcVP; |
| 2899 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR
AMEBUFFER, &dstVP); | 2884 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR
AMEBUFFER, &dstVP); |
| 2900 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR
AMEBUFFER, &srcVP); | 2885 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR
AMEBUFFER, &srcVP); |
| 2901 // We modified the bound FBO | 2886 // We modified the bound FBO |
| 2902 fHWBoundRenderTarget = NULL; | 2887 fHWBoundRenderTargetInstanceID = 0; |
| 2903 GrGLIRect srcGLRect; | 2888 GrGLIRect srcGLRect; |
| 2904 GrGLIRect dstGLRect; | 2889 GrGLIRect dstGLRect; |
| 2905 srcGLRect.setRelativeTo(srcVP, | 2890 srcGLRect.setRelativeTo(srcVP, |
| 2906 srcRect.fLeft, | 2891 srcRect.fLeft, |
| 2907 srcRect.fTop, | 2892 srcRect.fTop, |
| 2908 srcRect.width(), | 2893 srcRect.width(), |
| 2909 srcRect.height(), | 2894 srcRect.height(), |
| 2910 src->origin()); | 2895 src->origin()); |
| 2911 dstGLRect.setRelativeTo(dstVP, | 2896 dstGLRect.setRelativeTo(dstVP, |
| 2912 dstRect.fLeft, | 2897 dstRect.fLeft, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3018 this->setVertexArrayID(gpu, 0); | 3003 this->setVertexArrayID(gpu, 0); |
| 3019 } | 3004 } |
| 3020 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3005 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 3021 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3006 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 3022 fDefaultVertexArrayAttribState.resize(attrCount); | 3007 fDefaultVertexArrayAttribState.resize(attrCount); |
| 3023 } | 3008 } |
| 3024 attribState = &fDefaultVertexArrayAttribState; | 3009 attribState = &fDefaultVertexArrayAttribState; |
| 3025 } | 3010 } |
| 3026 return attribState; | 3011 return attribState; |
| 3027 } | 3012 } |
| OLD | NEW |