| 3158 | } |
| 3159 | |
| 3160 | void |
| 3161 | SDL_DestroyTexture(SDL_Texture * texture) |
| 3162 | { |
| 3163 | SDL_Renderer *renderer; |
| 3164 | |
| 3165 | CHECK_TEXTURE_MAGIC(texture, ); |
| 3166 | |
| 3167 | renderer = texture->renderer; |
| 3168 | if (texture == renderer->target) { |
| 3169 | SDL_SetRenderTarget(renderer, NULL); /* implies command queue flush */ |
| 3170 | } else { |
| 3171 | FlushRenderCommandsIfTextureNeeded(texture); |
| 3172 | } |
| 3173 | |
| 3174 | texture->magic = NULL; |
| 3175 | |
| 3176 | if (texture->next) { |
| 3177 | texture->next->prev = texture->prev; |
| 3178 | } |
| 3179 | if (texture->prev) { |
| 3180 | texture->prev->next = texture->next; |
| 3181 | } else { |
| 3182 | renderer->textures = texture->next; |
| 3183 | } |
| 3184 | |
| 3185 | if (texture->native) { |
| 3186 | SDL_DestroyTexture(texture->native); |
| 3187 | } |
| 3188 | #if SDL_HAVE_YUV |
| 3189 | if (texture->yuv) { |
| 3190 | SDL_SW_DestroyYUVTexture(texture->yuv); |
| 3191 | } |
| 3192 | #endif |
| 3193 | SDL_free(texture->pixels); |
| 3194 | |
| 3195 | renderer->DestroyTexture(renderer, texture); |
| 3196 | |
| 3197 | SDL_FreeSurface(texture->locked_surface); |
| 3198 | texture->locked_surface = NULL; |
| 3199 | |
| 3200 | SDL_free(texture); |
| 3201 | } |
| 3202 | |
| 3203 | void |
| 3204 | SDL_DestroyRenderer(SDL_Renderer * renderer) |