_cairo_array_init:
   59|    828|{
   60|    828|    array->size = 0;
   61|    828|    array->num_elements = 0;
   62|    828|    array->element_size = element_size;
   63|       |    array->elements = NULL;
   64|    828|}
_cairo_array_fini:
   76|    828|{
   77|    828|    free (array->elements);
   78|    828|}
_cairo_array_grow_by:
   90|  20.2k|{
   91|  20.2k|    char *new_elements;
   92|  20.2k|    unsigned int old_size = array->size;
   93|  20.2k|    unsigned int required_size = array->num_elements + additional;
   94|  20.2k|    unsigned int new_size;
   95|       |
   96|       |    /* check for integer overflow */
   97|  20.2k|    if (required_size > INT_MAX || required_size < array->num_elements)
  ------------------
  |  Branch (97:9): [True: 0, False: 20.2k]
  |  Branch (97:36): [True: 0, False: 20.2k]
  ------------------
   98|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
   99|       |
  100|  20.2k|    if (CAIRO_INJECT_FAULT ())
  ------------------
  |  |   47|  20.2k|#define CAIRO_INJECT_FAULT() 0
  |  |  ------------------
  |  |  |  Branch (47:30): [Folded, False: 20.2k]
  |  |  ------------------
  ------------------
  101|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  102|       |
  103|  20.2k|    if (required_size <= old_size)
  ------------------
  |  Branch (103:9): [True: 18.5k, False: 1.70k]
  ------------------
  104|  18.5k|	return CAIRO_STATUS_SUCCESS;
  105|       |
  106|  1.70k|    if (old_size == 0)
  ------------------
  |  Branch (106:9): [True: 513, False: 1.19k]
  ------------------
  107|    513|	new_size = 1;
  108|  1.19k|    else
  109|  1.19k|	new_size = old_size * 2;
  110|       |
  111|  3.32k|    while (new_size < required_size)
  ------------------
  |  Branch (111:12): [True: 1.61k, False: 1.70k]
  ------------------
  112|  1.61k|	new_size = new_size * 2;
  113|       |
  114|  1.70k|    array->size = new_size;
  115|  1.70k|    new_elements = _cairo_realloc_ab (array->elements,
  116|  1.70k|			              array->size, array->element_size);
  117|       |
  118|  1.70k|    if (unlikely (new_elements == NULL)) {
  ------------------
  |  |  145|  1.70k|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1.70k]
  |  |  ------------------
  ------------------
  119|      0|	array->size = old_size;
  120|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  121|      0|    }
  122|       |
  123|  1.70k|    array->elements = new_elements;
  124|       |
  125|  1.70k|    return CAIRO_STATUS_SUCCESS;
  126|  1.70k|}
_cairo_array_index:
  168|    315|{
  169|       |    /* We allow an index of 0 for the no-elements case.
  170|       |     * This makes for cleaner calling code which will often look like:
  171|       |     *
  172|       |     *    elements = _cairo_array_index (array, 0);
  173|       |     *	  for (i=0; i < num_elements; i++) {
  174|       |     *        ... use elements[i] here ...
  175|       |     *    }
  176|       |     *
  177|       |     * which in the num_elements==0 case gets the NULL pointer here,
  178|       |     * but never dereferences it.
  179|       |     */
  180|    315|    if (index == 0 && array->num_elements == 0)
  ------------------
  |  Branch (180:9): [True: 315, False: 0]
  |  Branch (180:23): [True: 105, False: 210]
  ------------------
  181|    105|	return NULL;
  182|       |
  183|    315|    assert (index < array->num_elements);
  ------------------
  |  Branch (183:5): [True: 0, False: 210]
  |  Branch (183:5): [True: 210, False: 0]
  ------------------
  184|       |
  185|    210|    return array->elements + (size_t)index * array->element_size;
  186|    210|}
_cairo_array_append:
  266|    105|{
  267|    105|    return _cairo_array_append_multiple (array, element, 1);
  268|    105|}
_cairo_array_append_multiple:
  286|  20.2k|{
  287|  20.2k|    cairo_status_t status;
  288|  20.2k|    void *dest;
  289|       |
  290|  20.2k|    status = _cairo_array_allocate (array, num_elements, &dest);
  291|  20.2k|    if (unlikely (status))
  ------------------
  |  |  145|  20.2k|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 20.2k]
  |  |  ------------------
  ------------------
  292|      0|	return status;
  293|       |
  294|  20.2k|    memcpy (dest, elements, (size_t)num_elements * array->element_size);
  295|       |
  296|  20.2k|    return CAIRO_STATUS_SUCCESS;
  297|  20.2k|}
_cairo_array_allocate:
  316|  20.2k|{
  317|  20.2k|    cairo_status_t status;
  318|       |
  319|  20.2k|    status = _cairo_array_grow_by (array, num_elements);
  320|  20.2k|    if (unlikely (status))
  ------------------
  |  |  145|  20.2k|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 20.2k]
  |  |  ------------------
  ------------------
  321|      0|	return status;
  322|       |
  323|  20.2k|    assert (array->num_elements + num_elements <= array->size);
  ------------------
  |  Branch (323:5): [True: 0, False: 20.2k]
  |  Branch (323:5): [True: 20.2k, False: 0]
  ------------------
  324|       |
  325|  20.2k|    *elements = array->elements + (size_t)array->num_elements * array->element_size;
  326|       |
  327|  20.2k|    array->num_elements += num_elements;
  328|       |
  329|  20.2k|    return CAIRO_STATUS_SUCCESS;
  330|  20.2k|}
_cairo_array_num_elements:
  342|    105|{
  343|    105|    return array->num_elements;
  344|    105|}
_cairo_user_data_array_init:
  372|    417|{
  373|    417|    _cairo_array_init (array, sizeof (cairo_user_data_slot_t));
  374|    417|}
_cairo_user_data_array_fini:
  385|    417|{
  386|    417|    unsigned int num_slots;
  387|       |
  388|    417|    num_slots = array->num_elements;
  389|    417|    if (num_slots) {
  ------------------
  |  Branch (389:9): [True: 105, False: 312]
  ------------------
  390|    105|	cairo_user_data_slot_t *slots;
  391|       |
  392|    105|	slots = _cairo_array_index (array, 0);
  393|    210|	while (num_slots--) {
  ------------------
  |  Branch (393:9): [True: 105, False: 105]
  ------------------
  394|    105|	    cairo_user_data_slot_t *s = &slots[num_slots];
  395|    105|	    if (s->user_data != NULL && s->destroy != NULL)
  ------------------
  |  Branch (395:10): [True: 105, False: 0]
  |  Branch (395:34): [True: 105, False: 0]
  ------------------
  396|    105|		s->destroy (s->user_data);
  397|    105|	}
  398|    105|    }
  399|       |
  400|    417|    _cairo_array_fini (array);
  401|    417|}
_cairo_user_data_array_set_data:
  457|    105|{
  458|    105|    cairo_status_t status;
  459|    105|    unsigned int i, num_slots;
  460|    105|    cairo_user_data_slot_t *slots, *slot, new_slot;
  461|       |
  462|    105|    if (user_data) {
  ------------------
  |  Branch (462:9): [True: 105, False: 0]
  ------------------
  463|    105|	new_slot.key = key;
  464|    105|	new_slot.user_data = user_data;
  465|    105|	new_slot.destroy = destroy;
  466|    105|    } else {
  467|      0|	new_slot.key = NULL;
  468|      0|	new_slot.user_data = NULL;
  469|      0|	new_slot.destroy = NULL;
  470|      0|    }
  471|       |
  472|    105|    slot = NULL;
  473|    105|    num_slots = array->num_elements;
  474|    105|    slots = _cairo_array_index (array, 0);
  475|    105|    for (i = 0; i < num_slots; i++) {
  ------------------
  |  Branch (475:17): [True: 0, False: 105]
  ------------------
  476|      0|	if (slots[i].key == key) {
  ------------------
  |  Branch (476:6): [True: 0, False: 0]
  ------------------
  477|      0|	    slot = &slots[i];
  478|      0|	    if (slot->destroy && slot->user_data)
  ------------------
  |  Branch (478:10): [True: 0, False: 0]
  |  Branch (478:27): [True: 0, False: 0]
  ------------------
  479|      0|		slot->destroy (slot->user_data);
  480|      0|	    break;
  481|      0|	}
  482|      0|	if (user_data && slots[i].user_data == NULL) {
  ------------------
  |  Branch (482:6): [True: 0, False: 0]
  |  Branch (482:19): [True: 0, False: 0]
  ------------------
  483|      0|	    slot = &slots[i];	/* Have to keep searching for an exact match */
  484|      0|	}
  485|      0|    }
  486|       |
  487|    105|    if (slot) {
  ------------------
  |  Branch (487:9): [True: 0, False: 105]
  ------------------
  488|      0|	*slot = new_slot;
  489|      0|	return CAIRO_STATUS_SUCCESS;
  490|      0|    }
  491|       |
  492|    105|    if (user_data == NULL)
  ------------------
  |  Branch (492:9): [True: 0, False: 105]
  ------------------
  493|      0|	return CAIRO_STATUS_SUCCESS;
  494|       |
  495|    105|    status = _cairo_array_append (array, &new_slot);
  496|    105|    if (unlikely (status))
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
  497|      0|	return status;
  498|       |
  499|    105|    return CAIRO_STATUS_SUCCESS;
  500|    105|}

cairo-surface.c:_cairo_atomic_int_cmpxchg_impl:
   92|    156|{
   93|    156|    int expected = oldv;
   94|       |    return atomic_compare_exchange_strong_explicit (x, &expected, newv, memory_order_seq_cst, memory_order_seq_cst);
   95|    156|}
cairo-surface.c:_cairo_atomic_int_get:
   61|  1.19k|{
   62|       |    return atomic_load_explicit (x, memory_order_seq_cst);
   63|  1.19k|}
cairo-image-compositor.c:_cairo_atomic_init_once_enter:
  541|    157|{
  542|    157|    if (likely(_cairo_atomic_int_get(once) == CAIRO_ATOMIC_ONCE_INITIALIZED))
  ------------------
  |  |  144|    157|#define likely(expr) (__builtin_expect (!!(expr), 1))
  |  |  ------------------
  |  |  |  Branch (144:22): [True: 155, False: 2]
  |  |  ------------------
  ------------------
  543|    155|	return 0;
  544|       |
  545|      2|    if (_cairo_atomic_int_cmpxchg(once,
  ------------------
  |  |   98|      2|  _cairo_atomic_int_cmpxchg_impl(x, oldv, newv)
  |  |  ------------------
  |  |  |  Branch (98:3): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  546|      2|				  CAIRO_ATOMIC_ONCE_UNINITIALIZED,
  547|      2|				  CAIRO_ATOMIC_ONCE_INITIALIZING))
  548|      2|	return 1;
  549|       |
  550|      0|    while (_cairo_atomic_int_get(once) != CAIRO_ATOMIC_ONCE_INITIALIZED) {}
  ------------------
  |  |  536|      0|#define CAIRO_ATOMIC_ONCE_INITIALIZED   (2)
  ------------------
  |  Branch (550:12): [True: 0, False: 0]
  ------------------
  551|      0|    return 0;
  552|      2|}
cairo-image-compositor.c:_cairo_atomic_int_get:
   61|    157|{
   62|       |    return atomic_load_explicit (x, memory_order_seq_cst);
   63|    157|}
cairo-image-compositor.c:_cairo_atomic_int_cmpxchg_impl:
   92|      4|{
   93|      4|    int expected = oldv;
   94|       |    return atomic_compare_exchange_strong_explicit (x, &expected, newv, memory_order_seq_cst, memory_order_seq_cst);
   95|      4|}
cairo-image-compositor.c:_cairo_atomic_init_once_leave:
  556|      2|{
  557|      2|    if (unlikely(!_cairo_atomic_int_cmpxchg(once,
  ------------------
  |  |  145|      2|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 2]
  |  |  ------------------
  ------------------
  558|      2|					    CAIRO_ATOMIC_ONCE_INITIALIZING,
  559|      2|					    CAIRO_ATOMIC_ONCE_INITIALIZED)))
  560|       |	assert (0 && "incorrect use of _cairo_atomic_init_once API (once != CAIRO_ATOMIC_ONCE_INITIALIZING)");
  ------------------
  |  Branch (560:2): [Folded, False: 0]
  |  Branch (560:2): [True: 0, False: 0]
  |  Branch (560:2): [Folded, False: 0]
  |  Branch (560:2): [True: 0, False: 0]
  ------------------
  561|      2|}

cairo_device_reference:
  208|    156|{
  209|    156|    if (device == NULL ||
  ------------------
  |  Branch (209:9): [True: 156, False: 0]
  ------------------
  210|      0|	CAIRO_REFERENCE_COUNT_IS_INVALID (&device->ref_count))
  ------------------
  |  |   58|      0|#define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   53|      0|#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC) _cairo_atomic_int_get (&(RC)->ref_count)
  |  |  ------------------
  |  |               #define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   55|      0|#define CAIRO_REFERENCE_COUNT_INVALID_VALUE ((int) -1)
  |  |  ------------------
  |  |  |  Branch (58:46): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  211|    156|    {
  212|    156|	return device;
  213|    156|    }
  214|       |
  215|    156|    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&device->ref_count));
  ------------------
  |  Branch (215:5): [True: 0, False: 0]
  |  Branch (215:5): [True: 0, False: 0]
  ------------------
  216|      0|    _cairo_reference_count_inc (&device->ref_count);
  ------------------
  |  |   47|      0|#define _cairo_reference_count_inc(RC) _cairo_atomic_int_inc (&(RC)->ref_count)
  |  |  ------------------
  |  |  |  |   83|      0|# define _cairo_atomic_int_inc(x) ((void) atomic_fetch_add_explicit(x, 1, memory_order_seq_cst))
  |  |  ------------------
  ------------------
  217|       |
  218|      0|    return device;
  219|      0|}

_cairo_error:
   66|    360|{
   67|    360|    CAIRO_ENSURE_UNIQUE;
  ------------------
  |  |  183|    360|#define CAIRO_ENSURE_UNIQUE    do { } while (0)
  |  |  ------------------
  |  |  |  Branch (183:46): [Folded, False: 360]
  |  |  ------------------
  ------------------
   68|    360|    assert (_cairo_status_is_error (status));
  ------------------
  |  Branch (68:5): [True: 0, False: 360]
  |  Branch (68:5): [True: 0, False: 0]
  |  Branch (68:5): [True: 360, False: 0]
  |  Branch (68:5): [True: 360, False: 0]
  ------------------
   69|       |
   70|    360|    return status;
   71|    360|}

