diff options
| author | Ian Romanick <idr@us.ibm.com> | 2007-05-09 21:51:49 -0700 | 
|---|---|---|
| committer | Ian Romanick <idr@us.ibm.com> | 2007-05-10 08:20:41 -0700 | 
| commit | 87a980a795b29c5114c07a74aa5d95b6e7a7f971 (patch) | |
| tree | ad78157c5ce95959fc4631aa8662c46a0983e816 | |
| parent | e282f89a380bfbc8ad4840b535b499541635ca9f (diff) | |
Refactor the loop in unbind_texobj_from_texunits.
Common code was pulled out of the per-target if-statment and put at the end
of the for-loop.  The common code is guarded by a new variable, curr, that
is set to point to the unit's current target in each if-statement.
| -rw-r--r-- | src/mesa/main/texobj.c | 30 | 
1 files changed, 12 insertions, 18 deletions
| diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 3cfbfa5eb5..56d816e45f 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -630,40 +630,34 @@ unbind_texobj_from_texunits(GLcontext *ctx, struct gl_texture_object *texObj)     for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {        struct gl_texture_unit *unit = &ctx->Texture.Unit[u]; +      struct gl_texture_object **curr = NULL; +        if (texObj == unit->Current1D) { +         curr = &unit->Current1D;           unit->Current1D = ctx->Shared->Default1D; -         ctx->Shared->Default1D->RefCount++; -         texObj->RefCount--; -         if (texObj == unit->_Current) -            unit->_Current = unit->Current1D;        }        else if (texObj == unit->Current2D) { +         curr = &unit->Current2D;           unit->Current2D = ctx->Shared->Default2D; -         ctx->Shared->Default2D->RefCount++; -         texObj->RefCount--; -         if (texObj == unit->_Current) -            unit->_Current = unit->Current2D;        }        else if (texObj == unit->Current3D) { +         curr = &unit->Current3D;           unit->Current3D = ctx->Shared->Default3D; -         ctx->Shared->Default3D->RefCount++; -         texObj->RefCount--; -         if (texObj == unit->_Current) -            unit->_Current = unit->Current3D;        }        else if (texObj == unit->CurrentCubeMap) { +         curr = &unit->CurrentCubeMap;           unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; -         ctx->Shared->DefaultCubeMap->RefCount++; -         texObj->RefCount--; -         if (texObj == unit->_Current) -            unit->_Current = unit->CurrentCubeMap;        }        else if (texObj == unit->CurrentRect) { +         curr = &unit->CurrentRect;           unit->CurrentRect = ctx->Shared->DefaultRect; -         ctx->Shared->DefaultRect->RefCount++; +      } + +      if (curr) { +         (*curr)->RefCount++;           texObj->RefCount--;           if (texObj == unit->_Current) -            unit->_Current = unit->CurrentRect; +            unit->_Current = *curr;        }     }  } | 
