예제 #1
0
static cairo_status_t
radeon_surface_finish (void *abstract_surface)
{
    radeon_surface_t *surface = abstract_surface;

    return _cairo_drm_surface_finish (&surface->base);
}
예제 #2
0
static cairo_surface_t *
radeon_surface_create_internal (cairo_drm_device_t *device,
				cairo_format_t format,
				int width, int height)
{
    radeon_surface_t *surface;
    cairo_status_t status;

    surface = malloc (sizeof (radeon_surface_t));
    if (unlikely (surface == NULL))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    radeon_surface_init (surface, device, format, width, height);

    if (width && height) {
	surface->base.stride =
	    cairo_format_stride_for_width (surface->base.format, width);

	surface->base.bo = radeon_bo_create (to_radeon_device (&device->base),
					     surface->base.stride * height,
					     RADEON_GEM_DOMAIN_GTT);

	if (unlikely (surface->base.bo == NULL)) {
	    status = _cairo_drm_surface_finish (&surface->base);
	    free (surface);
	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
	}
    }

    return &surface->base.base;
}
예제 #3
0
static cairo_surface_t *
intel_surface_create (cairo_drm_device_t *device,
		      cairo_format_t format,
		      int width, int height)
{
    intel_surface_t *surface;
    cairo_status_t status;

    surface = malloc (sizeof (intel_surface_t));
    if (unlikely (surface == NULL))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    intel_surface_init (surface, &intel_surface_backend, device,
			format, width, height);

    if (width && height) {
	/* Vol I, p134: size restrictions for textures */
	width  = (width  + 3) & -4;
	height = (height + 1) & -2;
	surface->drm.stride =
	    cairo_format_stride_for_width (surface->drm.format, width);
	surface->drm.bo = &intel_bo_create (to_intel_device (&device->base),
					    surface->drm.stride * height,
					    surface->drm.stride * height,
					    TRUE, I915_TILING_NONE, surface->drm.stride)->base;
	if (surface->drm.bo == NULL) {
	    status = _cairo_drm_surface_finish (&surface->drm);
	    free (surface);
	    return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
	}
    }

    return &surface->drm.base;
}
예제 #4
0
cairo_status_t
intel_surface_finish (void *abstract_surface)
{
    intel_surface_t *surface = abstract_surface;

    intel_bo_in_flight_add (to_intel_device (surface->drm.base.device),
			    to_intel_bo (surface->drm.bo));
    return _cairo_drm_surface_finish (&surface->drm);
}
예제 #5
0
static cairo_status_t
gallium_surface_finish (void *abstract_surface)
{
    gallium_surface_t *surface = abstract_surface;
    gallium_device_t *device = gallium_device (surface);
    cairo_status_t status;

    status = cairo_device_acquire (&device->drm.base);
    if (likely (status == CAIRO_STATUS_SUCCESS)) {
        pipe_resource_reference (&surface->texture, NULL);
        cairo_device_release (&device->drm.base);
    }

    return _cairo_drm_surface_finish (&surface->drm);
}
예제 #6
0
static cairo_surface_t *
intel_surface_create_for_name (cairo_drm_device_t *device,
			       unsigned int name,
			       cairo_format_t format,
			       int width, int height, int stride)
{
    intel_surface_t *surface;
    cairo_status_t status;

    switch (format) {
    default:
    case CAIRO_FORMAT_INVALID:
    case CAIRO_FORMAT_A1:
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
    case CAIRO_FORMAT_ARGB32:
    case CAIRO_FORMAT_RGB16_565:
    case CAIRO_FORMAT_RGB24:
    case CAIRO_FORMAT_A8:
	break;
    }

    if (stride < cairo_format_stride_for_width (format, width))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));

    surface = malloc (sizeof (intel_surface_t));
    if (unlikely (surface == NULL))
	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));

    intel_surface_init (surface, &intel_surface_backend,
			device, format, width, height);

    if (width && height) {
	surface->drm.stride = stride;

	surface->drm.bo = &intel_bo_create_for_name (to_intel_device (&device->base),
						      name)->base;
	if (unlikely (surface->drm.bo == NULL)) {
	    status = _cairo_drm_surface_finish (&surface->drm);
	    free (surface);
	    return _cairo_surface_create_in_error (_cairo_error
						   (CAIRO_STATUS_NO_MEMORY));
	}
    }

    return &surface->drm.base;
}