_cairo_hash_table_create:
  164|      1|{
  165|      1|    cairo_hash_table_t *hash_table;
  166|       |
  167|      1|    hash_table = _cairo_calloc (sizeof (cairo_hash_table_t));
  ------------------
  |  |   79|      1|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 1, Folded]
  |  |  ------------------
  ------------------
  168|      1|    if (unlikely (hash_table == NULL)) {
  ------------------
  |  |  145|      1|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  169|      0|	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
  ------------------
  |  |  126|      0|#define _cairo_error_throw(status) do { \
  |  |  127|      0|    cairo_status_t status__ = _cairo_error (status); \
  |  |  128|      0|    (void) status__; \
  |  |  129|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (129:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  170|      0|	return NULL;
  171|      0|    }
  172|       |
  173|      1|    if (keys_equal == NULL)
  ------------------
  |  Branch (173:9): [True: 0, False: 1]
  ------------------
  174|      0|	hash_table->keys_equal = _cairo_hash_table_uid_keys_equal;
  175|      1|    else
  176|      1|	hash_table->keys_equal = keys_equal;
  177|       |
  178|      1|    memset (&hash_table->cache, 0, sizeof (hash_table->cache));
  179|      1|    hash_table->table_size = &hash_table_sizes[0];
  180|       |
  181|      1|    hash_table->entries = _cairo_calloc_ab (*hash_table->table_size,
  182|      1|				  sizeof (cairo_hash_entry_t *));
  183|      1|    if (unlikely (hash_table->entries == NULL)) {
  ------------------
  |  |  145|      1|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  184|      0|	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
  ------------------
  |  |  126|      0|#define _cairo_error_throw(status) do { \
  |  |  127|      0|    cairo_status_t status__ = _cairo_error (status); \
  |  |  128|      0|    (void) status__; \
  |  |  129|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (129:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  185|      0|	free (hash_table);
  186|      0|	return NULL;
  187|      0|    }
  188|       |
  189|      1|    hash_table->live_entries = 0;
  190|      1|    hash_table->free_entries = *hash_table->table_size;
  191|      1|    hash_table->iterating = 0;
  192|       |
  193|      1|    return hash_table;
  194|      1|}
_cairo_hash_table_lookup:
  340|    105|{
  341|    105|    cairo_hash_entry_t *entry;
  342|    105|    unsigned long table_size, i, idx, step;
  343|    105|    uintptr_t hash = key->hash;
  344|       |
  345|    105|    entry = hash_table->cache[hash & 31];
  346|    105|    if (entry && entry->hash == hash && hash_table->keys_equal (key, entry))
  ------------------
  |  Branch (346:9): [True: 104, False: 1]
  |  Branch (346:18): [True: 104, False: 0]
  |  Branch (346:41): [True: 104, False: 0]
  ------------------
  347|    104|	return entry;
  348|       |
  349|      1|    table_size = *hash_table->table_size;
  350|      1|    idx = hash % table_size;
  351|       |
  352|      1|    entry = hash_table->entries[idx];
  353|      1|    if (ENTRY_IS_LIVE (entry)) {
  ------------------
  |  |   60|      1|#define ENTRY_IS_LIVE(entry) ((entry) >  DEAD_ENTRY)
  |  |  ------------------
  |  |  |  |   56|      1|#define DEAD_ENTRY ((cairo_hash_entry_t *) 0x1)
  |  |  ------------------
  |  |  |  Branch (60:30): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  354|      0|	if (entry->hash == hash && hash_table->keys_equal (key, entry))
  ------------------
  |  Branch (354:6): [True: 0, False: 0]
  |  Branch (354:29): [True: 0, False: 0]
  ------------------
  355|      0|		goto insert_cache;
  356|      1|    } else if (ENTRY_IS_FREE (entry))
  ------------------
  |  |   58|      1|#define ENTRY_IS_FREE(entry) ((entry) == NULL)
  |  |  ------------------
  |  |  |  Branch (58:30): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  357|      1|	return NULL;
  358|       |
  359|      0|    i = 1;
  360|      0|    step = 1 + hash % (table_size - 2);
  361|      0|    do {
  362|      0|	idx += step;
  363|      0|	if (idx >= table_size)
  ------------------
  |  Branch (363:6): [True: 0, False: 0]
  ------------------
  364|      0|	    idx -= table_size;
  365|       |
  366|      0|	entry = hash_table->entries[idx];
  367|      0|	if (ENTRY_IS_LIVE (entry)) {
  ------------------
  |  |   60|      0|#define ENTRY_IS_LIVE(entry) ((entry) >  DEAD_ENTRY)
  |  |  ------------------
  |  |  |  |   56|      0|#define DEAD_ENTRY ((cairo_hash_entry_t *) 0x1)
  |  |  ------------------
  |  |  |  Branch (60:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  368|      0|	    if (entry->hash == hash && hash_table->keys_equal (key, entry))
  ------------------
  |  Branch (368:10): [True: 0, False: 0]
  |  Branch (368:33): [True: 0, False: 0]
  ------------------
  369|      0|		    goto insert_cache;
  370|      0|	} else if (ENTRY_IS_FREE (entry))
  ------------------
  |  |   58|      0|#define ENTRY_IS_FREE(entry) ((entry) == NULL)
  |  |  ------------------
  |  |  |  Branch (58:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  371|      0|	    return NULL;
  372|      0|    } while (++i < table_size);
  ------------------
  |  Branch (372:14): [True: 0, False: 0]
  ------------------
  373|       |
  374|      0|    ASSERT_NOT_REACHED;
  ------------------
  |  |  140|      0|#define ASSERT_NOT_REACHED		\
  |  |  141|      0|do {					\
  |  |  142|      0|    assert (!"reached");		\
  |  |  143|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (143:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (374:5): [Folded, False: 0]
  |  Branch (374:5): [Folded, False: 0]
  ------------------
  375|      0|    return NULL;
  376|       |
  377|      0|insert_cache:
  378|      0|    hash_table->cache[hash & 31] = entry;
  379|      0|    return entry;
  380|      0|}
_cairo_hash_table_insert:
  457|      1|{
  458|      1|    cairo_hash_entry_t **entry;
  459|      1|    cairo_status_t status;
  460|       |
  461|       |    /* Insert is illegal while an iterator is running. */
  462|      1|    assert (hash_table->iterating == 0);
  ------------------
  |  Branch (462:5): [True: 0, False: 1]
  |  Branch (462:5): [True: 1, False: 0]
  ------------------
  463|       |
  464|      1|    status = _cairo_hash_table_manage (hash_table);
  465|      1|    if (unlikely (status))
  ------------------
  |  |  145|      1|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  466|      0|	return status;
  467|       |
  468|      1|    entry = _cairo_hash_table_lookup_unique_key (hash_table, key_and_value);
  469|       |
  470|      1|    if (ENTRY_IS_FREE (*entry))
  ------------------
  |  |   58|      1|#define ENTRY_IS_FREE(entry) ((entry) == NULL)
  |  |  ------------------
  |  |  |  Branch (58:30): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  471|      1|	hash_table->free_entries--;
  472|       |
  473|      1|    *entry = key_and_value;
  474|      1|    hash_table->cache[key_and_value->hash & 31] = key_and_value;
  475|      1|    hash_table->live_entries++;
  476|       |
  477|      1|    return CAIRO_STATUS_SUCCESS;
  478|      1|}
cairo-hash.c:_cairo_hash_table_manage:
  269|      1|{
  270|      1|    cairo_hash_table_t tmp;
  271|      1|    unsigned long new_size, i;
  272|       |
  273|       |    /* Keep between 12.5% and 50% entries in the hash table alive and
  274|       |     * at least 25% free. */
  275|      1|    unsigned long live_high = *hash_table->table_size >> 1;
  276|      1|    unsigned long live_low = live_high >> 2;
  277|      1|    unsigned long free_low = live_high >> 1;
  278|       |
  279|      1|    tmp = *hash_table;
  280|       |
  281|      1|    if (hash_table->live_entries > live_high)
  ------------------
  |  Branch (281:9): [True: 0, False: 1]
  ------------------
  282|      0|    {
  283|      0|	tmp.table_size = hash_table->table_size + 1;
  284|       |	/* This code is being abused if we can't make a table big enough. */
  285|      0|	assert (tmp.table_size - hash_table_sizes <
  ------------------
  |  Branch (285:2): [True: 0, False: 0]
  |  Branch (285:2): [True: 0, False: 0]
  ------------------
  286|      0|		ARRAY_LENGTH (hash_table_sizes));
  287|      0|    }
  288|      1|    else if (hash_table->live_entries < live_low)
  ------------------
  |  Branch (288:14): [True: 1, False: 0]
  ------------------
  289|      1|    {
  290|       |	/* Can't shrink if we're at the smallest size */
  291|      1|	if (hash_table->table_size == &hash_table_sizes[0])
  ------------------
  |  Branch (291:6): [True: 1, False: 0]
  ------------------
  292|      1|	    tmp.table_size = hash_table->table_size;
  293|      0|	else
  294|      0|	    tmp.table_size = hash_table->table_size - 1;
  295|      1|    }
  296|       |
  297|      1|    if (tmp.table_size == hash_table->table_size &&
  ------------------
  |  Branch (297:9): [True: 1, False: 0]
  ------------------
  298|      1|	hash_table->free_entries > free_low)
  ------------------
  |  Branch (298:2): [True: 1, False: 0]
  ------------------
  299|      1|    {
  300|       |	/* The number of live entries is within the desired bounds
  301|       |	 * (we're not going to resize the table) and we have enough
  302|       |	 * free entries. Do nothing. */
  303|      1|	return CAIRO_STATUS_SUCCESS;
  304|      1|    }
  305|       |
  306|      0|    new_size = *tmp.table_size;
  307|      0|    tmp.entries = _cairo_calloc_ab (new_size, sizeof (cairo_hash_entry_t*));
  308|      0|    if (unlikely (tmp.entries == NULL))
  ------------------
  |  |  145|      0|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  309|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  310|       |
  311|      0|    for (i = 0; i < *hash_table->table_size; ++i) {
  ------------------
  |  Branch (311:17): [True: 0, False: 0]
  ------------------
  312|      0|	if (ENTRY_IS_LIVE (hash_table->entries[i])) {
  ------------------
  |  |   60|      0|#define ENTRY_IS_LIVE(entry) ((entry) >  DEAD_ENTRY)
  |  |  ------------------
  |  |  |  |   56|      0|#define DEAD_ENTRY ((cairo_hash_entry_t *) 0x1)
  |  |  ------------------
  |  |  |  Branch (60:30): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  313|      0|	    *_cairo_hash_table_lookup_unique_key (&tmp, hash_table->entries[i])
  314|      0|		= hash_table->entries[i];
  315|      0|	}
  316|      0|    }
  317|       |
  318|      0|    free (hash_table->entries);
  319|      0|    hash_table->entries = tmp.entries;
  320|      0|    hash_table->table_size = tmp.table_size;
  321|      0|    hash_table->free_entries = new_size - hash_table->live_entries;
  322|       |
  323|      0|    return CAIRO_STATUS_SUCCESS;
  324|      0|}
cairo-hash.c:_cairo_hash_table_lookup_unique_key:
  228|      1|{
  229|      1|    unsigned long table_size, i, idx, step;
  230|      1|    cairo_hash_entry_t **entry;
  231|       |
  232|      1|    table_size = *hash_table->table_size;
  233|      1|    idx = key->hash % table_size;
  234|       |
  235|      1|    entry = &hash_table->entries[idx];
  236|      1|    if (! ENTRY_IS_LIVE (*entry))
  ------------------
  |  |   60|      1|#define ENTRY_IS_LIVE(entry) ((entry) >  DEAD_ENTRY)
  |  |  ------------------
  |  |  |  |   56|      1|#define DEAD_ENTRY ((cairo_hash_entry_t *) 0x1)
  |  |  ------------------
  ------------------
  |  Branch (236:9): [True: 1, False: 0]
  ------------------
  237|      1|	return entry;
  238|       |
  239|      0|    i = 1;
  240|      0|    step = 1 + key->hash % (table_size - 2);
  241|      0|    do {
  242|      0|	idx += step;
  243|      0|	if (idx >= table_size)
  ------------------
  |  Branch (243:6): [True: 0, False: 0]
  ------------------
  244|      0|	    idx -= table_size;
  245|       |
  246|      0|	entry = &hash_table->entries[idx];
  247|      0|	if (! ENTRY_IS_LIVE (*entry))
  ------------------
  |  |   60|      0|#define ENTRY_IS_LIVE(entry) ((entry) >  DEAD_ENTRY)
  |  |  ------------------
  |  |  |  |   56|      0|#define DEAD_ENTRY ((cairo_hash_entry_t *) 0x1)
  |  |  ------------------
  ------------------
  |  Branch (247:6): [True: 0, False: 0]
  ------------------
  248|      0|	    return entry;
  249|      0|    } while (++i < table_size);
  ------------------
  |  Branch (249:14): [True: 0, False: 0]
  ------------------
  250|       |
  251|      0|    ASSERT_NOT_REACHED;
  ------------------
  |  |  140|      0|#define ASSERT_NOT_REACHED		\
  |  |  141|      0|do {					\
  |  |  142|      0|    assert (!"reached");		\
  |  |  143|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (143:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (251:5): [Folded, False: 0]
  |  Branch (251:5): [Folded, False: 0]
  ------------------
  252|      0|    return NULL;
  253|      0|}

_cairo_image_traps_compositor_get:
 1275|      1|{
 1276|      1|    static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;
  ------------------
  |  |  537|      1|#define CAIRO_ATOMIC_ONCE_INIT          CAIRO_ATOMIC_ONCE_UNINITIALIZED
  |  |  ------------------
  |  |  |  |  534|      1|#define CAIRO_ATOMIC_ONCE_UNINITIALIZED (0)
  |  |  ------------------
  ------------------
 1277|      1|    static cairo_traps_compositor_t compositor;
 1278|       |
 1279|      1|    if (_cairo_atomic_init_once_enter(&once)) {
  ------------------
  |  Branch (1279:9): [True: 1, False: 0]
  ------------------
 1280|      1|	_cairo_traps_compositor_init(&compositor,
 1281|      1|				     &__cairo_no_compositor);
 1282|      1|	compositor.acquire = acquire;
 1283|      1|	compositor.release = release;
 1284|      1|	compositor.set_clip_region = set_clip_region;
 1285|      1|	compositor.pattern_to_surface = _cairo_image_source_create_for_pattern;
 1286|      1|	compositor.draw_image_boxes = draw_image_boxes;
 1287|       |	//compositor.copy_boxes = copy_boxes;
 1288|      1|	compositor.fill_boxes = fill_boxes;
 1289|      1|	compositor.check_composite = check_composite;
 1290|      1|	compositor.composite = composite;
 1291|      1|	compositor.lerp = lerp;
 1292|       |	//compositor.check_composite_boxes = check_composite_boxes;
 1293|      1|	compositor.composite_boxes = composite_boxes;
 1294|       |	//compositor.check_composite_traps = check_composite_traps;
 1295|      1|	compositor.composite_traps = composite_traps;
 1296|       |	//compositor.check_composite_tristrip = check_composite_traps;
 1297|      1|	compositor.composite_tristrip = composite_tristrip;
 1298|      1|	compositor.check_composite_glyphs = check_composite_glyphs;
 1299|      1|	compositor.composite_glyphs = composite_glyphs;
 1300|       |
 1301|      1|	_cairo_atomic_init_once_leave(&once);
 1302|      1|    }
 1303|       |
 1304|      1|    return &compositor.base;
 1305|      1|}
_cairo_image_spans_compositor_get:
 3144|    156|{
 3145|    156|    static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;
  ------------------
  |  |  537|    156|#define CAIRO_ATOMIC_ONCE_INIT          CAIRO_ATOMIC_ONCE_UNINITIALIZED
  |  |  ------------------
  |  |  |  |  534|    156|#define CAIRO_ATOMIC_ONCE_UNINITIALIZED (0)
  |  |  ------------------
  ------------------
 3146|    156|    static cairo_spans_compositor_t spans;
 3147|    156|    static cairo_compositor_t shape;
 3148|       |
 3149|    156|    if (_cairo_atomic_init_once_enter(&once)) {
  ------------------
  |  Branch (3149:9): [True: 1, False: 155]
  ------------------
 3150|      1|	_cairo_shape_mask_compositor_init (&shape,
 3151|      1|					   _cairo_image_traps_compositor_get());
 3152|      1|	shape.glyphs = NULL;
 3153|       |
 3154|      1|	_cairo_spans_compositor_init (&spans, &shape);
 3155|       |
 3156|      1|	spans.flags = 0;
 3157|       |#if PIXMAN_HAS_OP_LERP
 3158|       |	spans.flags |= CAIRO_SPANS_COMPOSITOR_HAS_LERP;
 3159|       |#endif
 3160|       |
 3161|       |	//spans.acquire = acquire;
 3162|       |	//spans.release = release;
 3163|      1|	spans.fill_boxes = fill_boxes;
 3164|      1|	spans.draw_image_boxes = draw_image_boxes;
 3165|       |	//spans.copy_boxes = copy_boxes;
 3166|      1|	spans.pattern_to_surface = _cairo_image_source_create_for_pattern;
 3167|       |	//spans.check_composite_boxes = check_composite_boxes;
 3168|      1|	spans.composite_boxes = composite_boxes;
 3169|       |	//spans.check_span_renderer = check_span_renderer;
 3170|      1|	spans.renderer_init = span_renderer_init;
 3171|      1|	spans.renderer_fini = span_renderer_fini;
 3172|       |
 3173|      1|	_cairo_atomic_init_once_leave(&once);
 3174|      1|    }
 3175|       |
 3176|    156|    return &spans.base;
 3177|    156|}

cairo-image-surface.c:_cairo_surface_is_image:
   75|    105|{
   76|       |    /* _cairo_surface_nil sets a NULL backend so be safe */
   77|    105|    return surface->backend && surface->backend->type == CAIRO_SURFACE_TYPE_IMAGE;
  ------------------
  |  Branch (77:12): [True: 105, False: 0]
  |  Branch (77:32): [True: 105, False: 0]
  ------------------
   78|    105|}

_cairo_format_from_pixman_format:
   94|    156|{
   95|    156|    switch (pixman_format) {
   96|     35|    case PIXMAN_rgba_float:
  ------------------
  |  Branch (96:5): [True: 35, False: 121]
  ------------------
   97|     35|	return CAIRO_FORMAT_RGBA128F;
   98|     66|    case PIXMAN_rgb_float:
  ------------------
  |  Branch (98:5): [True: 66, False: 90]
  ------------------
   99|     66|	return CAIRO_FORMAT_RGB96F;
  100|     12|    case PIXMAN_a8r8g8b8:
  ------------------
  |  Branch (100:5): [True: 12, False: 144]
  ------------------
  101|     12|	return CAIRO_FORMAT_ARGB32;
  102|      0|    case PIXMAN_x2r10g10b10:
  ------------------
  |  Branch (102:5): [True: 0, False: 156]
  ------------------
  103|      0|	return CAIRO_FORMAT_RGB30;
  104|     43|    case PIXMAN_x8r8g8b8:
  ------------------
  |  Branch (104:5): [True: 43, False: 113]
  ------------------
  105|     43|	return CAIRO_FORMAT_RGB24;
  106|      0|    case PIXMAN_a8:
  ------------------
  |  Branch (106:5): [True: 0, False: 156]
  ------------------
  107|      0|	return CAIRO_FORMAT_A8;
  108|      0|    case PIXMAN_a1:
  ------------------
  |  Branch (108:5): [True: 0, False: 156]
  ------------------
  109|      0|	return CAIRO_FORMAT_A1;
  110|      0|    case PIXMAN_r5g6b5:
  ------------------
  |  Branch (110:5): [True: 0, False: 156]
  ------------------
  111|      0|	return CAIRO_FORMAT_RGB16_565;
  112|      0|    case PIXMAN_r8g8b8a8: case PIXMAN_r8g8b8x8:
  ------------------
  |  Branch (112:5): [True: 0, False: 156]
  |  Branch (112:27): [True: 0, False: 156]
  ------------------
  113|      0|    case PIXMAN_a8r8g8b8_sRGB:
  ------------------
  |  Branch (113:5): [True: 0, False: 156]
  ------------------
  114|      0|#if HAS_PIXMAN_r8g8b8_sRGB
  115|      0|    case PIXMAN_r8g8b8_sRGB:
  ------------------
  |  Branch (115:5): [True: 0, False: 156]
  ------------------
  116|      0|#endif
  117|      0|    case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8:
  ------------------
  |  Branch (117:5): [True: 0, False: 156]
  |  Branch (117:27): [True: 0, False: 156]
  |  Branch (117:49): [True: 0, False: 156]
  ------------------
  118|      0|    case PIXMAN_b8g8r8:   case PIXMAN_b5g6r5:
  ------------------
  |  Branch (118:5): [True: 0, False: 156]
  |  Branch (118:27): [True: 0, False: 156]
  ------------------
  119|      0|    case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5:
  ------------------
  |  Branch (119:5): [True: 0, False: 156]
  |  Branch (119:27): [True: 0, False: 156]
  |  Branch (119:49): [True: 0, False: 156]
  ------------------
  120|      0|    case PIXMAN_x1b5g5r5: case PIXMAN_a4r4g4b4: case PIXMAN_x4r4g4b4:
  ------------------
  |  Branch (120:5): [True: 0, False: 156]
  |  Branch (120:27): [True: 0, False: 156]
  |  Branch (120:49): [True: 0, False: 156]
  ------------------
  121|      0|    case PIXMAN_a4b4g4r4: case PIXMAN_x4b4g4r4: case PIXMAN_r3g3b2:
  ------------------
  |  Branch (121:5): [True: 0, False: 156]
  |  Branch (121:27): [True: 0, False: 156]
  |  Branch (121:49): [True: 0, False: 156]
  ------------------
  122|      0|    case PIXMAN_b2g3r3:   case PIXMAN_a2r2g2b2: case PIXMAN_a2b2g2r2:
  ------------------
  |  Branch (122:5): [True: 0, False: 156]
  |  Branch (122:27): [True: 0, False: 156]
  |  Branch (122:49): [True: 0, False: 156]
  ------------------
  123|      0|    case PIXMAN_c8:       case PIXMAN_g8:       case PIXMAN_x4a4:
  ------------------
  |  Branch (123:5): [True: 0, False: 156]
  |  Branch (123:27): [True: 0, False: 156]
  |  Branch (123:49): [True: 0, False: 156]
  ------------------
  124|      0|    case PIXMAN_a4:       case PIXMAN_r1g2b1:   case PIXMAN_b1g2r1:
  ------------------
  |  Branch (124:5): [True: 0, False: 156]
  |  Branch (124:27): [True: 0, False: 156]
  |  Branch (124:49): [True: 0, False: 156]
  ------------------
  125|      0|    case PIXMAN_a1r1g1b1: case PIXMAN_a1b1g1r1: case PIXMAN_c4:
  ------------------
  |  Branch (125:5): [True: 0, False: 156]
  |  Branch (125:27): [True: 0, False: 156]
  |  Branch (125:49): [True: 0, False: 156]
  ------------------
  126|      0|    case PIXMAN_g4:       case PIXMAN_g1:
  ------------------
  |  Branch (126:5): [True: 0, False: 156]
  |  Branch (126:27): [True: 0, False: 156]
  ------------------
  127|      0|    case PIXMAN_yuy2:     case PIXMAN_yv12:
  ------------------
  |  Branch (127:5): [True: 0, False: 156]
  |  Branch (127:27): [True: 0, False: 156]
  ------------------
  128|      0|    case PIXMAN_b8g8r8x8:
  ------------------
  |  Branch (128:5): [True: 0, False: 156]
  ------------------
  129|      0|    case PIXMAN_b8g8r8a8:
  ------------------
  |  Branch (129:5): [True: 0, False: 156]
  ------------------
  130|      0|    case PIXMAN_a2b10g10r10:
  ------------------
  |  Branch (130:5): [True: 0, False: 156]
  ------------------
  131|      0|    case PIXMAN_x2b10g10r10:
  ------------------
  |  Branch (131:5): [True: 0, False: 156]
  ------------------
  132|      0|    case PIXMAN_a2r10g10b10:
  ------------------
  |  Branch (132:5): [True: 0, False: 156]
  ------------------
  133|      0|    case PIXMAN_x14r6g6b6:
  ------------------
  |  Branch (133:5): [True: 0, False: 156]
  ------------------
  134|      0|    default:
  ------------------
  |  Branch (134:5): [True: 0, False: 156]
  ------------------
  135|      0|	return CAIRO_FORMAT_INVALID;
  136|    156|    }
  137|       |
  138|      0|    return CAIRO_FORMAT_INVALID;
  139|    156|}
_cairo_content_from_pixman_format:
  143|    156|{
  144|    156|    cairo_content_t content;
  145|       |
  146|    156|    content = 0;
  147|    156|    if (PIXMAN_FORMAT_RGB (pixman_format))
  ------------------
  |  |  850|    156|#define PIXMAN_FORMAT_RGB(f)	(((f)      ) & 0xfff)
  |  |  ------------------
  |  |  |  Branch (850:30): [True: 156, False: 0]
  |  |  ------------------
  ------------------
  148|    156|	content |= CAIRO_CONTENT_COLOR;
  149|    156|    if (PIXMAN_FORMAT_A (pixman_format))
  ------------------
  |  |  846|    156|#define PIXMAN_FORMAT_A(f)	PIXMAN_FORMAT_RESHIFT(f, 12, 4)
  |  |  ------------------
  |  |  |  |  841|    156|	(((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (841:2): [True: 47, False: 109]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|     47|	content |= CAIRO_CONTENT_ALPHA;
  151|       |
  152|    156|    return content;
  153|    156|}
_cairo_image_surface_init:
  159|    156|{
  160|    156|    surface->parent = NULL;
  161|    156|    surface->pixman_image = pixman_image;
  162|       |
  163|    156|    surface->pixman_format = pixman_format;
  164|    156|    surface->format = _cairo_format_from_pixman_format (pixman_format);
  165|    156|    surface->data = (uint8_t *) pixman_image_get_data (pixman_image);
  166|    156|    surface->owns_data = FALSE;
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  167|    156|    surface->transparency = CAIRO_IMAGE_UNKNOWN;
  168|    156|    surface->color = CAIRO_IMAGE_UNKNOWN_COLOR;
  169|       |
  170|    156|    surface->width = pixman_image_get_width (pixman_image);
  171|    156|    surface->height = pixman_image_get_height (pixman_image);
  172|    156|    surface->stride = pixman_image_get_stride (pixman_image);
  173|    156|    surface->depth = pixman_image_get_depth (pixman_image);
  174|       |
  175|    156|    surface->base.is_clear = surface->width == 0 || surface->height == 0;
  ------------------
  |  Branch (175:30): [True: 0, False: 156]
  |  Branch (175:53): [True: 0, False: 156]
  ------------------
  176|       |
  177|    156|    surface->compositor = _cairo_image_spans_compositor_get ();
  178|    156|}
_cairo_image_surface_create_for_pixman_image:
  183|    156|{
  184|    156|    cairo_image_surface_t *surface;
  185|       |
  186|    156|    surface = _cairo_calloc (sizeof (cairo_image_surface_t));
  ------------------
  |  |   79|    156|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 156, Folded]
  |  |  ------------------
  ------------------
  187|    156|    if (unlikely (surface == NULL))
  ------------------
  |  |  145|    156|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 156]
  |  |  ------------------
  ------------------
  188|      0|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  189|       |
  190|    156|    _cairo_surface_init (&surface->base,
  191|    156|			 &_cairo_image_surface_backend,
  192|    156|			 NULL, /* device */
  193|    156|			 _cairo_content_from_pixman_format (pixman_format),
  194|    156|			 FALSE); /* is_vector */
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  195|       |
  196|    156|    _cairo_image_surface_init (surface, pixman_image, pixman_format);
  197|       |
  198|    156|    return &surface->base;
  199|    156|}
_cairo_format_to_pixman_format_code:
  326|    166|{
  327|    166|    pixman_format_code_t ret;
  328|    166|    switch (format) {
  329|      0|    case CAIRO_FORMAT_A1:
  ------------------
  |  Branch (329:5): [True: 0, False: 166]
  ------------------
  330|      0|	ret = PIXMAN_a1;
  331|      0|	break;
  332|      0|    case CAIRO_FORMAT_A8:
  ------------------
  |  Branch (332:5): [True: 0, False: 166]
  ------------------
  333|      0|	ret = PIXMAN_a8;
  334|      0|	break;
  335|     43|    case CAIRO_FORMAT_RGB24:
  ------------------
  |  Branch (335:5): [True: 43, False: 123]
  ------------------
  336|     43|	ret = PIXMAN_x8r8g8b8;
  337|     43|	break;
  338|      0|    case CAIRO_FORMAT_RGB30:
  ------------------
  |  Branch (338:5): [True: 0, False: 166]
  ------------------
  339|      0|	ret = PIXMAN_x2r10g10b10;
  340|      0|	break;
  341|      0|    case CAIRO_FORMAT_RGB16_565:
  ------------------
  |  Branch (341:5): [True: 0, False: 166]
  ------------------
  342|      0|	ret = PIXMAN_r5g6b5;
  343|      0|	break;
  344|     66|    case CAIRO_FORMAT_RGB96F:
  ------------------
  |  Branch (344:5): [True: 66, False: 100]
  ------------------
  345|     66|	ret = PIXMAN_rgb_float;
  346|     66|	break;
  347|     45|    case CAIRO_FORMAT_RGBA128F:
  ------------------
  |  Branch (347:5): [True: 45, False: 121]
  ------------------
  348|     45|	ret = PIXMAN_rgba_float;
  349|     45|	break;
  350|     12|    case CAIRO_FORMAT_ARGB32:
  ------------------
  |  Branch (350:5): [True: 12, False: 154]
  ------------------
  351|     12|    case CAIRO_FORMAT_INVALID:
  ------------------
  |  Branch (351:5): [True: 0, False: 166]
  ------------------
  352|     12|    default:
  ------------------
  |  Branch (352:5): [True: 0, False: 166]
  ------------------
  353|     12|	ret = PIXMAN_a8r8g8b8;
  354|     12|	break;
  355|    166|    }
  356|    166|    return ret;
  357|    166|}
_cairo_image_surface_create_with_pixman_format:
  365|    166|{
  366|    166|    cairo_surface_t *surface;
  367|    166|    pixman_image_t *pixman_image;
  368|       |
  369|    166|    if (! _cairo_image_surface_is_size_valid (width, height))
  ------------------
  |  Branch (369:9): [True: 0, False: 166]
  ------------------
  370|      0|    {
  371|      0|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
  372|      0|    }
  373|       |
  374|    166|    pixman_image = pixman_image_create_bits (pixman_format, width, height,
  375|    166|					     (uint32_t *) data, stride);
  376|       |
  377|    166|    if (unlikely (pixman_image == NULL))
  ------------------
  |  |  145|    166|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 10, False: 156]
  |  |  ------------------
  ------------------
  378|     10|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  379|       |
  380|    156|    surface = _cairo_image_surface_create_for_pixman_image (pixman_image,
  381|    156|							    pixman_format);
  382|    156|    if (unlikely (surface->status)) {
  ------------------
  |  |  145|    156|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 156]
  |  |  ------------------
  ------------------
  383|      0|	pixman_image_unref (pixman_image);
  384|      0|	return surface;
  385|      0|    }
  386|       |
  387|       |    /* we can not make any assumptions about the initial state of user data */
  388|    156|    surface->is_clear = data == NULL;
  389|    156|    return surface;
  390|    156|}
cairo_format_stride_for_width:
  469|    382|{
  470|    382|    int bpp;
  471|       |
  472|    382|    if (! CAIRO_FORMAT_VALID (format)) {
  ------------------
  |  | 1556|    382|#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&		\
  |  |  ------------------
  |  |  |  Branch (1556:37): [True: 382, False: 0]
  |  |  ------------------
  |  | 1557|    382|                                    (format) <= CAIRO_FORMAT_RGBA128F)
  |  |  ------------------
  |  |  |  Branch (1557:37): [True: 382, False: 0]
  |  |  ------------------
  ------------------
  473|      0|	_cairo_error_throw (CAIRO_STATUS_INVALID_FORMAT);
  ------------------
  |  |  126|      0|#define _cairo_error_throw(status) do { \
  |  |  127|      0|    cairo_status_t status__ = _cairo_error (status); \
  |  |  128|      0|    (void) status__; \
  |  |  129|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (129:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  474|      0|	return -1;
  475|      0|    }
  476|       |
  477|    382|    bpp = _cairo_format_bits_per_pixel (format);
  478|    382|    if ((unsigned) (width) >= (INT32_MAX - 7) / (unsigned) (bpp))
  ------------------
  |  Branch (478:9): [True: 0, False: 382]
  ------------------
  479|      0|	return -1;
  480|       |
  481|    382|    return CAIRO_STRIDE_FOR_WIDTH_BPP (width, bpp);
  ------------------
  |  | 1562|    382|   ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
  |  |  ------------------
  |  |  |  | 1560|    382|#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  |  |  ------------------
  |  |                  ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
  |  |  ------------------
  |  |  |  | 1560|    382|#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  |  |  ------------------
  ------------------
  482|    382|}
cairo_image_surface_create_for_data:
  535|    211|{
  536|    211|    pixman_format_code_t pixman_format;
  537|    211|    int minstride;
  538|       |
  539|    211|    if (! CAIRO_FORMAT_VALID (format))
  ------------------
  |  | 1556|    211|#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&		\
  |  |  ------------------
  |  |  |  Branch (1556:37): [True: 211, False: 0]
  |  |  ------------------
  |  | 1557|    211|                                    (format) <= CAIRO_FORMAT_RGBA128F)
  |  |  ------------------
  |  |  |  Branch (1557:37): [True: 211, False: 0]
  |  |  ------------------
  ------------------
  540|      0|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
  541|       |
  542|    211|    if ((stride & (CAIRO_STRIDE_ALIGNMENT-1)) != 0)
  ------------------
  |  | 1560|    211|#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  ------------------
  |  Branch (542:9): [True: 44, False: 167]
  ------------------
  543|     44|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  544|       |
  545|    167|    if (! _cairo_image_surface_is_size_valid (width, height))
  ------------------
  |  Branch (545:9): [True: 1, False: 166]
  ------------------
  546|      1|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
  547|       |
  548|    166|    minstride = cairo_format_stride_for_width (format, width);
  549|    166|    if (stride < 0) {
  ------------------
  |  Branch (549:9): [True: 0, False: 166]
  ------------------
  550|      0|	if (stride > -minstride) {
  ------------------
  |  Branch (550:6): [True: 0, False: 0]
  ------------------
  551|      0|	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  552|      0|	}
  553|    166|    } else {
  554|    166|	if (stride < minstride) {
  ------------------
  |  Branch (554:6): [True: 0, False: 166]
  ------------------
  555|      0|	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  556|      0|	}
  557|    166|    }
  558|       |
  559|    166|    pixman_format = _cairo_format_to_pixman_format_code (format);
  560|    166|    return _cairo_image_surface_create_with_pixman_format (data,
  561|    166|							   pixman_format,
  562|    166|							   width, height,
  563|    166|							   stride);
  564|    166|}
cairo_image_surface_get_format:
  609|    105|{
  610|    105|    cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
  611|       |
  612|    105|    if (! _cairo_surface_is_image (surface)) {
  ------------------
  |  Branch (612:9): [True: 0, False: 105]
  ------------------
  613|      0|	_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
  ------------------
  |  |  126|      0|#define _cairo_error_throw(status) do { \
  |  |  127|      0|    cairo_status_t status__ = _cairo_error (status); \
  |  |  128|      0|    (void) status__; \
  |  |  129|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (129:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  614|      0|	return CAIRO_FORMAT_INVALID;
  615|      0|    }
  616|       |
  617|    105|    return image_surface->format;
  618|    105|}
_cairo_format_from_content:
  695|     17|{
  696|     17|    switch (content) {
  ------------------
  |  Branch (696:13): [True: 17, False: 0]
  ------------------
  697|     13|    case CAIRO_CONTENT_COLOR:
  ------------------
  |  Branch (697:5): [True: 13, False: 4]
  ------------------
  698|     13|	return CAIRO_FORMAT_RGB24;
  699|      0|    case CAIRO_CONTENT_ALPHA:
  ------------------
  |  Branch (699:5): [True: 0, False: 17]
  ------------------
  700|      0|	return CAIRO_FORMAT_A8;
  701|      4|    case CAIRO_CONTENT_COLOR_ALPHA:
  ------------------
  |  Branch (701:5): [True: 4, False: 13]
  ------------------
  702|      4|	return CAIRO_FORMAT_ARGB32;
  703|     17|    }
  704|       |
  705|      0|    ASSERT_NOT_REACHED;
  ------------------
  |  |  140|      0|#define ASSERT_NOT_REACHED		\
  |  |  141|      0|do {					\
  |  |  142|      0|    assert (!"reached");		\
  |  |  143|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (143:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (705:5): [Folded, False: 0]
  |  Branch (705:5): [Folded, False: 0]
  ------------------
  706|      0|    return CAIRO_FORMAT_INVALID;
  707|      0|}
_cairo_format_bits_per_pixel:
  736|    382|{
  737|    382|    switch (format) {
  738|     83|    case CAIRO_FORMAT_RGBA128F:
  ------------------
  |  Branch (738:5): [True: 83, False: 299]
  ------------------
  739|     83|	return 128;
  740|    113|    case CAIRO_FORMAT_RGB96F:
  ------------------
  |  Branch (740:5): [True: 113, False: 269]
  ------------------
  741|    113|	return 96;
  742|     68|    case CAIRO_FORMAT_ARGB32:
  ------------------
  |  Branch (742:5): [True: 68, False: 314]
  ------------------
  743|     68|    case CAIRO_FORMAT_RGB30:
  ------------------
  |  Branch (743:5): [True: 0, False: 382]
  ------------------
  744|    186|    case CAIRO_FORMAT_RGB24:
  ------------------
  |  Branch (744:5): [True: 118, False: 264]
  ------------------
  745|    186|	return 32;
  746|      0|    case CAIRO_FORMAT_RGB16_565:
  ------------------
  |  Branch (746:5): [True: 0, False: 382]
  ------------------
  747|      0|	return 16;
  748|      0|    case CAIRO_FORMAT_A8:
  ------------------
  |  Branch (748:5): [True: 0, False: 382]
  ------------------
  749|      0|	return 8;
  750|      0|    case CAIRO_FORMAT_A1:
  ------------------
  |  Branch (750:5): [True: 0, False: 382]
  ------------------
  751|      0|	return 1;
  752|      0|    case CAIRO_FORMAT_INVALID:
  ------------------
  |  Branch (752:5): [True: 0, False: 382]
  ------------------
  753|      0|    default:
  ------------------
  |  Branch (753:5): [True: 0, False: 382]
  ------------------
  754|      0|	ASSERT_NOT_REACHED;
  ------------------
  |  |  140|      0|#define ASSERT_NOT_REACHED		\
  |  |  141|      0|do {					\
  |  |  142|      0|    assert (!"reached");		\
  |  |  143|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (143:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (754:2): [Folded, False: 0]
  |  Branch (754:2): [Folded, False: 0]
  ------------------
  755|      0|	return 0;
  756|    382|    }
  757|    382|}
_cairo_image_surface_finish:
  865|    156|{
  866|    156|    cairo_image_surface_t *surface = abstract_surface;
  867|       |
  868|    156|    if (surface->pixman_image) {
  ------------------
  |  Branch (868:9): [True: 156, False: 0]
  ------------------
  869|    156|	pixman_image_unref (surface->pixman_image);
  870|    156|	surface->pixman_image = NULL;
  871|    156|    }
  872|       |
  873|    156|    if (surface->owns_data) {
  ------------------
  |  Branch (873:9): [True: 105, False: 51]
  ------------------
  874|    105|	free (surface->data);
  875|    105|	surface->data = NULL;
  876|    105|    }
  877|       |
  878|    156|    if (surface->parent) {
  ------------------
  |  Branch (878:9): [True: 0, False: 156]
  ------------------
  879|      0|	cairo_surface_t *parent = surface->parent;
  880|      0|	surface->parent = NULL;
  881|      0|	cairo_surface_destroy (parent);
  882|      0|    }
  883|       |
  884|    156|    return CAIRO_STATUS_SUCCESS;
  885|    156|}
_cairo_image_surface_assume_ownership_of_data:
  889|    105|{
  890|    105|    surface->owns_data = TRUE;
  ------------------
  |  |  106|    105|#define TRUE 1
  ------------------
  891|    105|}
_cairo_image_surface_acquire_source_image:
  912|     51|{
  913|     51|    *image_out = abstract_surface;
  914|     51|    *image_extra = NULL;
  915|       |
  916|     51|    return CAIRO_STATUS_SUCCESS;
  917|     51|}
_cairo_image_surface_release_source_image:
  923|     51|{
  924|     51|}
_cairo_image_surface_coerce:
 1085|     17|{
 1086|     17|    return _cairo_image_surface_coerce_to_format (surface,
 1087|     17|		                                  _cairo_format_from_content (surface->base.content));
 1088|     17|}
_cairo_image_surface_coerce_to_format:
 1095|     17|{
 1096|     17|    cairo_image_surface_t *clone;
 1097|     17|    cairo_status_t status;
 1098|       |
 1099|     17|    status = surface->base.status;
 1100|     17|    if (unlikely (status))
  ------------------
  |  |  145|     17|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 17]
  |  |  ------------------
  ------------------
 1101|      0|	return (cairo_image_surface_t *)_cairo_surface_create_in_error (status);
 1102|       |
 1103|     17|    if (surface->format == format)
  ------------------
  |  Branch (1103:9): [True: 17, False: 0]
  ------------------
 1104|     17|	return (cairo_image_surface_t *)cairo_surface_reference(&surface->base);
 1105|       |
 1106|      0|    clone = (cairo_image_surface_t *)
 1107|      0|	cairo_image_surface_create (format, surface->width, surface->height);
 1108|      0|    if (unlikely (clone->base.status))
  ------------------
  |  |  145|      0|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1109|      0|	return clone;
 1110|       |
 1111|      0|    pixman_image_composite32 (PIXMAN_OP_SRC,
 1112|      0|                              surface->pixman_image, NULL, clone->pixman_image,
 1113|      0|                              0, 0,
 1114|      0|                              0, 0,
 1115|      0|                              0, 0,
 1116|      0|                              surface->width, surface->height);
 1117|      0|    clone->base.is_clear = FALSE;
  ------------------
  |  |  102|      0|#define FALSE 0
  ------------------
 1118|       |
 1119|      0|    clone->base.device_transform =
 1120|      0|	surface->base.device_transform;
 1121|      0|    clone->base.device_transform_inverse =
 1122|      0|	surface->base.device_transform_inverse;
 1123|       |
 1124|      0|    return clone;
 1125|      0|}
_cairo_image_analyze_transparency:
 1238|      4|{
 1239|      4|    if (_cairo_surface_is_snapshot (&image->base)) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 4]
  ------------------
 1240|      0|	if (image->transparency == CAIRO_IMAGE_UNKNOWN)
  ------------------
  |  Branch (1240:6): [True: 0, False: 0]
  ------------------
 1241|      0|	    image->transparency = _cairo_image_compute_transparency (image);
 1242|       |
 1243|      0|	return image->transparency;
 1244|      0|    }
 1245|       |
 1246|      4|    return _cairo_image_compute_transparency (image);
 1247|      4|}
cairo-image-surface.c:_cairo_image_surface_is_size_valid:
   87|    333|{
   88|    333|    return 0 <= width  &&  width <= MAX_IMAGE_SIZE &&
  ------------------
  |  |   62|    666|#define MAX_IMAGE_SIZE 32767
  ------------------
  |  Branch (88:12): [True: 333, False: 0]
  |  Branch (88:28): [True: 332, False: 1]
  ------------------
   89|    332|	   0 <= height && height <= MAX_IMAGE_SIZE;
  ------------------
  |  |   62|    332|#define MAX_IMAGE_SIZE 32767
  ------------------
  |  Branch (89:5): [True: 332, False: 0]
  |  Branch (89:20): [True: 332, False: 0]
  ------------------
   90|    333|}
cairo-image-surface.c:_cairo_image_compute_transparency:
 1184|      4|{
 1185|      4|    int x, y;
 1186|      4|    cairo_image_transparency_t transparency;
 1187|       |
 1188|      4|    if ((image->base.content & CAIRO_CONTENT_ALPHA) == 0)
  ------------------
  |  Branch (1188:9): [True: 0, False: 4]
  ------------------
 1189|      0|	return CAIRO_IMAGE_IS_OPAQUE;
 1190|       |
 1191|      4|    if (image->base.is_clear)
  ------------------
  |  Branch (1191:9): [True: 0, False: 4]
  ------------------
 1192|      0|	return CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
 1193|       |
 1194|      4|    if ((image->base.content & CAIRO_CONTENT_COLOR) == 0) {
  ------------------
  |  Branch (1194:9): [True: 0, False: 4]
  ------------------
 1195|      0|	if (image->format == CAIRO_FORMAT_A1) {
  ------------------
  |  Branch (1195:6): [True: 0, False: 0]
  ------------------
 1196|      0|	    return CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
 1197|      0|	} else if (image->format == CAIRO_FORMAT_A8) {
  ------------------
  |  Branch (1197:13): [True: 0, False: 0]
  ------------------
 1198|      0|	    for (y = 0; y < image->height; y++) {
  ------------------
  |  Branch (1198:18): [True: 0, False: 0]
  ------------------
 1199|      0|		uint8_t *alpha = (uint8_t *) (image->data + y * image->stride);
 1200|       |
 1201|      0|		for (x = 0; x < image->width; x++, alpha++) {
  ------------------
  |  Branch (1201:15): [True: 0, False: 0]
  ------------------
 1202|      0|		    if (*alpha > 0 && *alpha < 255)
  ------------------
  |  Branch (1202:11): [True: 0, False: 0]
  |  Branch (1202:25): [True: 0, False: 0]
  ------------------
 1203|      0|			return CAIRO_IMAGE_HAS_ALPHA;
 1204|      0|		}
 1205|      0|	    }
 1206|      0|	    return CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
 1207|      0|	} else {
 1208|      0|	    return CAIRO_IMAGE_HAS_ALPHA;
 1209|      0|	}
 1210|      0|    }
 1211|       |
 1212|      4|    if (image->format == CAIRO_FORMAT_RGB16_565) {
  ------------------
  |  Branch (1212:9): [True: 0, False: 4]
  ------------------
 1213|      0|	return CAIRO_IMAGE_IS_OPAQUE;
 1214|      0|    }
 1215|       |
 1216|      4|    if (image->format != CAIRO_FORMAT_ARGB32)
  ------------------
  |  Branch (1216:9): [True: 0, False: 4]
  ------------------
 1217|      0|	return CAIRO_IMAGE_HAS_ALPHA;
 1218|       |
 1219|      4|    transparency = CAIRO_IMAGE_IS_OPAQUE;
 1220|      4|    for (y = 0; y < image->height; y++) {
  ------------------
  |  Branch (1220:17): [True: 4, False: 0]
  ------------------
 1221|      4|	uint32_t *pixel = (uint32_t *) (image->data + y * image->stride);
 1222|       |
 1223|      4|	for (x = 0; x < image->width; x++, pixel++) {
  ------------------
  |  Branch (1223:14): [True: 4, False: 0]
  ------------------
 1224|      4|	    int a = (*pixel & 0xff000000) >> 24;
 1225|      4|	    if (a > 0 && a < 255) {
  ------------------
  |  Branch (1225:10): [True: 4, False: 0]
  |  Branch (1225:19): [True: 4, False: 0]
  ------------------
 1226|      4|		return CAIRO_IMAGE_HAS_ALPHA;
 1227|      4|	    } else if (a == 0) {
  ------------------
  |  Branch (1227:17): [True: 0, False: 0]
  ------------------
 1228|      0|		transparency = CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
 1229|      0|	    }
 1230|      4|	}
 1231|      4|    }
 1232|       |
 1233|      0|    return transparency;
 1234|      4|}

cairo-surface.c:cairo_list_init:
  187|    312|{
  188|    312|    entry->next = entry;
  189|    312|    entry->prev = entry;
  190|    312|}
cairo-surface.c:cairo_list_is_empty:
  345|    468|{
  346|    468|    cairo_list_validate (head);
  347|    468|    return head->next == head;
  348|    468|}

cairo-png.c:_cairo_malloc_ab:
  100|    517|{
  101|    517|    size_t c;
  102|    517|    if (_cairo_mul_size_t_overflow (a, size, &c))
  ------------------
  |  |  223|    517|#define _cairo_mul_size_t_overflow(a, b, c)  __builtin_mul_overflow((size_t)(a), (size_t)(b), (size_t*)(c))
  |  |  ------------------
  |  |  |  Branch (223:46): [True: 0, False: 517]
  |  |  ------------------
  ------------------
  103|      0|	return NULL;
  104|       |
  105|    517|    return _cairo_malloc(c);
  ------------------
  |  |   63|    517|   ((size) != 0 ? malloc(size) : NULL)
  |  |  ------------------
  |  |  |  Branch (63:5): [True: 517, False: 0]
  |  |  ------------------
  ------------------
  106|    517|}
cairo-array.c:_cairo_realloc_ab:
  153|  1.70k|{
  154|  1.70k|    size_t c;
  155|  1.70k|    if (_cairo_mul_size_t_overflow (a, size, &c))
  ------------------
  |  |  223|  1.70k|#define _cairo_mul_size_t_overflow(a, b, c)  __builtin_mul_overflow((size_t)(a), (size_t)(b), (size_t*)(c))
  |  |  ------------------
  |  |  |  Branch (223:46): [True: 0, False: 1.70k]
  |  |  ------------------
  ------------------
  156|      0|	return NULL;
  157|       |
  158|  1.70k|    return realloc(ptr, c);
  159|  1.70k|}
cairo-hash.c:_cairo_calloc_ab:
  125|      1|{
  126|      1|    size_t c;
  127|      1|    if (_cairo_mul_size_t_overflow (a, size, &c))
  ------------------
  |  |  223|      1|#define _cairo_mul_size_t_overflow(a, b, c)  __builtin_mul_overflow((size_t)(a), (size_t)(b), (size_t*)(c))
  |  |  ------------------
  |  |  |  Branch (223:46): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  128|      0|	return NULL;
  129|       |
  130|      1|    return _cairo_calloc(c);
  ------------------
  |  |   79|      1|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  131|      1|}

cairo_matrix_init_identity:
   82|    312|{
   83|    312|    cairo_matrix_init (matrix,
   84|    312|		       1, 0,
   85|    312|		       0, 1,
   86|    312|		       0, 0);
   87|    312|}
cairo_matrix_init:
  115|    312|{
  116|    312|    matrix->xx = xx; matrix->yx = yx;
  117|    312|    matrix->xy = xy; matrix->yy = yy;
  118|    312|    matrix->x0 = x0; matrix->y0 = y0;
  119|    312|}

_cairo_fopen:
  937|    462|{
  938|    462|    FILE *result;
  939|       |#ifdef _WIN32 /* also defined on x86_64 */
  940|       |    uint16_t *filename_w;
  941|       |    uint16_t *mode_w;
  942|       |    cairo_status_t status;
  943|       |
  944|       |    *file_out = NULL;
  945|       |
  946|       |    if (filename == NULL || mode == NULL) {
  947|       |	errno = EINVAL;
  948|       |	return CAIRO_STATUS_SUCCESS;
  949|       |    }
  950|       |
  951|       |    if ((status = _cairo_utf8_to_utf16 (filename, -1, &filename_w, NULL)) != CAIRO_STATUS_SUCCESS) {
  952|       |	errno = EINVAL;
  953|       |	return status;
  954|       |    }
  955|       |
  956|       |    if ((status = _cairo_utf8_to_utf16 (mode, -1, &mode_w, NULL)) != CAIRO_STATUS_SUCCESS) {
  957|       |	free (filename_w);
  958|       |	errno = EINVAL;
  959|       |	return status;
  960|       |    }
  961|       |
  962|       |    result = _wfopen (filename_w, mode_w);
  963|       |
  964|       |    free (filename_w);
  965|       |    free (mode_w);
  966|       |
  967|       |#else /* Use fopen directly */
  968|       |
  969|    462|#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 7)
  970|       |    /* Glibc 2.7 supports the "e" mode flag that opens the file with O_CLOEXEC.
  971|       |     * this avoid the race condition in the fcntl fallback below. */
  972|       |
  973|    462|    char new_mode[20];
  974|    462|    snprintf (new_mode, sizeof (new_mode), "%s%s", mode, "e");
  975|    462|    result = fopen (filename, new_mode);
  976|       |
  977|       |#else /* fopen "e" not available */
  978|       |
  979|       |    result = fopen (filename, mode);
  980|       |
  981|       |#if defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC)
  982|       |    /* Manually set CLOEXEC */
  983|       |    if (result != NULL) {
  984|       |	int fd = fileno (result);
  985|       |	if (fd != -1) {
  986|       |	    int flags = fcntl (fd, F_GETFD);
  987|       |	    if (flags >= 0)
  988|       |		flags = fcntl (fd, F_SETFD, flags | FD_CLOEXEC);
  989|       |	}
  990|       |    }
  991|       |#endif /* defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) */
  992|       |
  993|       |#endif /* fopen "e" not available */
  994|       |
  995|    462|#endif /* !_WIN32 */
  996|       |
  997|    462|    *file_out = result;
  998|       |
  999|    462|    return CAIRO_STATUS_SUCCESS;
 1000|    462|}
_cairo_string_hash:
 1118|    105|{
 1119|    105|    const signed char *p = (const signed char *) str;
 1120|    105|    unsigned int h = *p;
 1121|       |
 1122|  1.05k|    for (p += 1; len > 0; len--, p++)
  ------------------
  |  Branch (1122:18): [True: 945, False: 105]
  ------------------
 1123|    945|	h = (h << 5) - h + *p;
 1124|       |
 1125|    105|    return h;
 1126|    105|}
_cairo_intern_string:
 1142|    105|{
 1143|    105|    char *str = (char *) *str_inout;
 1144|    105|    cairo_intern_string_t tmpl, *istring;
 1145|    105|    cairo_status_t status = CAIRO_STATUS_SUCCESS;
 1146|       |
 1147|    105|    if (CAIRO_INJECT_FAULT ())
  ------------------
  |  |   47|    105|#define CAIRO_INJECT_FAULT() 0
  |  |  ------------------
  |  |  |  Branch (47:30): [Folded, False: 105]
  |  |  ------------------
  ------------------
 1148|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 1149|       |
 1150|    105|    if (len < 0)
  ------------------
  |  Branch (1150:9): [True: 105, False: 0]
  ------------------
 1151|    105|	len = strlen (str);
 1152|    105|    tmpl.hash_entry.hash = _cairo_string_hash (str, len);
 1153|    105|    tmpl.len = len;
 1154|    105|    tmpl.string = (char *) str;
 1155|       |
 1156|    105|    CAIRO_MUTEX_LOCK (_cairo_intern_string_mutex);
  ------------------
  |  |  175|    105|#define CAIRO_MUTEX_LOCK		CAIRO_MUTEX_IMPL_LOCK
  |  |  ------------------
  |  |  |  |  206|    105|# define CAIRO_MUTEX_IMPL_LOCK(mutex) pthread_mutex_lock (&(mutex))
  |  |  ------------------
  ------------------
 1157|    105|    if (_cairo_intern_string_ht == NULL) {
  ------------------
  |  Branch (1157:9): [True: 1, False: 104]
  ------------------
 1158|      1|	_cairo_intern_string_ht = _cairo_hash_table_create (_intern_string_equal);
 1159|      1|	if (unlikely (_cairo_intern_string_ht == NULL)) {
  ------------------
  |  |  145|      1|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1160|      0|	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 1161|      0|	    goto BAIL;
 1162|      0|	}
 1163|      1|    }
 1164|       |
 1165|    105|    istring = _cairo_hash_table_lookup (_cairo_intern_string_ht,
 1166|    105|					&tmpl.hash_entry);
 1167|    105|    if (istring == NULL) {
  ------------------
  |  Branch (1167:9): [True: 1, False: 104]
  ------------------
 1168|      1|	istring = _cairo_malloc (sizeof (cairo_intern_string_t) + len + 1);
  ------------------
  |  |   63|      1|   ((size) != 0 ? malloc(size) : NULL)
  |  |  ------------------
  |  |  |  Branch (63:5): [True: 1, False: 0]
  |  |  ------------------
  ------------------
 1169|      1|	if (likely (istring != NULL)) {
  ------------------
  |  |  144|      1|#define likely(expr) (__builtin_expect (!!(expr), 1))
  |  |  ------------------
  |  |  |  Branch (144:22): [True: 1, False: 0]
  |  |  ------------------
  ------------------
 1170|      1|	    istring->hash_entry.hash = tmpl.hash_entry.hash;
 1171|      1|	    istring->len = tmpl.len;
 1172|      1|	    istring->string = (char *) (istring + 1);
 1173|      1|	    memcpy (istring->string, str, len);
 1174|      1|	    istring->string[len] = '\0';
 1175|       |
 1176|      1|	    status = _cairo_hash_table_insert (_cairo_intern_string_ht,
 1177|      1|					       &istring->hash_entry);
 1178|      1|	    if (unlikely (status)) {
  ------------------
  |  |  145|      1|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1]
  |  |  ------------------
  ------------------
 1179|      0|		free (istring);
 1180|      0|		goto BAIL;
 1181|      0|	    }
 1182|      1|	} else {
 1183|      0|	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 1184|      0|	    goto BAIL;
 1185|      0|	}
 1186|      1|    }
 1187|       |
 1188|    105|    *str_inout = istring->string;
 1189|       |
 1190|    105|  BAIL:
 1191|    105|    CAIRO_MUTEX_UNLOCK (_cairo_intern_string_mutex);
  ------------------
  |  |  177|    105|#define CAIRO_MUTEX_UNLOCK		CAIRO_MUTEX_IMPL_UNLOCK
  |  |  ------------------
  |  |  |  |  208|    105|# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
  |  |  ------------------
  ------------------
 1192|    105|    return status;
 1193|    105|}
cairo-misc.c:_intern_string_equal:
 1130|    104|{
 1131|    104|    const cairo_intern_string_t *a = _a;
 1132|    104|    const cairo_intern_string_t *b = _b;
 1133|       |
 1134|    104|    if (a->len != b->len)
  ------------------
  |  Branch (1134:9): [True: 0, False: 104]
  ------------------
 1135|      0|	return FALSE;
  ------------------
  |  |  102|      0|#define FALSE 0
  ------------------
 1136|       |
 1137|    104|    return memcmp (a->string, b->string, a->len) == 0;
 1138|    104|}

_cairo_output_stream_init:
   77|    411|{
   78|    411|    stream->write_func = write_func;
   79|    411|    stream->flush_func = flush_func;
   80|    411|    stream->close_func = close_func;
   81|    411|    stream->position = 0;
   82|    411|    stream->status = CAIRO_STATUS_SUCCESS;
   83|    411|    stream->closed = FALSE;
  ------------------
  |  |  102|    411|#define FALSE 0
  ------------------
   84|    411|}
_cairo_output_stream_fini:
   88|    411|{
   89|    411|    return _cairo_output_stream_close (stream);
   90|    411|}
_cairo_output_stream_close:
  215|    411|{
  216|    411|    cairo_status_t status;
  217|       |
  218|    411|    if (stream->closed)
  ------------------
  |  Branch (218:9): [True: 0, False: 411]
  ------------------
  219|      0|	return stream->status;
  220|       |
  221|    411|    if (stream == &_cairo_output_stream_nil ||
  ------------------
  |  Branch (221:9): [True: 0, False: 411]
  ------------------
  222|    411|	stream == &_cairo_output_stream_nil_write_error)
  ------------------
  |  Branch (222:2): [True: 0, False: 411]
  ------------------
  223|      0|    {
  224|      0|	return stream->status;
  225|      0|    }
  226|       |
  227|    411|    if (stream->close_func) {
  ------------------
  |  Branch (227:9): [True: 411, False: 0]
  ------------------
  228|    411|	status = stream->close_func (stream);
  229|       |	/* Don't overwrite a pre-existing status failure. */
  230|    411|	if (stream->status == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (230:6): [True: 411, False: 0]
  ------------------
  231|    411|	    stream->status = status;
  232|    411|    }
  233|       |
  234|    411|    stream->closed = TRUE;
  ------------------
  |  |  106|    411|#define TRUE 1
  ------------------
  235|       |
  236|    411|    return stream->status;
  237|    411|}
_cairo_output_stream_destroy:
  241|    411|{
  242|    411|    cairo_status_t status;
  243|       |
  244|    411|    assert (stream != NULL);
  ------------------
  |  Branch (244:5): [True: 0, False: 411]
  |  Branch (244:5): [True: 411, False: 0]
  ------------------
  245|       |
  246|    411|    if (stream == &_cairo_output_stream_nil ||
  ------------------
  |  Branch (246:9): [True: 0, False: 411]
  ------------------
  247|    411|	stream == &_cairo_output_stream_nil_write_error)
  ------------------
  |  Branch (247:2): [True: 0, False: 411]
  ------------------
  248|      0|    {
  249|      0|	return stream->status;
  250|      0|    }
  251|       |
  252|    411|    status = _cairo_output_stream_fini (stream);
  253|    411|    free (stream);
  254|       |
  255|    411|    return status;
  256|    411|}
_cairo_output_stream_write:
  261|  20.1k|{
  262|  20.1k|    if (length == 0 || stream->status)
  ------------------
  |  Branch (262:9): [True: 1, False: 20.1k]
  |  Branch (262:24): [True: 0, False: 20.1k]
  ------------------
  263|      1|	return;
  264|       |
  265|  20.1k|    if (stream->closed) {
  ------------------
  |  Branch (265:9): [True: 0, False: 20.1k]
  ------------------
  266|      0|	stream->status = CAIRO_STATUS_WRITE_ERROR;
  267|      0|	return;
  268|      0|    }
  269|       |
  270|  20.1k|    stream->status = stream->write_func (stream, data, length);
  271|  20.1k|    stream->position += length;
  272|  20.1k|}
_cairo_memory_stream_create:
  738|    411|{
  739|    411|    memory_stream_t *stream;
  740|       |
  741|    411|    stream = _cairo_calloc (sizeof *stream);
  ------------------
  |  |   79|    411|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 411, Folded]
  |  |  ------------------
  ------------------
  742|    411|    if (unlikely (stream == NULL)) {
  ------------------
  |  |  145|    411|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 411]
  |  |  ------------------
  ------------------
  743|      0|	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
  ------------------
  |  |  126|      0|#define _cairo_error_throw(status) do { \
  |  |  127|      0|    cairo_status_t status__ = _cairo_error (status); \
  |  |  128|      0|    (void) status__; \
  |  |  129|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (129:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  744|      0|	return (cairo_output_stream_t *) &_cairo_output_stream_nil;
  745|      0|    }
  746|       |
  747|    411|    _cairo_output_stream_init (&stream->base, memory_write, NULL, memory_close);
  748|    411|    _cairo_array_init (&stream->array, 1);
  749|       |
  750|    411|    return &stream->base;
  751|    411|}
_cairo_memory_stream_destroy:
  757|    105|{
  758|    105|    memory_stream_t *stream;
  759|    105|    cairo_status_t status;
  760|       |
  761|    105|    status = abstract_stream->status;
  762|    105|    if (unlikely (status))
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
  763|      0|	return _cairo_output_stream_destroy (abstract_stream);
  764|       |
  765|    105|    stream = (memory_stream_t *) abstract_stream;
  766|       |
  767|    105|    *length_out = _cairo_array_num_elements (&stream->array);
  768|    105|    *data_out = _cairo_calloc (*length_out);
  ------------------
  |  |   79|    105|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 105, False: 0]
  |  |  ------------------
  ------------------
  769|    105|    if (unlikely (*data_out == NULL)) {
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
  770|      0|	status = _cairo_output_stream_destroy (abstract_stream);
  771|      0|	assert (status == CAIRO_STATUS_SUCCESS);
  ------------------
  |  Branch (771:2): [True: 0, False: 0]
  |  Branch (771:2): [True: 0, False: 0]
  ------------------
  772|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  773|      0|    }
  774|    105|    memcpy (*data_out, _cairo_array_index (&stream->array, 0), *length_out);
  775|       |
  776|    105|    return _cairo_output_stream_destroy (abstract_stream);
  777|    105|}
cairo-output-stream.c:memory_write:
  720|  20.1k|{
  721|  20.1k|    memory_stream_t *stream = (memory_stream_t *) base;
  722|       |
  723|  20.1k|    return _cairo_array_append_multiple (&stream->array, data, length);
  724|  20.1k|}
cairo-output-stream.c:memory_close:
  728|    411|{
  729|    411|    memory_stream_t *stream = (memory_stream_t *) base;
  730|       |
  731|    411|    _cairo_array_fini (&stream->array);
  732|       |
  733|    411|    return CAIRO_STATUS_SUCCESS;
  734|    411|}

cairo_surface_write_to_png:
  484|     51|{
  485|     51|    FILE *fp;
  486|     51|    cairo_status_t status;
  487|       |
  488|     51|    if (surface->status)
  ------------------
  |  Branch (488:9): [True: 0, False: 51]
  ------------------
  489|      0|	return surface->status;
  490|       |
  491|     51|    if (surface->finished)
  ------------------
  |  Branch (491:9): [True: 0, False: 51]
  ------------------
  492|      0|	return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
  493|       |
  494|     51|    status = _cairo_fopen (filename, "wb", &fp);
  495|       |
  496|     51|    if (status != CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (496:9): [True: 0, False: 51]
  ------------------
  497|      0|	return _cairo_error (status);
  498|       |
  499|     51|    if (fp == NULL) {
  ------------------
  |  Branch (499:9): [True: 0, False: 51]
  ------------------
  500|      0|	switch (errno) {
  501|      0|	case ENOMEM:
  ------------------
  |  Branch (501:2): [True: 0, False: 0]
  ------------------
  502|      0|	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  503|      0|	default:
  ------------------
  |  Branch (503:2): [True: 0, False: 0]
  ------------------
  504|      0|	    return _cairo_error (CAIRO_STATUS_WRITE_ERROR);
  505|      0|	}
  506|      0|    }
  507|       |
  508|     51|    status = write_png (surface, stdio_write_func, fp);
  509|       |
  510|     51|    if (fclose (fp) && status == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (510:9): [True: 0, False: 51]
  |  Branch (510:24): [True: 0, False: 0]
  ------------------
  511|      0|	status = _cairo_error (CAIRO_STATUS_WRITE_ERROR);
  512|       |
  513|     51|    return status;
  514|     51|}
cairo_image_surface_create_from_png:
  915|    411|{
  916|    411|    struct png_read_closure_t png_closure;
  917|    411|    cairo_surface_t *surface;
  918|    411|    cairo_status_t status;
  919|       |
  920|    411|    status = _cairo_fopen (filename, "rb", (FILE **) &png_closure.closure);
  921|       |
  922|    411|    if (status != CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (922:9): [True: 0, False: 411]
  ------------------
  923|      0|	return _cairo_surface_create_in_error (status);
  924|       |
  925|    411|    if (png_closure.closure == NULL) {
  ------------------
  |  Branch (925:9): [True: 0, False: 411]
  ------------------
  926|      0|	switch (errno) {
  927|      0|	case ENOMEM:
  ------------------
  |  Branch (927:2): [True: 0, False: 0]
  ------------------
  928|      0|	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  929|      0|	    break;
  930|      0|	case ENOENT:
  ------------------
  |  Branch (930:2): [True: 0, False: 0]
  ------------------
  931|      0|	    status = _cairo_error (CAIRO_STATUS_FILE_NOT_FOUND);
  932|      0|	    break;
  933|      0|	default:
  ------------------
  |  Branch (933:2): [True: 0, False: 0]
  ------------------
  934|      0|	    status = _cairo_error (CAIRO_STATUS_READ_ERROR);
  935|      0|	    break;
  936|      0|	}
  937|      0|	return _cairo_surface_create_in_error (status);
  938|      0|    }
  939|       |
  940|    411|    png_closure.read_func = stdio_read_func;
  941|       |
  942|    411|    surface = read_png (&png_closure);
  943|       |
  944|    411|    fclose (png_closure.closure);
  945|       |
  946|    411|    return surface;
  947|    411|}
cairo-png.c:write_png:
  251|     51|{
  252|     51|    int i;
  253|     51|    cairo_int_status_t status;
  254|     51|    cairo_image_surface_t *image;
  255|     51|    cairo_image_surface_t * volatile clone;
  256|     51|    void *image_extra;
  257|     51|    png_struct *png;
  258|     51|    png_info *info;
  259|     51|    png_byte **volatile rows = NULL;
  260|     51|    png_color_16 white;
  261|     51|    int png_color_type;
  262|     51|    int bpc;
  263|     51|    unsigned char *volatile u16_copy = NULL;
  264|       |
  265|     51|    status = _cairo_surface_acquire_source_image (surface,
  266|     51|						  &image,
  267|     51|						  &image_extra);
  268|       |
  269|     51|    if (status == CAIRO_INT_STATUS_UNSUPPORTED)
  ------------------
  |  Branch (269:9): [True: 0, False: 51]
  ------------------
  270|      0|	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
  271|     51|    else if (unlikely (status))
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
  272|      0|        return status;
  273|       |
  274|       |    /* PNG complains about "Image width or height is zero in IHDR" */
  275|     51|    if (image->width == 0 || image->height == 0) {
  ------------------
  |  Branch (275:9): [True: 0, False: 51]
  |  Branch (275:30): [True: 0, False: 51]
  ------------------
  276|      0|	status = _cairo_error (CAIRO_STATUS_WRITE_ERROR);
  277|      0|	goto BAIL1;
  278|      0|    }
  279|       |
  280|       |    /* Don't coerce to a lower resolution format */
  281|     51|    if (image->format == CAIRO_FORMAT_RGB96F ||
  ------------------
  |  Branch (281:9): [True: 27, False: 24]
  ------------------
  282|     34|        image->format == CAIRO_FORMAT_RGBA128F) {
  ------------------
  |  Branch (282:9): [True: 7, False: 17]
  ------------------
  283|     34|	u16_copy = _cairo_malloc_ab (image->width * 8, image->height);
  284|     34|	if (!u16_copy) {
  ------------------
  |  Branch (284:6): [True: 0, False: 34]
  ------------------
  285|      0|	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  286|      0|	    goto BAIL1;
  287|      0|	}
  288|     34|	clone = (cairo_image_surface_t *)cairo_surface_reference (&image->base);
  289|     34|    } else {
  290|       |	  /* Handle the various fallback formats (e.g. low bit-depth XServers)
  291|       |	  * by coercing them to a simpler format using pixman.
  292|       |	  */
  293|     17|	  clone = _cairo_image_surface_coerce (image);
  294|     17|	  status = clone->base.status;
  295|     17|    }
  296|     51|    if (unlikely (status))
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
  297|      0|        goto BAIL1;
  298|       |
  299|     51|    rows = _cairo_malloc_ab (clone->height, sizeof (png_byte*));
  300|     51|    if (unlikely (rows == NULL)) {
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
  301|      0|	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  302|      0|	goto BAIL2;
  303|      0|    }
  304|       |
  305|     51|    if (!u16_copy) {
  ------------------
  |  Branch (305:9): [True: 17, False: 34]
  ------------------
  306|     34|	for (i = 0; i < clone->height; i++)
  ------------------
  |  Branch (306:14): [True: 17, False: 17]
  ------------------
  307|     17|	    rows[i] = (png_byte *)clone->data + i * clone->stride;
  308|     34|    } else {
  309|     68|	for (i = 0; i < clone->height; i++) {
  ------------------
  |  Branch (309:14): [True: 34, False: 34]
  ------------------
  310|     34|	    float *float_line = (float *)&clone->data[i * clone->stride];
  311|     34|	    uint16_t *u16_line = (uint16_t *)&u16_copy[i * clone->width * 8];
  312|       |
  313|     34|	    if (image->format == CAIRO_FORMAT_RGBA128F)
  ------------------
  |  Branch (313:10): [True: 7, False: 27]
  ------------------
  314|      7|		unpremultiply_float (float_line, u16_line, clone->width);
  315|     27|	    else
  316|     27|		convert_float_to_u16 (float_line, u16_line, clone->width);
  317|       |
  318|     34|	    rows[i] = (png_byte *)u16_line;
  319|     34|	}
  320|     34|    }
  321|       |
  322|     51|    png = png_create_write_struct (PNG_LIBPNG_VER_STRING, &status,
  ------------------
  |  |  281|     51|#define PNG_LIBPNG_VER_STRING "1.6.37"
  ------------------
  323|     51|	                           png_simple_error_callback,
  324|     51|	                           png_simple_warning_callback);
  325|     51|    if (unlikely (png == NULL)) {
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
  326|      0|	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  327|      0|	goto BAIL3;
  328|      0|    }
  329|       |
  330|     51|    info = png_create_info_struct (png);
  331|     51|    if (unlikely (info == NULL)) {
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
  332|      0|	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  333|      0|	goto BAIL4;
  334|      0|    }
  335|       |
  336|     51|#ifdef PNG_SETJMP_SUPPORTED
  337|     51|    if (setjmp (png_jmpbuf (png)))
  ------------------
  |  Branch (337:9): [True: 0, False: 51]
  ------------------
  338|      0|	goto BAIL4;
  339|     51|#endif
  340|       |
  341|     51|    png_set_write_fn (png, closure, write_func, png_simple_output_flush_fn);
  342|       |
  343|     51|    switch (clone->format) {
  344|      4|    case CAIRO_FORMAT_ARGB32:
  ------------------
  |  Branch (344:5): [True: 4, False: 47]
  ------------------
  345|      4|	bpc = 8;
  346|      4|	if (_cairo_image_analyze_transparency (clone) == CAIRO_IMAGE_IS_OPAQUE)
  ------------------
  |  Branch (346:6): [True: 0, False: 4]
  ------------------
  347|      0|	    png_color_type = PNG_COLOR_TYPE_RGB;
  ------------------
  |  |  670|      0|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|      0|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  348|      4|	else
  349|      4|	    png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
  ------------------
  |  |  671|      4|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|      4|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|      4|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  350|      4|	break;
  351|      0|    case CAIRO_FORMAT_RGB30:
  ------------------
  |  Branch (351:5): [True: 0, False: 51]
  ------------------
  352|      0|	bpc = 10;
  353|      0|	png_color_type = PNG_COLOR_TYPE_RGB;
  ------------------
  |  |  670|      0|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|      0|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  354|      0|	break;
  355|     13|    case CAIRO_FORMAT_RGB24:
  ------------------
  |  Branch (355:5): [True: 13, False: 38]
  ------------------
  356|     13|	bpc = 8;
  357|     13|	png_color_type = PNG_COLOR_TYPE_RGB;
  ------------------
  |  |  670|     13|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|     13|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  358|     13|	break;
  359|      0|    case CAIRO_FORMAT_A8:
  ------------------
  |  Branch (359:5): [True: 0, False: 51]
  ------------------
  360|      0|	bpc = 8;
  361|      0|	png_color_type = PNG_COLOR_TYPE_GRAY;
  ------------------
  |  |  668|      0|#define PNG_COLOR_TYPE_GRAY 0
  ------------------
  362|      0|	break;
  363|      0|    case CAIRO_FORMAT_A1:
  ------------------
  |  Branch (363:5): [True: 0, False: 51]
  ------------------
  364|      0|	bpc = 1;
  365|      0|	png_color_type = PNG_COLOR_TYPE_GRAY;
  ------------------
  |  |  668|      0|#define PNG_COLOR_TYPE_GRAY 0
  ------------------
  366|      0|#ifndef WORDS_BIGENDIAN
  367|      0|	png_set_packswap (png);
  368|      0|#endif
  369|      0|	break;
  370|     27|    case CAIRO_FORMAT_RGB96F:
  ------------------
  |  Branch (370:5): [True: 27, False: 24]
  ------------------
  371|     27|	bpc = 16;
  372|     27|	png_color_type = PNG_COLOR_TYPE_RGB;
  ------------------
  |  |  670|     27|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|     27|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  373|     27|	break;
  374|      7|    case CAIRO_FORMAT_RGBA128F:
  ------------------
  |  Branch (374:5): [True: 7, False: 44]
  ------------------
  375|      7|	bpc = 16;
  376|      7|	png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
  ------------------
  |  |  671|      7|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|      7|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|      7|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  377|      7|	break;
  378|      0|    case CAIRO_FORMAT_INVALID:
  ------------------
  |  Branch (378:5): [True: 0, False: 51]
  ------------------
  379|      0|    case CAIRO_FORMAT_RGB16_565:
  ------------------
  |  Branch (379:5): [True: 0, False: 51]
  ------------------
  380|      0|    default:
  ------------------
  |  Branch (380:5): [True: 0, False: 51]
  ------------------
  381|      0|	status = _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
  382|      0|	goto BAIL4;
  383|     51|    }
  384|       |
  385|     51|    png_set_IHDR (png, info,
  386|     51|		  clone->width,
  387|     51|		  clone->height, bpc,
  388|     51|		  png_color_type,
  389|     51|		  PNG_INTERLACE_NONE,
  ------------------
  |  |  687|     51|#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
  ------------------
  390|     51|		  PNG_COMPRESSION_TYPE_DEFAULT,
  ------------------
  |  |  679|     51|#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
  |  |  ------------------
  |  |  |  |  678|     51|#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
  |  |  ------------------
  ------------------
  391|     51|		  PNG_FILTER_TYPE_DEFAULT);
  ------------------
  |  |  684|     51|#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
  |  |  ------------------
  |  |  |  |  682|     51|#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
  |  |  ------------------
  ------------------
  392|       |
  393|     51|    white.gray = (1 << bpc) - 1;
  394|     51|    white.red = white.blue = white.green = white.gray;
  395|     51|    png_set_bKGD (png, info, &white);
  396|       |
  397|     51|    if (0) { /* XXX extract meta-data from surface (i.e. creation date) */
  ------------------
  |  Branch (397:9): [Folded, False: 51]
  ------------------
  398|      0|	png_time pt;
  399|       |
  400|      0|	png_convert_from_time_t (&pt, time (NULL));
  401|      0|	png_set_tIME (png, info, &pt);
  402|      0|    }
  403|       |
  404|       |    /* We have to call png_write_info() before setting up the write
  405|       |     * transformation, since it stores data internally in 'png'
  406|       |     * that is needed for the write transformation functions to work.
  407|       |     */
  408|     51|    png_write_info (png, info);
  409|       |
  410|     51|#ifndef WORDS_BIGENDIAN
  411|       |    /* libpng treats 16-bit data as big-endian by default. Swapping the
  412|       |     * byte-order on little endian ensures the native-endian data can be
  413|       |     * provided to png_write_image. This does not affect 8-bit data.
  414|       |     */
  415|     51|    png_set_swap (png);
  416|     51|#endif
  417|       |
  418|     51|    if (png_color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  ------------------
  |  |  671|     51|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|     51|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|     51|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (418:9): [True: 11, False: 40]
  ------------------
  419|     11|	if (clone->format != CAIRO_FORMAT_RGBA128F)
  ------------------
  |  Branch (419:6): [True: 4, False: 7]
  ------------------
  420|      4|	    png_set_write_user_transform_fn (png, unpremultiply_data);
  421|     40|    } else if (png_color_type == PNG_COLOR_TYPE_RGB) {
  ------------------
  |  |  670|     40|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|     40|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  |  Branch (421:16): [True: 40, False: 0]
  ------------------
  422|     40|	if (clone->format != CAIRO_FORMAT_RGB96F)
  ------------------
  |  Branch (422:6): [True: 13, False: 27]
  ------------------
  423|     13|	    png_set_write_user_transform_fn (png, convert_data_to_bytes);
  424|     40|	png_set_filler (png, 0, PNG_FILLER_AFTER);
  ------------------
  |  | 1249|     40|#  define PNG_FILLER_AFTER 1
  ------------------
  425|     40|    }
  426|       |
  427|     51|    png_write_image (png, rows);
  428|     51|    png_write_end (png, info);
  429|       |
  430|     51|BAIL4:
  431|     51|    png_destroy_write_struct (&png, &info);
  432|     51|BAIL3:
  433|     51|    free (rows);
  434|     51|BAIL2:
  435|     51|    cairo_surface_destroy (&clone->base);
  436|     51|    free (u16_copy);
  437|     51|BAIL1:
  438|     51|    _cairo_surface_release_source_image (surface, image, image_extra);
  439|       |
  440|     51|    return status;
  441|     51|}
cairo-png.c:unpremultiply_float:
  120|      7|{
  121|      7|    unsigned int i;
  122|       |
  123|     14|    for (i = 0; i < width; i++) {
  ------------------
  |  Branch (123:17): [True: 7, False: 7]
  ------------------
  124|      7|	float r, g, b, a;
  125|       |
  126|      7|	r = *f++;
  127|      7|	g = *f++;
  128|      7|	b = *f++;
  129|      7|	a = *f++;
  130|       |
  131|      7|	if (a > 0) {
  ------------------
  |  Branch (131:6): [True: 7, False: 0]
  ------------------
  132|      7|	    *d16++ = f_to_u16(r / a);
  133|      7|	    *d16++ = f_to_u16(g / a);
  134|      7|	    *d16++ = f_to_u16(b / a);
  135|      7|	    *d16++ = f_to_u16(a);
  136|      7|	} else {
  137|      0|	    *d16++ = 0;
  138|      0|	    *d16++ = 0;
  139|      0|	    *d16++ = 0;
  140|      0|	    *d16++ = 0;
  141|      0|	}
  142|      7|    }
  143|      7|}
cairo-png.c:f_to_u16:
  109|    109|{
  110|    109|    if (val < 0)
  ------------------
  |  Branch (110:9): [True: 3, False: 106]
  ------------------
  111|      3|	return 0;
  112|    106|    else if (val > 1)
  ------------------
  |  Branch (112:14): [True: 39, False: 67]
  ------------------
  113|     39|	return 65535;
  114|     67|    else
  115|     67|	return (uint16_t)(val * 65535.f);
  116|    109|}
cairo-png.c:convert_float_to_u16:
  175|     27|{
  176|     27|    unsigned int i;
  177|       |
  178|     54|    for (i = 0; i < width; i++) {
  ------------------
  |  Branch (178:17): [True: 27, False: 27]
  ------------------
  179|     27|	*d16++ = f_to_u16(*f++);
  180|     27|	*d16++ = f_to_u16(*f++);
  181|     27|	*d16++ = f_to_u16(*f++);
  182|     27|	*d16++ = 0;
  183|     27|    }
  184|     27|}
cairo-png.c:png_simple_error_callback:
  212|    305|{
  213|    305|    cairo_status_t *error = png_get_error_ptr (png);
  214|       |
  215|       |    /* default to the most likely error */
  216|    305|    if (*error == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (216:9): [True: 96, False: 209]
  ------------------
  217|     96|	*error = _cairo_error (CAIRO_STATUS_PNG_ERROR);
  218|       |
  219|    305|#ifdef PNG_SETJMP_SUPPORTED
  220|    305|    longjmp (png_jmpbuf (png), 1);
  ------------------
  |  |  953|    305|      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
  ------------------
  221|    305|#endif
  222|       |
  223|       |    /* if we get here, then we have to choice but to abort ... */
  224|    305|}
cairo-png.c:png_simple_warning_callback:
  229|  6.04k|{
  230|       |    /* png does not expect to abort and will try to tidy up and continue
  231|       |     * loading the image after a warning. So we also want to return the
  232|       |     * (incorrect?) surface.
  233|       |     *
  234|       |     * We use our own warning callback to squelch any attempts by libpng
  235|       |     * to write to stderr as we may not be in control of that output.
  236|       |     */
  237|  6.04k|}
cairo-png.c:unpremultiply_data:
   87|      4|{
   88|      4|    unsigned int i;
   89|       |
   90|      8|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (90:17): [True: 4, False: 4]
  ------------------
   91|      4|        uint8_t *b = &data[i];
   92|      4|        uint32_t pixel;
   93|      4|        uint8_t  alpha;
   94|       |
   95|      4|	memcpy (&pixel, b, sizeof (uint32_t));
   96|      4|	alpha = (pixel & 0xff000000) >> 24;
   97|      4|        if (alpha == 0) {
  ------------------
  |  Branch (97:13): [True: 0, False: 4]
  ------------------
   98|      0|	    b[0] = b[1] = b[2] = b[3] = 0;
   99|      4|	} else {
  100|      4|            b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
  101|      4|            b[1] = (((pixel & 0x00ff00) >>  8) * 255 + alpha / 2) / alpha;
  102|      4|            b[2] = (((pixel & 0x0000ff) >>  0) * 255 + alpha / 2) / alpha;
  103|      4|	    b[3] = alpha;
  104|      4|	}
  105|      4|    }
  106|      4|}
cairo-png.c:convert_data_to_bytes:
  189|     13|{
  190|     13|    unsigned int i;
  191|       |
  192|     26|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (192:17): [True: 13, False: 13]
  ------------------
  193|     13|        uint8_t *b = &data[i];
  194|     13|        uint32_t pixel;
  195|       |
  196|     13|	memcpy (&pixel, b, sizeof (uint32_t));
  197|       |
  198|     13|	b[0] = (pixel & 0xff0000) >> 16;
  199|     13|	b[1] = (pixel & 0x00ff00) >>  8;
  200|     13|	b[2] = (pixel & 0x0000ff) >>  0;
  201|     13|	b[3] = 0;
  202|     13|    }
  203|     13|}
cairo-png.c:stdio_write_func:
  445|    612|{
  446|    612|    FILE *fp;
  447|       |
  448|    612|    fp = png_get_io_ptr (png);
  449|  1.22k|    while (size) {
  ------------------
  |  Branch (449:12): [True: 612, False: 612]
  ------------------
  450|    612|	size_t ret = fwrite (data, 1, size, fp);
  451|    612|	size -= ret;
  452|    612|	data += ret;
  453|    612|	if (size && ferror (fp)) {
  ------------------
  |  Branch (453:6): [True: 0, False: 612]
  |  Branch (453:14): [True: 0, False: 0]
  ------------------
  454|      0|	    cairo_status_t *error = png_get_error_ptr (png);
  455|      0|	    if (*error == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (455:10): [True: 0, False: 0]
  ------------------
  456|      0|		*error = _cairo_error (CAIRO_STATUS_WRITE_ERROR);
  457|       |	    png_error (png, NULL);
  458|      0|	}
  459|    612|    }
  460|    612|}
cairo-png.c:stdio_read_func:
  631|  20.3k|{
  632|  20.3k|    FILE *file = closure;
  633|       |
  634|  40.4k|    while (size) {
  ------------------
  |  Branch (634:12): [True: 20.3k, False: 20.1k]
  ------------------
  635|  20.3k|	size_t ret;
  636|       |
  637|  20.3k|	ret = fread (data, 1, size, file);
  638|  20.3k|	size -= ret;
  639|  20.3k|	data += ret;
  640|       |
  641|  20.3k|	if (size && (feof (file) || ferror (file)))
  ------------------
  |  Branch (641:6): [True: 209, False: 20.1k]
  |  Branch (641:15): [True: 209, False: 0]
  |  Branch (641:30): [True: 0, False: 0]
  ------------------
  642|    209|	    return _cairo_error (CAIRO_STATUS_READ_ERROR);
  643|  20.3k|    }
  644|       |
  645|  20.1k|    return CAIRO_STATUS_SUCCESS;
  646|  20.3k|}
cairo-png.c:read_png:
  668|    411|{
  669|    411|    cairo_surface_t * volatile surface;
  670|    411|    png_struct *png = NULL;
  671|    411|    png_info *info;
  672|    411|    png_byte * volatile data = NULL;
  673|    411|    png_byte ** volatile row_pointers = NULL;
  674|    411|    png_uint_32 png_width, png_height;
  675|    411|    int depth, color_type, interlace, stride;
  676|    411|    unsigned int i;
  677|    411|    cairo_format_t format;
  678|    411|    cairo_status_t status;
  679|    411|    unsigned char *mime_data;
  680|    411|    unsigned long mime_data_length;
  681|       |
  682|    411|    png_closure->png_data = _cairo_memory_stream_create ();
  683|       |
  684|       |    /* XXX: Perhaps we'll want some other error handlers? */
  685|    411|    png = png_create_read_struct (PNG_LIBPNG_VER_STRING,
  ------------------
  |  |  281|    411|#define PNG_LIBPNG_VER_STRING "1.6.37"
  ------------------
  686|    411|                                  &status,
  687|    411|	                          png_simple_error_callback,
  688|    411|	                          png_simple_warning_callback);
  689|    411|    if (unlikely (png == NULL)) {
  ------------------
  |  |  145|    411|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 411]
  |  |  ------------------
  ------------------
  690|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  691|      0|	goto BAIL;
  692|      0|    }
  693|       |
  694|    411|    info = png_create_info_struct (png);
  695|    411|    if (unlikely (info == NULL)) {
  ------------------
  |  |  145|    411|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 411]
  |  |  ------------------
  ------------------
  696|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  697|      0|	goto BAIL;
  698|      0|    }
  699|       |
  700|    411|    png_set_read_fn (png, png_closure, stream_read_func);
  701|       |
  702|    411|    status = CAIRO_STATUS_SUCCESS;
  703|    411|#ifdef PNG_SETJMP_SUPPORTED
  704|    411|    if (setjmp (png_jmpbuf (png))) {
  ------------------
  |  Branch (704:9): [True: 305, False: 106]
  ------------------
  705|    305|	surface = _cairo_surface_create_in_error (status);
  706|    305|	goto BAIL;
  707|    305|    }
  708|    106|#endif
  709|       |
  710|    106|    png_read_info (png, info);
  711|       |
  712|    106|#ifndef WORDS_BIGENDIAN
  713|       |    /* libpng treats 16-bit data as big-endian by default. Swapping the
  714|       |     * byte-order on little endian ensures the native-endian data can be
  715|       |     * provided to png_read_image. This does not affect 8-bit data.
  716|       |     */
  717|    106|    png_set_swap (png);
  718|    106|#endif
  719|       |
  720|    106|    png_get_IHDR (png, info,
  721|    106|                  &png_width, &png_height, &depth,
  722|    106|                  &color_type, &interlace, NULL, NULL);
  723|    106|    if (unlikely (status)) { /* catch any early warnings */
  ------------------
  |  |  145|    106|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 106]
  |  |  ------------------
  ------------------
  724|      0|	surface = _cairo_surface_create_in_error (status);
  725|      0|	goto BAIL;
  726|      0|    }
  727|       |
  728|       |    /* convert palette/gray image to rgb */
  729|    106|    if (color_type == PNG_COLOR_TYPE_PALETTE)
  ------------------
  |  |  669|    106|#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  |  |  ------------------
  |  |  |  |  664|    106|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  |  |  ------------------
  |  |  |  |  663|    106|#define PNG_COLOR_MASK_PALETTE    1
  |  |  ------------------
  ------------------
  |  Branch (729:9): [True: 7, False: 99]
  ------------------
  730|      7|        png_set_palette_to_rgb (png);
  731|       |
  732|       |    /* expand gray bit depth if needed */
  733|    106|    if (color_type == PNG_COLOR_TYPE_GRAY)
  ------------------
  |  |  668|    106|#define PNG_COLOR_TYPE_GRAY 0
  ------------------
  |  Branch (733:9): [True: 84, False: 22]
  ------------------
  734|     84|        png_set_expand_gray_1_2_4_to_8 (png);
  735|       |
  736|       |    /* transform transparency to alpha */
  737|    106|    if (png_get_valid (png, info, PNG_INFO_tRNS))
  ------------------
  |  |  736|    106|#define PNG_INFO_tRNS 0x0010U
  ------------------
  |  Branch (737:9): [True: 16, False: 90]
  ------------------
  738|     16|        png_set_tRNS_to_alpha (png);
  739|       |
  740|    106|    if (depth < 8)
  ------------------
  |  Branch (740:9): [True: 47, False: 59]
  ------------------
  741|     47|        png_set_packing (png);
  742|       |
  743|       |    /* convert grayscale to RGB */
  744|    106|    if (color_type == PNG_COLOR_TYPE_GRAY ||
  ------------------
  |  |  668|    212|#define PNG_COLOR_TYPE_GRAY 0
  ------------------
  |  Branch (744:9): [True: 18.4E, False: 132]
  ------------------
  745|    132|	color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
  ------------------
  |  |  672|    132|#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|    132|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (745:2): [True: 26, False: 106]
  ------------------
  746|    110|    {
  747|    110|	png_set_gray_to_rgb (png);
  748|    110|    }
  749|       |
  750|    106|    if (interlace != PNG_INTERLACE_NONE)
  ------------------
  |  |  687|    106|#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
  ------------------
  |  Branch (750:9): [True: 105, False: 1]
  ------------------
  751|    105|        png_set_interlace_handling (png);
  752|       |
  753|    106|    png_set_filler (png, 0xff, PNG_FILLER_AFTER);
  ------------------
  |  | 1249|    106|#  define PNG_FILLER_AFTER 1
  ------------------
  754|       |
  755|       |    /* recheck header after setting EXPAND options */
  756|    106|    png_read_update_info (png, info);
  757|    106|    png_get_IHDR (png, info,
  758|    106|                  &png_width, &png_height, &depth,
  759|    106|                  &color_type, &interlace, NULL, NULL);
  760|    106|    if ((depth != 8 && depth != 16) ||
  ------------------
  |  Branch (760:10): [True: 85, False: 21]
  |  Branch (760:24): [True: 0, False: 85]
  ------------------
  761|    216|	! (color_type == PNG_COLOR_TYPE_RGB ||
  ------------------
  |  |  670|    432|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|    216|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  |  Branch (761:5): [True: 122, False: 94]
  ------------------
  762|     94|	   color_type == PNG_COLOR_TYPE_RGB_ALPHA))
  ------------------
  |  |  671|     94|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|     94|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|     94|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (762:5): [True: 94, False: 0]
  ------------------
  763|      0|    {
  764|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_READ_ERROR));
  765|      0|	goto BAIL;
  766|      0|    }
  767|       |
  768|    106|    switch (color_type) {
  769|      0|	default:
  ------------------
  |  Branch (769:2): [True: 0, False: 106]
  ------------------
  770|      0|	    ASSERT_NOT_REACHED;
  ------------------
  |  |  140|      0|#define ASSERT_NOT_REACHED		\
  |  |  141|      0|do {					\
  |  |  142|      0|    assert (!"reached");		\
  |  |  143|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (143:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (770:6): [Folded, False: 0]
  |  Branch (770:6): [Folded, False: 0]
  ------------------
  771|       |	    /* fall-through just in case ;-) */
  772|       |
  773|     94|	case PNG_COLOR_TYPE_RGB_ALPHA:
  ------------------
  |  |  671|     94|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|     94|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|     94|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (773:2): [True: 94, False: 12]
  ------------------
  774|     94|	    if (depth == 8) {
  ------------------
  |  Branch (774:10): [True: 56, False: 38]
  ------------------
  775|     56|		format = CAIRO_FORMAT_ARGB32;
  776|     56|		png_set_read_user_transform_fn (png, premultiply_data);
  777|     56|	    } else {
  778|     38|		format = CAIRO_FORMAT_RGBA128F;
  779|     38|	    }
  780|     94|	    break;
  781|       |
  782|    122|	case PNG_COLOR_TYPE_RGB:
  ------------------
  |  |  670|    122|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|    122|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  |  Branch (782:2): [True: 122, False: 18.4E]
  ------------------
  783|    122|	    if (depth == 8) {
  ------------------
  |  Branch (783:10): [True: 75, False: 47]
  ------------------
  784|     75|		format = CAIRO_FORMAT_RGB24;
  785|     75|		png_set_read_user_transform_fn (png, convert_bytes_to_data);
  786|     75|	    } else {
  787|     47|		format = CAIRO_FORMAT_RGB96F;
  788|     47|	    }
  789|    122|	    break;
  790|    106|    }
  791|       |
  792|    216|    stride = cairo_format_stride_for_width (format, png_width);
  793|    216|    if (stride < 0) {
  ------------------
  |  Branch (793:9): [True: 0, False: 216]
  ------------------
  794|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  795|      0|	goto BAIL;
  796|      0|    }
  797|       |
  798|    216|    data = _cairo_malloc_ab (png_height, stride);
  799|    216|    if (unlikely (data == NULL)) {
  ------------------
  |  |  145|    216|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 216]
  |  |  ------------------
  ------------------
  800|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  801|      0|	goto BAIL;
  802|      0|    }
  803|       |
  804|    216|    row_pointers = _cairo_malloc_ab (png_height, sizeof (char *));
  805|    216|    if (unlikely (row_pointers == NULL)) {
  ------------------
  |  |  145|    216|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 216]
  |  |  ------------------
  ------------------
  806|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  807|      0|	goto BAIL;
  808|      0|    }
  809|       |
  810|  5.02M|    for (i = 0; i < png_height; i++)
  ------------------
  |  Branch (810:17): [True: 5.02M, False: 216]
  ------------------
  811|  5.02M|        row_pointers[i] = &data[i * (ptrdiff_t)stride];
  812|       |
  813|    216|    png_read_image (png, row_pointers);
  814|    216|    png_read_end (png, info);
  815|       |
  816|    216|    if (unlikely (status)) { /* catch any late warnings - probably hit an error already */
  ------------------
  |  |  145|    216|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 216]
  |  |  ------------------
  ------------------
  817|      0|	surface = _cairo_surface_create_in_error (status);
  818|      0|	goto BAIL;
  819|      0|    }
  820|       |
  821|    216|    if (format == CAIRO_FORMAT_RGBA128F) {
  ------------------
  |  Branch (821:9): [True: 28, False: 188]
  ------------------
  822|     28|	i = png_height;
  823|       |
  824|    728|	while (i--) {
  ------------------
  |  Branch (824:9): [True: 700, False: 28]
  ------------------
  825|    700|	    float *float_line = (float *)row_pointers[i];
  826|    700|	    uint16_t *u16_line = (uint16_t *)row_pointers[i];
  827|       |
  828|    700|	    premultiply_float (float_line, u16_line, png_width);
  829|    700|	}
  830|    188|    } else if (format == CAIRO_FORMAT_RGB96F) {
  ------------------
  |  Branch (830:16): [True: 39, False: 149]
  ------------------
  831|     39|	i = png_height;
  832|       |
  833|  5.82k|	while (i--) {
  ------------------
  |  Branch (833:9): [True: 5.79k, False: 39]
  ------------------
  834|  5.79k|	    float *float_line = (float *)row_pointers[i];
  835|  5.79k|	    uint16_t *u16_line = (uint16_t *)row_pointers[i];
  836|       |
  837|  5.79k|	    convert_u16_to_float (float_line, u16_line, png_width);
  838|  5.79k|	}
  839|     39|    }
  840|       |
  841|    216|    surface = cairo_image_surface_create_for_data (data, format,
  842|    216|						   png_width, png_height,
  843|    216|						   stride);
  844|    216|    if (surface->status)
  ------------------
  |  Branch (844:9): [True: 1, False: 215]
  ------------------
  845|      1|	goto BAIL;
  846|       |
  847|    215|    _cairo_image_surface_assume_ownership_of_data ((cairo_image_surface_t*)surface);
  848|    215|    data = NULL;
  849|       |
  850|    215|    _cairo_debug_check_image_surface_is_defined (surface);
  851|       |
  852|    215|    status = _cairo_memory_stream_destroy (png_closure->png_data,
  853|    215|					   &mime_data,
  854|    215|					   &mime_data_length);
  855|    215|    png_closure->png_data = NULL;
  856|    215|    if (unlikely (status)) {
  ------------------
  |  |  145|    215|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 215]
  |  |  ------------------
  ------------------
  857|      0|	cairo_surface_destroy (surface);
  858|      0|	surface = _cairo_surface_create_in_error (status);
  859|      0|	goto BAIL;
  860|      0|    }
  861|       |
  862|    215|    status = cairo_surface_set_mime_data (surface,
  863|    215|					  CAIRO_MIME_TYPE_PNG,
  ------------------
  |  | 2621|    215|#define CAIRO_MIME_TYPE_PNG "image/png"
  ------------------
  864|    215|					  mime_data,
  865|    215|					  mime_data_length,
  866|    215|					  free,
  867|    215|					  mime_data);
  868|    215|    if (unlikely (status)) {
  ------------------
  |  |  145|    215|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 215]
  |  |  ------------------
  ------------------
  869|      0|	free (mime_data);
  870|      0|	cairo_surface_destroy (surface);
  871|      0|	surface = _cairo_surface_create_in_error (status);
  872|      0|	goto BAIL;
  873|      0|    }
  874|       |
  875|    411| BAIL:
  876|    411|    free (row_pointers);
  877|    411|    free (data);
  878|    411|    if (png != NULL)
  ------------------
  |  Branch (878:9): [True: 411, False: 0]
  ------------------
  879|    411|	png_destroy_read_struct (&png, &info, NULL);
  880|    411|    if (png_closure->png_data != NULL) {
  ------------------
  |  Branch (880:9): [True: 306, False: 105]
  ------------------
  881|    306|	cairo_status_t status_ignored;
  882|       |
  883|    306|	status_ignored = _cairo_output_stream_destroy (png_closure->png_data);
  884|    306|    }
  885|       |
  886|    411|    return surface;
  887|    215|}
cairo-png.c:stream_read_func:
  650|  20.3k|{
  651|  20.3k|    cairo_status_t status;
  652|  20.3k|    struct png_read_closure_t *png_closure;
  653|       |
  654|  20.3k|    png_closure = png_get_io_ptr (png);
  655|  20.3k|    status = png_closure->read_func (png_closure->closure, data, size);
  656|  20.3k|    if (unlikely (status)) {
  ------------------
  |  |  145|  20.3k|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 209, False: 20.1k]
  |  |  ------------------
  ------------------
  657|    209|	cairo_status_t *error = png_get_error_ptr (png);
  658|    209|	if (*error == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (658:6): [True: 209, False: 0]
  ------------------
  659|    209|	    *error = status;
  660|    209|	png_error (png, NULL);
  661|    209|    }
  662|       |
  663|  20.1k|    _cairo_output_stream_write (png_closure->png_data, data, size);
  664|  20.1k|}
cairo-png.c:premultiply_data:
  585|  1.40k|{
  586|  1.40k|    unsigned int i;
  587|       |
  588|  1.94M|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (588:17): [True: 1.93M, False: 1.40k]
  ------------------
  589|  1.93M|	uint8_t *base  = &data[i];
  590|  1.93M|	uint8_t  alpha = base[3];
  591|  1.93M|	uint32_t p;
  592|       |
  593|  1.93M|	if (alpha == 0) {
  ------------------
  |  Branch (593:6): [True: 808k, False: 1.13M]
  ------------------
  594|   808k|	    p = 0;
  595|  1.13M|	} else {
  596|  1.13M|	    uint8_t  red   = base[0];
  597|  1.13M|	    uint8_t  green = base[1];
  598|  1.13M|	    uint8_t  blue  = base[2];
  599|       |
  600|  1.13M|	    if (alpha != 0xff) {
  ------------------
  |  Branch (600:10): [True: 264k, False: 865k]
  ------------------
  601|   264k|		red   = multiply_alpha (alpha, red);
  602|   264k|		green = multiply_alpha (alpha, green);
  603|   264k|		blue  = multiply_alpha (alpha, blue);
  604|   264k|	    }
  605|  1.13M|	    p = ((uint32_t)alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
  606|  1.13M|	}
  607|  1.93M|	memcpy (base, &p, sizeof (uint32_t));
  608|  1.93M|    }
  609|  1.40k|}
cairo-png.c:multiply_alpha:
  575|   792k|{
  576|   792k|    int temp = (alpha * color) + 0x80;
  577|   792k|    return ((temp + (temp >> 8)) >> 8);
  578|   792k|}
cairo-png.c:convert_bytes_to_data:
  614|  6.36k|{
  615|  6.36k|    unsigned int i;
  616|       |
  617|  9.10M|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (617:17): [True: 9.09M, False: 6.36k]
  ------------------
  618|  9.09M|	uint8_t *base  = &data[i];
  619|  9.09M|	uint8_t  red   = base[0];
  620|  9.09M|	uint8_t  green = base[1];
  621|  9.09M|	uint8_t  blue  = base[2];
  622|  9.09M|	uint32_t pixel;
  623|       |
  624|  9.09M|	pixel = (0xffu << 24) | (red << 16) | (green << 8) | (blue << 0);
  625|  9.09M|	memcpy (base, &pixel, sizeof (uint32_t));
  626|  9.09M|    }
  627|  6.36k|}
