[Libreoffice-commits] core.git: Branch 'distro/collabora/cd-5.3' - vcl/headless

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Jan 9 13:34:36 UTC 2018


 vcl/headless/svpgdi.cxx |   21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

New commits:
commit 67db4fe90e4c6e038b06bd3597fd876322cf8e48
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Jan 7 21:11:31 2018 -0500

    vcl: mask must alwasy be argb32 even when we can use rgb24
    
    Change-Id: I932669fc5ead7de60561d769dd21d2c35c1f957d
    Reviewed-on: https://gerrit.libreoffice.org/47564
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    (cherry picked from commit acb43c0b8efbfb841e7b40603d75a8432eb21f21)
    Reviewed-on: https://gerrit.libreoffice.org/47626
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index e928961055c3..42799ae12785 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -226,12 +226,16 @@ namespace
     class SourceHelper
     {
     public:
-        explicit SourceHelper(const SalBitmap& rSourceBitmap)
+        explicit SourceHelper(const SalBitmap& rSourceBitmap, const bool bForceARGB32 = false)
+#ifdef HAVE_CAIRO_FORMAT_RGB24_888
+            : m_bForceARGB32(bForceARGB32)
+#endif
         {
             const SvpSalBitmap& rSrcBmp = static_cast<const SvpSalBitmap&>(rSourceBitmap);
 #ifdef HAVE_CAIRO_FORMAT_RGB24_888
-            if (rSrcBmp.GetBitCount() != 32 && rSrcBmp.GetBitCount() != 24)
+            if ((rSrcBmp.GetBitCount() != 32 && rSrcBmp.GetBitCount() != 24) || bForceARGB32)
 #else
+            (void)bForceARGB32;
             if (rSrcBmp.GetBitCount() != 32)
 #endif
             {
@@ -272,13 +276,22 @@ namespace
 
             unsigned char *mask_data = cairo_image_surface_get_data(source);
 
-            cairo_format_t nFormat = cairo_image_surface_get_format(source);
+            const cairo_format_t nFormat = cairo_image_surface_get_format(source);
+#ifdef HAVE_CAIRO_FORMAT_RGB24_888
+            if (!m_bForceARGB32)
+                assert(nFormat == CAIRO_FORMAT_RGB24_888 && "Expected RGB24_888 image");
+            else
+#endif
             assert(nFormat == CAIRO_FORMAT_ARGB32 && "need to implement CAIRO_FORMAT_A1 after all here");
+
             rStride = cairo_format_stride_for_width(nFormat, cairo_image_surface_get_width(source));
 
             return mask_data;
         }
     private:
+#ifdef HAVE_CAIRO_FORMAT_RGB24_888
+        const bool m_bForceARGB32;
+#endif
         SvpSalBitmap aTmpBmp;
         cairo_surface_t* source;
 
@@ -1230,7 +1243,7 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR,
 {
     /** creates an image from the given rectangle, replacing all black pixels
      *  with nMaskColor and make all other full transparent */
-    SourceHelper aSurface(rSalBitmap);
+    SourceHelper aSurface(rSalBitmap, true); // The mask is argb32
     sal_Int32 nStride;
     unsigned char *mask_data = aSurface.getBits(nStride);
     for (sal_Int32 y = rTR.mnSrcY ; y < rTR.mnSrcY + rTR.mnSrcHeight; ++y)


More information about the Libreoffice-commits mailing list