summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2009-12-08 12:40:20 +0100
committerBenjamin Otte <otte@redhat.com>2010-02-11 18:34:27 +0100
commit758d29eaa7661765603c1e352342db8735148354 (patch)
tree461fc21bf98674083d26bcfc7ed6d52e86693ce2
parent642daf53364cf808839e68c9a922cc21bb550c56 (diff)
Make the pixman_image_t refcount atomicthreads
-rw-r--r--pixman/pixman-image.c8
-rw-r--r--pixman/pixman-private.h4
2 files changed, 6 insertions, 6 deletions
diff --git a/pixman/pixman-image.c b/pixman/pixman-image.c
index 3322e8e..7d76cdc 100644
--- a/pixman/pixman-image.c
+++ b/pixman/pixman-image.c
@@ -114,7 +114,7 @@ _pixman_image_allocate (void)
common->n_filter_params = 0;
common->alpha_map = NULL;
common->component_alpha = FALSE;
- common->ref_count = 1;
+ _pixman_atomic_int_set (&common->ref_count, 1);
common->classify = NULL;
common->client_clip = FALSE;
common->destroy_func = NULL;
@@ -176,7 +176,7 @@ image_property_changed (pixman_image_t *image)
PIXMAN_EXPORT pixman_image_t *
pixman_image_ref (pixman_image_t *image)
{
- image->common.ref_count++;
+ _pixman_atomic_int_inc (&image->common.ref_count);
return image;
}
@@ -187,9 +187,7 @@ pixman_image_unref (pixman_image_t *image)
{
image_common_t *common = (image_common_t *)image;
- common->ref_count--;
-
- if (common->ref_count == 0)
+ if (_pixman_atomic_int_dec_and_test (&common->ref_count))
{
if (image->common.destroy_func)
image->common.destroy_func (image, image->common.destroy_data);
diff --git a/pixman/pixman-private.h b/pixman/pixman-private.h
index 76eff16..51a7fe6 100644
--- a/pixman/pixman-private.h
+++ b/pixman/pixman-private.h
@@ -14,6 +14,8 @@
#include "pixman-compiler.h"
+#include "pixman-atomic-private.h"
+
/*
* Images
*/
@@ -77,7 +79,7 @@ typedef void (*property_changed_func_t) (pixman_image_t *image);
struct image_common
{
image_type_t type;
- int32_t ref_count;
+ pixman_atomic_int_t ref_count;
pixman_region32_t clip_region;
pixman_bool_t have_clip_region; /* FALSE if there is no clip */
pixman_bool_t client_clip; /* Whether the source clip was