cairo-png.c:premultiply_float:
  147|    700|{
  148|    700|    unsigned int i = width;
  149|       |
  150|       |    /* Convert d16 in place back to float */
  151|  2.41k|    while (i--) {
  ------------------
  |  Branch (151:12): [True: 1.71k, False: 700]
  ------------------
  152|  1.71k|	float a = d16[i * 4 + 3] / 65535.f;
  153|       |
  154|  1.71k|	f[i * 4 + 3] = a;
  155|  1.71k|	f[i * 4 + 2] = (float)d16[i * 4 + 2] / 65535.f * a;
  156|  1.71k|	f[i * 4 + 1] = (float)d16[i * 4 + 1] / 65535.f * a;
  157|  1.71k|	f[i * 4] = (float)d16[i * 4] / 65535.f * a;
  158|  1.71k|    }
  159|    700|}
cairo-png.c:convert_u16_to_float:
  162|  5.79k|{
  163|       |    /* Convert d16 in place back to float */
  164|  5.79k|    unsigned int i = width;
  165|       |
  166|  19.1k|    while (i--) {
  ------------------
  |  Branch (166:12): [True: 13.3k, False: 5.79k]
  ------------------
  167|  13.3k|	f[i * 3 + 2] = (float)d16[i * 4 + 2] / 65535.f;
  168|  13.3k|	f[i * 3 + 1] = (float)d16[i * 4 + 1] / 65535.f;
  169|  13.3k|	f[i * 3] = (float)d16[i * 4] / 65535.f;
  170|  13.3k|    }
  171|  5.79k|}

