Permalink
Browse files

Palette: rename ref counting functions

bring them inline with other classes and be compatible with Holder smart ptr
  • Loading branch information...
1 parent fed83e6 commit c367f9a2268d0254a0f7d3c9de741ba8eae85300 @bradallred bradallred committed Jun 8, 2013
@@ -136,7 +136,7 @@ Sprite2D* AnimationFactory::GetPaperdollImage(ieDword *Colors,
Palette* palette = Picture2->GetPalette();
palette->SetupPaperdollColours(Colors, type);
Picture2->SetPalette(palette);
- palette->Release();
+ palette->release();
}
Picture2->XPos = (short)frames[1]->XPos;
@@ -148,7 +148,7 @@ Sprite2D* AnimationFactory::GetPaperdollImage(ieDword *Colors,
Palette* palette = spr->GetPalette();
palette->SetupPaperdollColours(Colors, type);
spr->SetPalette(palette);
- palette->Release();
+ palette->release();
}
spr->XPos = (short)frames[0]->XPos;
@@ -138,13 +138,13 @@ void ControlAnimation::UpdateAnimation(bool paused)
palette->CreateShadedAlphaChannel();
}
pic->SetPalette(palette);
- palette->Release();
+ palette->release();
} else {
if (is_blended) {
Palette* palette = pic->GetPalette();
palette->CreateShadedAlphaChannel();
pic->SetPalette(palette);
- palette->Release();
+ palette->release();
}
}
View
@@ -33,8 +33,8 @@
namespace GemRB {
#define SET_BLIT_PALETTE( palette )\
-if (palette != NULL) ((Palette*)palette)->IncRef();\
-if (blitPalette != NULL) blitPalette->Release();\
+if (palette != NULL) ((Palette*)palette)->acquire();\
+if (blitPalette != NULL) blitPalette->release();\
blitPalette = palette;
Font::Font()
@@ -624,14 +624,14 @@ void Font::SetName(const char* newName)
Palette* Font::GetPalette() const
{
assert(palette);
- palette->IncRef();
+ palette->acquire();
return palette;
}
void Font::SetPalette(Palette* pal)
{
- if (pal) pal->IncRef();
- if (palette) palette->Release();
+ if (pal) pal->acquire();
+ if (palette) palette->release();
palette = pal;
}
@@ -130,7 +130,7 @@ void WorldMapControl::Draw(unsigned short XWin, unsigned short YWin)
icon->SetPalette(pal_selected);
video->BlitSprite( icon, xOffs, yOffs, true, &r );
icon->SetPalette(pal);
- pal->Release();
+ pal->release();
} else {
video->BlitSprite( icon, xOffs, yOffs, true, &r );
}
View
@@ -68,7 +68,7 @@ static void ReleasePalette(void *poi)
//we allow nulls, but we shouldn't release them
if (!poi) return;
//as long as palette has its own refcount, this should be Release
- ((Palette *) poi)->Release();
+ ((Palette *) poi)->release();
}
GEM_EXPORT GameData* gamedata;
@@ -271,7 +271,7 @@ void GameData::FreePalette(Palette *&pal, const ieResRef name)
if(pal->named) {
error("GameData", "Palette is supposed to be named, but got no name!\n");
} else {
- pal->Release();
+ pal->release();
pal=NULL;
}
return;
@@ -284,7 +284,7 @@ void GameData::FreePalette(Palette *&pal, const ieResRef name)
error("Core", "Corrupted Palette cache encountered (reference count went below zero), Palette name is: %.8s\n", name);
}
if (!res) {
- pal->Release();
+ pal->release();
}
pal = NULL;
}
View
@@ -62,7 +62,7 @@ void Palette::Brighten()
Palette* Palette::Copy()
{
Palette* pal = new Palette(col, alpha);
- Release();
+ release();
return pal;
}
View
@@ -65,11 +65,11 @@ class GEM_EXPORT Palette {
Color front; // Original colors used by core->CreatePalette()
Color back;
- void IncRef() {
+ void acquire() {
refcount++;
}
- void Release() {
+ void release() {
assert(refcount > 0);
if (!--refcount)
delete this;
@@ -620,7 +620,7 @@ void Actor::SetAnimationID(unsigned int AnimID)
}
// Take ownership so the palette won't be deleted
if (recover) {
- recover->IncRef();
+ recover->acquire();
}
delete( anims );
}
View
@@ -87,7 +87,7 @@ Palette* Sprite2D::GetPalette() const
}
Sprite2D_BAM_Internal* data = (Sprite2D_BAM_Internal*)vptr;
- data->pal->IncRef();
+ data->pal->acquire();
return data->pal;
}
@@ -98,8 +98,8 @@ void Sprite2D::SetPalette(Palette* pal)
core->GetVideoDriver()->SetPalette(vptr, pal);
} else {
Sprite2D_BAM_Internal* data = (Sprite2D_BAM_Internal*)vptr;
- data->pal->Release();
- pal->IncRef();
+ data->pal->release();
+ pal->acquire();
data->pal = pal;
}
}
View
@@ -46,7 +46,7 @@ class AnimationFactory;
class Sprite2D_BAM_Internal {
public:
Sprite2D_BAM_Internal() { pal = 0; }
- ~Sprite2D_BAM_Internal() { if (pal) { pal->Release(); pal = 0; } }
+ ~Sprite2D_BAM_Internal() { if (pal) { pal->release(); pal = 0; } }
Palette* pal;
bool RLE;
@@ -52,7 +52,7 @@ BAMFont::BAMFont(AnimationFactory* af, int* baseline)
Sprite2D* first = af->GetFrameWithoutCycle(0);
Palette* pal = first->GetPalette();
SetPalette(pal);
- pal->Release();
+ pal->release();
first->release();
blank = core->GetVideoDriver()->CreateSprite8(0, 0, 8, NULL, palette->col);
@@ -163,7 +163,7 @@ Sprite2D* BAMImporter::GetFrameInternal(unsigned short findex, unsigned char mod
// without creating a local copy for this sprite?
Palette* pal = spr->GetPalette();
pal->CreateShadedAlphaChannel();
- pal->Release();
+ pal->release();
}
return spr;
}
@@ -3740,7 +3740,7 @@ static PyObject* SetButtonBAM(int wi, int ci, const char *ResRef, int CycleIndex
Palette* newpal = Picture->GetPalette()->Copy();
core->GetPalette( col1, 12, &newpal->col[4]);
Picture->SetPalette( newpal );
- newpal->Release();
+ newpal->release();
}
btn->SetPicture( Picture );
@@ -430,7 +430,7 @@ Sprite2D* SDLVideoDriver::CreateSpriteBAM8(int w, int h, bool rle,
{
Sprite2D_BAM_Internal* data = new Sprite2D_BAM_Internal;
- palette->IncRef();
+ palette->acquire();
data->pal = palette;
data->transindex = transindex;
data->flip_hor = false;
@@ -692,7 +692,7 @@ void SDLVideoDriver::BlitSprite(const Sprite2D* spr, int x, int y, bool anchor,
SetSurfacePalette(( SDL_Surface * )spr->vptr, (SDL_Color*)palette->col, 256);
SDL_BlitSurface( ( SDL_Surface * ) spr->vptr, srect, backBuf, &drect );
SetSurfacePalette(( SDL_Surface * )spr->vptr, (SDL_Color*)tmpPal->col, 256);
- tmpPal->Release();
+ tmpPal->release();
} else {
SDL_BlitSurface( ( SDL_Surface * ) spr->vptr, srect, backBuf, &drect );
}

0 comments on commit c367f9a

Please sign in to comment.