Ejemplo n.º 1
0
void IMB_freeImBuf(ImBuf *ibuf)
{
    if (ibuf) {
        bool needs_free = false;

        BLI_spin_lock(&refcounter_spin);
        if (ibuf->refcounter > 0) {
            ibuf->refcounter--;
        }
        else {
            needs_free = true;
        }
        BLI_spin_unlock(&refcounter_spin);

        if (needs_free) {
            imb_freerectImBuf(ibuf);
            imb_freerectfloatImBuf(ibuf);
            imb_freetilesImBuf(ibuf);
            IMB_freezbufImBuf(ibuf);
            IMB_freezbuffloatImBuf(ibuf);
            freeencodedbufferImBuf(ibuf);
            IMB_metadata_free(ibuf);
            colormanage_cache_free(ibuf);

            if (ibuf->dds_data.data != NULL) {
                free(ibuf->dds_data.data); /* dds_data.data is allocated by DirectDrawSurface::readData(), so don't use MEM_freeN! */
            }
            MEM_freeN(ibuf);
        }
    }
}
Ejemplo n.º 2
0
static void imbuf_cache_destructor(void *data)
{
    ImBuf *ibuf = (ImBuf *) data;

    imb_freerectImBuf(ibuf);
    imb_freerectfloatImBuf(ibuf);
    IMB_freezbufImBuf(ibuf);
    IMB_freezbuffloatImBuf(ibuf);
    freeencodedbufferImBuf(ibuf);

    ibuf->c_handle = NULL;
}
Ejemplo n.º 3
0
bool addzbufImBuf(ImBuf *ibuf)
{
	if (ibuf == NULL) return false;

	IMB_freezbufImBuf(ibuf);

	if ((ibuf->zbuf = imb_alloc_pixels(ibuf->x, ibuf->y, 1, sizeof(unsigned int), __func__))) {
		ibuf->mall |= IB_zbuf;
		ibuf->flags |= IB_zbuf;
		return true;
	}

	return false;
}
Ejemplo n.º 4
0
bool addzbufImBuf(ImBuf *ibuf)
{
    size_t size;

    if (ibuf == NULL) return false;

    IMB_freezbufImBuf(ibuf);

    size = (size_t)ibuf->x * (size_t)ibuf->y * sizeof(unsigned int);

    if ((ibuf->zbuf = MEM_mapallocN(size, __func__))) {
        ibuf->mall |= IB_zbuf;
        ibuf->flags |= IB_zbuf;
        return true;
    }

    return false;
}