_cairo_shape_mask_compositor_init:
  332|      1|{
  333|      1|    compositor->delegate = delegate;
  334|       |
  335|      1|    compositor->paint  = NULL;
  336|       |    compositor->mask   = NULL;
  337|      1|    compositor->fill   = _cairo_shape_mask_compositor_fill;
  338|      1|    compositor->stroke = _cairo_shape_mask_compositor_stroke;
  339|      1|    compositor->glyphs = _cairo_shape_mask_compositor_glyphs;
  340|      1|}

_cairo_spans_compositor_init:
 1193|      1|{
 1194|      1|    compositor->base.delegate = delegate;
 1195|       |
 1196|      1|    compositor->base.paint  = _cairo_spans_compositor_paint;
 1197|      1|    compositor->base.mask   = _cairo_spans_compositor_mask;
 1198|      1|    compositor->base.fill   = _cairo_spans_compositor_fill;
 1199|      1|    compositor->base.stroke = _cairo_spans_compositor_stroke;
 1200|       |    compositor->base.glyphs = NULL;
 1201|      1|}

cairo-surface.c:__cairo_surface_flush:
   45|    156|{
   46|    156|    cairo_status_t status = CAIRO_STATUS_SUCCESS;
   47|    156|    if (surface->backend->flush)
  ------------------
  |  Branch (47:9): [True: 0, False: 156]
  ------------------
   48|      0|	status = surface->backend->flush (surface, flags);
   49|    156|    return status;
   50|    156|}

