add an --enable-cairo-rgba to set the order of pixels for internal cairo
Change-Id: Ieab2ef59f63a7722bffea3273d2eeefadef47b56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153628 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
parent
aa86e7e8c2
commit
22ab4f30ac
10 changed files with 72 additions and 30 deletions
|
@ -145,6 +145,7 @@ export ENABLE_AVAHI=@ENABLE_AVAHI@
|
|||
export ENABLE_BREAKPAD=@ENABLE_BREAKPAD@
|
||||
export DEFAULT_CRASHDUMP_VALUE=@DEFAULT_CRASHDUMP_VALUE@
|
||||
export ENABLE_CAIRO_CANVAS=@ENABLE_CAIRO_CANVAS@
|
||||
export ENABLE_CAIRO_RGBA=@ENABLE_CAIRO_RGBA@
|
||||
export ENABLE_CIPHER_OPENSSL_BACKEND=@ENABLE_CIPHER_OPENSSL_BACKEND@
|
||||
export ENABLE_CLUCENE=@ENABLE_CLUCENE@
|
||||
export ENABLE_LIBCMIS=@ENABLE_LIBCMIS@
|
||||
|
|
6
config_host/config_cairo_rgba.h.in
Normal file
6
config_host/config_cairo_rgba.h.in
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef CONFIG_CAIRO_RGBA_H
|
||||
#define CONFIG_CAIRO_RGBA_H
|
||||
|
||||
#define ENABLE_CAIRO_RGBA 0
|
||||
|
||||
#endif
|
21
configure.ac
21
configure.ac
|
@ -2482,6 +2482,10 @@ AC_ARG_WITH(system-hunspell,
|
|||
[Use libhunspell already on system.]),,
|
||||
[with_system_hunspell="$with_system_libs"])
|
||||
|
||||
libo_FUZZ_ARG_ENABLE(cairo-rgba,
|
||||
AS_HELP_STRING([--enable-cairo-rgba],
|
||||
[Use RGBA order, instead of default BRGA. Not possible with --with-system-cairo]))
|
||||
|
||||
libo_FUZZ_ARG_ENABLE(zxing,
|
||||
AS_HELP_STRING([--disable-zxing],
|
||||
[Disable use of zxing external library.]))
|
||||
|
@ -13610,6 +13614,20 @@ fi
|
|||
AC_SUBST(USE_XINERAMA)
|
||||
AC_SUBST(XINERAMA_LINK)
|
||||
|
||||
AC_MSG_CHECKING([whether to use non-standard RGBA32 cairo pixel order])
|
||||
if test -z "$enable_cairo_rgba" -a "$_os" = "Android"; then
|
||||
enable_cairo_rgba=yes
|
||||
fi
|
||||
if test "$enable_cairo_rgba" = yes; then
|
||||
AC_DEFINE(ENABLE_CAIRO_RGBA)
|
||||
ENABLE_CAIRO_RGBA=TRUE
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
ENABLE_CAIRO_RGBA=
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
AC_SUBST(ENABLE_CAIRO_RGBA)
|
||||
|
||||
dnl ===================================================================
|
||||
dnl Test whether to build cairo or rely on the system version
|
||||
dnl ===================================================================
|
||||
|
@ -13618,7 +13636,7 @@ if test "$test_cairo" = "yes"; then
|
|||
AC_MSG_CHECKING([whether to use the system cairo])
|
||||
|
||||
: ${with_system_cairo:=$with_system_libs}
|
||||
if test "$with_system_cairo" = "yes"; then
|
||||
if test "$with_system_cairo" = "yes" -a "$enable_cairo_rgba" != "yes"; then
|
||||
SYSTEM_CAIRO=TRUE
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
|
@ -14924,6 +14942,7 @@ AC_CONFIG_HEADERS([config_host/config_dconf.h])
|
|||
AC_CONFIG_HEADERS([config_host/config_eot.h])
|
||||
AC_CONFIG_HEADERS([config_host/config_extensions.h])
|
||||
AC_CONFIG_HEADERS([config_host/config_cairo_canvas.h])
|
||||
AC_CONFIG_HEADERS([config_host/config_cairo_rgba.h])
|
||||
AC_CONFIG_HEADERS([config_host/config_cxxabi.h])
|
||||
AC_CONFIG_HEADERS([config_host/config_dbus.h])
|
||||
AC_CONFIG_HEADERS([config_host/config_features.h])
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <sfx2/lokhelper.hxx>
|
||||
#include <config_buildconfig.h>
|
||||
#include <config_cairo_rgba.h>
|
||||
#include <config_features.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -4229,7 +4230,11 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
|
|||
static int doc_getTileMode(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/)
|
||||
{
|
||||
SetLastExceptionMsg();
|
||||
#if ENABLE_CAIRO_RGBA
|
||||
return LOK_TILEMODE_RGBA;
|
||||
#else
|
||||
return LOK_TILEMODE_BGRA;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
--with-myspell-dicts
|
||||
--with-system-zlib
|
||||
--disable-poppler
|
||||
--enable-cairo-rgba
|
||||
--without-system-cairo
|
||||
--without-system-fontconfig
|
||||
--without-system-freetype
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
--disable-odk
|
||||
--disable-online-update
|
||||
--disable-skia
|
||||
--enable-cairo-rgba
|
||||
--enable-pdfimport
|
||||
--disable-postgresql-sdbc
|
||||
--disable-report-builder
|
||||
|
|
3
external/cairo/UnpackedTarball_cairo.mk
vendored
3
external/cairo/UnpackedTarball_cairo.mk
vendored
|
@ -40,8 +40,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,cairo,\
|
|||
))
|
||||
endif
|
||||
|
||||
# To be applied only when ENABLE_ANDROID_LOK is not defined
|
||||
ifeq ($(OS)$(ENABLE_ANDROID_LOK),ANDROID)
|
||||
ifeq ($(ENABLE_CAIRO_RGBA),TRUE)
|
||||
$(eval $(call gb_UnpackedTarball_add_patches,cairo,\
|
||||
external/cairo/cairo/cairo.GL_RGBA.patch \
|
||||
))
|
||||
|
|
|
@ -24,14 +24,20 @@
|
|||
#include <vcl/Scanline.hxx>
|
||||
#include <vcl/vclptr.hxx>
|
||||
#include <config_features.h>
|
||||
#include <config_cairo_rgba.h>
|
||||
#include <memory>
|
||||
|
||||
//Using formats that match cairo's formats. For android we patch cairo,
|
||||
//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.
|
||||
// Using formats that match cairo's formats.
|
||||
// SVP_24BIT_FORMAT is used to store 24-bit images in 3-byte pixels to conserve memory.
|
||||
#if defined(ANDROID) && !HAVE_FEATURE_ANDROID_LOK
|
||||
|
||||
/*
|
||||
For internal cairo we have the option --enable-cairo-rgba which is potentially
|
||||
useful for Andoid or Online to switch the rgb components. For Android cairo then
|
||||
matches the OpenGL GL_RGBA format so we can use it there where we don't have
|
||||
GL_BGRA support. Similarly for Online we can then use cairo's pixel data
|
||||
without needing to swizzle it for use as a canvas ImageData.
|
||||
*/
|
||||
#if ENABLE_CAIRO_RGBA
|
||||
#define SVP_24BIT_FORMAT (ScanlineFormat::N24BitTcRgb | ScanlineFormat::TopDown)
|
||||
#define SVP_CAIRO_FORMAT (ScanlineFormat::N32BitTcRgba | ScanlineFormat::TopDown)
|
||||
#define SVP_CAIRO_BLUE 1
|
||||
|
|
|
@ -110,29 +110,33 @@ static void dumpTile(const char *pNameStem,
|
|||
for (int x = 0; x < nWidth; ++x)
|
||||
{
|
||||
const char* pixel = row + x * 4;
|
||||
if (mode == LOK_TILEMODE_RGBA)
|
||||
{
|
||||
ofs.write(pixel, 3); // Skip alpha
|
||||
}
|
||||
else if (mode == LOK_TILEMODE_BGRA)
|
||||
{
|
||||
const int alpha = *(pixel + 3);
|
||||
char buf[3];
|
||||
if (alpha == 0)
|
||||
{
|
||||
buf[0] = 0;
|
||||
buf[1] = 0;
|
||||
buf[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
buf[0] = (*(pixel + 2) * 255 + alpha / 2) / alpha;
|
||||
buf[1] = (*(pixel + 1) * 255 + alpha / 2) / alpha;
|
||||
buf[2] = (*(pixel + 0) * 255 + alpha / 2) / alpha;
|
||||
}
|
||||
|
||||
ofs.write(buf, 3);
|
||||
const int alpha = *(pixel + 3);
|
||||
char buf[3];
|
||||
if (alpha == 0)
|
||||
{
|
||||
buf[0] = 0;
|
||||
buf[1] = 0;
|
||||
buf[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case LOK_TILEMODE_RGBA:
|
||||
buf[0] = (*(pixel + 0) * 255 + alpha / 2) / alpha;
|
||||
buf[1] = (*(pixel + 1) * 255 + alpha / 2) / alpha;
|
||||
buf[2] = (*(pixel + 2) * 255 + alpha / 2) / alpha;
|
||||
break;
|
||||
case LOK_TILEMODE_BGRA:
|
||||
buf[0] = (*(pixel + 2) * 255 + alpha / 2) / alpha;
|
||||
buf[1] = (*(pixel + 1) * 255 + alpha / 2) / alpha;
|
||||
buf[2] = (*(pixel + 0) * 255 + alpha / 2) / alpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ofs.write(buf, 3);
|
||||
if (dumpText)
|
||||
{
|
||||
int lowResI = (pixel[0] + pixel[1] + pixel[2])/(3*16);
|
||||
|
|
|
@ -2037,7 +2037,7 @@ std::unique_ptr<BitmapBuffer> FastConvert24BitRgbTo32BitCairo(const BitmapBuffer
|
|||
sal_uInt8* pD = pDst->mpBits + y * pDst->mnScanlineSize;
|
||||
for (tools::Long x = 0; x < nWidth; ++x)
|
||||
{
|
||||
#if defined(ANDROID) && !HAVE_FEATURE_ANDROID_LOK
|
||||
#if ENABLE_CAIRO_RGBA
|
||||
static_assert((SVP_CAIRO_FORMAT & ~ScanlineFormat::TopDown)
|
||||
== ScanlineFormat::N32BitTcRgba,
|
||||
"Expected SVP_CAIRO_FORMAT set to N32BitTcBgra");
|
||||
|
|
Loading…
Reference in a new issue