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

Unified Diff: src/gpu/gl/GrGpuGL.cpp

Issue 405023003: Revert of 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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGpuGL.cpp
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 52e3c33601fee7ed886385acf16f600d0cea666b..3a2be13aacb95737690a1f2dd7ec7e5f4cd35ad5 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -120,7 +120,7 @@
SkASSERT(ctx.isInitialized());
fCaps.reset(SkRef(ctx.caps()));
- fHWBoundTextureInstanceIDs.reset(this->glCaps().maxFragmentTextureUnits());
+ fHWBoundTextures.reset(this->glCaps().maxFragmentTextureUnits());
fHWPathTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords());
GrGLClearErr(fGLContext.interface());
@@ -273,8 +273,8 @@
fHWActiveTextureUnitIdx = -1; // invalid
if (resetBits & kTextureBinding_GrGLBackendState) {
- for (int s = 0; s < fHWBoundTextureInstanceIDs.count(); ++s) {
- fHWBoundTextureInstanceIDs[s] = 0;
+ for (int s = 0; s < fHWBoundTextures.count(); ++s) {
+ fHWBoundTextures[s] = NULL;
}
}
@@ -298,7 +298,7 @@
}
if (resetBits & kRenderTarget_GrGLBackendState) {
- fHWBoundRenderTargetInstanceID = 0;
+ fHWBoundRenderTarget = NULL;
}
if (resetBits & kPathRendering_GrGLBackendState) {
@@ -867,7 +867,7 @@
}
// below here we may bind the FBO
- fHWBoundRenderTargetInstanceID = 0;
+ fHWBoundRenderTarget = NULL;
if (desc->fRTFBOID != desc->fTexFBOID) {
SkASSERT(desc->fSampleCnt > 0);
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER,
@@ -1252,7 +1252,7 @@
GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb);
GrGLuint rb = glsb->renderbufferID();
- fHWBoundRenderTargetInstanceID = 0;
+ fHWBoundRenderTarget = NULL;
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo));
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
@@ -1458,8 +1458,8 @@
}
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
- if (renderTarget->getInstanceID() != fHWBoundRenderTargetInstanceID) {
- fHWBoundRenderTargetInstanceID = 0;
+ if (renderTarget != fHWBoundRenderTarget) {
+ fHWBoundRenderTarget = NULL;
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
}
switch (this->glCaps().invalidateFBType()) {
@@ -1722,8 +1722,7 @@
static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget());
SkASSERT(NULL != rt);
- uint64_t rtID = rt->getInstanceID();
- if (fHWBoundRenderTargetInstanceID != rtID) {
+ if (fHWBoundRenderTarget != rt) {
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID()));
#ifdef SK_DEBUG
// don't do this check in Chromium -- this is causing
@@ -1738,7 +1737,7 @@
}
}
#endif
- fHWBoundRenderTargetInstanceID = rtID;
+ fHWBoundRenderTarget = rt;
const GrGLIRect& vp = rt->getViewport();
if (fHWViewport != vp) {
vp.pushToGLViewport(this->glInterface());
@@ -2005,7 +2004,7 @@
GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()));
// make sure we go through flushRenderTarget() since we've modified
// the bound DRAW FBO ID.
- fHWBoundRenderTargetInstanceID = 0;
+ fHWBoundRenderTarget = NULL;
const GrGLIRect& vp = rt->getViewport();
const SkIRect dirtyRect = rt->getResolveRect();
GrGLIRect r;
@@ -2299,11 +2298,10 @@
this->onResolveRenderTarget(texRT);
}
- uint64_t textureID = texture->getInstanceID();
- if (fHWBoundTextureInstanceIDs[unitIdx] != textureID) {
+ if (fHWBoundTextures[unitIdx] != texture) {
this->setTextureUnit(unitIdx);
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID()));
- fHWBoundTextureInstanceIDs[unitIdx] = textureID;
+ fHWBoundTextures[unitIdx] = texture;
}
ResetTimestamp timestamp;
@@ -2530,6 +2528,23 @@
fHWDrawFace = drawState.getDrawFace();
}
}
+
+void GrGpuGL::notifyRenderTargetDelete(GrRenderTarget* renderTarget) {
+ SkASSERT(NULL != renderTarget);
+ if (fHWBoundRenderTarget == renderTarget) {
+ fHWBoundRenderTarget = NULL;
+ }
+}
+
+void GrGpuGL::notifyTextureDelete(GrGLTexture* texture) {
+ for (int s = 0; s < fHWBoundTextures.count(); ++s) {
+ if (fHWBoundTextures[s] == texture) {
+ // deleting bound texture does implied bind to 0
+ fHWBoundTextures[s] = NULL;
+ }
+ }
+}
+
GrGLuint GrGpuGL::createGLPathObject() {
if (NULL == fPathNameAllocator.get()) {
@@ -2701,7 +2716,7 @@
}
void GrGpuGL::setTextureUnit(int unit) {
- SkASSERT(unit >= 0 && unit < fHWBoundTextureInstanceIDs.count());
+ SkASSERT(unit >= 0 && unit < fHWBoundTextures.count());
if (unit != fHWActiveTextureUnitIdx) {
GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit));
fHWActiveTextureUnitIdx = unit;
@@ -2710,14 +2725,14 @@
void GrGpuGL::setScratchTextureUnit() {
// Bind the last texture unit since it is the least likely to be used by GrGLProgram.
- int lastUnitIdx = fHWBoundTextureInstanceIDs.count() - 1;
+ int lastUnitIdx = fHWBoundTextures.count() - 1;
if (lastUnitIdx != fHWActiveTextureUnitIdx) {
GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + lastUnitIdx));
fHWActiveTextureUnitIdx = lastUnitIdx;
}
// clear out the this field so that if a program does use this unit it will rebind the correct
// texture.
- fHWBoundTextureInstanceIDs[lastUnitIdx] = 0;
+ fHWBoundTextures[lastUnitIdx] = NULL;
}
namespace {
@@ -2854,7 +2869,7 @@
GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture());
SkASSERT(NULL != dstTex);
// We modified the bound FBO
- fHWBoundRenderTargetInstanceID = 0;
+ fHWBoundRenderTarget = NULL;
GrGLIRect srcGLRect;
srcGLRect.setRelativeTo(srcVP,
srcRect.fLeft,
@@ -2896,7 +2911,7 @@
dstFBO = bind_surface_as_fbo(this->glInterface(), dst, GR_GL_DRAW_FRAMEBUFFER, &dstVP);
srcFBO = bind_surface_as_fbo(this->glInterface(), src, GR_GL_READ_FRAMEBUFFER, &srcVP);
// We modified the bound FBO
- fHWBoundRenderTargetInstanceID = 0;
+ fHWBoundRenderTarget = NULL;
GrGLIRect srcGLRect;
GrGLIRect dstGLRect;
srcGLRect.setRelativeTo(srcVP,
« 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