Esempio n. 1
0
VdpStatus vdp_bitmap_surface_destroy(VdpBitmapSurface surface)
{
	bitmap_surface_ctx_t *out = handle_get(surface);
	if (!out)
		return VDP_STATUS_INVALID_HANDLE;

	rgba_destroy(&out->rgba);

	handle_destroy(surface);

	return VDP_STATUS_OK;
}
VdpStatus vdp_output_surface_destroy(VdpOutputSurface surface)
{
	output_surface_ctx_t *out = handle_get(surface);
	if (!out)
		return VDP_STATUS_INVALID_HANDLE;

	rgba_destroy(&out->rgba);

	if (out->yuv)
		yuv_unref(out->yuv);

	handle_destroy(surface);
	free(out);

	return VDP_STATUS_OK;
}
VdpStatus vdp_output_surface_create(VdpDevice device,
                                    VdpRGBAFormat rgba_format,
                                    uint32_t width,
                                    uint32_t height,
                                    VdpOutputSurface *surface)
{
	int ret = VDP_STATUS_OK;

	if (!surface)
		return VDP_STATUS_INVALID_POINTER;

	device_ctx_t *dev = handle_get(device);
	if (!dev)
		return VDP_STATUS_INVALID_HANDLE;

	output_surface_ctx_t *out = calloc(1, sizeof(output_surface_ctx_t));
	if (!out)
		return VDP_STATUS_RESOURCES;

	out->contrast = 1.0;
	out->saturation = 1.0;

	ret = rgba_create(&out->rgba, dev, width, height, rgba_format);
	if (ret != VDP_STATUS_OK)
	{
		free(out);
		return ret;
	}

	int handle = handle_create(out);
	if (handle == -1)
	{
		rgba_destroy(&out->rgba);
		free(out);
		return VDP_STATUS_RESOURCES;
	}

	*surface = handle;

	return VDP_STATUS_OK;
}
VdpStatus vdp_bitmap_surface_create(VdpDevice device,
                                    VdpRGBAFormat rgba_format,
                                    uint32_t width,
                                    uint32_t height,
                                    VdpBool frequently_accessed,
                                    VdpBitmapSurface *surface)
{
    int ret = VDP_STATUS_OK;

    if (!surface)
        return VDP_STATUS_INVALID_POINTER;

    device_ctx_t *dev = handle_get(device);
    if (!dev)
        return VDP_STATUS_INVALID_HANDLE;

    bitmap_surface_ctx_t *out = calloc(1, sizeof(bitmap_surface_ctx_t));
    if (!out)
        return VDP_STATUS_RESOURCES;

    out->frequently_accessed = frequently_accessed;

    ret = rgba_create(&out->rgba, dev, width, height, rgba_format);
    if (ret != VDP_STATUS_OK)
    {
        free(out);
        return ret;
    }

    int handle = handle_create(out);
    if (handle == -1)
    {
        rgba_destroy(&out->rgba);
        free(out);
        return VDP_STATUS_RESOURCES;
    }

    *surface = handle;

    return VDP_STATUS_OK;
}