summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-12 09:18:30 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-12 12:50:31 +0100
commit244b7cbfffdcda4761948eaa37ed2a30ca81f107 (patch)
tree51c06d77b858fe5b3670198c1b50d00dac963b85
parentcb887cfc670bf63993bd313ff33927afb8198eae (diff)
uxa: Use accelerated PutImage for uploading pixman images.
Short-circuits the current use of PutImage from CopyArea, bypassing all the temporary allocations.
-rw-r--r--uxa/uxa-render.c104
1 files changed, 57 insertions, 47 deletions
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index f8105aff..ee91b5c0 100644
--- a/uxa/uxa-render.c
+++ b/uxa/uxa-render.c
@@ -450,74 +450,84 @@ uxa_picture_for_pixman_format(ScreenPtr pScreen,
}
static PicturePtr
-uxa_picture_from_pixman_image(ScreenPtr pScreen,
+uxa_picture_from_pixman_image(ScreenPtr screen,
pixman_image_t * image,
pixman_format_code_t format)
{
- PicturePtr pPicture;
- PixmapPtr pPixmap;
+ uxa_screen_t *uxa_screen = uxa_get_screen(screen);
+ PicturePtr picture;
+ PixmapPtr pixmap;
int width, height;
width = pixman_image_get_width(image);
height = pixman_image_get_height(image);
- pPicture = uxa_picture_for_pixman_format(pScreen, format,
- width, height);
- if (!pPicture)
+ picture = uxa_picture_for_pixman_format(screen, format,
+ width, height);
+ if (!picture)
return 0;
- pPixmap = GetScratchPixmapHeader(pScreen, width, height,
- PIXMAN_FORMAT_DEPTH(format),
- PIXMAN_FORMAT_BPP(format),
- pixman_image_get_stride(image),
- pixman_image_get_data(image));
- if (!pPixmap) {
- FreePicture(pPicture, 0);
+ if (uxa_screen->info->put_image &&
+ ((picture->pDrawable->depth << 24) | picture->format) == format &&
+ uxa_screen->info->put_image((PixmapPtr)picture->pDrawable,
+ 0, 0,
+ width, height,
+ (char *)pixman_image_get_data(image),
+ pixman_image_get_stride(image)))
+ return picture;
+
+ pixmap = GetScratchPixmapHeader(screen, width, height,
+ PIXMAN_FORMAT_DEPTH(format),
+ PIXMAN_FORMAT_BPP(format),
+ pixman_image_get_stride(image),
+ pixman_image_get_data(image));
+ if (!pixmap) {
+ FreePicture(picture, 0);
return 0;
}
- if (((pPicture->pDrawable->depth << 24) | pPicture->format) == format) {
- GCPtr pGC;
+ if (((picture->pDrawable->depth << 24) | picture->format) == format) {
+ GCPtr gc;
- pGC = GetScratchGC(PIXMAN_FORMAT_DEPTH(format), pScreen);
- if (!pGC) {
- FreeScratchPixmapHeader(pPixmap);
- FreePicture(pPicture, 0);
- return 0;
- }
- ValidateGC(pPicture->pDrawable, pGC);
+ gc = GetScratchGC(PIXMAN_FORMAT_DEPTH(format), screen);
+ if (!gc) {
+ FreeScratchPixmapHeader(pixmap);
+ FreePicture(picture, 0);
+ return 0;
+ }
+ ValidateGC(picture->pDrawable, gc);
- (*pGC->ops->CopyArea) (&pPixmap->drawable, pPicture->pDrawable,
- pGC, 0, 0, width, height, 0, 0);
+ (*gc->ops->CopyArea) (&pixmap->drawable, picture->pDrawable,
+ gc, 0, 0, width, height, 0, 0);
- FreeScratchGC(pGC);
+ FreeScratchGC(gc);
} else {
- PicturePtr pSrc;
- int error;
-
- pSrc = CreatePicture(0, &pPixmap->drawable,
- PictureMatchFormat(pScreen,
- PIXMAN_FORMAT_DEPTH(format),
- format),
- 0, 0, serverClient, &error);
- if (!pSrc) {
- FreeScratchPixmapHeader(pPixmap);
- FreePicture(pPicture, 0);
- return 0;
- }
- ValidatePicture(pSrc);
+ PicturePtr src;
+ int error;
+
+ src = CreatePicture(0, &pixmap->drawable,
+ PictureMatchFormat(screen,
+ PIXMAN_FORMAT_DEPTH(format),
+ format),
+ 0, 0, serverClient, &error);
+ if (!src) {
+ FreeScratchPixmapHeader(pixmap);
+ FreePicture(picture, 0);
+ return 0;
+ }
+ ValidatePicture(src);
- if (uxa_prepare_access(pPicture->pDrawable, UXA_ACCESS_RW)) {
- fbComposite(PictOpSrc, pSrc, NULL, pPicture,
- 0, 0, 0, 0, 0, 0, width, height);
- uxa_finish_access(pPicture->pDrawable);
- }
+ if (uxa_prepare_access(picture->pDrawable, UXA_ACCESS_RW)) {
+ fbComposite(PictOpSrc, src, NULL, picture,
+ 0, 0, 0, 0, 0, 0, width, height);
+ uxa_finish_access(picture->pDrawable);
+ }
- FreePicture(pSrc, 0);
+ FreePicture(src, 0);
}
- FreeScratchPixmapHeader(pPixmap);
+ FreeScratchPixmapHeader(pixmap);
- return pPicture;
+ return picture;
}
static PicturePtr