_cairo_array_init:
   59|    838|{
   60|    838|    array->size = 0;
   61|    838|    array->num_elements = 0;
   62|    838|    array->element_size = element_size;
   63|       |    array->elements = NULL;
   64|    838|}
_cairo_array_fini:
   76|    838|{
   77|    838|    free (array->elements);
   78|    838|}
_cairo_array_grow_by:
   90|  1.31M|{
   91|  1.31M|    char *new_elements;
   92|  1.31M|    unsigned int old_size = array->size;
   93|  1.31M|    unsigned int required_size = array->num_elements + additional;
   94|  1.31M|    unsigned int new_size;
   95|       |
   96|       |    /* check for integer overflow */
   97|  1.31M|    if (required_size > INT_MAX || required_size < array->num_elements)
  ------------------
  |  Branch (97:9): [True: 0, False: 1.31M]
  |  Branch (97:36): [True: 0, False: 1.31M]
  ------------------
   98|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
   99|       |
  100|  1.31M|    if (CAIRO_INJECT_FAULT ())
  ------------------
  |  |   47|  1.31M|#define CAIRO_INJECT_FAULT() 0
  |  |  ------------------
  |  |  |  Branch (47:30): [Folded, False: 1.31M]
  |  |  ------------------
  ------------------
  101|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  102|       |
  103|  1.31M|    if (required_size <= old_size)
  ------------------
  |  Branch (103:9): [True: 1.31M, False: 1.84k]
  ------------------
  104|  1.31M|	return CAIRO_STATUS_SUCCESS;
  105|       |
  106|  1.84k|    if (old_size == 0)
  ------------------
  |  Branch (106:9): [True: 531, False: 1.31k]
  ------------------
  107|    531|	new_size = 1;
  108|  1.31k|    else
  109|  1.31k|	new_size = old_size * 2;
  110|       |
  111|  3.51k|    while (new_size < required_size)
  ------------------
  |  Branch (111:12): [True: 1.67k, False: 1.84k]
  ------------------
  112|  1.67k|	new_size = new_size * 2;
  113|       |
  114|  1.84k|    array->size = new_size;
  115|  1.84k|    new_elements = _cairo_realloc_ab (array->elements,
  116|  1.84k|			              array->size, array->element_size);
  117|       |
  118|  1.84k|    if (unlikely (new_elements == NULL)) {
  ------------------
  |  |  145|  1.84k|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1.84k]
  |  |  ------------------
  ------------------
  119|      0|	array->size = old_size;
  120|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
  121|      0|    }
  122|       |
  123|  1.84k|    array->elements = new_elements;
  124|       |
  125|  1.84k|    return CAIRO_STATUS_SUCCESS;
  126|  1.84k|}
_cairo_array_index:
  168|    330|{
  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|    330|    if (index == 0 && array->num_elements == 0)
  ------------------
  |  Branch (180:9): [True: 330, False: 0]
  |  Branch (180:23): [True: 110, False: 220]
  ------------------
  181|    110|	return NULL;
  182|       |
  183|    330|    assert (index < array->num_elements);
  ------------------
  |  Branch (183:5): [True: 0, False: 220]
  |  Branch (183:5): [True: 220, False: 0]
  ------------------
  184|       |
  185|    220|    return array->elements + (size_t)index * array->element_size;
  186|    220|}
_cairo_array_append:
  266|    110|{
  267|    110|    return _cairo_array_append_multiple (array, element, 1);
  268|    110|}
_cairo_array_append_multiple:
  286|  1.31M|{
  287|  1.31M|    cairo_status_t status;
  288|  1.31M|    void *dest;
  289|       |
  290|  1.31M|    status = _cairo_array_allocate (array, num_elements, &dest);
  291|  1.31M|    if (unlikely (status))
  ------------------
  |  |  145|  1.31M|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1.31M]
  |  |  ------------------
  ------------------
  292|      0|	return status;
  293|       |
  294|  1.31M|    memcpy (dest, elements, (size_t)num_elements * array->element_size);
  295|       |
  296|  1.31M|    return CAIRO_STATUS_SUCCESS;
  297|  1.31M|}
_cairo_array_allocate:
  316|  1.31M|{
  317|  1.31M|    cairo_status_t status;
  318|       |
  319|  1.31M|    status = _cairo_array_grow_by (array, num_elements);
  320|  1.31M|    if (unlikely (status))
  ------------------
  |  |  145|  1.31M|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 1.31M]
  |  |  ------------------
  ------------------
  321|      0|	return status;
  322|       |
  323|  1.31M|    assert (array->num_elements + num_elements <= array->size);
  ------------------
  |  Branch (323:5): [True: 0, False: 1.31M]
  |  Branch (323:5): [True: 1.31M, False: 0]
  ------------------
  324|       |
  325|  1.31M|    *elements = array->elements + (size_t)array->num_elements * array->element_size;
  326|       |
  327|  1.31M|    array->num_elements += num_elements;
  328|       |
  329|  1.31M|    return CAIRO_STATUS_SUCCESS;
  330|  1.31M|}
_cairo_array_num_elements:
  342|    110|{
  343|    110|    return array->num_elements;
  344|    110|}
_cairo_user_data_array_init:
  372|    414|{
  373|    414|    _cairo_array_init (array, sizeof (cairo_user_data_slot_t));
  374|    414|}
_cairo_user_data_array_fini:
  385|    414|{
  386|    414|    unsigned int num_slots;
  387|       |
  388|    414|    num_slots = array->num_elements;
  389|    414|    if (num_slots) {
  ------------------
  |  Branch (389:9): [True: 110, False: 304]
  ------------------
  390|    110|	cairo_user_data_slot_t *slots;
  391|       |
  392|    110|	slots = _cairo_array_index (array, 0);
  393|    220|	while (num_slots--) {
  ------------------
  |  Branch (393:9): [True: 110, False: 110]
  ------------------
  394|    110|	    cairo_user_data_slot_t *s = &slots[num_slots];
  395|    110|	    if (s->user_data != NULL && s->destroy != NULL)
  ------------------
  |  Branch (395:10): [True: 110, False: 0]
  |  Branch (395:34): [True: 110, False: 0]
  ------------------
  396|    110|		s->destroy (s->user_data);
  397|    110|	}
  398|    110|    }
  399|       |
  400|    414|    _cairo_array_fini (array);
  401|    414|}
_cairo_user_data_array_set_data:
  457|    110|{
  458|    110|    cairo_status_t status;
  459|    110|    unsigned int i, num_slots;
  460|    110|    cairo_user_data_slot_t *slots, *slot, new_slot;
  461|       |
  462|    110|    if (user_data) {
  ------------------
  |  Branch (462:9): [True: 110, False: 0]
  ------------------
  463|    110|	new_slot.key = key;
  464|    110|	new_slot.user_data = user_data;
  465|    110|	new_slot.destroy = destroy;
  466|    110|    } else {
  467|      0|	new_slot.key = NULL;
  468|      0|	new_slot.user_data = NULL;
  469|      0|	new_slot.destroy = NULL;
  470|      0|    }
  471|       |
  472|    110|    slot = NULL;
  473|    110|    num_slots = array->num_elements;
  474|    110|    slots = _cairo_array_index (array, 0);
  475|    110|    for (i = 0; i < num_slots; i++) {
  ------------------
  |  Branch (475:17): [True: 0, False: 110]
  ------------------
  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|    110|    if (slot) {
  ------------------
  |  Branch (487:9): [True: 0, False: 110]
  ------------------
  488|      0|	*slot = new_slot;
  489|      0|	return CAIRO_STATUS_SUCCESS;
  490|      0|    }
  491|       |
  492|    110|    if (user_data == NULL)
  ------------------
  |  Branch (492:9): [True: 0, False: 110]
  ------------------
  493|      0|	return CAIRO_STATUS_SUCCESS;
  494|       |
  495|    110|    status = _cairo_array_append (array, &new_slot);
  496|    110|    if (unlikely (status))
  ------------------
  |  |  145|    110|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 110]
  |  |  ------------------
  ------------------
  497|      0|	return status;
  498|       |
  499|    110|    return CAIRO_STATUS_SUCCESS;
  500|    110|}

cairo-surface.c:_cairo_atomic_int_cmpxchg_impl:
   92|    152|{
   93|    152|    int expected = oldv;
   94|       |    return atomic_compare_exchange_strong_explicit (x, &expected, newv, memory_order_seq_cst, memory_order_seq_cst);
   95|    152|}
cairo-surface.c:_cairo_atomic_int_get:
   61|  1.14k|{
   62|       |    return atomic_load_explicit (x, memory_order_seq_cst);
   63|  1.14k|}