cairo-image-surface.c:_cairo_surface_is_snapshot:
   63|      4|{
   64|      4|    return surface->backend->type == (cairo_surface_type_t)CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT;
   65|      4|}

cairo_surface_status:
  266|    516|{
  267|    516|    return surface->status;
  268|    516|}
_cairo_surface_init:
  412|    156|{
  413|    156|    CAIRO_MUTEX_INITIALIZE ();
  ------------------
  |  |  173|    156|#define CAIRO_MUTEX_INITIALIZE		CAIRO_MUTEX_IMPL_INITIALIZE
  |  |  ------------------
  |  |  |  |   88|    156|#  define CAIRO_MUTEX_IMPL_INITIALIZE() CAIRO_MUTEX_IMPL_NOOP
  |  |  |  |  ------------------
  |  |  |  |  |  |   53|    156|#define CAIRO_MUTEX_IMPL_NOOP	do {/*no-op*/} while (0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (53:53): [Folded, False: 156]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|       |
  415|    156|    surface->backend = backend;
  416|    156|    surface->device = cairo_device_reference (device);
  417|    156|    surface->content = content;
  418|    156|    surface->type = backend->type;
  419|    156|    surface->is_vector = is_vector;
  420|       |
  421|    156|    CAIRO_REFERENCE_COUNT_INIT (&surface->ref_count, 1);
  ------------------
  |  |   51|    156|#define CAIRO_REFERENCE_COUNT_INIT(RC, VALUE) ((RC)->ref_count = (VALUE))
  ------------------
  422|    156|    surface->status = CAIRO_STATUS_SUCCESS;
  423|    156|    surface->unique_id = _cairo_surface_allocate_unique_id ();
  424|    156|    surface->finished = FALSE;
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  425|    156|    surface->_finishing = FALSE;
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  426|    156|    surface->is_clear = FALSE;
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  427|    156|    surface->serial = 0;
  428|    156|    surface->damage = NULL;
  429|    156|    surface->owns_device = (device != NULL);
  430|       |
  431|    156|    _cairo_user_data_array_init (&surface->user_data);
  432|    156|    _cairo_user_data_array_init (&surface->mime_data);
  433|       |
  434|    156|    cairo_matrix_init_identity (&surface->device_transform);
  435|    156|    cairo_matrix_init_identity (&surface->device_transform_inverse);
  436|    156|    cairo_list_init (&surface->device_transform_observers);
  437|       |
  438|    156|    surface->x_resolution = CAIRO_SURFACE_RESOLUTION_DEFAULT;
  ------------------
  |  |  731|    156|#define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
  ------------------
  439|    156|    surface->y_resolution = CAIRO_SURFACE_RESOLUTION_DEFAULT;
  ------------------
  |  |  731|    156|#define CAIRO_SURFACE_RESOLUTION_DEFAULT 72.0
  ------------------
  440|       |
  441|    156|    surface->x_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
  ------------------
  |  |  732|    156|#define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
  ------------------
  442|    156|    surface->y_fallback_resolution = CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT;
  ------------------
  |  |  732|    156|#define CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT 300.0
  ------------------
  443|       |
  444|    156|    cairo_list_init (&surface->snapshots);
  445|    156|    surface->snapshot_of = NULL;
  446|       |
  447|    156|    surface->has_font_options = FALSE;
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  448|       |
  449|    156|    surface->foreground_source = NULL;
  450|    156|    surface->foreground_used = FALSE;
  ------------------
  |  |  102|    156|#define FALSE 0
  ------------------
  451|    156|}
