This patch adds 'pixman_texture_conversion' function which will be used by following patches for converting textures between different pixel formats.
Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikk...@gmail.com> --- src/mesa/main/texstore.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c index cb81f3f..a32b406 100644 --- a/src/mesa/main/texstore.c +++ b/src/mesa/main/texstore.c @@ -75,6 +75,10 @@ #include "../../gallium/auxiliary/util/u_format_r11g11b10f.h" +#ifdef HAVE_PIXMAN +# include <pixman.h> +#endif + enum { ZERO = 4, ONE = 5 @@ -966,6 +970,67 @@ memcpy_texture(struct gl_context *ctx, } } +#ifdef HAVE_PIXMAN +/** + * Use Pixman library to copy and convert src image to dst image. + * \param srcFormat pixman_format_code_t of the source image. + * \param srcBits pointer to source bits. + * \param srcStride the length of source stride. + * \param width of the source and destination images. + * \param height of the source and destination images. + * \param dstFormat pixman_format_code_t of the destination image. + * \param dstBits pointer to destination bits. + * \param dstStride the length of destination stride. + * \return GLboolean GL_TRUE if everything ok. + */ +static GLboolean +pixman_texture_conversion( + const pixman_format_code_t srcFormat, + uint32_t *srcBits, const uint32_t srcStride, + const uint16_t width, const uint16_t height, + const pixman_format_code_t dstFormat, + uint32_t *dstBits, const uint32_t dstStride) +{ + pixman_image_t *pixmanImage[2]; + + if ((pixmanImage[0] = pixman_image_create_bits_no_clear(srcFormat, + width, + height, + srcBits, + srcStride)) + == NULL) + return GL_FALSE; + + /* Assumption source and destination images are same size here. + */ + if ((pixmanImage[1] = pixman_image_create_bits_no_clear(dstFormat, + width, + height, + dstBits, + dstStride)) + == NULL) { + pixman_image_unref(pixmanImage[0]); + return GL_FALSE; + } + + pixman_image_composite(PIXMAN_OP_SRC, + pixmanImage[0], + (pixman_image_t*) NULL, + pixmanImage[1], + 0, + 0, + 0, + 0, + 0, + 0, + width, + height); + + pixman_image_unref(pixmanImage[0]); + pixman_image_unref(pixmanImage[1]); + return GL_TRUE; +} +#endif /* HAVE_PIXMAN */ /** * General-case function for storing a color texture images with -- 1.8.1.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev