~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/main/texobj.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
697
697
      if (textures[i] > 0) {
698
698
         struct gl_texture_object *delObj
699
699
            = _mesa_lookup_texture(ctx, textures[i]);
 
700
 
700
701
         if (delObj) {
 
702
            GLboolean delete;
 
703
 
 
704
            _mesa_lock_texture(ctx, delObj);
701
705
 
702
706
            /* Check if texture is bound to any framebuffer objects.
703
707
             * If so, unbind.
724
728
             * XXX all RefCount accesses should be protected by a mutex.
725
729
             */
726
730
            delObj->RefCount--;
727
 
            if (delObj->RefCount == 0) {
 
731
            delete = (delObj->RefCount == 0);
 
732
            _mesa_unlock_texture(ctx, delObj);
 
733
 
 
734
            /* We know that refcount went to zero above, so this is
 
735
             * the only pointer left to delObj, so we don't have to
 
736
             * worry about locking any more:
 
737
             */
 
738
            if (delete) {
728
739
               ASSERT(delObj->Name != 0); /* Never delete default tex objs */
729
740
               ASSERT(ctx->Driver.DeleteTexture);
730
741
               (*ctx->Driver.DeleteTexture)(ctx, delObj);
1052
1063
   return t && t->Target;
1053
1064
}
1054
1065
 
 
1066
/* Simplest implementation of texture locking: Grab the a new mutex in
 
1067
 * the shared context.  Examine the shared context state timestamp and
 
1068
 * if there has been a change, set the appropriate bits in
 
1069
 * ctx->NewState.
 
1070
 *
 
1071
 * See also _mesa_lock/unlock_texture in texobj.h
 
1072
 */
 
1073
void _mesa_lock_context_textures( GLcontext *ctx )
 
1074
{
 
1075
   _glthread_LOCK_MUTEX(ctx->Shared->TexMutex);
 
1076
 
 
1077
   if (ctx->Shared->TextureStateStamp != ctx->TextureStateTimestamp) {
 
1078
      ctx->NewState |= _NEW_TEXTURE;
 
1079
      ctx->TextureStateTimestamp = ctx->Shared->TextureStateStamp;
 
1080
   }
 
1081
}
 
1082
 
 
1083
 
 
1084
void _mesa_unlock_context_textures( GLcontext *ctx )
 
1085
{
 
1086
   assert(ctx->Shared->TextureStateStamp == ctx->TextureStateTimestamp);
 
1087
   _glthread_UNLOCK_MUTEX(ctx->Shared->TexMutex);
 
1088
}
 
1089
 
1055
1090
/*@}*/
 
1091
 
 
1092