cairo_surface_reference:
  934|     51|{
  935|     51|    if (surface == NULL ||
  ------------------
  |  Branch (935:9): [True: 0, False: 51]
  ------------------
  936|     51|	    CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
  ------------------
  |  |   58|     51|#define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   53|     51|#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC) _cairo_atomic_int_get (&(RC)->ref_count)
  |  |  ------------------
  |  |               #define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   55|     51|#define CAIRO_REFERENCE_COUNT_INVALID_VALUE ((int) -1)
  |  |  ------------------
  |  |  |  Branch (58:46): [True: 0, False: 51]
  |  |  ------------------
  ------------------
  937|      0|	return surface;
  938|       |
  939|     51|    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count));
  ------------------
  |  Branch (939:5): [True: 0, False: 51]
  |  Branch (939:5): [True: 51, False: 0]
  ------------------
  940|       |
  941|     51|    _cairo_reference_count_inc (&surface->ref_count);
  ------------------
  |  |   47|     51|#define _cairo_reference_count_inc(RC) _cairo_atomic_int_inc (&(RC)->ref_count)
  |  |  ------------------
  |  |  |  |   83|     51|# define _cairo_atomic_int_inc(x) ((void) atomic_fetch_add_explicit(x, 1, memory_order_seq_cst))
  |  |  ------------------
  ------------------
  942|       |
  943|     51|    return surface;
  944|     51|}
