summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-12-07 13:34:01 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-12-07 20:49:53 +0000
commit0b7776fac09797c910de6bce615409eeecdeb65c (patch)
tree4484f2946cfc3608251fc4168aed24fd9daf6b54
parent2fbff6cdb3266a26a32390ddddd58ebd11947c49 (diff)
Resolves: tdf#96224 don't fiddle around with a separate alpha buffer
use a format that supports alpha directly now we can unify the android and linux cases as well and drop the BGRX support Change-Id: I3c845913691d8194822423005d308cfa7ef13ec3 Reviewed-on: https://gerrit.libreoffice.org/20440 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit bc45215ec6e5d508415465ad3f619c3dbe23f7c8)
-rw-r--r--basebmp/inc/rgbmaskpixelformats.hxx14
-rw-r--r--basebmp/source/bitmapdevice.cxx7
-rw-r--r--basebmp/source/debug.cxx2
-rw-r--r--basebmp/test/bmpmasktest.cxx4
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx2
-rw-r--r--desktop/source/lib/init.cxx37
-rw-r--r--include/basebmp/scanlineformats.hxx4
-rw-r--r--vcl/headless/svpbmp.cxx20
-rw-r--r--vcl/headless/svpgdi.cxx4
-rw-r--r--vcl/inc/headless/svpgdi.hxx2
-rw-r--r--vcl/qa/cppunit/BitmapTest.cxx2
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx2
12 files changed, 11 insertions, 89 deletions
diff --git a/basebmp/inc/rgbmaskpixelformats.hxx b/basebmp/inc/rgbmaskpixelformats.hxx
index 63068826e04f..9fde0d015730 100644
--- a/basebmp/inc/rgbmaskpixelformats.hxx
+++ b/basebmp/inc/rgbmaskpixelformats.hxx
@@ -334,20 +334,6 @@ typedef PixelFormatTraitsTemplate_RGBMask<
BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_RGBA32_8888::getter_type,
PixelFormatTraits_RGBA32_8888::setter_type);
-// Added for Cairo needs, perhaps Android should get an XRGB and replace
-// some uses of ARGB with that instead ?
-
-typedef PixelFormatTraitsTemplate_RGBMask<
- sal_uInt32,
- 0x00000000,
- 0x00FF0000,
- 0x0000FF00,
- 0x000000FF,
- BASEBMP_TRUECOLORMASK_LSB_SWAP > PixelFormatTraits_BGRX32_8888;
-BASEBMP_SPECIALIZE_ACCESSORTRAITS(PixelFormatTraits_BGRX32_8888::getter_type,
- PixelFormatTraits_BGRX32_8888::setter_type);
-
-
} // namespace basebmp
#endif /* INCLUDED_BASEBMP_INC_RGBMASKPIXELFORMATS_HXX */
diff --git a/basebmp/source/bitmapdevice.cxx b/basebmp/source/bitmapdevice.cxx
index a50f0dfd5efc..37ebf9136686 100644
--- a/basebmp/source/bitmapdevice.cxx
+++ b/basebmp/source/bitmapdevice.cxx
@@ -109,7 +109,6 @@ static const o3tl::enumarray<Format,sal_uInt8> bitsPerPixel =
16, // SIXTEEN_BIT_LSB_TC_MASK
16, // SIXTEEN_BIT_MSB_TC_MASK
24, // TWENTYFOUR_BIT_TC_MASK
- 32, // TWENTYFOUR_BIT_TC_MASK_BGRX
32, // THIRTYTWO_BIT_TC_MASK_BGRA
32, // THIRTYTWO_BIT_TC_MASK_ARGB
32, // THIRTYTWO_BIT_TC_MASK_ABGR
@@ -2053,12 +2052,6 @@ BitmapDeviceSharedPtr createBitmapDeviceImplInner( const basegfx::B2IVector&
// thirtytwo bit formats
- // 8 red bits, 8 green bits, 8 blue bits, and 8 ignored bits like CAIRO_FORMAT_RGB24
- case Format::ThirtyTwoBitTcMaskBGRX:
- return createRenderer<PixelFormatTraits_BGRX32_8888,StdMasks>(
- aBounds, rSize, nScanlineFormat, nScanlineStride,
- pFirstScanline, pMem, pPal, rDamage );
-
case Format::ThirtyTwoBitTcMaskBGRA:
return createRenderer<PixelFormatTraits_BGRA32_8888,StdMasks>(
aBounds, rSize, nScanlineFormat, nScanlineStride,
diff --git a/basebmp/source/debug.cxx b/basebmp/source/debug.cxx
index 3b9de684e86b..f01fd390e1c2 100644
--- a/basebmp/source/debug.cxx
+++ b/basebmp/source/debug.cxx
@@ -63,8 +63,6 @@ namespace basebmp
return "SIXTEEN_BIT_MSB_TC_MASK";
case Format::TwentyFourBitTcMask:
return "TWENTYFOUR_BIT_TC_MASK";
- case Format::ThirtyTwoBitTcMaskBGRX:
- return "THIRTYTWO_BIT_TC_MASK_BGRX";
case Format::ThirtyTwoBitTcMaskBGRA:
return "THIRTYTWO_BIT_TC_MASK_BGRA";
case Format::ThirtyTwoBitTcMaskARGB:
diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx
index 7f7e9130c3d2..daa926365a46 100644
--- a/basebmp/test/bmpmasktest.cxx
+++ b/basebmp/test/bmpmasktest.cxx
@@ -177,13 +177,13 @@ public:
DrawMode::Paint );
xBitmap = createBitmapDevice( aSize, false,
- Format::ThirtyTwoBitTcMaskBGRX );
+ Format::ThirtyTwoBitTcMaskBGRA );
xBitmap->clear(Color(0x80808080));
}
{ // mpOutput & mpBitmap
const basegfx::B2ISize aSize(9, 9);
xOutput = createBitmapDevice( aSize, false,
- Format::ThirtyTwoBitTcMaskBGRX );
+ Format::ThirtyTwoBitTcMaskBGRA );
xOutput->clear(Color(0xffffffff));
}
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 07607dd6b365..987ac1be9618 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -316,7 +316,7 @@ void DesktopLOKTest::testPaintTile()
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
int nCanvasWidth = 100;
int nCanvasHeight = 300;
- sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRX,
+ sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRA,
nCanvasWidth);
std::vector<unsigned char> aBuffer(nStride * nCanvasHeight);
int nTilePosX = 0;
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2bdea806e3cf..963bb1bcf072 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -886,33 +886,17 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
-#elif defined(ANDROID)
- ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ;
-
- boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >());
-
- boost::shared_array<sal_uInt8> aAlphaBuffer;
-
- pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, aAlphaBuffer);
-
- pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
#else
ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ;
+#if !defined(ANDROID)
// Set background to transparent by default.
pDevice->SetBackground(Wallpaper(Color(COL_TRANSPARENT)));
+#endif
boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- // Allocate a separate buffer for the alpha device.
- sal_Int32 nStride = basebmp::getBitmapDeviceStrideForWidth(basebmp::Format::ThirtyTwoBitTcMaskBGRX,
- nCanvasWidth);
- std::vector<sal_uInt8> aAlpha(nCanvasHeight * nStride);
-
- boost::shared_array<sal_uInt8> aAlphaBuffer(aAlpha.data(), NoDelete<sal_uInt8>());
+ boost::shared_array<sal_uInt8> aAlphaBuffer;
pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
@@ -933,21 +917,6 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
pDevice->DrawRect(aRect);
pDevice->Pop();
}
-
- // Overwrite pBuffer's alpha channel with the separate alpha buffer.
- for (int nRow = 0; nRow < nCanvasHeight; ++nRow)
- {
- for (int nCol = 0; nCol < nCanvasWidth; ++nCol)
- {
- const int nOffset = (nRow * nStride) + nCol * 4;
- // VCL's transparent is 0, RGBA's transparent is 0xff.
- pBuffer[nOffset + 3] = 0xff - aAlpha[nOffset];
- double fAlpha = pBuffer[nOffset + 3]/255.0;
- for (int i = 0; i < 3; ++i)
- pBuffer[nOffset + i] *= fAlpha;
- }
- }
-
#endif
#else
diff --git a/include/basebmp/scanlineformats.hxx b/include/basebmp/scanlineformats.hxx
index ec246d2d1409..efdc43fc533f 100644
--- a/include/basebmp/scanlineformats.hxx
+++ b/include/basebmp/scanlineformats.hxx
@@ -42,10 +42,6 @@ enum class Format
SixteenBitLsbTcMask,
SixteenBitMsbTcMask,
TwentyFourBitTcMask,
- // CAIRO_FORMAT_RGB24, each pixel is a 32-bit quantity, with the upper 8
- // bits unused. Red, Green, and Blue are stored in the remaining 24 bits in
- // that order (below U is for unused)
- ThirtyTwoBitTcMaskBGRX,
// The order of the channels code letters indicates the order of the
// channel bytes in memory
ThirtyTwoBitTcMaskBGRA,
diff --git a/vcl/headless/svpbmp.cxx b/vcl/headless/svpbmp.cxx
index 02f1453ede59..e6d962f268b3 100644
--- a/vcl/headless/svpbmp.cxx
+++ b/vcl/headless/svpbmp.cxx
@@ -198,25 +198,6 @@ BitmapBuffer* SvpSalBitmap::AcquireBuffer( BitmapAccessMode )
nBitCount = 24;
pBuf->mnFormat = BMP_FORMAT_24BIT_TC_BGR;
break;
- case Format::ThirtyTwoBitTcMaskBGRX:
- {
- nBitCount = 32;
- pBuf->mnFormat = BMP_FORMAT_32BIT_TC_MASK;
-#ifdef OSL_BIGENDIAN
- ColorMaskElement aRedMask(0x0000ff00);
- ColorMaskElement aGreenMask(0x00ff0000);
- ColorMaskElement aBlueMask(0xff000000);
-#else
- ColorMaskElement aRedMask(0x00ff0000);
- ColorMaskElement aGreenMask(0x0000ff00);
- ColorMaskElement aBlueMask(0x000000ff);
-#endif
- aBlueMask.CalcMaskShift();
- aRedMask.CalcMaskShift();
- aGreenMask.CalcMaskShift();
- pBuf->maColorMask = ColorMask(aRedMask, aGreenMask, aBlueMask);
- break;
- }
case Format::ThirtyTwoBitTcMaskBGRA:
{
nBitCount = 32;
@@ -457,7 +438,6 @@ sal_uInt32 SvpSalBitmap::getBitCountFromScanlineFormat( basebmp::Format nFormat
case Format::TwentyFourBitTcMask:
nBitCount = 24;
break;
- case Format::ThirtyTwoBitTcMaskBGRX:
case Format::ThirtyTwoBitTcMaskBGRA:
case Format::ThirtyTwoBitTcMaskARGB:
case Format::ThirtyTwoBitTcMaskABGR:
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 9e3b16ed3aa1..57cb68ab9de5 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -110,7 +110,7 @@ namespace
sal_Int32 nStride = rBuffer->getScanlineStride();
cairo_format_t nFormat;
if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT)
- nFormat = CAIRO_FORMAT_RGB24;
+ nFormat = CAIRO_FORMAT_ARGB32;
else
nFormat = CAIRO_FORMAT_A1;
return (cairo_format_stride_for_width(nFormat, size.getX()) == nStride);
@@ -1045,7 +1045,7 @@ cairo_t* SvpSalGraphics::createCairoContext(const basebmp::BitmapDeviceSharedPtr
basebmp::RawMemorySharedArray data = rBuffer->getBuffer();
cairo_format_t nFormat;
if (rBuffer->getScanlineFormat() == SVP_CAIRO_FORMAT)
- nFormat = CAIRO_FORMAT_RGB24;
+ nFormat = CAIRO_FORMAT_ARGB32;
else
nFormat = CAIRO_FORMAT_A1;
cairo_surface_t *target =
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 944ac83e3ff7..fa6a06377b60 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -41,7 +41,7 @@
#ifdef ANDROID
# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskRGBA
#else
-# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskBGRX
+# define SVP_CAIRO_FORMAT basebmp::Format::ThirtyTwoBitTcMaskBGRA
#endif
class GlyphCache;
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 33820e467c3b..eb393bc5c538 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -70,7 +70,7 @@ void BitmapTest::testConvert()
{
Bitmap::ScopedReadAccess pReadAccess(aBitmap);
#if defined LINUX
- // 24 bit Bitmap on SVP backend uses 32bit BGRX format
+ // 24 bit Bitmap on SVP backend uses 32bit BGRA format
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(32), pReadAccess->GetBitCount());
CPPUNIT_ASSERT_EQUAL(sal_uLong(40), pReadAccess->GetScanlineSize());
#else
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 75fa0dfbb36e..62b2ac46125e 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -1511,7 +1511,7 @@ void GtkSalFrame::AllocateFrame()
if( aFrameSize.getY() == 0 )
aFrameSize.setY( 1 );
m_aFrame = basebmp::createBitmapDevice(aFrameSize, true, SVP_CAIRO_FORMAT);
- assert(cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, aFrameSize.getX()) ==
+ assert(cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, aFrameSize.getX()) ==
m_aFrame->getScanlineStride());
m_aFrame->setDamageTracker(
basebmp::IBitmapDeviceDamageTrackerSharedPtr(new DamageTracker(*this)) );