Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 376703009: Use the GrCacheable ID to eliminate the need for notifications to GrGpuGL when textures and RTs are… (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: now with 64 bits Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 fHWBoundRenderTarget = NULL; 870 fHWBoundRenderTargetInstanceID = 0;
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
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 fHWBoundRenderTarget = NULL; 1255 fHWBoundRenderTargetInstanceID = 0;
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
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 != fHWBoundRenderTarget) { 1461 if (renderTarget->getInstanceID() != fHWBoundRenderTargetInstanceID) {
1462 fHWBoundRenderTarget = NULL; 1462 fHWBoundRenderTargetInstanceID = 0;
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
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 if (fHWBoundRenderTarget != rt) { 1725 uint64_t rtID = rt->getInstanceID();
1726 if (fHWBoundRenderTargetInstanceID != rtID) {
1726 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID())); 1727 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID()));
1727 #ifdef SK_DEBUG 1728 #ifdef SK_DEBUG
1728 // don't do this check in Chromium -- this is causing 1729 // don't do this check in Chromium -- this is causing
1729 // lots of repeated command buffer flushes when the compositor is 1730 // lots of repeated command buffer flushes when the compositor is
1730 // rendering with Ganesh, which is really slow; even too slow for 1731 // rendering with Ganesh, which is really slow; even too slow for
1731 // Debug mode. 1732 // Debug mode.
1732 if (!this->glContext().isChromium()) { 1733 if (!this->glContext().isChromium()) {
1733 GrGLenum status; 1734 GrGLenum status;
1734 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER)); 1735 GL_CALL_RET(status, CheckFramebufferStatus(GR_GL_FRAMEBUFFER));
1735 if (status != GR_GL_FRAMEBUFFER_COMPLETE) { 1736 if (status != GR_GL_FRAMEBUFFER_COMPLETE) {
1736 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x \n", status); 1737 GrPrintf("GrGpuGL::flushRenderTarget glCheckFramebufferStatus %x \n", status);
1737 } 1738 }
1738 } 1739 }
1739 #endif 1740 #endif
1740 fHWBoundRenderTarget = rt; 1741 fHWBoundRenderTargetInstanceID = rtID;
1741 const GrGLIRect& vp = rt->getViewport(); 1742 const GrGLIRect& vp = rt->getViewport();
1742 if (fHWViewport != vp) { 1743 if (fHWViewport != vp) {
1743 vp.pushToGLViewport(this->glInterface()); 1744 vp.pushToGLViewport(this->glInterface());
1744 fHWViewport = vp; 1745 fHWViewport = vp;
1745 } 1746 }
1746 } 1747 }
1747 if (NULL == bound || !bound->isEmpty()) { 1748 if (NULL == bound || !bound->isEmpty()) {
1748 rt->flagAsNeedingResolve(bound); 1749 rt->flagAsNeedingResolve(bound);
1749 } 1750 }
1750 1751
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) { 1998 void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) {
1998 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target); 1999 GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(target);
1999 if (rt->needsResolve()) { 2000 if (rt->needsResolve()) {
2000 // Some extensions automatically resolves the texture when it is read. 2001 // Some extensions automatically resolves the texture when it is read.
2001 if (this->glCaps().usesMSAARenderBuffers()) { 2002 if (this->glCaps().usesMSAARenderBuffers()) {
2002 SkASSERT(rt->textureFBOID() != rt->renderFBOID()); 2003 SkASSERT(rt->textureFBOID() != rt->renderFBOID());
2003 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID())); 2004 GL_CALL(BindFramebuffer(GR_GL_READ_FRAMEBUFFER, rt->renderFBOID()));
2004 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ; 2005 GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID())) ;
2005 // make sure we go through flushRenderTarget() since we've modified 2006 // make sure we go through flushRenderTarget() since we've modified
2006 // the bound DRAW FBO ID. 2007 // the bound DRAW FBO ID.
2007 fHWBoundRenderTarget = NULL; 2008 fHWBoundRenderTargetInstanceID = 0;
2008 const GrGLIRect& vp = rt->getViewport(); 2009 const GrGLIRect& vp = rt->getViewport();
2009 const SkIRect dirtyRect = rt->getResolveRect(); 2010 const SkIRect dirtyRect = rt->getResolveRect();
2010 GrGLIRect r; 2011 GrGLIRect r;
2011 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop, 2012 r.setRelativeTo(vp, dirtyRect.fLeft, dirtyRect.fTop,
2012 dirtyRect.width(), dirtyRect.height(), target->origi n()); 2013 dirtyRect.width(), dirtyRect.height(), target->origi n());
2013 2014
2014 GrAutoTRestore<ScissorState> asr; 2015 GrAutoTRestore<ScissorState> asr;
2015 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { 2016 if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) {
2016 // Apple's extension uses the scissor as the blit bounds. 2017 // Apple's extension uses the scissor as the blit bounds.
2017 asr.reset(&fScissorState); 2018 asr.reset(&fScissorState);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 SkASSERT(NULL != texture); 2292 SkASSERT(NULL != texture);
2292 2293
2293 // If we created a rt/tex and rendered to it without using a texture and now we're texturing 2294 // If we created a rt/tex and rendered to it without using a texture and now we're texturing
2294 // from the rt it will still be the last bound texture, but it needs resolvi ng. So keep this 2295 // from the rt it will still be the last bound texture, but it needs resolvi ng. So keep this
2295 // out of the "last != next" check. 2296 // out of the "last != next" check.
2296 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT arget()); 2297 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderT arget());
2297 if (NULL != texRT) { 2298 if (NULL != texRT) {
2298 this->onResolveRenderTarget(texRT); 2299 this->onResolveRenderTarget(texRT);
2299 } 2300 }
2300 2301
2301 if (fHWBoundTextures[unitIdx] != texture) { 2302 uint64_t textureID = texture->getInstanceID();
2303 if (fHWBoundTextureInstanceIDs[unitIdx] != textureID) {
2302 this->setTextureUnit(unitIdx); 2304 this->setTextureUnit(unitIdx);
2303 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID())); 2305 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID()));
2304 fHWBoundTextures[unitIdx] = texture; 2306 fHWBoundTextureInstanceIDs[unitIdx] = textureID;
2305 } 2307 }
2306 2308
2307 ResetTimestamp timestamp; 2309 ResetTimestamp timestamp;
2308 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti mestamp); 2310 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti mestamp);
2309 bool setAll = timestamp < this->getResetTimestamp(); 2311 bool setAll = timestamp < this->getResetTimestamp();
2310 GrGLTexture::TexParams newTexParams; 2312 GrGLTexture::TexParams newTexParams;
2311 2313
2312 static GrGLenum glMinFilterModes[] = { 2314 static GrGLenum glMinFilterModes[] = {
2313 GR_GL_NEAREST, 2315 GR_GL_NEAREST,
2314 GR_GL_LINEAR, 2316 GR_GL_LINEAR,
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 case GrDrawState::kBoth_DrawFace: 2524 case GrDrawState::kBoth_DrawFace:
2523 GL_CALL(Disable(GR_GL_CULL_FACE)); 2525 GL_CALL(Disable(GR_GL_CULL_FACE));
2524 break; 2526 break;
2525 default: 2527 default:
2526 SkFAIL("Unknown draw face."); 2528 SkFAIL("Unknown draw face.");
2527 } 2529 }
2528 fHWDrawFace = drawState.getDrawFace(); 2530 fHWDrawFace = drawState.getDrawFace();
2529 } 2531 }
2530 } 2532 }
2531 2533
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
2549 GrGLuint GrGpuGL::createGLPathObject() { 2534 GrGLuint GrGpuGL::createGLPathObject() {
2550 if (NULL == fPathNameAllocator.get()) { 2535 if (NULL == fPathNameAllocator.get()) {
2551 static const int range = 65536; 2536 static const int range = 65536;
2552 GrGLuint firstName; 2537 GrGLuint firstName;
2553 GL_CALL_RET(firstName, GenPaths(range)); 2538 GL_CALL_RET(firstName, GenPaths(range));
2554 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first Name + range))); 2539 fPathNameAllocator.reset(SkNEW_ARGS(GrGLNameAllocator, (firstName, first Name + range)));
2555 } 2540 }
2556 2541
2557 GrGLuint name = fPathNameAllocator->allocateName(); 2542 GrGLuint name = fPathNameAllocator->allocateName();
2558 if (0 == name) { 2543 if (0 == name) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2709 *externalType = GR_GL_FLOAT; 2694 *externalType = GR_GL_FLOAT;
2710 break; 2695 break;
2711 2696
2712 default: 2697 default:
2713 return false; 2698 return false;
2714 } 2699 }
2715 return true; 2700 return true;
2716 } 2701 }
2717 2702
2718 void GrGpuGL::setTextureUnit(int unit) { 2703 void GrGpuGL::setTextureUnit(int unit) {
2719 SkASSERT(unit >= 0 && unit < fHWBoundTextures.count()); 2704 SkASSERT(unit >= 0 && unit < fHWBoundTextureInstanceIDs.count());
2720 if (unit != fHWActiveTextureUnitIdx) { 2705 if (unit != fHWActiveTextureUnitIdx) {
2721 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit)); 2706 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit));
2722 fHWActiveTextureUnitIdx = unit; 2707 fHWActiveTextureUnitIdx = unit;
2723 } 2708 }
2724 } 2709 }
2725 2710
2726 void GrGpuGL::setScratchTextureUnit() { 2711 void GrGpuGL::setScratchTextureUnit() {
2727 // Bind the last texture unit since it is the least likely to be used by GrG LProgram. 2712 // Bind the last texture unit since it is the least likely to be used by GrG LProgram.
2728 int lastUnitIdx = fHWBoundTextures.count() - 1; 2713 int lastUnitIdx = fHWBoundTextureInstanceIDs.count() - 1;
2729 if (lastUnitIdx != fHWActiveTextureUnitIdx) { 2714 if (lastUnitIdx != fHWActiveTextureUnitIdx) {
2730 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx)); 2715 GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx));
2731 fHWActiveTextureUnitIdx = lastUnitIdx; 2716 fHWActiveTextureUnitIdx = lastUnitIdx;
2732 } 2717 }
2733 // clear out the this field so that if a program does use this unit it will rebind the correct 2718 // clear out the this field so that if a program does use this unit it will rebind the correct
2734 // texture. 2719 // texture.
2735 fHWBoundTextures[lastUnitIdx] = NULL; 2720 fHWBoundTextureInstanceIDs[lastUnitIdx] = 0;
2736 } 2721 }
2737 2722
2738 namespace { 2723 namespace {
2739 // Determines whether glBlitFramebuffer could be used between src and dst. 2724 // Determines whether glBlitFramebuffer could be used between src and dst.
2740 inline bool can_blit_framebuffer(const GrSurface* dst, 2725 inline bool can_blit_framebuffer(const GrSurface* dst,
2741 const GrSurface* src, 2726 const GrSurface* src,
2742 const GrGpuGL* gpu, 2727 const GrGpuGL* gpu,
2743 bool* wouldNeedTempFBO = NULL) { 2728 bool* wouldNeedTempFBO = NULL) {
2744 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt > 0) && 2729 if (gpu->glCaps().isConfigRenderable(dst->config(), dst->desc().fSampleCnt > 0) &&
2745 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) && 2730 gpu->glCaps().isConfigRenderable(src->config(), src->desc().fSampleCnt > 0) &&
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2862 bool copied = false; 2847 bool copied = false;
2863 bool wouldNeedTempFBO = false; 2848 bool wouldNeedTempFBO = false;
2864 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) && 2849 if (can_copy_texsubimage(dst, src, this, &wouldNeedTempFBO) &&
2865 (!wouldNeedTempFBO || !inheritedCouldCopy)) { 2850 (!wouldNeedTempFBO || !inheritedCouldCopy)) {
2866 GrGLuint srcFBO; 2851 GrGLuint srcFBO;
2867 GrGLIRect srcVP; 2852 GrGLIRect srcVP;
2868 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER , &srcVP); 2853 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_FRAMEBUFFER , &srcVP);
2869 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture()); 2854 GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture());
2870 SkASSERT(NULL != dstTex); 2855 SkASSERT(NULL != dstTex);
2871 // We modified the bound FBO 2856 // We modified the bound FBO
2872 fHWBoundRenderTarget = NULL; 2857 fHWBoundRenderTargetInstanceID = 0;
2873 GrGLIRect srcGLRect; 2858 GrGLIRect srcGLRect;
2874 srcGLRect.setRelativeTo(srcVP, 2859 srcGLRect.setRelativeTo(srcVP,
2875 srcRect.fLeft, 2860 srcRect.fLeft,
2876 srcRect.fTop, 2861 srcRect.fTop,
2877 srcRect.width(), 2862 srcRect.width(),
2878 srcRect.height(), 2863 srcRect.height(),
2879 src->origin()); 2864 src->origin());
2880 2865
2881 this->setScratchTextureUnit(); 2866 this->setScratchTextureUnit();
2882 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID())); 2867 GL_CALL(BindTexture(GR_GL_TEXTURE_2D, dstTex->textureID()));
(...skipping 21 matching lines...) Expand all
2904 } 2889 }
2905 2890
2906 if (!selfOverlap) { 2891 if (!selfOverlap) {
2907 GrGLuint dstFBO; 2892 GrGLuint dstFBO;
2908 GrGLuint srcFBO; 2893 GrGLuint srcFBO;
2909 GrGLIRect dstVP; 2894 GrGLIRect dstVP;
2910 GrGLIRect srcVP; 2895 GrGLIRect srcVP;
2911 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR AMEBUFFER, &dstVP); 2896 dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FR AMEBUFFER, &dstVP);
2912 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR AMEBUFFER, &srcVP); 2897 srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FR AMEBUFFER, &srcVP);
2913 // We modified the bound FBO 2898 // We modified the bound FBO
2914 fHWBoundRenderTarget = NULL; 2899 fHWBoundRenderTargetInstanceID = 0;
2915 GrGLIRect srcGLRect; 2900 GrGLIRect srcGLRect;
2916 GrGLIRect dstGLRect; 2901 GrGLIRect dstGLRect;
2917 srcGLRect.setRelativeTo(srcVP, 2902 srcGLRect.setRelativeTo(srcVP,
2918 srcRect.fLeft, 2903 srcRect.fLeft,
2919 srcRect.fTop, 2904 srcRect.fTop,
2920 srcRect.width(), 2905 srcRect.width(),
2921 srcRect.height(), 2906 srcRect.height(),
2922 src->origin()); 2907 src->origin());
2923 dstGLRect.setRelativeTo(dstVP, 2908 dstGLRect.setRelativeTo(dstVP,
2924 dstRect.fLeft, 2909 dstRect.fLeft,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
3030 this->setVertexArrayID(gpu, 0); 3015 this->setVertexArrayID(gpu, 0);
3031 } 3016 }
3032 int attrCount = gpu->glCaps().maxVertexAttributes(); 3017 int attrCount = gpu->glCaps().maxVertexAttributes();
3033 if (fDefaultVertexArrayAttribState.count() != attrCount) { 3018 if (fDefaultVertexArrayAttribState.count() != attrCount) {
3034 fDefaultVertexArrayAttribState.resize(attrCount); 3019 fDefaultVertexArrayAttribState.resize(attrCount);
3035 } 3020 }
3036 attribState = &fDefaultVertexArrayAttribState; 3021 attribState = &fDefaultVertexArrayAttribState;
3037 } 3022 }
3038 return attribState; 3023 return attribState;
3039 } 3024 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698