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 fHWBoundTextureInstanceIDs.reset(this->glCaps().maxFragmentTextureUnits()); | 123 fHWBoundTextures.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 < fHWBoundTextureInstanceIDs.count(); ++s) { | 276 for (int s = 0; s < fHWBoundTextures.count(); ++s) { |
277 fHWBoundTextureInstanceIDs[s] = 0; | 277 fHWBoundTextures[s] = NULL; |
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 fHWBoundRenderTargetInstanceID = 0; | 301 fHWBoundRenderTarget = NULL; |
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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 &msColorFormat, | 860 &msColorFormat, |
861 NULL, | 861 NULL, |
862 NULL)) { | 862 NULL)) { |
863 goto FAILED; | 863 goto FAILED; |
864 } | 864 } |
865 } else { | 865 } else { |
866 desc->fRTFBOID = desc->fTexFBOID; | 866 desc->fRTFBOID = desc->fTexFBOID; |
867 } | 867 } |
868 | 868 |
869 // below here we may bind the FBO | 869 // below here we may bind the FBO |
870 fHWBoundRenderTargetInstanceID = 0; | 870 fHWBoundRenderTarget = NULL; |
871 if (desc->fRTFBOID != desc->fTexFBOID) { | 871 if (desc->fRTFBOID != desc->fTexFBOID) { |
872 SkASSERT(desc->fSampleCnt > 0); | 872 SkASSERT(desc->fSampleCnt > 0); |
873 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, | 873 GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER, |
874 desc->fMSColorRenderbufferID)); | 874 desc->fMSColorRenderbufferID)); |
875 if (!renderbuffer_storage_msaa(fGLContext, | 875 if (!renderbuffer_storage_msaa(fGLContext, |
876 desc->fSampleCnt, | 876 desc->fSampleCnt, |
877 msColorFormat, | 877 msColorFormat, |
878 width, height)) { | 878 width, height)) { |
879 goto FAILED; | 879 goto FAILED; |
880 } | 880 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 GrGLenum status; | 1245 GrGLenum status; |
1246 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1246 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
1247 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); | 1247 SkASSERT(GR_GL_FRAMEBUFFER_COMPLETE == status); |
1248 #endif | 1248 #endif |
1249 } | 1249 } |
1250 return true; | 1250 return true; |
1251 } else { | 1251 } else { |
1252 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); | 1252 GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb); |
1253 GrGLuint rb = glsb->renderbufferID(); | 1253 GrGLuint rb = glsb->renderbufferID(); |
1254 | 1254 |
1255 fHWBoundRenderTargetInstanceID = 0; | 1255 fHWBoundRenderTarget = NULL; |
1256 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo)); | 1256 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo)); |
1257 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1257 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
1258 GR_GL_STENCIL_ATTACHMENT, | 1258 GR_GL_STENCIL_ATTACHMENT, |
1259 GR_GL_RENDERBUFFER, rb)); | 1259 GR_GL_RENDERBUFFER, rb)); |
1260 if (glsb->format().fPacked) { | 1260 if (glsb->format().fPacked) { |
1261 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1261 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
1262 GR_GL_DEPTH_ATTACHMENT, | 1262 GR_GL_DEPTH_ATTACHMENT, |
1263 GR_GL_RENDERBUFFER, rb)); | 1263 GR_GL_RENDERBUFFER, rb)); |
1264 } else { | 1264 } else { |
1265 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, | 1265 GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 return; | 1451 return; |
1452 } | 1452 } |
1453 if (NULL == renderTarget) { | 1453 if (NULL == renderTarget) { |
1454 renderTarget = this->drawState()->getRenderTarget(); | 1454 renderTarget = this->drawState()->getRenderTarget(); |
1455 if (NULL == renderTarget) { | 1455 if (NULL == renderTarget) { |
1456 return; | 1456 return; |
1457 } | 1457 } |
1458 } | 1458 } |
1459 | 1459 |
1460 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); | 1460 GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget); |
1461 if (renderTarget->getInstanceID() != fHWBoundRenderTargetInstanceID) { | 1461 if (renderTarget != fHWBoundRenderTarget) { |
1462 fHWBoundRenderTargetInstanceID = 0; | 1462 fHWBoundRenderTarget = NULL; |
1463 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); | 1463 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID())); |
1464 } | 1464 } |
1465 switch (this->glCaps().invalidateFBType()) { | 1465 switch (this->glCaps().invalidateFBType()) { |
1466 case GrGLCaps::kNone_FBFetchType: | 1466 case GrGLCaps::kNone_FBFetchType: |
1467 SkFAIL("Should never get here."); | 1467 SkFAIL("Should never get here."); |
1468 break; | 1468 break; |
1469 case GrGLCaps::kInvalidate_InvalidateFBType: | 1469 case GrGLCaps::kInvalidate_InvalidateFBType: |
1470 if (0 == glRT->renderFBOID()) { | 1470 if (0 == glRT->renderFBOID()) { |
1471 // When rendering to the default framebuffer the legal values f
or attachments | 1471 // When rendering to the default framebuffer the legal values f
or attachments |
1472 // are GL_COLOR, GL_DEPTH, GL_STENCIL, ... rather than the vari
ous FBO attachment | 1472 // 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... |
1715 } | 1715 } |
1716 return true; | 1716 return true; |
1717 } | 1717 } |
1718 | 1718 |
1719 void GrGpuGL::flushRenderTarget(const SkIRect* bound) { | 1719 void GrGpuGL::flushRenderTarget(const SkIRect* bound) { |
1720 | 1720 |
1721 GrGLRenderTarget* rt = | 1721 GrGLRenderTarget* rt = |
1722 static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget()); | 1722 static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget()); |
1723 SkASSERT(NULL != rt); | 1723 SkASSERT(NULL != rt); |
1724 | 1724 |
1725 uint64_t rtID = rt->getInstanceID(); | 1725 if (fHWBoundRenderTarget != rt) { |
1726 if (fHWBoundRenderTargetInstanceID != rtID) { | |
1727 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID())); | 1726 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID())); |
1728 #ifdef SK_DEBUG | 1727 #ifdef SK_DEBUG |
1729 // don't do this check in Chromium -- this is causing | 1728 // don't do this check in Chromium -- this is causing |
1730 // lots of repeated command buffer flushes when the compositor is | 1729 // lots of repeated command buffer flushes when the compositor is |
1731 // rendering with Ganesh, which is really slow; even too slow for | 1730 // rendering with Ganesh, which is really slow; even too slow for |
1732 // Debug mode. | 1731 // Debug mode. |
1733 if (!this->glContext().isChromium()) { | 1732 if (!this->glContext().isChromium()) { |
1734 GrGLenum status; | 1733 GrGLenum status; |
1735 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); | 1734 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); |
1736 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { | 1735 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { |
1737 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x
\n", status); | 1736 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x
\n", status); |
1738 } | 1737 } |
1739 } | 1738 } |
1740 #endif | 1739 #endif |
1741 fHWBoundRenderTargetInstanceID = rtID; | 1740 fHWBoundRenderTarget = rt; |
1742 const GrGLIRect& vp = rt->getViewport(); | 1741 const GrGLIRect& vp = rt->getViewport(); |
1743 if (fHWViewport != vp) { | 1742 if (fHWViewport != vp) { |
1744 vp.pushToGLViewport(this->glInterface()); | 1743 vp.pushToGLViewport(this->glInterface()); |
1745 fHWViewport = vp; | 1744 fHWViewport = vp; |
1746 } | 1745 } |
1747 } | 1746 } |
1748 if (NULL == bound || !bound->isEmpty()) { | 1747 if (NULL == bound || !bound->isEmpty()) { |
1749 rt->flagAsNeedingResolve(bound); | 1748 rt->flagAsNeedingResolve(bound); |
1750 } | 1749 } |
1751 | 1750 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { | 1997 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { |
1999 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); | 1998 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); |
2000 if (rt->needsResolve()) { | 1999 if (rt->needsResolve()) { |
2001 // Some extensions automatically resolves the texture when it is read. | 2000 // Some extensions automatically resolves the texture when it is read. |
2002 if (this->glCaps().usesMSAARenderBuffers()) { | 2001 if (this->glCaps().usesMSAARenderBuffers()) { |
2003 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); | 2002 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); |
2004 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); | 2003 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); |
2005 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; | 2004 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()))
; |
2006 // make sure we go through flushRenderTarget() since we've modified | 2005 // make sure we go through flushRenderTarget() since we've modified |
2007 // the bound DRAW FBO ID. | 2006 // the bound DRAW FBO ID. |
2008 fHWBoundRenderTargetInstanceID = 0; | 2007 fHWBoundRenderTarget = NULL; |
2009 const GrGLIRect& vp = rt->getViewport(); | 2008 const GrGLIRect& vp = rt->getViewport(); |
2010 const SkIRect dirtyRect = rt->getResolveRect(); | 2009 const SkIRect dirtyRect = rt->getResolveRect(); |
2011 GrGLIRect r; | 2010 GrGLIRect r; |
2012 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, | 2011 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, |
2013 dirtyRect.width(), dirtyRect.height(), target->origi
n()); | 2012 dirtyRect.width(), dirtyRect.height(), target->origi
n()); |
2014 | 2013 |
2015 GrAutoTRestore<ScissorState> asr; | 2014 GrAutoTRestore<ScissorState> asr; |
2016 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { | 2015 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { |
2017 // Apple's extension uses the scissor as the blit bounds. | 2016 // Apple's extension uses the scissor as the blit bounds. |
2018 asr.reset(&fScissorState); | 2017 asr.reset(&fScissorState); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2292 SkASSERT(NULL != texture); | 2291 SkASSERT(NULL != texture); |
2293 | 2292 |
2294 // 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 |
2295 // 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 |
2296 // out of the "last != next" check. | 2295 // out of the "last != next" check. |
2297 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT
arget()); | 2296 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT
arget()); |
2298 if (NULL != texRT) { | 2297 if (NULL != texRT) { |
2299 this->onResolveRenderTarget(texRT); | 2298 this->onResolveRenderTarget(texRT); |
2300 } | 2299 } |
2301 | 2300 |
2302 uint64_t textureID = texture->getInstanceID(); | 2301 if (fHWBoundTextures[unitIdx] != texture) { |
2303 if (fHWBoundTextureInstanceIDs[unitIdx] != textureID) { | |
2304 this->setTextureUnit(unitIdx); | 2302 this->setTextureUnit(unitIdx); |
2305 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); | 2303 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); |
2306 fHWBoundTextureInstanceIDs[unitIdx] = textureID; | 2304 fHWBoundTextures[unitIdx] = texture; |
2307 } | 2305 } |
2308 | 2306 |
2309 ResetTimestamp timestamp; | 2307 ResetTimestamp timestamp; |
2310 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); | 2308 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); |
2311 bool setAll = timestamp < this->getResetTimestamp(); | 2309 bool setAll = timestamp < this->getResetTimestamp(); |
2312 GrGLTexture::TexParams newTexParams; | 2310 GrGLTexture::TexParams newTexParams; |
2313 | 2311 |
2314 static GrGLenum glMinFilterModes[] = { | 2312 static GrGLenum glMinFilterModes[] = { |
2315 GR_GL_NEAREST, | 2313 GR_GL_NEAREST, |
2316 GR_GL_LINEAR, | 2314 GR_GL_LINEAR, |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2524 case GrDrawState::kBoth_DrawFace: | 2522 case GrDrawState::kBoth_DrawFace: |
2525 GL_CALL(Disable(GR_GL_CULL_FACE)); | 2523 GL_CALL(Disable(GR_GL_CULL_FACE)); |
2526 break; | 2524 break; |
2527 default: | 2525 default: |
2528 SkFAIL("Unknown draw face."); | 2526 SkFAIL("Unknown draw face."); |
2529 } | 2527 } |
2530 fHWDrawFace = drawState.getDrawFace(); | 2528 fHWDrawFace = drawState.getDrawFace(); |
2531 } | 2529 } |
2532 } | 2530 } |
2533 | 2531 |
| 2532 void GrGpuGL::notifyRenderTargetDelete(GrRenderTarget* renderTarget) { |
| 2533 SkASSERT(NULL != renderTarget); |
| 2534 if (fHWBoundRenderTarget == renderTarget) { |
| 2535 fHWBoundRenderTarget = NULL; |
| 2536 } |
| 2537 } |
| 2538 |
| 2539 void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) { |
| 2540 for (int s = 0; s < fHWBoundTextures.count(); ++s) { |
| 2541 if (fHWBoundTextures[s] == texture) { |
| 2542 // deleting bound texture does implied bind to 0 |
| 2543 fHWBoundTextures[s] = NULL; |
| 2544 } |
| 2545 } |
| 2546 } |
| 2547 |
| 2548 |
2534 GrGLuint GrGpuGL::createGLPathObject() { | 2549 GrGLuint GrGpuGL::createGLPathObject() { |
2535 if (NULL == fPathNameAllocator.get()) { | 2550 if (NULL == fPathNameAllocator.get()) { |
2536 static const int range = 65536; | 2551 static const int range = 65536; |
2537 GrGLuint firstName; | 2552 GrGLuint firstName; |
2538 GL_CALL_RET(firstName, GenPaths(range)); | 2553 GL_CALL_RET(firstName, GenPaths(range)); |
2539 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first
Name + range))); | 2554 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first
Name + range))); |
2540 } | 2555 } |
2541 | 2556 |
2542 GrGLuint name = fPathNameAllocator->allocateName(); | 2557 GrGLuint name = fPathNameAllocator->allocateName(); |
2543 if (0 == name) { | 2558 if (0 == name) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2694 *externalType = GR_GL_FLOAT; | 2709 *externalType = GR_GL_FLOAT; |
2695 break; | 2710 break; |
2696 | 2711 |
2697 default: | 2712 default: |
2698 return false; | 2713 return false; |
2699 } | 2714 } |
2700 return true; | 2715 return true; |
2701 } | 2716 } |
2702 | 2717 |
2703 void GrGpuGL::setTextureUnit(int unit) { | 2718 void GrGpuGL::setTextureUnit(int unit) { |
2704 SkASSERT(unit >= 0 && unit < fHWBoundTextureInstanceIDs.count()); | 2719 SkASSERT(unit >= 0 && unit < fHWBoundTextures.count()); |
2705 if (unit != fHWActiveTextureUnitIdx) { | 2720 if (unit != fHWActiveTextureUnitIdx) { |
2706 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); | 2721 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); |
2707 fHWActiveTextureUnitIdx = unit; | 2722 fHWActiveTextureUnitIdx = unit; |
2708 } | 2723 } |
2709 } | 2724 } |
2710 | 2725 |
2711 void GrGpuGL::setScratchTextureUnit() { | 2726 void GrGpuGL::setScratchTextureUnit() { |
2712 // Bind the last texture unit since it is the least likely to be used by GrG
LProgram. | 2727 // Bind the last texture unit since it is the least likely to be used by GrG
LProgram. |
2713 int lastUnitIdx = fHWBoundTextureInstanceIDs.count() - 1; | 2728 int lastUnitIdx = fHWBoundTextures.count() - 1; |
2714 if (lastUnitIdx != fHWActiveTextureUnitIdx) { | 2729 if (lastUnitIdx != fHWActiveTextureUnitIdx) { |
2715 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); | 2730 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); |
2716 fHWActiveTextureUnitIdx = lastUnitIdx; | 2731 fHWActiveTextureUnitIdx = lastUnitIdx; |
2717 } | 2732 } |
2718 // clear out the this field so that if a program does use this unit it will
rebind the correct | 2733 // clear out the this field so that if a program does use this unit it will
rebind the correct |
2719 // texture. | 2734 // texture. |
2720 fHWBoundTextureInstanceIDs[lastUnitIdx] = 0; | 2735 fHWBoundTextures[lastUnitIdx] = NULL; |
2721 } | 2736 } |
2722 | 2737 |
2723 namespace { | 2738 namespace { |
2724 // Determines whether glBlitFramebuffer could be used between src and dst. | 2739 // Determines whether glBlitFramebuffer could be used between src and dst. |
2725 inline bool can_blit_framebuffer(const GrSurface* dst, | 2740 inline bool can_blit_framebuffer(const GrSurface* dst, |
2726 const GrSurface* src, | 2741 const GrSurface* src, |
2727 const GrGpuGL* gpu, | 2742 const GrGpuGL* gpu, |
2728 bool* wouldNeedTempFBO = NULL) { | 2743 bool* wouldNeedTempFBO = NULL) { |
2729 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && | 2744 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt >
0) && |
2730 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && | 2745 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt >
0) && |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2847 bool copied = false; | 2862 bool copied = false; |
2848 bool wouldNeedTempFBO = false; | 2863 bool wouldNeedTempFBO = false; |
2849 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && | 2864 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && |
2850 (!wouldNeedTempFBO || !inheritedCouldCopy)) { | 2865 (!wouldNeedTempFBO || !inheritedCouldCopy)) { |
2851 GrGLuint srcFBO; | 2866 GrGLuint srcFBO; |
2852 GrGLIRect srcVP; | 2867 GrGLIRect srcVP; |
2853 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER
, &srcVP); | 2868 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER
, &srcVP); |
2854 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); | 2869 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); |
2855 SkASSERT(NULL != dstTex); | 2870 SkASSERT(NULL != dstTex); |
2856 // We modified the bound FBO | 2871 // We modified the bound FBO |
2857 fHWBoundRenderTargetInstanceID = 0; | 2872 fHWBoundRenderTarget = NULL; |
2858 GrGLIRect srcGLRect; | 2873 GrGLIRect srcGLRect; |
2859 srcGLRect.setRelativeTo(srcVP, | 2874 srcGLRect.setRelativeTo(srcVP, |
2860 srcRect.fLeft, | 2875 srcRect.fLeft, |
2861 srcRect.fTop, | 2876 srcRect.fTop, |
2862 srcRect.width(), | 2877 srcRect.width(), |
2863 srcRect.height(), | 2878 srcRect.height(), |
2864 src->origin()); | 2879 src->origin()); |
2865 | 2880 |
2866 this->setScratchTextureUnit(); | 2881 this->setScratchTextureUnit(); |
2867 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); | 2882 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); |
(...skipping 21 matching lines...) Expand all Loading... |
2889 } | 2904 } |
2890 | 2905 |
2891 if (!selfOverlap) { | 2906 if (!selfOverlap) { |
2892 GrGLuint dstFBO; | 2907 GrGLuint dstFBO; |
2893 GrGLuint srcFBO; | 2908 GrGLuint srcFBO; |
2894 GrGLIRect dstVP; | 2909 GrGLIRect dstVP; |
2895 GrGLIRect srcVP; | 2910 GrGLIRect srcVP; |
2896 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR
AMEBUFFER, &dstVP); | 2911 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR
AMEBUFFER, &dstVP); |
2897 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR
AMEBUFFER, &srcVP); | 2912 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR
AMEBUFFER, &srcVP); |
2898 // We modified the bound FBO | 2913 // We modified the bound FBO |
2899 fHWBoundRenderTargetInstanceID = 0; | 2914 fHWBoundRenderTarget = NULL; |
2900 GrGLIRect srcGLRect; | 2915 GrGLIRect srcGLRect; |
2901 GrGLIRect dstGLRect; | 2916 GrGLIRect dstGLRect; |
2902 srcGLRect.setRelativeTo(srcVP, | 2917 srcGLRect.setRelativeTo(srcVP, |
2903 srcRect.fLeft, | 2918 srcRect.fLeft, |
2904 srcRect.fTop, | 2919 srcRect.fTop, |
2905 srcRect.width(), | 2920 srcRect.width(), |
2906 srcRect.height(), | 2921 srcRect.height(), |
2907 src->origin()); | 2922 src->origin()); |
2908 dstGLRect.setRelativeTo(dstVP, | 2923 dstGLRect.setRelativeTo(dstVP, |
2909 dstRect.fLeft, | 2924 dstRect.fLeft, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3015 this->setVertexArrayID(gpu, 0); | 3030 this->setVertexArrayID(gpu, 0); |
3016 } | 3031 } |
3017 int attrCount = gpu->glCaps().maxVertexAttributes(); | 3032 int attrCount = gpu->glCaps().maxVertexAttributes(); |
3018 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 3033 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
3019 fDefaultVertexArrayAttribState.resize(attrCount); | 3034 fDefaultVertexArrayAttribState.resize(attrCount); |
3020 } | 3035 } |
3021 attribState = &fDefaultVertexArrayAttribState; | 3036 attribState = &fDefaultVertexArrayAttribState; |
3022 } | 3037 } |
3023 return attribState; | 3038 return attribState; |
3024 } | 3039 } |
OLD | NEW |