From eb53d111bd8651cd00c1b728b09e8be09b8482f7 Mon Sep 17 00:00:00 2001 From: Aaron Plattner Date: Wed, 25 Jun 2008 17:55:28 -0700 Subject: [PATCH] Add a lossy 32-bit generic pixel fetch function for wide surfaces. The transformed fetch path currently only works at 32-bit precision. Until a wide version of that function is added, we need to have a path to perform a wide FetchPixel and then contract it down to a8r8g8b8. Also, use the right format when expanding the result in fbFetchTransformed64. fbFetchTransformed returns a8r8g8b8 results. --- pixman/pixman-access.c | 22 ++++++++++++++++++++-- pixman/pixman-transformed.c | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pixman/pixman-access.c b/pixman/pixman-access.c index ca9619c..d01f8bd 100644 --- a/pixman/pixman-access.c +++ b/pixman/pixman-access.c @@ -1258,6 +1258,24 @@ fbFetchPixel_yv12 (bits_image_t *pict, int offset, int line) (b >= 0 ? b < 0x1000000 ? (b >> 16) & 0x0000ff : 0x0000ff : 0); } +/* + * XXX: The transformed fetch path only works at 32-bpp so far. When all paths + * have wide versions, this can be removed. + * + * WARNING: This function loses precision! + */ +static FASTCALL uint32_t +fbFetchPixel32_generic_lossy (bits_image_t *pict, int offset, int line) +{ + fetchPixelProc64 fetchPixel64 = ACCESS(pixman_fetchPixelProcForPicture64) (pict); + const uint64_t argb16Pixel = fetchPixel64(pict, offset, line); + uint32_t argb8Pixel; + + pixman_contract(&argb8Pixel, &argb16Pixel, 1); + + return argb8Pixel; +} + fetchPixelProc32 ACCESS(pixman_fetchPixelProcForPicture32) (bits_image_t * pict) { switch(pict->format) { @@ -1266,8 +1284,8 @@ fetchPixelProc32 ACCESS(pixman_fetchPixelProcForPicture32) (bits_image_t * pict) case PIXMAN_a8b8g8r8: return fbFetchPixel_a8b8g8r8; case PIXMAN_x8b8g8r8: return fbFetchPixel_x8b8g8r8; /* These two require wide compositing */ - case PIXMAN_a2b10g10r10: return NULL; - case PIXMAN_x2b10g10r10: return NULL; + case PIXMAN_a2b10g10r10: return fbFetchPixel32_generic_lossy; + case PIXMAN_x2b10g10r10: return fbFetchPixel32_generic_lossy; /* 24bpp formats */ case PIXMAN_r8g8b8: return fbFetchPixel_r8g8b8; diff --git a/pixman/pixman-transformed.c b/pixman/pixman-transformed.c index 9f566bf..8dba26c 100644 --- a/pixman/pixman-transformed.c +++ b/pixman/pixman-transformed.c @@ -657,7 +657,7 @@ ACCESS(fbFetchTransformed64)(bits_image_t * pict, int x, int y, int width, maskBits); // Expand from 32bpp to 64bpp in place. - pixman_expand(buffer, (uint32_t*)buffer, pict->format, width); + pixman_expand(buffer, (uint32_t*)buffer, PIXMAN_a8r8g8b8, width); free(mask8); } -- 2.34.1