Kaydet (Commit) bc45215e authored tarafından Caolán McNamara's avatar Caolán McNamara

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/20440Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 48f0ba92
......@@ -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 */
......
......@@ -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,
......
......@@ -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:
......
......@@ -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));
}
......
......@@ -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;
......
......@@ -892,35 +892,19 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
// the Size argument is irrelevant, I hope
ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), DeviceFormat::DEFAULT);
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(),
......@@ -941,21 +925,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
......
......@@ -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,
......
......@@ -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:
......
......@@ -308,7 +308,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);
......@@ -1305,7 +1305,7 @@ cairo_surface_t* SvpSalGraphics::createCairoSurface(const basebmp::BitmapDeviceS
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 =
......
......@@ -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;
......
......@@ -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
......
......@@ -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)) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment