diff options
| author | Dave Foster <daf@minuslab.net> | 2007-09-20 15:30:18 -0400 |
|---|---|---|
| committer | Mikael Magnusson <mikachu@gmail.com> | 2010-10-14 15:54:44 +0200 |
| commit | 6d30d66efb028fbafb58712aa5b71cadfeef2e32 (patch) | |
| tree | 245d4a413f09759925f85986bc94c79aaf8ca616 /obrender/render.c | |
| parent | b566d3fcfe7a23b0616d776fd2db17ef7461185e (diff) | |
Adding RrButton to libobrender, ref counted appearances.
Diffstat (limited to 'obrender/render.c')
| -rw-r--r-- | obrender/render.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/obrender/render.c b/obrender/render.c index fb59e216..7a342042 100644 --- a/obrender/render.c +++ b/obrender/render.c @@ -204,6 +204,7 @@ RrAppearance *RrAppearanceNew(const RrInstance *inst, gint numtex) out = g_slice_new0(RrAppearance); out->inst = inst; + out->ref = 1; out->textures = numtex; out->surface.bevel_light_adjust = 128; out->surface.bevel_dark_adjust = 64; @@ -231,12 +232,22 @@ void RrAppearanceClearTextures(RrAppearance *a) memset(a->texture, 0, a->textures * sizeof(RrTexture)); } +/* shallow copy means up the ref count and return it */ +RrAppearance *RrAppearanceCopyShallow(RrAppearance *orig) +{ + orig->ref++; + return orig; +} + +/* deep copy of orig, means reset ref to 1 on copy + * and copy each thing memwise. */ RrAppearance *RrAppearanceCopy(RrAppearance *orig) { RrSurface *spo, *spc; RrAppearance *copy = g_slice_new(RrAppearance); copy->inst = orig->inst; + copy->ref = 1; spo = &(orig->surface); spc = &(copy->surface); @@ -316,6 +327,7 @@ RrAppearance *RrAppearanceCopy(RrAppearance *orig) return copy; } +/* now decrements ref counter, and frees only if ref <= 0 */ void RrAppearanceFree(RrAppearance *a) { if (a) { |