cairo_surface_destroy:
  958|    207|{
  959|    207|    if (surface == NULL ||
  ------------------
  |  Branch (959:9): [True: 0, False: 207]
  ------------------
  960|    207|	    CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
  ------------------
  |  |   58|    207|#define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   53|    207|#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC) _cairo_atomic_int_get (&(RC)->ref_count)
  |  |  ------------------
  |  |               #define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   55|    207|#define CAIRO_REFERENCE_COUNT_INVALID_VALUE ((int) -1)
  |  |  ------------------
  |  |  |  Branch (58:46): [True: 0, False: 207]
  |  |  ------------------
  ------------------
  961|      0|	return;
  962|       |
  963|    207|    assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count));
  ------------------
  |  Branch (963:5): [True: 0, False: 207]
  |  Branch (963:5): [True: 207, False: 0]
  ------------------
  964|       |
  965|    207|    if (! _cairo_reference_count_dec_and_test (&surface->ref_count))
  ------------------
  |  |   49|    207|#define _cairo_reference_count_dec_and_test(RC) _cairo_atomic_int_dec_and_test (&(RC)->ref_count)
  |  |  ------------------
  |  |  |  |   85|    207|# define _cairo_atomic_int_dec_and_test(x) (atomic_fetch_sub_explicit(x, 1, memory_order_seq_cst) == 1)
  |  |  ------------------
  ------------------
  |  Branch (965:9): [True: 51, False: 156]
  ------------------
  966|     51|	return;
  967|       |
  968|    207|    assert (surface->snapshot_of == NULL);
  ------------------
  |  Branch (968:5): [True: 0, False: 156]
  |  Branch (968:5): [True: 156, False: 0]
  ------------------
  969|       |
  970|    156|    if (! surface->finished) {
  ------------------
  |  Branch (970:9): [True: 156, False: 0]
  ------------------
  971|    156|	_cairo_surface_finish_snapshots (surface);
  972|       |	/* We may have been referenced by a snapshot prior to have
  973|       |	 * detaching it with the copy-on-write.
  974|       |	 */
  975|    156|	if (CAIRO_REFERENCE_COUNT_GET_VALUE (&surface->ref_count))
  ------------------
  |  |   53|    156|#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC) _cairo_atomic_int_get (&(RC)->ref_count)
  |  |  ------------------
  |  |  |  Branch (53:45): [True: 0, False: 156]
  |  |  ------------------
  ------------------
  976|      0|	    return;
  977|       |
  978|    156|	_cairo_surface_finish (surface);
  979|    156|    }
  980|       |
  981|    156|    if (surface->damage)
  ------------------
  |  Branch (981:9): [True: 0, False: 156]
  ------------------
  982|      0|	_cairo_damage_destroy (surface->damage);
  983|       |
  984|    156|    _cairo_user_data_array_fini (&surface->user_data);
  985|    156|    _cairo_user_data_array_fini (&surface->mime_data);
  986|       |
  987|    156|    if (surface->foreground_source)
  ------------------
  |  Branch (987:9): [True: 0, False: 156]
  ------------------
  988|      0|	cairo_pattern_destroy (surface->foreground_source);
  989|       |
  990|    156|    if (surface->owns_device)
  ------------------
  |  Branch (990:9): [True: 0, False: 156]
  ------------------
  991|      0|        cairo_device_destroy (surface->device);
  992|       |
  993|    156|    if (surface->has_font_options)
  ------------------
  |  Branch (993:9): [True: 0, False: 156]
  ------------------
  994|      0|	_cairo_font_options_fini (&surface->font_options);
  995|       |
  996|    156|    assert (surface->snapshot_of == NULL);
  ------------------
  |  Branch (996:5): [True: 0, False: 156]
  |  Branch (996:5): [True: 156, False: 0]
  ------------------
  997|    156|    assert (! _cairo_surface_has_snapshots (surface));
  ------------------
  |  Branch (997:5): [True: 0, False: 156]
  |  Branch (997:5): [True: 156, False: 0]
  ------------------
  998|       |    /* paranoid check that nobody took a reference whilst finishing */
  999|    156|    assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count));
  ------------------
  |  Branch (999:5): [True: 0, False: 156]
  |  Branch (999:5): [True: 156, False: 0]
  ------------------
 1000|       |
 1001|    156|    free (surface);
 1002|    156|}
cairo_surface_set_mime_data:
 1432|    105|{
 1433|    105|    cairo_status_t status;
 1434|    105|    cairo_mime_data_t *mime_data;
 1435|       |
 1436|    105|    if (CAIRO_REFERENCE_COUNT_IS_INVALID (&surface->ref_count))
  ------------------
  |  |   58|    105|#define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   53|    105|#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC) _cairo_atomic_int_get (&(RC)->ref_count)
  |  |  ------------------
  |  |               #define CAIRO_REFERENCE_COUNT_IS_INVALID(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) == CAIRO_REFERENCE_COUNT_INVALID_VALUE)
  |  |  ------------------
  |  |  |  |   55|    105|#define CAIRO_REFERENCE_COUNT_INVALID_VALUE ((int) -1)
  |  |  ------------------
  |  |  |  Branch (58:46): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1437|      0|	return surface->status;
 1438|       |
 1439|    105|    if (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&surface->ref_count))
  ------------------
  |  |   60|    105|#define CAIRO_REFERENCE_COUNT_HAS_REFERENCE(RC) (CAIRO_REFERENCE_COUNT_GET_VALUE (RC) > 0)
  |  |  ------------------
  |  |  |  |   53|    105|#define CAIRO_REFERENCE_COUNT_GET_VALUE(RC) _cairo_atomic_int_get (&(RC)->ref_count)
  |  |  ------------------
  ------------------
  |  Branch (1439:9): [True: 0, False: 105]
  ------------------
 1440|      0|	return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
 1441|       |
 1442|    105|    if (unlikely (surface->status))
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1443|      0|	return surface->status;
 1444|    105|    if (unlikely (surface->finished))
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1445|      0|	return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
 1446|       |
 1447|    105|    status = _cairo_intern_string (&mime_type, -1);
 1448|    105|    if (unlikely (status))
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1449|      0|	return _cairo_surface_set_error (surface, status);
 1450|       |
 1451|    105|    if (data != NULL) {
  ------------------
  |  Branch (1451:9): [True: 105, False: 0]
  ------------------
 1452|    105|	mime_data = _cairo_calloc (sizeof (cairo_mime_data_t));
  ------------------
  |  |   79|    105|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 105, Folded]
  |  |  ------------------
  ------------------
 1453|    105|	if (unlikely (mime_data == NULL))
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1454|      0|	    return _cairo_surface_set_error (surface, _cairo_error (CAIRO_STATUS_NO_MEMORY));
 1455|       |
 1456|    105|	CAIRO_REFERENCE_COUNT_INIT (&mime_data->ref_count, 1);
  ------------------
  |  |   51|    105|#define CAIRO_REFERENCE_COUNT_INIT(RC, VALUE) ((RC)->ref_count = (VALUE))
  ------------------
 1457|       |
 1458|    105|	mime_data->data = (unsigned char *) data;
 1459|    105|	mime_data->length = length;
 1460|    105|	mime_data->destroy = destroy;
 1461|    105|	mime_data->closure = closure;
 1462|    105|    } else
 1463|      0|	mime_data = NULL;
 1464|       |
 1465|    105|    status = _cairo_user_data_array_set_data (&surface->mime_data,
 1466|    105|					      (cairo_user_data_key_t *) mime_type,
 1467|    105|					      mime_data,
 1468|    105|					      _cairo_mime_data_destroy);
 1469|    105|    if (unlikely (status)) {
  ------------------
  |  |  145|    105|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 105]
  |  |  ------------------
  ------------------
 1470|      0|	free (mime_data);
 1471|       |
 1472|      0|	return _cairo_surface_set_error (surface, status);
 1473|      0|    }
 1474|       |
 1475|    105|    surface->is_clear = FALSE;
  ------------------
  |  |  102|    105|#define FALSE 0
  ------------------
 1476|       |
 1477|    105|    return CAIRO_STATUS_SUCCESS;
 1478|    105|}
_cairo_surface_flush:
 1632|    156|{
 1633|       |    /* update the current snapshots *before* the user updates the surface */
 1634|    156|    _cairo_surface_detach_snapshots (surface);
 1635|    156|    if (surface->snapshot_of != NULL)
  ------------------
  |  Branch (1635:9): [True: 0, False: 156]
  ------------------
 1636|      0|	_cairo_surface_detach_snapshot (surface);
 1637|    156|    _cairo_surface_detach_mime_data (surface);
 1638|       |
 1639|    156|    return __cairo_surface_flush (surface, flags);
 1640|    156|}
_cairo_surface_acquire_source_image:
 2043|     51|{
 2044|     51|    cairo_status_t status;
 2045|       |
 2046|     51|    if (unlikely (surface->status))
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
 2047|      0|	return surface->status;
 2048|       |
 2049|     51|    assert (!surface->finished);
  ------------------
  |  Branch (2049:5): [True: 0, False: 51]
  |  Branch (2049:5): [True: 51, False: 0]
  ------------------
 2050|       |
 2051|     51|    if (surface->backend->acquire_source_image == NULL)
  ------------------
  |  Branch (2051:9): [True: 0, False: 51]
  ------------------
 2052|      0|	return CAIRO_INT_STATUS_UNSUPPORTED;
 2053|       |
 2054|     51|    status = surface->backend->acquire_source_image (surface,
 2055|     51|						     image_out, image_extra);
 2056|     51|    if (unlikely (status))
  ------------------
  |  |  145|     51|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 51]
  |  |  ------------------
  ------------------
 2057|      0|	return _cairo_surface_set_error (surface, status);
 2058|       |
 2059|     51|    _cairo_debug_check_image_surface_is_defined (&(*image_out)->base);
 2060|       |
 2061|     51|    return CAIRO_STATUS_SUCCESS;
 2062|     51|}
_cairo_surface_release_source_image:
 2091|     51|{
 2092|     51|    assert (!surface->finished);
  ------------------
  |  Branch (2092:5): [True: 0, False: 51]
  |  Branch (2092:5): [True: 51, False: 0]
  ------------------
 2093|       |
 2094|     51|    if (surface->backend->release_source_image)
  ------------------
  |  Branch (2094:9): [True: 51, False: 0]
  ------------------
 2095|     51|	surface->backend->release_source_image (surface, image, image_extra);
 2096|     51|}
