summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonhee Choi <mh0310.choi@samsung.com>2018-06-01 08:28:49 (GMT)
committerMoonhee Choi <mh0310.choi@samsung.com>2018-06-01 08:28:49 (GMT)
commit09169e90d07707dd089c2f24644c383ff4630337 (patch)
tree69af40a004c38c445c4c65195bfab4208fb09bb3
parent46d456ce0d57d981b6674b5af68068a6bd0836f7 (diff)
downloadcairo-tizen_5.0.zip
cairo-tizen_5.0.tar.gz
cairo-tizen_5.0.tar.bz2
Change-Id: I78792c2dc09e4c44c51ffedaea5f73de0ee87e4c Signed-off-by: Moonhee Choi <mh0310.choi@samsung.com>
-rw-r--r--src/cairo-image-surface-private.h1
-rw-r--r--src/cairo-image-surface.c22
2 files changed, 20 insertions, 3 deletions
diff --git a/src/cairo-image-surface-private.h b/src/cairo-image-surface-private.h
index 8ca694c..9dc7ac5 100644
--- a/src/cairo-image-surface-private.h
+++ b/src/cairo-image-surface-private.h
@@ -77,6 +77,7 @@ struct _cairo_image_surface {
unsigned owns_data : 1;
unsigned transparency : 2;
unsigned color : 2;
+ unsigned shadow_cache_init : 1;
};
#define to_image_surface(S) ((cairo_image_surface_t *)(S))
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index a399a81..bf8e262 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -96,12 +96,15 @@ static cairo_atomic_int_t shadow_caches_ref_count = 0;
static void
_cairo_image_shadow_caches_init (void)
{
+ CAIRO_RECURSIVE_MUTEX_INIT (shadow_caches_mutex);
+ CAIRO_MUTEX_LOCK (shadow_caches_mutex);
+
_cairo_atomic_int_inc (&shadow_caches_ref_count);
if (shadow_caches_ref_count == 1)
cairo_list_init (&shadow_caches);
- CAIRO_RECURSIVE_MUTEX_INIT (shadow_caches_mutex);
+ CAIRO_MUTEX_UNLOCK (shadow_caches_mutex);
}
static void
@@ -140,6 +143,11 @@ _cairo_image_surface_shadow_cache_acquire (void *abstract_surface)
if (unlikely (surface->base.status))
return surface->base.status;
+ if (!surface->shadow_cache_init) {
+ _cairo_image_shadow_caches_init();
+ surface->shadow_cache_init = 1;
+ }
+
CAIRO_MUTEX_LOCK (shadow_caches_mutex);
shadow_caches_mutex_depth++;
@@ -174,6 +182,11 @@ _cairo_image_surface_get_shadow_cache (void *abstract_surface)
if (unlikely (surface->base.status))
return NULL;
+ if (!surface->shadow_cache_init) {
+ _cairo_image_shadow_caches_init();
+ surface->shadow_cache_init = 1;
+ }
+
return &shadow_caches;
}
@@ -295,7 +308,7 @@ _cairo_image_surface_init (cairo_image_surface_t *surface,
surface->compositor = _cairo_image_spans_compositor_get ();
- _cairo_image_shadow_caches_init ();
+ surface->shadow_cache_init = 0;
CAIRO_TRACE_END (__func__);
}
@@ -1006,7 +1019,10 @@ _cairo_image_surface_finish (void *abstract_surface)
cairo_surface_destroy (parent);
}
- _cairo_image_shadow_caches_destroy ();
+ if (surface->shadow_cache_init) {
+ _cairo_image_shadow_caches_destroy ();
+ surface->shadow_cache_init = 0;
+ }
CAIRO_TRACE_END (__func__);
return CAIRO_STATUS_SUCCESS;