cairo-image-compositor.c:_cairo_atomic_init_once_enter:
  541|    153|{
  542|    153|    if (likely(_cairo_atomic_int_get(once) == CAIRO_ATOMIC_ONCE_INITIALIZED))
  ------------------
  |  |  144|    153|#define likely(expr) (__builtin_expect (!!(expr), 1))
  |  |  ------------------
  |  |  |  Branch (144:22): [True: 151, False: 2]
  |  |  ------------------
  ------------------
  543|    151|	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|    153|{
   62|       |    return atomic_load_explicit (x, memory_order_seq_cst);
   63|    153|}
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|    152|{
  209|    152|    if (device == NULL ||
  ------------------
  |  Branch (209:9): [True: 152, 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|    152|    {
  212|    152|	return device;
  213|    152|    }
  214|       |
  215|    152|    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|    382|{
   67|    382|    CAIRO_ENSURE_UNIQUE;
  ------------------
  |  |  183|    382|#define CAIRO_ENSURE_UNIQUE    do { } while (0)
  |  |  ------------------
  |  |  |  Branch (183:46): [Folded, False: 382]
  |  |  ------------------
  ------------------
   68|    382|    assert (_cairo_status_is_error (status));
  ------------------
  |  Branch (68:5): [True: 0, False: 382]
  |  Branch (68:5): [True: 0, False: 0]
  |  Branch (68:5): [True: 382, False: 0]
  |  Branch (68:5): [True: 382, False: 0]
  ------------------
   69|       |
   70|    382|    return status;
   71|    382|}

_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|    110|{
  341|    110|    cairo_hash_entry_t *entry;
  342|    110|    unsigned long table_size, i, idx, step;
  343|    110|    uintptr_t hash = key->hash;
  344|       |
  345|    110|    entry = hash_table->cache[hash & 31];
  346|    110|    if (entry && entry->hash == hash && hash_table->keys_equal (key, entry))
  ------------------
  |  Branch (346:9): [True: 109, False: 1]
  |  Branch (346:18): [True: 109, False: 0]
  |  Branch (346:41): [True: 109, False: 0]
  ------------------
  347|    109|	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|    152|{
 3145|    152|    static cairo_atomic_once_t once = CAIRO_ATOMIC_ONCE_INIT;
  ------------------
  |  |  537|    152|#define CAIRO_ATOMIC_ONCE_INIT          CAIRO_ATOMIC_ONCE_UNINITIALIZED
  |  |  ------------------
  |  |  |  |  534|    152|#define CAIRO_ATOMIC_ONCE_UNINITIALIZED (0)
  |  |  ------------------
  ------------------
 3146|    152|    static cairo_spans_compositor_t spans;
 3147|    152|    static cairo_compositor_t shape;
 3148|       |
 3149|    152|    if (_cairo_atomic_init_once_enter(&once)) {
  ------------------
  |  Branch (3149:9): [True: 1, False: 151]
  ------------------
 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|    152|    return &spans.base;
 3177|    152|}

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

_cairo_format_from_pixman_format:
   94|    152|{
   95|    152|    switch (pixman_format) {
   96|     47|    case PIXMAN_rgba_float:
  ------------------
  |  Branch (96:5): [True: 47, False: 105]
  ------------------
   97|     47|	return CAIRO_FORMAT_RGBA128F;
   98|     32|    case PIXMAN_rgb_float:
  ------------------
  |  Branch (98:5): [True: 32, False: 120]
  ------------------
   99|     32|	return CAIRO_FORMAT_RGB96F;
  100|      9|    case PIXMAN_a8r8g8b8:
  ------------------
  |  Branch (100:5): [True: 9, False: 143]
  ------------------
  101|      9|	return CAIRO_FORMAT_ARGB32;
  102|      0|    case PIXMAN_x2r10g10b10:
  ------------------
  |  Branch (102:5): [True: 0, False: 152]
  ------------------
  103|      0|	return CAIRO_FORMAT_RGB30;
  104|     64|    case PIXMAN_x8r8g8b8:
  ------------------
  |  Branch (104:5): [True: 64, False: 88]
  ------------------
  105|     64|	return CAIRO_FORMAT_RGB24;
  106|      0|    case PIXMAN_a8:
  ------------------
  |  Branch (106:5): [True: 0, False: 152]
  ------------------
  107|      0|	return CAIRO_FORMAT_A8;
  108|      0|    case PIXMAN_a1:
  ------------------
  |  Branch (108:5): [True: 0, False: 152]
  ------------------
  109|      0|	return CAIRO_FORMAT_A1;
  110|      0|    case PIXMAN_r5g6b5:
  ------------------
  |  Branch (110:5): [True: 0, False: 152]
  ------------------
  111|      0|	return CAIRO_FORMAT_RGB16_565;
  112|      0|    case PIXMAN_r8g8b8a8: case PIXMAN_r8g8b8x8:
  ------------------
  |  Branch (112:5): [True: 0, False: 152]
  |  Branch (112:27): [True: 0, False: 152]
  ------------------
  113|      0|    case PIXMAN_a8r8g8b8_sRGB:
  ------------------
  |  Branch (113:5): [True: 0, False: 152]
  ------------------
  114|      0|#if HAS_PIXMAN_r8g8b8_sRGB
  115|      0|    case PIXMAN_r8g8b8_sRGB:
  ------------------
  |  Branch (115:5): [True: 0, False: 152]
  ------------------
  116|      0|#endif
  117|      0|    case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8:
  ------------------
  |  Branch (117:5): [True: 0, False: 152]
  |  Branch (117:27): [True: 0, False: 152]
  |  Branch (117:49): [True: 0, False: 152]
  ------------------
  118|      0|    case PIXMAN_b8g8r8:   case PIXMAN_b5g6r5:
  ------------------
  |  Branch (118:5): [True: 0, False: 152]
  |  Branch (118:27): [True: 0, False: 152]
  ------------------
  119|      0|    case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5:
  ------------------
  |  Branch (119:5): [True: 0, False: 152]
  |  Branch (119:27): [True: 0, False: 152]
  |  Branch (119:49): [True: 0, False: 152]
  ------------------
  120|      0|    case PIXMAN_x1b5g5r5: case PIXMAN_a4r4g4b4: case PIXMAN_x4r4g4b4:
  ------------------
  |  Branch (120:5): [True: 0, False: 152]
  |  Branch (120:27): [True: 0, False: 152]
  |  Branch (120:49): [True: 0, False: 152]
  ------------------
  121|      0|    case PIXMAN_a4b4g4r4: case PIXMAN_x4b4g4r4: case PIXMAN_r3g3b2:
  ------------------
  |  Branch (121:5): [True: 0, False: 152]
  |  Branch (121:27): [True: 0, False: 152]
  |  Branch (121:49): [True: 0, False: 152]
  ------------------
  122|      0|    case PIXMAN_b2g3r3:   case PIXMAN_a2r2g2b2: case PIXMAN_a2b2g2r2:
  ------------------
  |  Branch (122:5): [True: 0, False: 152]
  |  Branch (122:27): [True: 0, False: 152]
  |  Branch (122:49): [True: 0, False: 152]
  ------------------
  123|      0|    case PIXMAN_c8:       case PIXMAN_g8:       case PIXMAN_x4a4:
  ------------------
  |  Branch (123:5): [True: 0, False: 152]
  |  Branch (123:27): [True: 0, False: 152]
  |  Branch (123:49): [True: 0, False: 152]
  ------------------
  124|      0|    case PIXMAN_a4:       case PIXMAN_r1g2b1:   case PIXMAN_b1g2r1:
  ------------------
  |  Branch (124:5): [True: 0, False: 152]
  |  Branch (124:27): [True: 0, False: 152]
  |  Branch (124:49): [True: 0, False: 152]
  ------------------
  125|      0|    case PIXMAN_a1r1g1b1: case PIXMAN_a1b1g1r1: case PIXMAN_c4:
  ------------------
  |  Branch (125:5): [True: 0, False: 152]
  |  Branch (125:27): [True: 0, False: 152]
  |  Branch (125:49): [True: 0, False: 152]
  ------------------
  126|      0|    case PIXMAN_g4:       case PIXMAN_g1:
  ------------------
  |  Branch (126:5): [True: 0, False: 152]
  |  Branch (126:27): [True: 0, False: 152]
  ------------------
  127|      0|    case PIXMAN_yuy2:     case PIXMAN_yv12:
  ------------------
  |  Branch (127:5): [True: 0, False: 152]
  |  Branch (127:27): [True: 0, False: 152]
  ------------------
  128|      0|    case PIXMAN_b8g8r8x8:
  ------------------
  |  Branch (128:5): [True: 0, False: 152]
  ------------------
  129|      0|    case PIXMAN_b8g8r8a8:
  ------------------
  |  Branch (129:5): [True: 0, False: 152]
  ------------------
  130|      0|    case PIXMAN_a2b10g10r10:
  ------------------
  |  Branch (130:5): [True: 0, False: 152]
  ------------------
  131|      0|    case PIXMAN_x2b10g10r10:
  ------------------
  |  Branch (131:5): [True: 0, False: 152]
  ------------------
  132|      0|    case PIXMAN_a2r10g10b10:
  ------------------
  |  Branch (132:5): [True: 0, False: 152]
  ------------------
  133|      0|    case PIXMAN_x14r6g6b6:
  ------------------
  |  Branch (133:5): [True: 0, False: 152]
  ------------------
  134|      0|    default:
  ------------------
  |  Branch (134:5): [True: 0, False: 152]
  ------------------
  135|      0|	return CAIRO_FORMAT_INVALID;
  136|    152|    }
  137|       |
  138|      0|    return CAIRO_FORMAT_INVALID;
  139|    152|}
_cairo_content_from_pixman_format:
  143|    152|{
  144|    152|    cairo_content_t content;
  145|       |
  146|    152|    content = 0;
  147|    152|    if (PIXMAN_FORMAT_RGB (pixman_format))
  ------------------
  |  |  850|    152|#define PIXMAN_FORMAT_RGB(f)	(((f)      ) & 0xfff)
  |  |  ------------------
  |  |  |  Branch (850:30): [True: 152, False: 0]
  |  |  ------------------
  ------------------
  148|    152|	content |= CAIRO_CONTENT_COLOR;
  149|    152|    if (PIXMAN_FORMAT_A (pixman_format))
  ------------------
  |  |  846|    152|#define PIXMAN_FORMAT_A(f)	PIXMAN_FORMAT_RESHIFT(f, 12, 4)
  |  |  ------------------
  |  |  |  |  841|    152|	(((val >> (ofs)) & ((1 << (num)) - 1)) << ((val >> 22) & 3))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (841:2): [True: 56, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|     56|	content |= CAIRO_CONTENT_ALPHA;
  151|       |
  152|    152|    return content;
  153|    152|}
_cairo_image_surface_init:
  159|    152|{
  160|    152|    surface->parent = NULL;
  161|    152|    surface->pixman_image = pixman_image;
  162|       |
  163|    152|    surface->pixman_format = pixman_format;
  164|    152|    surface->format = _cairo_format_from_pixman_format (pixman_format);
  165|    152|    surface->data = (uint8_t *) pixman_image_get_data (pixman_image);
  166|    152|    surface->owns_data = FALSE;
  ------------------
  |  |  102|    152|#define FALSE 0
  ------------------
  167|    152|    surface->transparency = CAIRO_IMAGE_UNKNOWN;
  168|    152|    surface->color = CAIRO_IMAGE_UNKNOWN_COLOR;
  169|       |
  170|    152|    surface->width = pixman_image_get_width (pixman_image);
  171|    152|    surface->height = pixman_image_get_height (pixman_image);
  172|    152|    surface->stride = pixman_image_get_stride (pixman_image);
  173|    152|    surface->depth = pixman_image_get_depth (pixman_image);
  174|       |
  175|    152|    surface->base.is_clear = surface->width == 0 || surface->height == 0;
  ------------------
  |  Branch (175:30): [True: 0, False: 152]
  |  Branch (175:53): [True: 0, False: 152]
  ------------------
  176|       |
  177|    152|    surface->compositor = _cairo_image_spans_compositor_get ();
  178|    152|}
_cairo_image_surface_create_for_pixman_image:
  183|    152|{
  184|    152|    cairo_image_surface_t *surface;
  185|       |
  186|    152|    surface = _cairo_calloc (sizeof (cairo_image_surface_t));
  ------------------
  |  |   79|    152|    ((size) != 0 ? calloc(1,size) : NULL)
  |  |  ------------------
  |  |  |  Branch (79:6): [True: 152, Folded]
  |  |  ------------------
  ------------------
  187|    152|    if (unlikely (surface == NULL))
  ------------------
  |  |  145|    152|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 152]
  |  |  ------------------
  ------------------
  188|      0|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  189|       |
  190|    152|    _cairo_surface_init (&surface->base,
  191|    152|			 &_cairo_image_surface_backend,
  192|    152|			 NULL, /* device */
  193|    152|			 _cairo_content_from_pixman_format (pixman_format),
  194|    152|			 FALSE); /* is_vector */
  ------------------
  |  |  102|    152|#define FALSE 0
  ------------------
  195|       |
  196|    152|    _cairo_image_surface_init (surface, pixman_image, pixman_format);
  197|       |
  198|    152|    return &surface->base;
  199|    152|}
_cairo_format_to_pixman_format_code:
  326|    171|{
  327|    171|    pixman_format_code_t ret;
  328|    171|    switch (format) {
  329|      0|    case CAIRO_FORMAT_A1:
  ------------------
  |  Branch (329:5): [True: 0, False: 171]
  ------------------
  330|      0|	ret = PIXMAN_a1;
  331|      0|	break;
  332|      0|    case CAIRO_FORMAT_A8:
  ------------------
  |  Branch (332:5): [True: 0, False: 171]
  ------------------
  333|      0|	ret = PIXMAN_a8;
  334|      0|	break;
  335|     64|    case CAIRO_FORMAT_RGB24:
  ------------------
  |  Branch (335:5): [True: 64, False: 107]
  ------------------
  336|     64|	ret = PIXMAN_x8r8g8b8;
  337|     64|	break;
  338|      0|    case CAIRO_FORMAT_RGB30:
  ------------------
  |  Branch (338:5): [True: 0, False: 171]
  ------------------
  339|      0|	ret = PIXMAN_x2r10g10b10;
  340|      0|	break;
  341|      0|    case CAIRO_FORMAT_RGB16_565:
  ------------------
  |  Branch (341:5): [True: 0, False: 171]
  ------------------
  342|      0|	ret = PIXMAN_r5g6b5;
  343|      0|	break;
  344|     32|    case CAIRO_FORMAT_RGB96F:
  ------------------
  |  Branch (344:5): [True: 32, False: 139]
  ------------------
  345|     32|	ret = PIXMAN_rgb_float;
  346|     32|	break;
  347|     66|    case CAIRO_FORMAT_RGBA128F:
  ------------------
  |  Branch (347:5): [True: 66, False: 105]
  ------------------
  348|     66|	ret = PIXMAN_rgba_float;
  349|     66|	break;
  350|      9|    case CAIRO_FORMAT_ARGB32:
  ------------------
  |  Branch (350:5): [True: 9, False: 162]
  ------------------
  351|      9|    case CAIRO_FORMAT_INVALID:
  ------------------
  |  Branch (351:5): [True: 0, False: 171]
  ------------------
  352|      9|    default:
  ------------------
  |  Branch (352:5): [True: 0, False: 171]
  ------------------
  353|      9|	ret = PIXMAN_a8r8g8b8;
  354|      9|	break;
  355|    171|    }
  356|    171|    return ret;
  357|    171|}
_cairo_image_surface_create_with_pixman_format:
  365|    171|{
  366|    171|    cairo_surface_t *surface;
  367|    171|    pixman_image_t *pixman_image;
  368|       |
  369|    171|    if (! _cairo_image_surface_is_size_valid (width, height))
  ------------------
  |  Branch (369:9): [True: 0, False: 171]
  ------------------
  370|      0|    {
  371|      0|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
  372|      0|    }
  373|       |
  374|    171|    pixman_image = pixman_image_create_bits (pixman_format, width, height,
  375|    171|					     (uint32_t *) data, stride);
  376|       |
  377|    171|    if (unlikely (pixman_image == NULL))
  ------------------
  |  |  145|    171|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 19, False: 152]
  |  |  ------------------
  ------------------
  378|     19|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  379|       |
  380|    152|    surface = _cairo_image_surface_create_for_pixman_image (pixman_image,
  381|    152|							    pixman_format);
  382|    152|    if (unlikely (surface->status)) {
  ------------------
  |  |  145|    152|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 152]
  |  |  ------------------
  ------------------
  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|    152|    surface->is_clear = data == NULL;
  389|    152|    return surface;
  390|    152|}
cairo_format_stride_for_width:
  469|    394|{
  470|    394|    int bpp;
  471|       |
  472|    394|    if (! CAIRO_FORMAT_VALID (format)) {
  ------------------
  |  | 1556|    394|#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&		\
  |  |  ------------------
  |  |  |  Branch (1556:37): [True: 394, False: 0]
  |  |  ------------------
  |  | 1557|    394|                                    (format) <= CAIRO_FORMAT_RGBA128F)
  |  |  ------------------
  |  |  |  Branch (1557:37): [True: 394, 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|    394|    bpp = _cairo_format_bits_per_pixel (format);
  478|    394|    if ((unsigned) (width) >= (INT32_MAX - 7) / (unsigned) (bpp))
  ------------------
  |  Branch (478:9): [True: 0, False: 394]
  ------------------
  479|      0|	return -1;
  480|       |
  481|    394|    return CAIRO_STRIDE_FOR_WIDTH_BPP (width, bpp);
  ------------------
  |  | 1562|    394|   ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
  |  |  ------------------
  |  |  |  | 1560|    394|#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  |  |  ------------------
  |  |                  ((((bpp)*(w)+7)/8 + CAIRO_STRIDE_ALIGNMENT-1) & -CAIRO_STRIDE_ALIGNMENT)
  |  |  ------------------
  |  |  |  | 1560|    394|#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  |  |  ------------------
  ------------------
  482|    394|}
cairo_image_surface_create_for_data:
  535|    223|{
  536|    223|    pixman_format_code_t pixman_format;
  537|    223|    int minstride;
  538|       |
  539|    223|    if (! CAIRO_FORMAT_VALID (format))
  ------------------
  |  | 1556|    223|#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 &&		\
  |  |  ------------------
  |  |  |  Branch (1556:37): [True: 223, False: 0]
  |  |  ------------------
  |  | 1557|    223|                                    (format) <= CAIRO_FORMAT_RGBA128F)
  |  |  ------------------
  |  |  |  Branch (1557:37): [True: 223, False: 0]
  |  |  ------------------
  ------------------
  540|      0|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
  541|       |
  542|    223|    if ((stride & (CAIRO_STRIDE_ALIGNMENT-1)) != 0)
  ------------------
  |  | 1560|    223|#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))
  ------------------
  |  Branch (542:9): [True: 49, False: 174]
  ------------------
  543|     49|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  544|       |
  545|    174|    if (! _cairo_image_surface_is_size_valid (width, height))
  ------------------
  |  Branch (545:9): [True: 3, False: 171]
  ------------------
  546|      3|	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
  547|       |
  548|    171|    minstride = cairo_format_stride_for_width (format, width);
  549|    171|    if (stride < 0) {
  ------------------
  |  Branch (549:9): [True: 0, False: 171]
  ------------------
  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|    171|    } else {
  554|    171|	if (stride < minstride) {
  ------------------
  |  Branch (554:6): [True: 0, False: 171]
  ------------------
  555|      0|	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  556|      0|	}
  557|    171|    }
  558|       |
  559|    171|    pixman_format = _cairo_format_to_pixman_format_code (format);
  560|    171|    return _cairo_image_surface_create_with_pixman_format (data,
  561|    171|							   pixman_format,
  562|    171|							   width, height,
  563|    171|							   stride);
  564|    171|}
cairo_image_surface_get_format:
  609|    110|{
  610|    110|    cairo_image_surface_t *image_surface = (cairo_image_surface_t *) surface;
  611|       |
  612|    110|    if (! _cairo_surface_is_image (surface)) {
  ------------------
  |  Branch (612:9): [True: 0, False: 110]
  ------------------
  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|    110|    return image_surface->format;
  618|    110|}
_cairo_format_from_content:
  695|     27|{
  696|     27|    switch (content) {
  ------------------
  |  Branch (696:13): [True: 27, False: 0]
  ------------------
  697|     24|    case CAIRO_CONTENT_COLOR:
  ------------------
  |  Branch (697:5): [True: 24, False: 3]
  ------------------
  698|     24|	return CAIRO_FORMAT_RGB24;
  699|      0|    case CAIRO_CONTENT_ALPHA:
  ------------------
  |  Branch (699:5): [True: 0, False: 27]
  ------------------
  700|      0|	return CAIRO_FORMAT_A8;
  701|      3|    case CAIRO_CONTENT_COLOR_ALPHA:
  ------------------
  |  Branch (701:5): [True: 3, False: 24]
  ------------------
  702|      3|	return CAIRO_FORMAT_ARGB32;
  703|     27|    }
  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|    394|{
  737|    394|    switch (format) {
  738|    111|    case CAIRO_FORMAT_RGBA128F:
  ------------------
  |  Branch (738:5): [True: 111, False: 283]
  ------------------
  739|    111|	return 128;
  740|     67|    case CAIRO_FORMAT_RGB96F:
  ------------------
  |  Branch (740:5): [True: 67, False: 327]
  ------------------
  741|     67|	return 96;
  742|     65|    case CAIRO_FORMAT_ARGB32:
  ------------------
  |  Branch (742:5): [True: 65, False: 329]
  ------------------
  743|     65|    case CAIRO_FORMAT_RGB30:
  ------------------
  |  Branch (743:5): [True: 0, False: 394]
  ------------------
  744|    216|    case CAIRO_FORMAT_RGB24:
  ------------------
  |  Branch (744:5): [True: 151, False: 243]
  ------------------
  745|    216|	return 32;
  746|      0|    case CAIRO_FORMAT_RGB16_565:
  ------------------
  |  Branch (746:5): [True: 0, False: 394]
  ------------------
  747|      0|	return 16;
  748|      0|    case CAIRO_FORMAT_A8:
  ------------------
  |  Branch (748:5): [True: 0, False: 394]
  ------------------
  749|      0|	return 8;
  750|      0|    case CAIRO_FORMAT_A1:
  ------------------
  |  Branch (750:5): [True: 0, False: 394]
  ------------------
  751|      0|	return 1;
  752|      0|    case CAIRO_FORMAT_INVALID:
  ------------------
  |  Branch (752:5): [True: 0, False: 394]
  ------------------
  753|      0|    default:
  ------------------
  |  Branch (753:5): [True: 0, False: 394]
  ------------------
  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|    394|    }
  757|    394|}
_cairo_image_surface_finish:
  865|    152|{
  866|    152|    cairo_image_surface_t *surface = abstract_surface;
  867|       |
  868|    152|    if (surface->pixman_image) {
  ------------------
  |  Branch (868:9): [True: 152, False: 0]
  ------------------
  869|    152|	pixman_image_unref (surface->pixman_image);
  870|    152|	surface->pixman_image = NULL;
  871|    152|    }
  872|       |
  873|    152|    if (surface->owns_data) {
  ------------------
  |  Branch (873:9): [True: 110, False: 42]
  ------------------
  874|    110|	free (surface->data);
  875|    110|	surface->data = NULL;
  876|    110|    }
  877|       |
  878|    152|    if (surface->parent) {
  ------------------
  |  Branch (878:9): [True: 0, False: 152]
  ------------------
  879|      0|	cairo_surface_t *parent = surface->parent;
  880|      0|	surface->parent = NULL;
  881|      0|	cairo_surface_destroy (parent);
  882|      0|    }
  883|       |
  884|    152|    return CAIRO_STATUS_SUCCESS;
  885|    152|}
_cairo_image_surface_assume_ownership_of_data:
  889|    110|{
  890|    110|    surface->owns_data = TRUE;
  ------------------
  |  |  106|    110|#define TRUE 1
  ------------------
  891|    110|}
_cairo_image_surface_acquire_source_image:
  912|     42|{
  913|     42|    *image_out = abstract_surface;
  914|     42|    *image_extra = NULL;
  915|       |
  916|     42|    return CAIRO_STATUS_SUCCESS;
  917|     42|}
_cairo_image_surface_release_source_image:
  923|     42|{
  924|     42|}
_cairo_image_surface_coerce:
 1085|     27|{
 1086|     27|    return _cairo_image_surface_coerce_to_format (surface,
 1087|     27|		                                  _cairo_format_from_content (surface->base.content));
 1088|     27|}
_cairo_image_surface_coerce_to_format:
 1095|     27|{
 1096|     27|    cairo_image_surface_t *clone;
 1097|     27|    cairo_status_t status;
 1098|       |
 1099|     27|    status = surface->base.status;
 1100|     27|    if (unlikely (status))
  ------------------
  |  |  145|     27|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 27]
  |  |  ------------------
  ------------------
 1101|      0|	return (cairo_image_surface_t *)_cairo_surface_create_in_error (status);
 1102|       |
 1103|     27|    if (surface->format == format)
  ------------------
  |  Branch (1103:9): [True: 27, False: 0]
  ------------------
 1104|     27|	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|      3|{
 1239|      3|    if (_cairo_surface_is_snapshot (&image->base)) {
  ------------------
  |  Branch (1239:9): [True: 0, False: 3]
  ------------------
 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|      3|    return _cairo_image_compute_transparency (image);
 1247|      3|}
cairo-image-surface.c:_cairo_image_surface_is_size_valid:
   87|    345|{
   88|    345|    return 0 <= width  &&  width <= MAX_IMAGE_SIZE &&
  ------------------
  |  |   62|    690|#define MAX_IMAGE_SIZE 32767
  ------------------
  |  Branch (88:12): [True: 345, False: 0]
  |  Branch (88:28): [True: 342, False: 3]
  ------------------
   89|    342|	   0 <= height && height <= MAX_IMAGE_SIZE;
  ------------------
  |  |   62|    342|#define MAX_IMAGE_SIZE 32767
  ------------------
  |  Branch (89:5): [True: 342, False: 0]
  |  Branch (89:20): [True: 342, False: 0]
  ------------------
   90|    345|}
cairo-image-surface.c:_cairo_image_compute_transparency:
 1184|      3|{
 1185|      3|    int x, y;
 1186|      3|    cairo_image_transparency_t transparency;
 1187|       |
 1188|      3|    if ((image->base.content & CAIRO_CONTENT_ALPHA) == 0)
  ------------------
  |  Branch (1188:9): [True: 0, False: 3]
  ------------------
 1189|      0|	return CAIRO_IMAGE_IS_OPAQUE;
 1190|       |
 1191|      3|    if (image->base.is_clear)
  ------------------
  |  Branch (1191:9): [True: 0, False: 3]
  ------------------
 1192|      0|	return CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
 1193|       |
 1194|      3|    if ((image->base.content & CAIRO_CONTENT_COLOR) == 0) {
  ------------------
  |  Branch (1194:9): [True: 0, False: 3]
  ------------------
 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|      3|    if (image->format == CAIRO_FORMAT_RGB16_565) {
  ------------------
  |  Branch (1212:9): [True: 0, False: 3]
  ------------------
 1213|      0|	return CAIRO_IMAGE_IS_OPAQUE;
 1214|      0|    }
 1215|       |
 1216|      3|    if (image->format != CAIRO_FORMAT_ARGB32)
  ------------------
  |  Branch (1216:9): [True: 0, False: 3]
  ------------------
 1217|      0|	return CAIRO_IMAGE_HAS_ALPHA;
 1218|       |
 1219|      3|    transparency = CAIRO_IMAGE_IS_OPAQUE;
 1220|      3|    for (y = 0; y < image->height; y++) {
  ------------------
  |  Branch (1220:17): [True: 3, False: 0]
  ------------------
 1221|      3|	uint32_t *pixel = (uint32_t *) (image->data + y * image->stride);
 1222|       |
 1223|      3|	for (x = 0; x < image->width; x++, pixel++) {
  ------------------
  |  Branch (1223:14): [True: 3, False: 0]
  ------------------
 1224|      3|	    int a = (*pixel & 0xff000000) >> 24;
 1225|      3|	    if (a > 0 && a < 255) {
  ------------------
  |  Branch (1225:10): [True: 3, False: 0]
  |  Branch (1225:19): [True: 3, False: 0]
  ------------------
 1226|      3|		return CAIRO_IMAGE_HAS_ALPHA;
 1227|      3|	    } else if (a == 0) {
  ------------------
  |  Branch (1227:17): [True: 0, False: 0]
  ------------------
 1228|      0|		transparency = CAIRO_IMAGE_HAS_BILEVEL_ALPHA;
 1229|      0|	    }
 1230|      3|	}
 1231|      3|    }
 1232|       |
 1233|      0|    return transparency;
 1234|      3|}

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

cairo-png.c:_cairo_malloc_ab:
  100|    503|{
  101|    503|    size_t c;
  102|    503|    if (_cairo_mul_size_t_overflow (a, size, &c))
  ------------------
  |  |  223|    503|#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: 503]
  |  |  ------------------
  ------------------
  103|      0|	return NULL;
  104|       |
  105|    503|    return _cairo_malloc(c);
  ------------------
  |  |   63|    503|   ((size) != 0 ? malloc(size) : NULL)
  |  |  ------------------
  |  |  |  Branch (63:5): [True: 503, False: 0]
  |  |  ------------------
  ------------------
  106|    503|}
cairo-array.c:_cairo_realloc_ab:
  153|  1.84k|{
  154|  1.84k|    size_t c;
  155|  1.84k|    if (_cairo_mul_size_t_overflow (a, size, &c))
  ------------------
  |  |  223|  1.84k|#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.84k]
  |  |  ------------------
  ------------------
  156|      0|	return NULL;
  157|       |
  158|  1.84k|    return realloc(ptr, c);
  159|  1.84k|}
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|    304|{
   83|    304|    cairo_matrix_init (matrix,
   84|    304|		       1, 0,
   85|    304|		       0, 1,
   86|    304|		       0, 0);
   87|    304|}
cairo_matrix_init:
  115|    304|{
  116|    304|    matrix->xx = xx; matrix->yx = yx;
  117|    304|    matrix->xy = xy; matrix->yy = yy;
  118|    304|    matrix->x0 = x0; matrix->y0 = y0;
  119|    304|}

_cairo_fopen:
  937|    466|{
  938|    466|    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|    466|#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|    466|    char new_mode[20];
  974|    466|    snprintf (new_mode, sizeof (new_mode), "%s%s", mode, "e");
  975|    466|    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|    466|#endif /* !_WIN32 */
  996|       |
  997|    466|    *file_out = result;
  998|       |
  999|    466|    return CAIRO_STATUS_SUCCESS;
 1000|    466|}
_cairo_string_hash:
 1118|    110|{
 1119|    110|    const signed char *p = (const signed char *) str;
 1120|    110|    unsigned int h = *p;
 1121|       |
 1122|  1.10k|    for (p += 1; len > 0; len--, p++)
  ------------------
  |  Branch (1122:18): [True: 990, False: 110]
  ------------------
 1123|    990|	h = (h << 5) - h + *p;
 1124|       |
 1125|    110|    return h;
 1126|    110|}
_cairo_intern_string:
 1142|    110|{
 1143|    110|    char *str = (char *) *str_inout;
 1144|    110|    cairo_intern_string_t tmpl, *istring;
 1145|    110|    cairo_status_t status = CAIRO_STATUS_SUCCESS;
 1146|       |
 1147|    110|    if (CAIRO_INJECT_FAULT ())
  ------------------
  |  |   47|    110|#define CAIRO_INJECT_FAULT() 0
  |  |  ------------------
  |  |  |  Branch (47:30): [Folded, False: 110]
  |  |  ------------------
  ------------------
 1148|      0|	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 1149|       |
 1150|    110|    if (len < 0)
  ------------------
  |  Branch (1150:9): [True: 110, False: 0]
  ------------------
 1151|    110|	len = strlen (str);
 1152|    110|    tmpl.hash_entry.hash = _cairo_string_hash (str, len);
 1153|    110|    tmpl.len = len;
 1154|    110|    tmpl.string = (char *) str;
 1155|       |
 1156|    110|    CAIRO_MUTEX_LOCK (_cairo_intern_string_mutex);
  ------------------
  |  |  175|    110|#define CAIRO_MUTEX_LOCK		CAIRO_MUTEX_IMPL_LOCK
  |  |  ------------------
  |  |  |  |  206|    110|# define CAIRO_MUTEX_IMPL_LOCK(mutex) pthread_mutex_lock (&(mutex))
  |  |  ------------------
  ------------------
 1157|    110|    if (_cairo_intern_string_ht == NULL) {
  ------------------
  |  Branch (1157:9): [True: 1, False: 109]
  ------------------
 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|    110|    istring = _cairo_hash_table_lookup (_cairo_intern_string_ht,
 1166|    110|					&tmpl.hash_entry);
 1167|    110|    if (istring == NULL) {
  ------------------
  |  Branch (1167:9): [True: 1, False: 109]
  ------------------
 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|    110|    *str_inout = istring->string;
 1189|       |
 1190|    110|  BAIL:
 1191|    110|    CAIRO_MUTEX_UNLOCK (_cairo_intern_string_mutex);
  ------------------
  |  |  177|    110|#define CAIRO_MUTEX_UNLOCK		CAIRO_MUTEX_IMPL_UNLOCK
  |  |  ------------------
  |  |  |  |  208|    110|# define CAIRO_MUTEX_IMPL_UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
  |  |  ------------------
  ------------------
 1192|    110|    return status;
 1193|    110|}
cairo-misc.c:_intern_string_equal:
 1130|    109|{
 1131|    109|    const cairo_intern_string_t *a = _a;
 1132|    109|    const cairo_intern_string_t *b = _b;
 1133|       |
 1134|    109|    if (a->len != b->len)
  ------------------
  |  Branch (1134:9): [True: 0, False: 109]
  ------------------
 1135|      0|	return FALSE;
  ------------------
  |  |  102|      0|#define FALSE 0
  ------------------
 1136|       |
 1137|    109|    return memcmp (a->string, b->string, a->len) == 0;
 1138|    109|}

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

cairo_surface_write_to_png:
  484|     42|{
  485|     42|    FILE *fp;
  486|     42|    cairo_status_t status;
  487|       |
  488|     42|    if (surface->status)
  ------------------
  |  Branch (488:9): [True: 0, False: 42]
  ------------------
  489|      0|	return surface->status;
  490|       |
  491|     42|    if (surface->finished)
  ------------------
  |  Branch (491:9): [True: 0, False: 42]
  ------------------
  492|      0|	return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
  493|       |
  494|     42|    status = _cairo_fopen (filename, "wb", &fp);
  495|       |
  496|     42|    if (status != CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (496:9): [True: 0, False: 42]
  ------------------
  497|      0|	return _cairo_error (status);
  498|       |
  499|     42|    if (fp == NULL) {
  ------------------
  |  Branch (499:9): [True: 0, False: 42]
  ------------------
  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|     42|    status = write_png (surface, stdio_write_func, fp);
  509|       |
  510|     42|    if (fclose (fp) && status == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (510:9): [True: 0, False: 42]
  |  Branch (510:24): [True: 0, False: 0]
  ------------------
  511|      0|	status = _cairo_error (CAIRO_STATUS_WRITE_ERROR);
  512|       |
  513|     42|    return status;
  514|     42|}
cairo_image_surface_create_from_png:
  915|    424|{
  916|    424|    struct png_read_closure_t png_closure;
  917|    424|    cairo_surface_t *surface;
  918|    424|    cairo_status_t status;
  919|       |
  920|    424|    status = _cairo_fopen (filename, "rb", (FILE **) &png_closure.closure);
  921|       |
  922|    424|    if (status != CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (922:9): [True: 0, False: 424]
  ------------------
  923|      0|	return _cairo_surface_create_in_error (status);
  924|       |
  925|    424|    if (png_closure.closure == NULL) {
  ------------------
  |  Branch (925:9): [True: 0, False: 424]
  ------------------
  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|    424|    png_closure.read_func = stdio_read_func;
  941|       |
  942|    424|    surface = read_png (&png_closure);
  943|       |
  944|    424|    fclose (png_closure.closure);
  945|       |
  946|    424|    return surface;
  947|    424|}
cairo-png.c:write_png:
  251|     42|{
  252|     42|    int i;
  253|     42|    cairo_int_status_t status;
  254|     42|    cairo_image_surface_t *image;
  255|     42|    cairo_image_surface_t * volatile clone;
  256|     42|    void *image_extra;
  257|     42|    png_struct *png;
  258|     42|    png_info *info;
  259|     42|    png_byte **volatile rows = NULL;
  260|     42|    png_color_16 white;
  261|     42|    int png_color_type;
  262|     42|    int bpc;
  263|     42|    unsigned char *volatile u16_copy = NULL;
  264|       |
  265|     42|    status = _cairo_surface_acquire_source_image (surface,
  266|     42|						  &image,
  267|     42|						  &image_extra);
  268|       |
  269|     42|    if (status == CAIRO_INT_STATUS_UNSUPPORTED)
  ------------------
  |  Branch (269:9): [True: 0, False: 42]
  ------------------
  270|      0|	return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
  271|     42|    else if (unlikely (status))
  ------------------
  |  |  145|     42|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 42]
  |  |  ------------------
  ------------------
  272|      0|        return status;
  273|       |
  274|       |    /* PNG complains about "Image width or height is zero in IHDR" */
  275|     42|    if (image->width == 0 || image->height == 0) {
  ------------------
  |  Branch (275:9): [True: 0, False: 42]
  |  Branch (275:30): [True: 0, False: 42]
  ------------------
  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|     42|    if (image->format == CAIRO_FORMAT_RGB96F ||
  ------------------
  |  Branch (281:9): [True: 8, False: 34]
  ------------------
  282|     34|        image->format == CAIRO_FORMAT_RGBA128F) {
  ------------------
  |  Branch (282:9): [True: 7, False: 27]
  ------------------
  283|     15|	u16_copy = _cairo_malloc_ab (image->width * 8, image->height);
  284|     15|	if (!u16_copy) {
  ------------------
  |  Branch (284:6): [True: 0, False: 15]
  ------------------
  285|      0|	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  286|      0|	    goto BAIL1;
  287|      0|	}
  288|     15|	clone = (cairo_image_surface_t *)cairo_surface_reference (&image->base);
  289|     27|    } 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|     27|	  clone = _cairo_image_surface_coerce (image);
  294|     27|	  status = clone->base.status;
  295|     27|    }
  296|     42|    if (unlikely (status))
  ------------------
  |  |  145|     42|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 42]
  |  |  ------------------
  ------------------
  297|      0|        goto BAIL1;
  298|       |
  299|     42|    rows = _cairo_malloc_ab (clone->height, sizeof (png_byte*));
  300|     42|    if (unlikely (rows == NULL)) {
  ------------------
  |  |  145|     42|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 42]
  |  |  ------------------
  ------------------
  301|      0|	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  302|      0|	goto BAIL2;
  303|      0|    }
  304|       |
  305|     42|    if (!u16_copy) {
  ------------------
  |  Branch (305:9): [True: 27, False: 15]
  ------------------
  306|     54|	for (i = 0; i < clone->height; i++)
  ------------------
  |  Branch (306:14): [True: 27, False: 27]
  ------------------
  307|     27|	    rows[i] = (png_byte *)clone->data + i * clone->stride;
  308|     27|    } else {
  309|     30|	for (i = 0; i < clone->height; i++) {
  ------------------
  |  Branch (309:14): [True: 15, False: 15]
  ------------------
  310|     15|	    float *float_line = (float *)&clone->data[i * clone->stride];
  311|     15|	    uint16_t *u16_line = (uint16_t *)&u16_copy[i * clone->width * 8];
  312|       |
  313|     15|	    if (image->format == CAIRO_FORMAT_RGBA128F)
  ------------------
  |  Branch (313:10): [True: 7, False: 8]
  ------------------
  314|      7|		unpremultiply_float (float_line, u16_line, clone->width);
  315|      8|	    else
  316|      8|		convert_float_to_u16 (float_line, u16_line, clone->width);
  317|       |
  318|     15|	    rows[i] = (png_byte *)u16_line;
  319|     15|	}
  320|     15|    }
  321|       |
  322|     42|    png = png_create_write_struct (PNG_LIBPNG_VER_STRING, &status,
  ------------------
  |  |  281|     42|#define PNG_LIBPNG_VER_STRING "1.6.37"
  ------------------
  323|     42|	                           png_simple_error_callback,
  324|     42|	                           png_simple_warning_callback);
  325|     42|    if (unlikely (png == NULL)) {
  ------------------
  |  |  145|     42|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 42]
  |  |  ------------------
  ------------------
  326|      0|	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  327|      0|	goto BAIL3;
  328|      0|    }
  329|       |
  330|     42|    info = png_create_info_struct (png);
  331|     42|    if (unlikely (info == NULL)) {
  ------------------
  |  |  145|     42|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 42]
  |  |  ------------------
  ------------------
  332|      0|	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
  333|      0|	goto BAIL4;
  334|      0|    }
  335|       |
  336|     42|#ifdef PNG_SETJMP_SUPPORTED
  337|     42|    if (setjmp (png_jmpbuf (png)))
  ------------------
  |  Branch (337:9): [True: 0, False: 42]
  ------------------
  338|      0|	goto BAIL4;
  339|     42|#endif
  340|       |
  341|     42|    png_set_write_fn (png, closure, write_func, png_simple_output_flush_fn);
  342|       |
  343|     42|    switch (clone->format) {
  344|      3|    case CAIRO_FORMAT_ARGB32:
  ------------------
  |  Branch (344:5): [True: 3, False: 39]
  ------------------
  345|      3|	bpc = 8;
  346|      3|	if (_cairo_image_analyze_transparency (clone) == CAIRO_IMAGE_IS_OPAQUE)
  ------------------
  |  Branch (346:6): [True: 0, False: 3]
  ------------------
  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|      3|	else
  349|      3|	    png_color_type = PNG_COLOR_TYPE_RGB_ALPHA;
  ------------------
  |  |  671|      3|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|      3|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|      3|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  350|      3|	break;
  351|      0|    case CAIRO_FORMAT_RGB30:
  ------------------
  |  Branch (351:5): [True: 0, False: 42]
  ------------------
  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|     24|    case CAIRO_FORMAT_RGB24:
  ------------------
  |  Branch (355:5): [True: 24, False: 18]
  ------------------
  356|     24|	bpc = 8;
  357|     24|	png_color_type = PNG_COLOR_TYPE_RGB;
  ------------------
  |  |  670|     24|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|     24|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  358|     24|	break;
  359|      0|    case CAIRO_FORMAT_A8:
  ------------------
  |  Branch (359:5): [True: 0, False: 42]
  ------------------
  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: 42]
  ------------------
  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|      8|    case CAIRO_FORMAT_RGB96F:
  ------------------
  |  Branch (370:5): [True: 8, False: 34]
  ------------------
  371|      8|	bpc = 16;
  372|      8|	png_color_type = PNG_COLOR_TYPE_RGB;
  ------------------
  |  |  670|      8|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|      8|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  373|      8|	break;
  374|      7|    case CAIRO_FORMAT_RGBA128F:
  ------------------
  |  Branch (374:5): [True: 7, False: 35]
  ------------------
  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: 42]
  ------------------
  379|      0|    case CAIRO_FORMAT_RGB16_565:
  ------------------
  |  Branch (379:5): [True: 0, False: 42]
  ------------------
  380|      0|    default:
  ------------------
  |  Branch (380:5): [True: 0, False: 42]
  ------------------
  381|      0|	status = _cairo_error (CAIRO_STATUS_INVALID_FORMAT);
  382|      0|	goto BAIL4;
  383|     42|    }
  384|       |
  385|     42|    png_set_IHDR (png, info,
  386|     42|		  clone->width,
  387|     42|		  clone->height, bpc,
  388|     42|		  png_color_type,
  389|     42|		  PNG_INTERLACE_NONE,
  ------------------
  |  |  687|     42|#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
  ------------------
  390|     42|		  PNG_COMPRESSION_TYPE_DEFAULT,
  ------------------
  |  |  679|     42|#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
  |  |  ------------------
  |  |  |  |  678|     42|#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
  |  |  ------------------
  ------------------
  391|     42|		  PNG_FILTER_TYPE_DEFAULT);
  ------------------
  |  |  684|     42|#define PNG_FILTER_TYPE_DEFAULT   PNG_FILTER_TYPE_BASE
  |  |  ------------------
  |  |  |  |  682|     42|#define PNG_FILTER_TYPE_BASE      0 /* Single row per-byte filtering */
  |  |  ------------------
  ------------------
  392|       |
  393|     42|    white.gray = (1 << bpc) - 1;
  394|     42|    white.red = white.blue = white.green = white.gray;
  395|     42|    png_set_bKGD (png, info, &white);
  396|       |
  397|     42|    if (0) { /* XXX extract meta-data from surface (i.e. creation date) */
  ------------------
  |  Branch (397:9): [Folded, False: 42]
  ------------------
  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|     42|    png_write_info (png, info);
  409|       |
  410|     42|#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|     42|    png_set_swap (png);
  416|     42|#endif
  417|       |
  418|     42|    if (png_color_type == PNG_COLOR_TYPE_RGB_ALPHA) {
  ------------------
  |  |  671|     42|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|     42|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|     42|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (418:9): [True: 10, False: 32]
  ------------------
  419|     10|	if (clone->format != CAIRO_FORMAT_RGBA128F)
  ------------------
  |  Branch (419:6): [True: 3, False: 7]
  ------------------
  420|      3|	    png_set_write_user_transform_fn (png, unpremultiply_data);
  421|     32|    } else if (png_color_type == PNG_COLOR_TYPE_RGB) {
  ------------------
  |  |  670|     32|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|     32|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  |  Branch (421:16): [True: 32, False: 0]
  ------------------
  422|     32|	if (clone->format != CAIRO_FORMAT_RGB96F)
  ------------------
  |  Branch (422:6): [True: 24, False: 8]
  ------------------
  423|     24|	    png_set_write_user_transform_fn (png, convert_data_to_bytes);
  424|     32|	png_set_filler (png, 0, PNG_FILLER_AFTER);
  ------------------
  |  | 1249|     32|#  define PNG_FILLER_AFTER 1
  ------------------
  425|     32|    }
  426|       |
  427|     42|    png_write_image (png, rows);
  428|     42|    png_write_end (png, info);
  429|       |
  430|     42|BAIL4:
  431|     42|    png_destroy_write_struct (&png, &info);
  432|     42|BAIL3:
  433|     42|    free (rows);
  434|     42|BAIL2:
  435|     42|    cairo_surface_destroy (&clone->base);
  436|     42|    free (u16_copy);
  437|     42|BAIL1:
  438|     42|    _cairo_surface_release_source_image (surface, image, image_extra);
  439|       |
  440|     42|    return status;
  441|     42|}
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|     52|{
  110|     52|    if (val < 0)
  ------------------
  |  Branch (110:9): [True: 2, False: 50]
  ------------------
  111|      2|	return 0;
  112|     50|    else if (val > 1)
  ------------------
  |  Branch (112:14): [True: 20, False: 30]
  ------------------
  113|     20|	return 65535;
  114|     30|    else
  115|     30|	return (uint16_t)(val * 65535.f);
  116|     52|}
cairo-png.c:convert_float_to_u16:
  175|      8|{
  176|      8|    unsigned int i;
  177|       |
  178|     16|    for (i = 0; i < width; i++) {
  ------------------
  |  Branch (178:17): [True: 8, False: 8]
  ------------------
  179|      8|	*d16++ = f_to_u16(*f++);
  180|      8|	*d16++ = f_to_u16(*f++);
  181|      8|	*d16++ = f_to_u16(*f++);
  182|      8|	*d16++ = 0;
  183|      8|    }
  184|      8|}
cairo-png.c:png_simple_error_callback:
  212|    311|{
  213|    311|    cairo_status_t *error = png_get_error_ptr (png);
  214|       |
  215|       |    /* default to the most likely error */
  216|    311|    if (*error == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (216:9): [True: 92, False: 219]
  ------------------
  217|     92|	*error = _cairo_error (CAIRO_STATUS_PNG_ERROR);
  218|       |
  219|    311|#ifdef PNG_SETJMP_SUPPORTED
  220|    311|    longjmp (png_jmpbuf (png), 1);
  ------------------
  |  |  953|    311|      (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
  ------------------
  221|    311|#endif
  222|       |
  223|       |    /* if we get here, then we have to choice but to abort ... */
  224|    311|}
cairo-png.c:png_simple_warning_callback:
  229|  2.53k|{
  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|  2.53k|}
cairo-png.c:unpremultiply_data:
   87|      3|{
   88|      3|    unsigned int i;
   89|       |
   90|      6|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (90:17): [True: 3, False: 3]
  ------------------
   91|      3|        uint8_t *b = &data[i];
   92|      3|        uint32_t pixel;
   93|      3|        uint8_t  alpha;
   94|       |
   95|      3|	memcpy (&pixel, b, sizeof (uint32_t));
   96|      3|	alpha = (pixel & 0xff000000) >> 24;
   97|      3|        if (alpha == 0) {
  ------------------
  |  Branch (97:13): [True: 0, False: 3]
  ------------------
   98|      0|	    b[0] = b[1] = b[2] = b[3] = 0;
   99|      3|	} else {
  100|      3|            b[0] = (((pixel & 0xff0000) >> 16) * 255 + alpha / 2) / alpha;
  101|      3|            b[1] = (((pixel & 0x00ff00) >>  8) * 255 + alpha / 2) / alpha;
  102|      3|            b[2] = (((pixel & 0x0000ff) >>  0) * 255 + alpha / 2) / alpha;
  103|      3|	    b[3] = alpha;
  104|      3|	}
  105|      3|    }
  106|      3|}
cairo-png.c:convert_data_to_bytes:
  189|     24|{
  190|     24|    unsigned int i;
  191|       |
  192|     48|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (192:17): [True: 24, False: 24]
  ------------------
  193|     24|        uint8_t *b = &data[i];
  194|     24|        uint32_t pixel;
  195|       |
  196|     24|	memcpy (&pixel, b, sizeof (uint32_t));
  197|       |
  198|     24|	b[0] = (pixel & 0xff0000) >> 16;
  199|     24|	b[1] = (pixel & 0x00ff00) >>  8;
  200|     24|	b[2] = (pixel & 0x0000ff) >>  0;
  201|     24|	b[3] = 0;
  202|     24|    }
  203|     24|}
cairo-png.c:stdio_write_func:
  445|    504|{
  446|    504|    FILE *fp;
  447|       |
  448|    504|    fp = png_get_io_ptr (png);
  449|  1.00k|    while (size) {
  ------------------
  |  Branch (449:12): [True: 504, False: 504]
  ------------------
  450|    504|	size_t ret = fwrite (data, 1, size, fp);
  451|    504|	size -= ret;
  452|    504|	data += ret;
  453|    504|	if (size && ferror (fp)) {
  ------------------
  |  Branch (453:6): [True: 0, False: 504]
  |  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|    504|    }
  460|    504|}
cairo-png.c:stdio_read_func:
  631|  1.31M|{
  632|  1.31M|    FILE *file = closure;
  633|       |
  634|  2.63M|    while (size) {
  ------------------
  |  Branch (634:12): [True: 1.31M, False: 1.31M]
  ------------------
  635|  1.31M|	size_t ret;
  636|       |
  637|  1.31M|	ret = fread (data, 1, size, file);
  638|  1.31M|	size -= ret;
  639|  1.31M|	data += ret;
  640|       |
  641|  1.31M|	if (size && (feof (file) || ferror (file)))
  ------------------
  |  Branch (641:6): [True: 219, False: 1.31M]
  |  Branch (641:15): [True: 219, False: 0]
  |  Branch (641:30): [True: 0, False: 0]
  ------------------
  642|    219|	    return _cairo_error (CAIRO_STATUS_READ_ERROR);
  643|  1.31M|    }
  644|       |
  645|  1.31M|    return CAIRO_STATUS_SUCCESS;
  646|  1.31M|}
cairo-png.c:read_png:
  668|    424|{
  669|    424|    cairo_surface_t * volatile surface;
  670|    424|    png_struct *png = NULL;
  671|    424|    png_info *info;
  672|    424|    png_byte * volatile data = NULL;
  673|    424|    png_byte ** volatile row_pointers = NULL;
  674|    424|    png_uint_32 png_width, png_height;
  675|    424|    int depth, color_type, interlace, stride;
  676|    424|    unsigned int i;
  677|    424|    cairo_format_t format;
  678|    424|    cairo_status_t status;
  679|    424|    unsigned char *mime_data;
  680|    424|    unsigned long mime_data_length;
  681|       |
  682|    424|    png_closure->png_data = _cairo_memory_stream_create ();
  683|       |
  684|       |    /* XXX: Perhaps we'll want some other error handlers? */
  685|    424|    png = png_create_read_struct (PNG_LIBPNG_VER_STRING,
  ------------------
  |  |  281|    424|#define PNG_LIBPNG_VER_STRING "1.6.37"
  ------------------
  686|    424|                                  &status,
  687|    424|	                          png_simple_error_callback,
  688|    424|	                          png_simple_warning_callback);
  689|    424|    if (unlikely (png == NULL)) {
  ------------------
  |  |  145|    424|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 424]
  |  |  ------------------
  ------------------
  690|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  691|      0|	goto BAIL;
  692|      0|    }
  693|       |
  694|    424|    info = png_create_info_struct (png);
  695|    424|    if (unlikely (info == NULL)) {
  ------------------
  |  |  145|    424|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 424]
  |  |  ------------------
  ------------------
  696|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  697|      0|	goto BAIL;
  698|      0|    }
  699|       |
  700|    424|    png_set_read_fn (png, png_closure, stream_read_func);
  701|       |
  702|    424|    status = CAIRO_STATUS_SUCCESS;
  703|    424|#ifdef PNG_SETJMP_SUPPORTED
  704|    424|    if (setjmp (png_jmpbuf (png))) {
  ------------------
  |  Branch (704:9): [True: 311, False: 113]
  ------------------
  705|    311|	surface = _cairo_surface_create_in_error (status);
  706|    311|	goto BAIL;
  707|    311|    }
  708|    113|#endif
  709|       |
  710|    113|    png_read_info (png, info);
  711|       |
  712|    113|#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|    113|    png_set_swap (png);
  718|    113|#endif
  719|       |
  720|    113|    png_get_IHDR (png, info,
  721|    113|                  &png_width, &png_height, &depth,
  722|    113|                  &color_type, &interlace, NULL, NULL);
  723|    113|    if (unlikely (status)) { /* catch any early warnings */
  ------------------
  |  |  145|    113|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 113]
  |  |  ------------------
  ------------------
  724|      0|	surface = _cairo_surface_create_in_error (status);
  725|      0|	goto BAIL;
  726|      0|    }
  727|       |
  728|       |    /* convert palette/gray image to rgb */
  729|    113|    if (color_type == PNG_COLOR_TYPE_PALETTE)
  ------------------
  |  |  669|    113|#define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  |  |  ------------------
  |  |  |  |  664|    113|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_PALETTE  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
  |  |  ------------------
  |  |  |  |  663|    113|#define PNG_COLOR_MASK_PALETTE    1
  |  |  ------------------
  ------------------
  |  Branch (729:9): [True: 4, False: 109]
  ------------------
  730|      4|        png_set_palette_to_rgb (png);
  731|       |
  732|       |    /* expand gray bit depth if needed */
  733|    113|    if (color_type == PNG_COLOR_TYPE_GRAY)
  ------------------
  |  |  668|    113|#define PNG_COLOR_TYPE_GRAY 0
  ------------------
  |  Branch (733:9): [True: 87, False: 26]
  ------------------
  734|     87|        png_set_expand_gray_1_2_4_to_8 (png);
  735|       |
  736|       |    /* transform transparency to alpha */
  737|    113|    if (png_get_valid (png, info, PNG_INFO_tRNS))
  ------------------
  |  |  736|    113|#define PNG_INFO_tRNS 0x0010U
  ------------------
  |  Branch (737:9): [True: 19, False: 94]
  ------------------
  738|     19|        png_set_tRNS_to_alpha (png);
  739|       |
  740|    113|    if (depth < 8)
  ------------------
  |  Branch (740:9): [True: 52, False: 61]
  ------------------
  741|     52|        png_set_packing (png);
  742|       |
  743|       |    /* convert grayscale to RGB */
  744|    113|    if (color_type == PNG_COLOR_TYPE_GRAY ||
  ------------------
  |  |  668|    226|#define PNG_COLOR_TYPE_GRAY 0
  ------------------
  |  Branch (744:9): [True: 18.4E, False: 136]
  ------------------
  745|    136|	color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
  ------------------
  |  |  672|    136|#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|    136|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (745:2): [True: 38, False: 98]
  ------------------
  746|    125|    {
  747|    125|	png_set_gray_to_rgb (png);
  748|    125|    }
  749|       |
  750|    113|    if (interlace != PNG_INTERLACE_NONE)
  ------------------
  |  |  687|    113|#define PNG_INTERLACE_NONE        0 /* Non-interlaced image */
  ------------------
  |  Branch (750:9): [True: 97, False: 16]
  ------------------
  751|     97|        png_set_interlace_handling (png);
  752|       |
  753|    113|    png_set_filler (png, 0xff, PNG_FILLER_AFTER);
  ------------------
  |  | 1249|    113|#  define PNG_FILLER_AFTER 1
  ------------------
  754|       |
  755|       |    /* recheck header after setting EXPAND options */
  756|    113|    png_read_update_info (png, info);
  757|    113|    png_get_IHDR (png, info,
  758|    113|                  &png_width, &png_height, &depth,
  759|    113|                  &color_type, &interlace, NULL, NULL);
  760|    113|    if ((depth != 8 && depth != 16) ||
  ------------------
  |  Branch (760:10): [True: 80, False: 33]
  |  Branch (760:24): [True: 0, False: 80]
  ------------------
  761|    223|	! (color_type == PNG_COLOR_TYPE_RGB ||
  ------------------
  |  |  670|    446|#define PNG_COLOR_TYPE_RGB        (PNG_COLOR_MASK_COLOR)
  |  |  ------------------
  |  |  |  |  664|    223|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  ------------------
  |  Branch (761:5): [True: 122, False: 101]
  ------------------
  762|    101|	   color_type == PNG_COLOR_TYPE_RGB_ALPHA))
  ------------------
  |  |  671|    101|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|    101|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|    101|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (762:5): [True: 101, 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|    113|    switch (color_type) {
  769|      0|	default:
  ------------------
  |  Branch (769:2): [True: 0, False: 113]
  ------------------
  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|    101|	case PNG_COLOR_TYPE_RGB_ALPHA:
  ------------------
  |  |  671|    101|#define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  664|    101|#define PNG_COLOR_MASK_COLOR      2
  |  |  ------------------
  |  |               #define PNG_COLOR_TYPE_RGB_ALPHA  (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
  |  |  ------------------
  |  |  |  |  665|    101|#define PNG_COLOR_MASK_ALPHA      4
  |  |  ------------------
  ------------------
  |  Branch (773:2): [True: 101, False: 12]
  ------------------
  774|    101|	    if (depth == 8) {
  ------------------
  |  Branch (774:10): [True: 56, False: 45]
  ------------------
  775|     56|		format = CAIRO_FORMAT_ARGB32;
  776|     56|		png_set_read_user_transform_fn (png, premultiply_data);
  777|     56|	    } else {
  778|     45|		format = CAIRO_FORMAT_RGBA128F;
  779|     45|	    }
  780|    101|	    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: 87, False: 35]
  ------------------
  784|     87|		format = CAIRO_FORMAT_RGB24;
  785|     87|		png_set_read_user_transform_fn (png, convert_bytes_to_data);
  786|     87|	    } else {
  787|     35|		format = CAIRO_FORMAT_RGB96F;
  788|     35|	    }
  789|    122|	    break;
  790|    113|    }
  791|       |
  792|    223|    stride = cairo_format_stride_for_width (format, png_width);
  793|    223|    if (stride < 0) {
  ------------------
  |  Branch (793:9): [True: 0, False: 223]
  ------------------
  794|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
  795|      0|	goto BAIL;
  796|      0|    }
  797|       |
  798|    223|    data = _cairo_malloc_ab (png_height, stride);
  799|    223|    if (unlikely (data == NULL)) {
  ------------------
  |  |  145|    223|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 223]
  |  |  ------------------
  ------------------
  800|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  801|      0|	goto BAIL;
  802|      0|    }
  803|       |
  804|    223|    row_pointers = _cairo_malloc_ab (png_height, sizeof (char *));
  805|    223|    if (unlikely (row_pointers == NULL)) {
  ------------------
  |  |  145|    223|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 223]
  |  |  ------------------
  ------------------
  806|      0|	surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
  807|      0|	goto BAIL;
  808|      0|    }
  809|       |
  810|  6.03M|    for (i = 0; i < png_height; i++)
  ------------------
  |  Branch (810:17): [True: 6.03M, False: 223]
  ------------------
  811|  6.03M|        row_pointers[i] = &data[i * (ptrdiff_t)stride];
  812|       |
  813|    223|    png_read_image (png, row_pointers);
  814|    223|    png_read_end (png, info);
  815|       |
  816|    223|    if (unlikely (status)) { /* catch any late warnings - probably hit an error already */
  ------------------
  |  |  145|    223|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 223]
  |  |  ------------------
  ------------------
  817|      0|	surface = _cairo_surface_create_in_error (status);
  818|      0|	goto BAIL;
  819|      0|    }
  820|       |
  821|    223|    if (format == CAIRO_FORMAT_RGBA128F) {
  ------------------
  |  Branch (821:9): [True: 40, False: 183]
  ------------------
  822|     40|	i = png_height;
  823|       |
  824|  1.27k|	while (i--) {
  ------------------
  |  Branch (824:9): [True: 1.23k, False: 40]
  ------------------
  825|  1.23k|	    float *float_line = (float *)row_pointers[i];
  826|  1.23k|	    uint16_t *u16_line = (uint16_t *)row_pointers[i];
  827|       |
  828|  1.23k|	    premultiply_float (float_line, u16_line, png_width);
  829|  1.23k|	}
  830|    183|    } else if (format == CAIRO_FORMAT_RGB96F) {
  ------------------
  |  Branch (830:16): [True: 24, False: 159]
  ------------------
  831|     24|	i = png_height;
  832|       |
  833|  1.43k|	while (i--) {
  ------------------
  |  Branch (833:9): [True: 1.40k, False: 24]
  ------------------
  834|  1.40k|	    float *float_line = (float *)row_pointers[i];
  835|  1.40k|	    uint16_t *u16_line = (uint16_t *)row_pointers[i];
  836|       |
  837|  1.40k|	    convert_u16_to_float (float_line, u16_line, png_width);
  838|  1.40k|	}
  839|     24|    }
  840|       |
  841|    223|    surface = cairo_image_surface_create_for_data (data, format,
  842|    223|						   png_width, png_height,
  843|    223|						   stride);
  844|    223|    if (surface->status)
  ------------------
  |  Branch (844:9): [True: 3, False: 220]
  ------------------
  845|      3|	goto BAIL;
  846|       |
  847|    220|    _cairo_image_surface_assume_ownership_of_data ((cairo_image_surface_t*)surface);
  848|    220|    data = NULL;
  849|       |
  850|    220|    _cairo_debug_check_image_surface_is_defined (surface);
  851|       |
  852|    220|    status = _cairo_memory_stream_destroy (png_closure->png_data,
  853|    220|					   &mime_data,
  854|    220|					   &mime_data_length);
  855|    220|    png_closure->png_data = NULL;
  856|    220|    if (unlikely (status)) {
  ------------------
  |  |  145|    220|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 220]
  |  |  ------------------
  ------------------
  857|      0|	cairo_surface_destroy (surface);
  858|      0|	surface = _cairo_surface_create_in_error (status);
  859|      0|	goto BAIL;
  860|      0|    }
  861|       |
  862|    220|    status = cairo_surface_set_mime_data (surface,
  863|    220|					  CAIRO_MIME_TYPE_PNG,
  ------------------
  |  | 2621|    220|#define CAIRO_MIME_TYPE_PNG "image/png"
  ------------------
  864|    220|					  mime_data,
  865|    220|					  mime_data_length,
  866|    220|					  free,
  867|    220|					  mime_data);
  868|    220|    if (unlikely (status)) {
  ------------------
  |  |  145|    220|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 0, False: 220]
  |  |  ------------------
  ------------------
  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|    424| BAIL:
  876|    424|    free (row_pointers);
  877|    424|    free (data);
  878|    424|    if (png != NULL)
  ------------------
  |  Branch (878:9): [True: 424, False: 0]
  ------------------
  879|    424|	png_destroy_read_struct (&png, &info, NULL);
  880|    424|    if (png_closure->png_data != NULL) {
  ------------------
  |  Branch (880:9): [True: 314, False: 110]
  ------------------
  881|    314|	cairo_status_t status_ignored;
  882|       |
  883|    314|	status_ignored = _cairo_output_stream_destroy (png_closure->png_data);
  884|    314|    }
  885|       |
  886|    424|    return surface;
  887|    220|}
cairo-png.c:stream_read_func:
  650|  1.31M|{
  651|  1.31M|    cairo_status_t status;
  652|  1.31M|    struct png_read_closure_t *png_closure;
  653|       |
  654|  1.31M|    png_closure = png_get_io_ptr (png);
  655|  1.31M|    status = png_closure->read_func (png_closure->closure, data, size);
  656|  1.31M|    if (unlikely (status)) {
  ------------------
  |  |  145|  1.31M|#define unlikely(expr) (__builtin_expect (!!(expr), 0))
  |  |  ------------------
  |  |  |  Branch (145:24): [True: 219, False: 1.31M]
  |  |  ------------------
  ------------------
  657|    219|	cairo_status_t *error = png_get_error_ptr (png);
  658|    219|	if (*error == CAIRO_STATUS_SUCCESS)
  ------------------
  |  Branch (658:6): [True: 219, False: 0]
  ------------------
  659|    219|	    *error = status;
  660|    219|	png_error (png, NULL);
  661|    219|    }
  662|       |
  663|  1.31M|    _cairo_output_stream_write (png_closure->png_data, data, size);
  664|  1.31M|}
cairo-png.c:premultiply_data:
  585|  1.03k|{
  586|  1.03k|    unsigned int i;
  587|       |
  588|  1.43M|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (588:17): [True: 1.43M, False: 1.03k]
  ------------------
  589|  1.43M|	uint8_t *base  = &data[i];
  590|  1.43M|	uint8_t  alpha = base[3];
  591|  1.43M|	uint32_t p;
  592|       |
  593|  1.43M|	if (alpha == 0) {
  ------------------
  |  Branch (593:6): [True: 901k, False: 536k]
  ------------------
  594|   901k|	    p = 0;
  595|   901k|	} else {
  596|   536k|	    uint8_t  red   = base[0];
  597|   536k|	    uint8_t  green = base[1];
  598|   536k|	    uint8_t  blue  = base[2];
  599|       |
  600|   536k|	    if (alpha != 0xff) {
  ------------------
  |  Branch (600:10): [True: 242k, False: 293k]
  ------------------
  601|   242k|		red   = multiply_alpha (alpha, red);
  602|   242k|		green = multiply_alpha (alpha, green);
  603|   242k|		blue  = multiply_alpha (alpha, blue);
  604|   242k|	    }
  605|   536k|	    p = ((uint32_t)alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
  606|   536k|	}
  607|  1.43M|	memcpy (base, &p, sizeof (uint32_t));
  608|  1.43M|    }
  609|  1.03k|}
cairo-png.c:multiply_alpha:
  575|   728k|{
  576|   728k|    int temp = (alpha * color) + 0x80;
  577|   728k|    return ((temp + (temp >> 8)) >> 8);
  578|   728k|}
cairo-png.c:convert_bytes_to_data:
  614|  3.49k|{
  615|  3.49k|    unsigned int i;
  616|       |
  617|  3.64M|    for (i = 0; i < row_info->rowbytes; i += 4) {
  ------------------
  |  Branch (617:17): [True: 3.63M, False: 3.49k]
  ------------------
  618|  3.63M|	uint8_t *base  = &data[i];
  619|  3.63M|	uint8_t  red   = base[0];
  620|  3.63M|	uint8_t  green = base[1];
  621|  3.63M|	uint8_t  blue  = base[2];
  622|  3.63M|	uint32_t pixel;
  623|       |
  624|  3.63M|	pixel = (0xffu << 24) | (red << 16) | (green << 8) | (blue << 0);
  625|  3.63M|	memcpy (base, &pixel, sizeof (uint32_t));
  626|  3.63M|    }
  627|  3.49k|}
cairo-png.c:premultiply_float:
  147|  1.23k|{
  148|  1.23k|    unsigned int i = width;
  149|       |
  150|       |    /* Convert d16 in place back to float */
  151|  3.38k|    while (i--) {
  ------------------
  |  Branch (151:12): [True: 2.15k, False: 1.23k]
  ------------------
  152|  2.15k|	float a = d16[i * 4 + 3] / 65535.f;
  153|       |
  154|  2.15k|	f[i * 4 + 3] = a;
  155|  2.15k|	f[i * 4 + 2] = (float)d16[i * 4 + 2] / 65535.f * a;
  156|  2.15k|	f[i * 4 + 1] = (float)d16[i * 4 + 1] / 65535.f * a;
  157|  2.15k|	f[i * 4] = (float)d16[i * 4] / 65535.f * a;
  158|  2.15k|    }
  159|  1.23k|}
cairo-png.c:convert_u16_to_float:
  162|  1.40k|{
  163|       |    /* Convert d16 in place back to float */
  164|  1.40k|    unsigned int i = width;
  165|       |
  166|  6.02k|    while (i--) {
  ------------------
  |  Branch (166:12): [True: 4.62k, False: 1.40k]
  ------------------
  167|  4.62k|	f[i * 3 + 2] = (float)d16[i * 4 + 2] / 65535.f;
  168|  4.62k|	f[i * 3 + 1] = (float)d16[i * 4 + 1] / 65535.f;
  169|  4.62k|	f[i * 3] = (float)d16[i * 4] / 65535.f;
  170|  4.62k|    }
  171|  1.40k|}

_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|    152|{
   46|    152|    cairo_status_t status = CAIRO_STATUS_SUCCESS;
   47|    152|    if (surface->backend->flush)
  ------------------
  |  Branch (47:9): [True: 0, False: 152]
  ------------------
   48|      0|	status = surface->backend->flush (surface, flags);
   49|    152|    return status;
   50|    152|}

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

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

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

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