_cairo_surface_create_in_error:
 3106|    360|{
 3107|    360|    assert (status < CAIRO_STATUS_LAST_STATUS);
  ------------------
  |  Branch (3107:5): [True: 0, False: 360]
  |  Branch (3107:5): [True: 360, False: 0]
  ------------------
 3108|    360|    switch (status) {
 3109|     10|    case CAIRO_STATUS_NO_MEMORY:
  ------------------
  |  Branch (3109:5): [True: 10, False: 350]
  ------------------
 3110|     10|	return (cairo_surface_t *) &_cairo_surface_nil;
 3111|      0|    case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
  ------------------
  |  Branch (3111:5): [True: 0, False: 360]
  ------------------
 3112|      0|	return (cairo_surface_t *) &_cairo_surface_nil_surface_type_mismatch;
 3113|      0|    case CAIRO_STATUS_INVALID_STATUS:
  ------------------
  |  Branch (3113:5): [True: 0, False: 360]
  ------------------
 3114|      0|	return (cairo_surface_t *) &_cairo_surface_nil_invalid_status;
 3115|      0|    case CAIRO_STATUS_INVALID_CONTENT:
  ------------------
  |  Branch (3115:5): [True: 0, False: 360]
  ------------------
 3116|      0|	return (cairo_surface_t *) &_cairo_surface_nil_invalid_content;
 3117|      0|    case CAIRO_STATUS_INVALID_FORMAT:
  ------------------
  |  Branch (3117:5): [True: 0, False: 360]
  ------------------
 3118|      0|	return (cairo_surface_t *) &_cairo_surface_nil_invalid_format;
 3119|      0|    case CAIRO_STATUS_INVALID_VISUAL:
  ------------------
  |  Branch (3119:5): [True: 0, False: 360]
  ------------------
 3120|      0|	return (cairo_surface_t *) &_cairo_surface_nil_invalid_visual;
 3121|    209|    case CAIRO_STATUS_READ_ERROR:
  ------------------
  |  Branch (3121:5): [True: 209, False: 151]
  ------------------
 3122|    209|	return (cairo_surface_t *) &_cairo_surface_nil_read_error;
 3123|      0|    case CAIRO_STATUS_WRITE_ERROR:
  ------------------
  |  Branch (3123:5): [True: 0, False: 360]
  ------------------
 3124|      0|	return (cairo_surface_t *) &_cairo_surface_nil_write_error;
 3125|      0|    case CAIRO_STATUS_FILE_NOT_FOUND:
  ------------------
  |  Branch (3125:5): [True: 0, False: 360]
  ------------------
 3126|      0|	return (cairo_surface_t *) &_cairo_surface_nil_file_not_found;
 3127|      0|    case CAIRO_STATUS_TEMP_FILE_ERROR:
  ------------------
  |  Branch (3127:5): [True: 0, False: 360]
  ------------------
 3128|      0|	return (cairo_surface_t *) &_cairo_surface_nil_temp_file_error;
 3129|     44|    case CAIRO_STATUS_INVALID_STRIDE:
  ------------------
  |  Branch (3129:5): [True: 44, False: 316]
  ------------------
 3130|     44|	return (cairo_surface_t *) &_cairo_surface_nil_invalid_stride;
 3131|      1|    case CAIRO_STATUS_INVALID_SIZE:
  ------------------
  |  Branch (3131:5): [True: 1, False: 359]
  ------------------
 3132|      1|	return (cairo_surface_t *) &_cairo_surface_nil_invalid_size;
 3133|      0|    case CAIRO_STATUS_DEVICE_TYPE_MISMATCH:
  ------------------
  |  Branch (3133:5): [True: 0, False: 360]
  ------------------
 3134|      0|	return (cairo_surface_t *) &_cairo_surface_nil_device_type_mismatch;
 3135|      0|    case CAIRO_STATUS_DEVICE_ERROR:
  ------------------
  |  Branch (3135:5): [True: 0, False: 360]
  ------------------
 3136|      0|	return (cairo_surface_t *) &_cairo_surface_nil_device_error;
 3137|     96|    case CAIRO_STATUS_PNG_ERROR:
  ------------------
  |  Branch (3137:5): [True: 96, False: 264]
  ------------------
 3138|     96|	return (cairo_surface_t *) &_cairo_surface_nil_png_error;
 3139|      0|    case CAIRO_STATUS_SUCCESS:
  ------------------
  |  Branch (3139:5): [True: 0, False: 360]
  ------------------
 3140|      0|    case CAIRO_STATUS_LAST_STATUS:
  ------------------
  |  Branch (3140:5): [True: 0, False: 360]
  ------------------
 3141|      0|	ASSERT_NOT_REACHED;
  ------------------
  |  |  140|      0|#define ASSERT_NOT_REACHED		\
  |  |  141|      0|do {					\
  |  |  142|      0|    assert (!"reached");		\
  |  |  143|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (143:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (3141:2): [Folded, False: 0]
  |  Branch (3141:2): [Folded, False: 0]
  ------------------
 3142|       |	/* fall-through */
 3143|      0|    case CAIRO_STATUS_INVALID_RESTORE:
  ------------------
  |  Branch (3143:5): [True: 0, False: 360]
  ------------------
 3144|      0|    case CAIRO_STATUS_INVALID_POP_GROUP:
  ------------------
  |  Branch (3144:5): [True: 0, False: 360]
  ------------------
 3145|      0|    case CAIRO_STATUS_NO_CURRENT_POINT:
  ------------------
  |  Branch (3145:5): [True: 0, False: 360]
  ------------------
 3146|      0|    case CAIRO_STATUS_INVALID_MATRIX:
  ------------------
  |  Branch (3146:5): [True: 0, False: 360]
  ------------------
 3147|      0|    case CAIRO_STATUS_NULL_POINTER:
  ------------------
  |  Branch (3147:5): [True: 0, False: 360]
  ------------------
 3148|      0|    case CAIRO_STATUS_INVALID_STRING:
  ------------------
  |  Branch (3148:5): [True: 0, False: 360]
  ------------------
 3149|      0|    case CAIRO_STATUS_INVALID_PATH_DATA:
  ------------------
  |  Branch (3149:5): [True: 0, False: 360]
  ------------------
 3150|      0|    case CAIRO_STATUS_SURFACE_FINISHED:
  ------------------
  |  Branch (3150:5): [True: 0, False: 360]
  ------------------
 3151|      0|    case CAIRO_STATUS_PATTERN_TYPE_MISMATCH:
  ------------------
  |  Branch (3151:5): [True: 0, False: 360]
  ------------------
 3152|      0|    case CAIRO_STATUS_INVALID_DASH:
  ------------------
  |  Branch (3152:5): [True: 0, False: 360]
  ------------------
 3153|      0|    case CAIRO_STATUS_INVALID_DSC_COMMENT:
  ------------------
  |  Branch (3153:5): [True: 0, False: 360]
  ------------------
 3154|      0|    case CAIRO_STATUS_INVALID_INDEX:
  ------------------
  |  Branch (3154:5): [True: 0, False: 360]
  ------------------
 3155|      0|    case CAIRO_STATUS_CLIP_NOT_REPRESENTABLE:
  ------------------
  |  Branch (3155:5): [True: 0, False: 360]
  ------------------
 3156|      0|    case CAIRO_STATUS_FONT_TYPE_MISMATCH:
  ------------------
  |  Branch (3156:5): [True: 0, False: 360]
  ------------------
 3157|      0|    case CAIRO_STATUS_USER_FONT_IMMUTABLE:
  ------------------
  |  Branch (3157:5): [True: 0, False: 360]
  ------------------
 3158|      0|    case CAIRO_STATUS_USER_FONT_ERROR:
  ------------------
  |  Branch (3158:5): [True: 0, False: 360]
  ------------------
 3159|      0|    case CAIRO_STATUS_NEGATIVE_COUNT:
  ------------------
  |  Branch (3159:5): [True: 0, False: 360]
  ------------------
 3160|      0|    case CAIRO_STATUS_INVALID_CLUSTERS:
  ------------------
  |  Branch (3160:5): [True: 0, False: 360]
  ------------------
 3161|      0|    case CAIRO_STATUS_INVALID_SLANT:
  ------------------
  |  Branch (3161:5): [True: 0, False: 360]
  ------------------
 3162|      0|    case CAIRO_STATUS_INVALID_WEIGHT:
  ------------------
  |  Branch (3162:5): [True: 0, False: 360]
  ------------------
 3163|      0|    case CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED:
  ------------------
  |  Branch (3163:5): [True: 0, False: 360]
  ------------------
 3164|      0|    case CAIRO_STATUS_INVALID_MESH_CONSTRUCTION:
  ------------------
  |  Branch (3164:5): [True: 0, False: 360]
  ------------------
 3165|      0|    case CAIRO_STATUS_DEVICE_FINISHED:
  ------------------
  |  Branch (3165:5): [True: 0, False: 360]
  ------------------
 3166|      0|    case CAIRO_STATUS_JBIG2_GLOBAL_MISSING:
  ------------------
  |  Branch (3166:5): [True: 0, False: 360]
  ------------------
 3167|      0|    case CAIRO_STATUS_FREETYPE_ERROR:
  ------------------
  |  Branch (3167:5): [True: 0, False: 360]
  ------------------
 3168|      0|    case CAIRO_STATUS_WIN32_GDI_ERROR:
  ------------------
  |  Branch (3168:5): [True: 0, False: 360]
  ------------------
 3169|      0|    case CAIRO_INT_STATUS_DWRITE_ERROR:
  ------------------
  |  Branch (3169:5): [True: 0, False: 360]
  ------------------
 3170|      0|    case CAIRO_STATUS_TAG_ERROR:
  ------------------
  |  Branch (3170:5): [True: 0, False: 360]
  ------------------
 3171|      0|    case CAIRO_STATUS_SVG_FONT_ERROR:
  ------------------
  |  Branch (3171:5): [True: 0, False: 360]
  ------------------
 3172|      0|    default:
  ------------------
  |  Branch (3172:5): [True: 0, False: 360]
  ------------------
 3173|      0|	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
  ------------------
  |  |  126|      0|#define _cairo_error_throw(status) do { \
  |  |  127|      0|    cairo_status_t status__ = _cairo_error (status); \
  |  |  128|      0|    (void) status__; \
  |  |  129|      0|} while (0)
  |  |  ------------------
  |  |  |  Branch (129:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
 3174|      0|	return (cairo_surface_t *) &_cairo_surface_nil;
 3175|    360|    }
 3176|    360|}
cairo-surface.c:_cairo_surface_allocate_unique_id:
  272|    156|{
  273|    156|    static cairo_atomic_int_t unique_id;
  274|       |
  275|       |#if CAIRO_NO_MUTEX
  276|       |    if (++unique_id == 0)
  277|       |	unique_id = 1;
  278|       |    return unique_id;
  279|       |#else
  280|    156|    int old, id;
  281|       |
  282|    156|    do {
  283|    156|	old = _cairo_atomic_uint_get (&unique_id);
  ------------------
  |  |  473|    156|#define _cairo_atomic_uint_get(x) _cairo_atomic_int_get(x)
  ------------------
  284|    156|	id = old + 1;
  285|    156|	if (id == 0)
  ------------------
  |  Branch (285:6): [True: 0, False: 156]
  ------------------
  286|      0|	    id = 1;
  287|    156|    } while (! _cairo_atomic_uint_cmpxchg (&unique_id, old, id));
  ------------------
  |  |  475|    156|    _cairo_atomic_int_cmpxchg((cairo_atomic_int_t *)x, oldv, newv)
  |  |  ------------------
  |  |  |  |   98|    156|  _cairo_atomic_int_cmpxchg_impl(x, oldv, newv)
  |  |  ------------------
  ------------------
  |  Branch (287:14): [True: 0, False: 156]
  ------------------
  288|       |
  289|    156|    return id;
  290|    156|#endif
  291|    156|}
cairo-surface.c:_cairo_surface_has_snapshots:
  316|    468|{
  317|    468|    return ! cairo_list_is_empty (&surface->snapshots);
  318|    468|}
cairo-surface.c:_cairo_surface_finish_snapshots:
 1027|    156|{
 1028|    156|    cairo_status_t status;
 1029|       |
 1030|       |    /* update the snapshots *before* we declare the surface as finished */
 1031|    156|    surface->_finishing = TRUE;
  ------------------
  |  |  106|    156|#define TRUE 1
  ------------------
 1032|    156|    status = _cairo_surface_flush (surface, 0);
 1033|    156|    (void) status;
 1034|    156|}
cairo-surface.c:_cairo_surface_finish:
 1038|    156|{
 1039|    156|    cairo_status_t status;
 1040|       |
 1041|       |    /* call finish even if in error mode */
 1042|    156|    if (surface->backend->finish) {
  ------------------
  |  Branch (1042:9): [True: 156, False: 0]
  ------------------
 1043|    156|	status = surface->backend->finish (surface);
 1044|    156|	if (unlikely (status))
  ------------------
  |  |  145|    156|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 156]
  |  |  ------------------
  ------------------
 1045|      0|	    _cairo_surface_set_error (surface, status);
 1046|    156|    }
 1047|       |
 1048|    156|    surface->finished = TRUE;
  ------------------
  |  |  106|    156|#define TRUE 1
  ------------------
 1049|       |
 1050|    156|    assert (surface->snapshot_of == NULL);
  ------------------
  |  Branch (1050:5): [True: 0, False: 156]
  |  Branch (1050:5): [True: 156, False: 0]
  ------------------
 1051|    156|    assert (!_cairo_surface_has_snapshots (surface));
  ------------------
  |  Branch (1051:5): [True: 0, False: 156]
  |  Branch (1051:5): [True: 156, False: 0]
  ------------------
 1052|    156|}
cairo-surface.c:_cairo_mime_data_destroy:
 1226|    105|{
 1227|    105|    cairo_mime_data_t *mime_data = ptr;
 1228|       |
 1229|    105|    if (! _cairo_reference_count_dec_and_test (&mime_data->ref_count))
  ------------------
  |  |   49|    105|#define _cairo_reference_count_dec_and_test(RC) _cairo_atomic_int_dec_and_test (&(RC)->ref_count)
  |  |  ------------------
  |  |  |  |   85|    105|# define _cairo_atomic_int_dec_and_test(x) (atomic_fetch_sub_explicit(x, 1, memory_order_seq_cst) == 1)
  |  |  ------------------
  ------------------
  |  Branch (1229:9): [True: 0, False: 105]
  ------------------
 1230|      0|	return;
 1231|       |
 1232|    105|    if (mime_data->destroy && mime_data->closure)
  ------------------
  |  Branch (1232:9): [True: 105, False: 0]
  |  Branch (1232:31): [True: 105, False: 0]
  ------------------
 1233|    105|	mime_data->destroy (mime_data->closure);
 1234|       |
 1235|    105|    free (mime_data);
 1236|    105|}
cairo-surface.c:_cairo_surface_detach_snapshots:
  338|    156|{
  339|    156|    while (_cairo_surface_has_snapshots (surface)) {
  ------------------
  |  Branch (339:12): [True: 0, False: 156]
  ------------------
  340|       |	_cairo_surface_detach_snapshot (cairo_list_first_entry (&surface->snapshots,
  ------------------
  |  |   54|      0|	cairo_list_entry((ptr)->next, type, member)
  |  |  ------------------
  |  |  |  |   51|      0|	cairo_container_of(ptr, type, member)
  |  |  |  |  ------------------
  |  |  |  |  |  |  130|      0|#define cairo_container_of(ptr, type, member) ({ \
  |  |  |  |  |  |  131|      0|    const __typeof__ (((type *) 0)->member) *mptr__ = (ptr); \
  |  |  |  |  |  |  132|      0|    (type *) ((char *) mptr__ - offsetof (type, member)); \
  |  |  |  |  |  |  133|      0|})
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      0|								cairo_surface_t,
  342|      0|								snapshot));
  343|      0|    }
  344|    156|}
cairo-surface.c:_cairo_surface_detach_mime_data:
  328|    156|{
  329|    156|    if (! _cairo_surface_has_mime_data (surface))
  ------------------
  |  Branch (329:9): [True: 51, False: 105]
  ------------------
  330|     51|	return;
  331|       |
  332|    105|    _cairo_user_data_array_fini (&surface->mime_data);
  333|    105|    _cairo_user_data_array_init (&surface->mime_data);
  334|    105|}
cairo-surface.c:_cairo_surface_has_mime_data:
  322|    156|{
  323|    156|    return surface->mime_data.num_elements != 0;
  324|    156|}

_cairo_traps_compositor_init:
 2343|      1|{
 2344|      1|    compositor->base.delegate = delegate;
 2345|       |
 2346|      1|    compositor->base.paint = _cairo_traps_compositor_paint;
 2347|      1|    compositor->base.mask = _cairo_traps_compositor_mask;
 2348|      1|    compositor->base.fill = _cairo_traps_compositor_fill;
 2349|      1|    compositor->base.stroke = _cairo_traps_compositor_stroke;
 2350|      1|    compositor->base.glyphs = _cairo_traps_compositor_glyphs;
 2351|      1|}

surface_write_png_fuzzer.c:fuzzer_get_tmpfile:
   29|    411|static char* fuzzer_get_tmpfile(const uint8_t* data, size_t size) {
   30|    411|    char* filename_buffer = strdup("/tmp/generate_temporary_file.XXXXXX");
   31|    411|    if (!filename_buffer) {
  ------------------
  |  Branch (31:9): [True: 0, False: 411]
  ------------------
   32|      0|        perror("Failed to allocate file name buffer.");
   33|      0|        abort();
   34|      0|    }
   35|    411|    const int file_descriptor = mkstemp(filename_buffer);
   36|    411|    if (file_descriptor < 0) {
  ------------------
  |  Branch (36:9): [True: 0, False: 411]
  ------------------
   37|      0|        perror("Failed to make temporary file.");
   38|      0|        abort();
   39|      0|    }
   40|    411|    FILE* file = fdopen(file_descriptor, "wb");
   41|    411|    if (!file) {
  ------------------
  |  Branch (41:9): [True: 0, False: 411]
  ------------------
   42|      0|        perror("Failed to open file descriptor.");
   43|      0|        close(file_descriptor);
   44|      0|        abort();
   45|      0|    }
   46|    411|    const size_t bytes_written = fwrite(data, sizeof(uint8_t), size, file);
   47|    411|    if (bytes_written < size) {
  ------------------
  |  Branch (47:9): [True: 0, False: 411]
  ------------------
   48|      0|        close(file_descriptor);
   49|      0|        fprintf(stderr, "Failed to write all bytes to file (%zu out of %zu)",
   50|      0|                bytes_written, size);
   51|      0|        abort();
   52|      0|    }
   53|    411|    fclose(file);
   54|    411|    return filename_buffer;
   55|    411|}
surface_write_png_fuzzer.c:fuzzer_release_tmpfile:
   57|    411|static void fuzzer_release_tmpfile(char* filename) {
   58|    411|    if (unlink(filename) != 0) {
  ------------------
  |  Branch (58:9): [True: 0, False: 411]
  ------------------
   59|      0|        perror("WARNING: Failed to delete temporary file.");
   60|      0|    }
   61|    411|    free(filename);
   62|    411|}

LLVMFuzzerTestOneInput:
   18|    411|int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
   19|    411|    cairo_surface_t *image;
   20|    411|    cairo_surface_t *surface;
   21|    411|    cairo_status_t status;
   22|    411|    cairo_format_t format;
   23|       |
   24|    411|    char *tmpfile = fuzzer_get_tmpfile(data, size);
   25|    411|    image = cairo_image_surface_create_from_png(tmpfile);
   26|    411|    status = cairo_surface_status (image);
   27|    411|    if (status != CAIRO_STATUS_SUCCESS) {
  ------------------
  |  Branch (27:9): [True: 306, False: 105]
  ------------------
   28|    306|        fuzzer_release_tmpfile(tmpfile);
   29|    306|        return 0;
   30|    306|    }
   31|       |
   32|    105|    format = cairo_image_surface_get_format(image);
   33|    105|    surface = cairo_image_surface_create_for_data((unsigned char*)data, format, 1, 1, size);
   34|    105|    status = cairo_surface_status (surface);
   35|    105|    if (status != CAIRO_STATUS_SUCCESS) {
  ------------------
  |  Branch (35:9): [True: 54, False: 51]
  ------------------
   36|     54|        cairo_surface_destroy(image);
   37|     54|        fuzzer_release_tmpfile(tmpfile);
   38|     54|        return 0;
   39|     54|    }
   40|     51|    cairo_surface_write_to_png(surface, tmpfile);
   41|       |
   42|     51|    cairo_surface_destroy(surface);
   43|     51|    cairo_surface_destroy(image);
   44|     51|    fuzzer_release_tmpfile(tmpfile);
   45|     51|    return 0;
   46|    105|}

