external/cairo/cairo/cairo-1.10.2.patch | 137 ++++++++++++++++++++++++++++---- vcl/headless/svpgdi.cxx | 42 +++++++-- vcl/inc/headless/svpgdi.hxx | 7 - 3 files changed, 157 insertions(+), 29 deletions(-)
New commits: commit 31c044e2501b9d4a0917e4e09133660bbe2a24dc Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Dec 9 16:28:42 2017 -0500 vcl-svp: add 24-bit (3-byte) RGB surface support to Cairo Change-Id: I7707219eae4c2d6d40c8dc957207b63d3049a75f (cherry picked from commit e8ba02b1d56dc7b59a4f0a7373995b28653a0597) Reviewed-on: https://gerrit.libreoffice.org/46681 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/external/cairo/cairo/cairo-1.10.2.patch b/external/cairo/cairo/cairo-1.10.2.patch index d564d53ab9e0..f50501926faa 100644 --- a/external/cairo/cairo/cairo-1.10.2.patch +++ b/external/cairo/cairo/cairo-1.10.2.patch @@ -1,5 +1,6 @@ ---- misc/cairo-1.10.2/build/Makefile.win32.features 2010-08-18 09:47:30.000000000 +0200 -+++ misc/build/cairo-1.10.2/build/Makefile.win32.features 2011-12-20 09:57:06.428170146 +0100 +diff -ruNw misc/cairo-1.10.2/build/Makefile.win32.features misc/build/cairo-1.10.2/build/Makefile.win32.features +--- misc/cairo-1.10.2/build/Makefile.win32.features 2015-10-27 17:04:21.000000000 -0400 ++++ misc/build/cairo-1.10.2/build/Makefile.win32.features 2017-11-24 21:43:14.103524768 -0500 @@ -30,7 +30,7 @@ CAIRO_HAS_FC_FONT=0 CAIRO_HAS_PS_SURFACE=1 @@ -9,9 +10,10 @@ CAIRO_HAS_TEST_SURFACES=0 CAIRO_HAS_TEE_SURFACE=0 CAIRO_HAS_XML_SURFACE=0 ---- misc/cairo-1.10.2/configure 2010-12-25 15:22:57.000000000 +0100 -+++ misc/build/cairo-1.10.2/configure 2010-12-25 15:22:57.000000000 +0100 -@@ -19259,59 +19259,10 @@ +diff -ruNw misc/cairo-1.10.2/configure misc/build/cairo-1.10.2/configure +--- misc/cairo-1.10.2/configure 2015-12-09 15:41:45.000000000 -0500 ++++ misc/build/cairo-1.10.2/configure 2017-11-24 21:43:14.103524768 -0500 +@@ -20580,61 +20580,12 @@ rm -f confcache @@ -58,8 +60,8 @@ have_libz=yes $as_echo "#define HAVE_ZLIB 1" >>confdefs.h -- -- + + -else - have_libz="no (requires zlib http://www.gzip.org/zlib/)" -fi @@ -68,10 +70,12 @@ -else - have_libz="no (requires zlib http://www.gzip.org/zlib/)" -fi - - +- +- save_LIBS="$LIBS" -@@ -29424,7 +29424,7 @@ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzo2a_decompress in -llzo2" >&5 + $as_echo_n "checking for lzo2a_decompress in -llzo2... " >&6; } +@@ -30069,7 +30020,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_VERSION - OK" >&5 $as_echo "$FREETYPE_VERSION - OK" >&6; } ft_NONPKGCONFIG_CFLAGS=`$FREETYPE_CONFIG --cflags` @@ -80,7 +84,7 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_VERSION - Too old" >&5 $as_echo "$FREETYPE_VERSION - Too old" >&6; } use_ft="no ($FREETYPE_VERSION found; version $FREETYPE_MIN_VERSION from release $FREETYPE_MIN_RELEASE required)" -@@ -29434,7 +29434,7 @@ +@@ -30079,7 +30030,7 @@ fi ft_CFLAGS="$FREETYPE_CFLAGS" @@ -89,7 +93,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cairo's FreeType font backend feature could be enabled" >&5 -@@ -30121,7 +30121,7 @@ +@@ -30686,7 +30637,7 @@ # The ps backend requires zlib. use_ps=$have_libz @@ -98,7 +102,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cairo's PostScript surface backend feature could be enabled" >&5 -@@ -30549,7 +30549,7 @@ +@@ -31082,7 +31033,7 @@ # The pdf backend requires zlib. use_pdf=$have_libz @@ -107,7 +111,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cairo's PDF surface backend feature could be enabled" >&5 -@@ -32296,7 +32296,7 @@ +@@ -32973,7 +32924,7 @@ use_xml=$have_libz @@ -116,4 +120,107 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cairo's xml surface backend feature could be enabled" >&5 -$as_echo_n "checking whether cairo's xml surface backend feature could be enabled... " >&6; } +diff -ruNw misc/cairo-1.10.2/src/cairo.h misc/build/cairo-1.10.2/src/cairo.h +--- misc/cairo-1.10.2/src/cairo.h 2015-10-27 17:04:21.000000000 -0400 ++++ misc/build/cairo-1.10.2/src/cairo.h 2017-12-17 12:09:59.880406411 -0500 +@@ -397,6 +397,8 @@ + * with red in the upper 5 bits, then green in the middle + * 6 bits, and blue in the lower 5 bits. (Since 1.2) + * @CAIRO_FORMAT_RGB30: like RGB24 but with 10bpc. (Since 1.12) ++ * @CAIRO_FORMAT_RGB24_888: each pixel is a 24-bit quantity, ++ * with Red, Green, Blue taking 8-bits each, in that order. (Since 1.1x) + * + * #cairo_format_t is used to identify the memory format of + * image data. +@@ -412,9 +414,16 @@ + CAIRO_FORMAT_A8 = 2, + CAIRO_FORMAT_A1 = 3, + CAIRO_FORMAT_RGB16_565 = 4, +- CAIRO_FORMAT_RGB30 = 5 ++ CAIRO_FORMAT_RGB30 = 5, ++ CAIRO_FORMAT_RGB24_888 = 6 + } cairo_format_t; + ++/** ++ * Need this until CAIRO_FORMAT_RGB24_888 is in some official release. ++ * Otherwise we can't reliably check if this is available or we should ++ * convert from 24-bit RGB to 32-bit RGB before passing to Cairo. ++ **/ ++#define HAVE_CAIRO_FORMAT_RGB24_888 + + /** + * cairo_write_func_t: +diff -ruNw misc/cairo-1.10.2/src/cairo-image-source.c misc/build/cairo-1.10.2/src/cairo-image-source.c +--- misc/cairo-1.10.2/src/cairo-image-source.c 2015-10-27 17:04:30.000000000 -0400 ++++ misc/build/cairo-1.10.2/src/cairo-image-source.c 2017-12-17 12:09:56.076344387 -0500 +@@ -508,6 +508,19 @@ + color.blue = expand_channel(pixel & 0x3fff, 10); + return pixman_image_create_solid_fill (&color); + ++ case CAIRO_FORMAT_RGB24_888: ++ pixel = *(uint32_t *) (image->data + y * image->stride + 3 * x); ++ pixel &= 0x00ffffff; /* ignore next pixel bits */ ++ if (pixel == 0) ++ return _pixman_black_image (); ++ if (pixel == 0x00ffffff) ++ return _pixman_white_image (); ++ ++ color.red = (pixel >> 16 & 0xff) | (pixel >> 8 & 0xff00); ++ color.green = (pixel >> 8 & 0xff) | (pixel & 0xff00); ++ color.blue = (pixel & 0xff) | (pixel << 8 & 0xff00); ++ return pixman_image_create_solid_fill (&color); ++ + case CAIRO_FORMAT_ARGB32: + case CAIRO_FORMAT_RGB24: + pixel = *(uint32_t *) (image->data + y * image->stride + 4 * x); +diff -ruNw misc/cairo-1.10.2/src/cairo-image-surface.c misc/build/cairo-1.10.2/src/cairo-image-surface.c +--- misc/cairo-1.10.2/src/cairo-image-surface.c 2015-10-27 17:04:30.000000000 -0400 ++++ misc/build/cairo-1.10.2/src/cairo-image-surface.c 2017-12-17 12:09:59.876406346 -0500 +@@ -104,13 +104,15 @@ + return CAIRO_FORMAT_A1; + case PIXMAN_r5g6b5: + return CAIRO_FORMAT_RGB16_565; ++ case PIXMAN_r8g8b8: ++ return CAIRO_FORMAT_RGB24_888; + #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0) + case PIXMAN_r8g8b8a8: case PIXMAN_r8g8b8x8: + #endif + #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,27,2) + case PIXMAN_a8r8g8b8_sRGB: + #endif +- case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8: ++ case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: + case PIXMAN_b8g8r8: case PIXMAN_b5g6r5: + case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5: + case PIXMAN_x1b5g5r5: case PIXMAN_a4r4g4b4: case PIXMAN_x4r4g4b4: +@@ -320,6 +322,9 @@ + case CAIRO_FORMAT_RGB16_565: + ret = PIXMAN_r5g6b5; + break; ++ case CAIRO_FORMAT_RGB24_888: ++ ret = PIXMAN_r8g8b8; ++ break; + case CAIRO_FORMAT_ARGB32: + case CAIRO_FORMAT_INVALID: + default: +@@ -718,6 +723,8 @@ + case CAIRO_FORMAT_RGB30: + case CAIRO_FORMAT_RGB24: + return 32; ++ case CAIRO_FORMAT_RGB24_888: ++ return 24; + case CAIRO_FORMAT_RGB16_565: + return 16; + case CAIRO_FORMAT_A8: +diff -ruNw misc/cairo-1.10.2/src/cairoint.h misc/build/cairo-1.10.2/src/cairoint.h +--- misc/cairo-1.10.2/src/cairoint.h 2015-10-27 17:04:30.000000000 -0400 ++++ misc/build/cairo-1.10.2/src/cairoint.h 2017-12-17 12:09:59.880406411 -0500 +@@ -1486,7 +1486,7 @@ + * in cairo-xlib-surface.c--again see -Wswitch-enum). + */ + #define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 && \ +- (format) <= CAIRO_FORMAT_RGB30) ++ (format) <= CAIRO_FORMAT_RGB24_888) + + /* pixman-required stride alignment in bytes. */ + #define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t)) diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index cd546ab5fdb1..e928961055c3 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -37,9 +37,9 @@ #include <cairo.h> #if ENABLE_CAIRO_CANVAS -#if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) -# define CAIRO_OPERATOR_DIFFERENCE (static_cast<cairo_operator_t>(23)) -#endif +# if defined CAIRO_VERSION && CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 10, 0) +# define CAIRO_OPERATOR_DIFFERENCE (static_cast<cairo_operator_t>(23)) +# endif #endif namespace @@ -103,9 +103,18 @@ namespace cairo_format_t getCairoFormat(const BitmapBuffer& rBuffer) { cairo_format_t nFormat; +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 + assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 24 || rBuffer.mnBitCount == 1); +#else assert(rBuffer.mnBitCount == 32 || rBuffer.mnBitCount == 1); +#endif + if (rBuffer.mnBitCount == 32) nFormat = CAIRO_FORMAT_ARGB32; +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 + else if (rBuffer.mnBitCount == 24) + nFormat = CAIRO_FORMAT_RGB24_888; +#endif else nFormat = CAIRO_FORMAT_A1; return nFormat; @@ -179,6 +188,15 @@ namespace { if ((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N32BitTcRgba) { + assert((SVP_24BIT_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N24BitTcRgb); + pD[0] = pS[0]; + pD[1] = pS[1]; + pD[2] = pS[2]; + pD[3] = 0xff; // Alpha + } + else if ((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N32BitTcBgra) + { + assert((SVP_24BIT_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N24BitTcBgr); pD[0] = pS[0]; pD[1] = pS[1]; pD[2] = pS[2]; @@ -186,18 +204,12 @@ namespace } else if ((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N32BitTcArgb) { + assert((SVP_24BIT_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N24BitTcRgb); pD[0] = 0xff; // Alpha pD[1] = pS[0]; pD[2] = pS[1]; pD[3] = pS[2]; } - else if ((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown) == ScanlineFormat::N32BitTcBgra) - { - pD[0] = pS[2]; - pD[1] = pS[1]; - pD[2] = pS[0]; - pD[3] = 0xff; // Alpha - } else { assert(!"Unsupported SVP_CAIRO_FORMAT!"); @@ -217,7 +229,11 @@ namespace explicit SourceHelper(const SalBitmap& rSourceBitmap) { const SvpSalBitmap& rSrcBmp = static_cast<const SvpSalBitmap&>(rSourceBitmap); +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 + if (rSrcBmp.GetBitCount() != 32 && rSrcBmp.GetBitCount() != 24) +#else if (rSrcBmp.GetBitCount() != 32) +#endif { //big stupid copy here static bool bWarnedOnce = false; @@ -1439,8 +1455,12 @@ namespace if (!pBuffer) return false; - // Cairo doesn't support 24-bit RGB; only ARGB with the alpha ignored. + // We use Cairo that supports 24-bit RGB. +#ifdef HAVE_CAIRO_FORMAT_RGB24_888 + if (pBuffer->mnBitCount != 32 && pBuffer->mnBitCount != 24 && pBuffer->mnBitCount != 1) +#else if (pBuffer->mnBitCount != 32 && pBuffer->mnBitCount != 1) +#endif return false; cairo_format_t nFormat = getCairoFormat(*pBuffer); diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index f092b0375822..27ebad049d16 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -38,19 +38,23 @@ //which is internal in that case, to swap the rgb components so that //cairo then matches the OpenGL GL_RGBA format so we can use it there //where we don't have GL_BGRA support. +// SVP_24BIT_FORMAT is used to store 24-bit images in 3-byte pixels to conserve memory. #if defined ANDROID +# define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown) # define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcRgba | ScanlineFormat::TopDown) # define SVP_CAIRO_BLUE 1 # define SVP_CAIRO_GREEN 2 # define SVP_CAIRO_RED 0 # define SVP_CAIRO_ALPHA 3 #elif defined OSL_BIGENDIAN +# define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown) # define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcArgb | ScanlineFormat::TopDown) # define SVP_CAIRO_BLUE 3 # define SVP_CAIRO_GREEN 2 # define SVP_CAIRO_RED 1 # define SVP_CAIRO_ALPHA 0 #else +# define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcBgr | ScanlineFormat::TopDown) # define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcBgra | ScanlineFormat::TopDown) # define SVP_CAIRO_BLUE 0 # define SVP_CAIRO_GREEN 1 @@ -58,9 +62,6 @@ # define SVP_CAIRO_ALPHA 3 #endif -// Used to store 24-bit images in 3-byte pixels to conserve memory. -#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown) - struct BitmapBuffer; class GlyphCache; class FreetypeFont; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits