third_party/cairo/src/cairo-surface-observer.c
cairo_surface_t *
cairo_surface_create_observer (cairo_surface_t *target,
			       cairo_surface_observer_mode_t mode)
{
    cairo_device_t *device;
    cairo_surface_t *surface;
    cairo_bool_t record;

    if (unlikely (target->status))
	return _cairo_surface_create_in_error (target->status);
    if (unlikely (target->finished))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));

    record = mode & CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS;
    device = _cairo_device_create_observer_internal (target->device, record);
    if (unlikely (device->status))
	return _cairo_surface_create_in_error (device->status);

    surface = _cairo_surface_create_observer_internal (device, target);
    cairo_device_destroy (device);

    return surface;
}
/**
 * cairo_surface_create_observer:
 * @target: an existing surface for which the observer will watch
 * @mode: sets the mode of operation (normal vs. record)
 *
 * Create a new surface that exists solely to watch another is doing. In
 * the process it will log operations and times, which are fast, which are
 * slow, which are frequent, etc.
 *
 * The @mode parameter can be set to either CAIRO_SURFACE_OBSERVER_NORMAL
 * or CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS, to control whether or not
 * the internal observer should record operations.
 *
 * Return value: a pointer to the newly allocated surface. The caller
 * owns the surface and should call cairo_surface_destroy() when done
 * with it.
 *
 * This function always returns a valid pointer, but it will return a
 * pointer to a "nil" surface if @other is already in an error state
 * or any other error occurs.
 *
 * Since: 1.12
 **/
@target: an existing surface for which the observer will watch
@mode: sets the mode of operation (normal vs. record)

Create a new surface that exists solely to watch another is doing. In
the process it will log operations and times, which are fast, which are
slow, which are frequent, etc.

The @mode parameter can be set to either CAIRO_SURFACE_OBSERVER_NORMAL
or CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS, to control whether or not
the internal observer should record operations.

Return value: a pointer to the newly allocated surface. The caller
owns the surface and should call cairo_surface_destroy() when done
with it.

This function always returns a valid pointer, but it will return a
pointer to a "nil" surface if @other is already in an error state
or any other error occurs.


@target : an existing surface for which the observer will watch @mode : sets the mode of operation ( normal vs . record ) Create a new surface that exists solely to watch another is doing . In the process it will log operations and times which are fast which are slow which are frequent etc . The @mode parameter can be set to either CAIRO_SURFACE_OBSERVER_NORMAL or CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS to control whether or not the internal observer should record operations . Return value : a pointer to the newly allocated surface . The caller owns the surface and should call cairo_surface_destroy () when done with it . This function always returns a valid pointer but it will return a pointer to a " nil " surface if @other is already in an error state or any other error occurs .
cairo_surface_t *
cairo_surface_create_observer (cairo_surface_t *target,
			       cairo_surface_observer_mode_t mode)
{
    cairo_device_t *device;
    cairo_surface_t *surface;
    cairo_bool_t record;
    if (unlikely (target->status))
	return _cairo_surface_create_in_error (target->status);
    if (unlikely (target->finished))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_SURFACE_FINISHED));
    record = mode & CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS;
    device = _cairo_device_create_observer_internal (target->device, record);
    if (unlikely (device->status))
	return _cairo_surface_create_in_error (device->status);
    surface = _cairo_surface_create_observer_internal (device, target);
    cairo_device_destroy (device);
    return surface;
}
cairo_surface_t * cairo_surface_create_observer ( cairo_surface_t * target , cairo_surface_observer_mode_t mode ) { cairo_device_t * device ; cairo_surface_t * surface ; cairo_bool_t record ; if ( unlikely ( target -> status ) ) return _cairo_surface_create_in_error ( target -> status ) ; if ( unlikely ( target -> finished ) ) return _cairo_surface_create_in_error ( _cairo_error ( CAIRO_STATUS_SURFACE_FINISHED ) ) ; record = mode & CAIRO_SURFACE_OBSERVER_RECORD_OPERATIONS ; device = _cairo_device_create_observer_internal ( target -> device , record ) ; if ( unlikely ( device -> status ) ) return _cairo_surface_create_in_error ( device -> status ) ; surface = _cairo_surface_create_observer_internal ( device , target ) ; cairo_device_destroy ( device ) ; return surface ; }
cairo_surface_create_observer:
 @target: an existing surface for which the observer will watch
 @mode: sets the mode of operation (normal vs. record)
cairo_surface_create_observer : @target : an existing surface for which the observer will watch @mode : sets the mode of operation ( normal vs . record )