Skip to content
Browse files

GLVideoDriver: Fixed leaks with palettes (thanks fuzzie). Fixed tint …

…in BlitGameSprite.
  • Loading branch information...
1 parent caed13e commit f07c489217cd5d5c3921f575ce1717804cf7901c @BehoIder BehoIder committed with lynxlynxlynx Jan 15, 2014
View
10 gemrb/plugins/SDLVideo/GLPaletteManager.cpp
@@ -84,12 +84,11 @@ void GLPaletteManager::RemovePaletteTexture(Palette* palette, unsigned int color
{
if (!palette->IsShared())
{
+ palette->release();
currentIndexes->erase(currentTextures->at(key));
glDeleteTextures(1, &(currentTextures->at(key)));
currentTextures->erase(key);
}
- else
- palette->release();
}
}
@@ -117,12 +116,11 @@ void GLPaletteManager::RemovePaletteTexture(GLuint texture, bool attached)
PaletteKey key = currentIndexes->at(texture);
if (!key.palette->IsShared())
{
+ key.palette->release();
currentIndexes->erase(texture);
glDeleteTextures(1, &texture);
currentTextures->erase(key);
}
- else
- key.palette->release();
}
}
@@ -145,13 +143,13 @@ void GLPaletteManager::ClearUnused(bool attached)
{
if (!it->first.palette->IsShared())
{
+ it->first.palette->release();
glDeleteTextures(1, &(currentTextures->at(it->first)));
currentIndexes->erase(it->second);
currentTextures->erase(it++);
}
else
{
- it->first.palette->release();
++it;
}
}
@@ -161,13 +159,15 @@ void GLPaletteManager::Clear()
{
for(std::map<PaletteKey, GLuint, PaletteKey>::iterator it = textures.begin(); it != textures.end(); ++it)
{
+ it->first.palette->release();
glDeleteTextures(1, &(textures[it->first]));
}
textures.clear();
indexes.clear();
for(std::map<PaletteKey, GLuint, PaletteKey>::iterator it = a_textures.begin(); it != a_textures.end(); ++it)
{
+ it->first.palette->release();
glDeleteTextures(1, &(a_textures[it->first]));
}
a_textures.clear();
View
2 gemrb/plugins/SDLVideo/GLTextureSprite2D.cpp
@@ -36,6 +36,8 @@ GLTextureSprite2D::GLTextureSprite2D (int Width, int Height, int Bpp, void* pixe
GLTextureSprite2D::~GLTextureSprite2D()
{
+ if (currentPalette != NULL)
+ currentPalette->release();
MakeUnused();
}
View
6 gemrb/plugins/SDLVideo/SDL20GLVideo.cpp
@@ -345,6 +345,7 @@ Sprite2D* GLVideoDriver::CreatePalettedSprite(int w, int h, int bpp, void* pixel
spr->SetPaletteManager(paletteManager);
Palette* pal = new Palette(palette);
spr->SetPalette(pal);
+ pal->release();
if (cK) spr->SetColorKey(index);
return spr;
}
@@ -592,12 +593,9 @@ void GLVideoDriver::BlitGameSprite(const Sprite2D* spr, int x, int y, unsigned i
flags |= BLIT_TINTED;
tint = *totint;
}
- blitSprite(glSprite, tx, ty, clip, palette, flags, &tint);
}
- else blitSprite(glSprite, tx, ty, clip, palette, flags);
}
- else
- blitSprite(glSprite, tx, ty, clip, palette, flags);
+ blitSprite(glSprite, tx, ty, clip, palette, flags, &tint);
}
else
blitSprite(glSprite, tx, ty, clip, palette, flags);

0 comments on commit f07c489

Please sign in to comment.
Something went wrong with that request. Please try again.