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

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

Issue 414493002: Revert "Revert of Use the GrCacheable ID to eliminate the need for notifications to GrGpuGL when te… (Closed) Base URL: https://skia.googlesource.com/skia.git@removestuff
Patch Set: Address round 2 of comments 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 d29c141c4f77606eea5cc3194e0962d0eeedc32d..a0e08e5a00b295e393e11835c5538c0155ba98dd 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -136,7 +136,7 @@ GrGpuGL::GrGpuGL(const GrGLContext& ctx, GrContext* context)
SkASSERT(ctx.isInitialized());
fCaps.reset(SkRef(ctx.caps()));
- fHWBoundTextures.reset(this->glCaps().maxFragmentTextureUnits());
+ fHWBoundTextureUniqueIDs.reset(this->glCaps().maxFragmentTextureUnits());
fHWPathTexGenSettings.reset(this->glCaps().maxFixedFunctionTextureCoords());
GrGLClearErr(fGLContext.interface());
@@ -287,8 +287,8 @@ void GrGpuGL::onResetContext(uint32_t resetBits) {
fHWActiveTextureUnitIdx = -1; // invalid
if (resetBits & kTextureBinding_GrGLBackendState) {
- for (int s = 0; s < fHWBoundTextures.count(); ++s) {
- fHWBoundTextures[s] = NULL;
+ for (int s = 0; s < fHWBoundTextureUniqueIDs.count(); ++s) {
+ fHWBoundTextureUniqueIDs[s] = SK_InvalidUniqueID;
}
}
@@ -312,7 +312,7 @@ void GrGpuGL::onResetContext(uint32_t resetBits) {
}
if (resetBits & kRenderTarget_GrGLBackendState) {
- fHWBoundRenderTarget = NULL;
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
}
if (resetBits & kPathRendering_GrGLBackendState) {
@@ -889,7 +889,7 @@ bool GrGpuGL::createRenderTargetObjects(int width, int height,
}
// below here we may bind the FBO
- fHWBoundRenderTarget = NULL;
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
if (desc->fRTFBOID != desc->fTexFBOID) {
SkASSERT(desc->fSampleCnt > 0);
GL_CALL(BindRenderbuffer(GR_GL_RENDERBUFFER,
@@ -1274,7 +1274,7 @@ bool GrGpuGL::attachStencilBufferToRenderTarget(GrStencilBuffer* sb, GrRenderTar
GrGLStencilBuffer* glsb = static_cast<GrGLStencilBuffer*>(sb);
GrGLuint rb = glsb->renderbufferID();
- fHWBoundRenderTarget = NULL;
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, fbo));
GL_CALL(FramebufferRenderbuffer(GR_GL_FRAMEBUFFER,
GR_GL_STENCIL_ATTACHMENT,
@@ -1485,8 +1485,8 @@ void GrGpuGL::discard(GrRenderTarget* renderTarget) {
}
GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(renderTarget);
- if (renderTarget != fHWBoundRenderTarget) {
- fHWBoundRenderTarget = NULL;
+ if (renderTarget->getUniqueID() != fHWBoundRenderTargetUniqueID) {
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, glRT->renderFBOID()));
}
switch (this->glCaps().invalidateFBType()) {
@@ -1749,7 +1749,8 @@ void GrGpuGL::flushRenderTarget(const SkIRect* bound) {
static_cast<GrGLRenderTarget*>(this->drawState()->getRenderTarget());
SkASSERT(NULL != rt);
- if (fHWBoundRenderTarget != rt) {
+ uint32_t rtID = rt->getUniqueID();
+ if (fHWBoundRenderTargetUniqueID != rtID) {
GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, rt->renderFBOID()));
#ifdef SK_DEBUG
// don't do this check in Chromium -- this is causing
@@ -1764,7 +1765,7 @@ void GrGpuGL::flushRenderTarget(const SkIRect* bound) {
}
}
#endif
- fHWBoundRenderTarget = rt;
+ fHWBoundRenderTargetUniqueID = rtID;
const GrGLIRect& vp = rt->getViewport();
if (fHWViewport != vp) {
vp.pushToGLViewport(this->glInterface());
@@ -2007,7 +2008,7 @@ void GrGpuGL::onResolveRenderTarget(GrRenderTarget* target) {
GL_CALL(BindFramebuffer(GR_GL_DRAW_FRAMEBUFFER, rt->textureFBOID()));
// make sure we go through flushRenderTarget() since we've modified
// the bound DRAW FBO ID.
- fHWBoundRenderTarget = NULL;
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
const GrGLIRect& vp = rt->getViewport();
const SkIRect dirtyRect = rt->getResolveRect();
GrGLIRect r;
@@ -2301,10 +2302,11 @@ void GrGpuGL::bindTexture(int unitIdx, const GrTextureParams& params, GrGLTextur
this->onResolveRenderTarget(texRT);
}
- if (fHWBoundTextures[unitIdx] != texture) {
+ uint32_t textureID = texture->getUniqueID();
+ if (fHWBoundTextureUniqueIDs[unitIdx] != textureID) {
this->setTextureUnit(unitIdx);
GL_CALL(BindTexture(GR_GL_TEXTURE_2D, texture->textureID()));
- fHWBoundTextures[unitIdx] = texture;
+ fHWBoundTextureUniqueIDs[unitIdx] = textureID;
}
ResetTimestamp timestamp;
@@ -2532,23 +2534,6 @@ void GrGpuGL::flushMiscFixedFunctionState() {
}
}
-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()) {
static const int range = 65536;
@@ -2719,7 +2704,7 @@ bool GrGpuGL::configToGLFormats(GrPixelConfig config,
}
void GrGpuGL::setTextureUnit(int unit) {
- SkASSERT(unit >= 0 && unit < fHWBoundTextures.count());
+ SkASSERT(unit >= 0 && unit < fHWBoundTextureUniqueIDs.count());
if (unit != fHWActiveTextureUnitIdx) {
GL_CALL(ActiveTexture(GR_GL_TEXTURE0 + unit));
fHWActiveTextureUnitIdx = unit;
@@ -2728,14 +2713,14 @@ void GrGpuGL::setTextureUnit(int unit) {
void GrGpuGL::setScratchTextureUnit() {
// Bind the last texture unit since it is the least likely to be used by GrGLProgram.
- int lastUnitIdx = fHWBoundTextures.count() - 1;
+ int lastUnitIdx = fHWBoundTextureUniqueIDs.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.
- fHWBoundTextures[lastUnitIdx] = NULL;
+ fHWBoundTextureUniqueIDs[lastUnitIdx] = SK_InvalidUniqueID;
}
namespace {
@@ -2872,7 +2857,7 @@ bool GrGpuGL::onCopySurface(GrSurface* dst,
GrGLTexture* dstTex = static_cast<GrGLTexture*>(dst->asTexture());
SkASSERT(NULL != dstTex);
// We modified the bound FBO
- fHWBoundRenderTarget = NULL;
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
GrGLIRect srcGLRect;
srcGLRect.setRelativeTo(srcVP,
srcRect.fLeft,
@@ -2914,7 +2899,7 @@ bool GrGpuGL::onCopySurface(GrSurface* dst,
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
- fHWBoundRenderTarget = NULL;
+ fHWBoundRenderTargetUniqueID = SK_InvalidUniqueID;
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