diff options
author | Thomas White <taw@bitwiz.org.uk> | 2009-08-18 21:14:44 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2009-08-18 21:14:44 +0100 |
commit | e727d8668afba6c2e50ee2097ae163b751274ce8 (patch) | |
tree | 01d4e1c855018b61af4b46061292d493386d2c9f /src/glamo-kms-exa.c | |
parent | ee235f08f1cd4ffc96fcd3e9a690c2c954afd663 (diff) |
Reallocate GEM objects when necessary
Diffstat (limited to 'src/glamo-kms-exa.c')
-rw-r--r-- | src/glamo-kms-exa.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/glamo-kms-exa.c b/src/glamo-kms-exa.c index 5303aeb..e7d78cf 100644 --- a/src/glamo-kms-exa.c +++ b/src/glamo-kms-exa.c @@ -455,6 +455,7 @@ static Bool GlamoKMSExaModifyPixmapHeader(PixmapPtr pPix, int width, int height, ScrnInfoPtr pScrn = xf86Screens[screen->myNum]; GlamoPtr pGlamo = GlamoPTR(pScrn); struct glamo_exa_pixmap_priv *priv; + int new_size; if (depth <= 0) depth = pPix->drawable.depth; if (bitsPerPixel <= 0) bitsPerPixel = pPix->drawable.bitsPerPixel; @@ -472,20 +473,19 @@ static Bool GlamoKMSExaModifyPixmapHeader(PixmapPtr pPix, int width, int height, return FALSE; } - if ( priv->bo == NULL ) { + new_size = (width * height * depth) / 8; + if ( new_size == 0 ) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Zero-sized pixmap in ModifyPixmapHeader\n"); + return FALSE; + } - int size; + if ( priv->bo == NULL ) { /* This pixmap has no associated buffer object. * It's time to create one */ - size = (width * height * depth) / 8; - if ( size == 0 ) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Zero-sized pixmap in ModifyPixmapHeader\n"); - } - priv->bo = glamo_bo_open(pGlamo->bufmgr, 0, size, 2, + priv->bo = glamo_bo_open(pGlamo->bufmgr, 0, new_size, 2, GLAMO_GEM_DOMAIN_VRAM, 0); - if ( priv->bo == NULL ) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to create buffer object" @@ -493,6 +493,25 @@ static Bool GlamoKMSExaModifyPixmapHeader(PixmapPtr pPix, int width, int height, return FALSE; } + } else { + + if ( priv->bo->size < new_size ) { + + /* Get rid of the old GEM object */ + glamo_bo_unref(priv->bo); + + /* Create a new one of the correct size */ + priv->bo = glamo_bo_open(pGlamo->bufmgr, 0, new_size, 2, + GLAMO_GEM_DOMAIN_VRAM, 0); + if ( priv->bo == NULL ) { + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "Failed to reallocate buffer object" + " in ModifyPixmapHeader.\n"); + return FALSE; + } + + } /* else, reallocation is not required */ + } return FALSE; |