summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-10-09 19:28:49 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-10-12 15:10:44 +0200
commit77809fba7d4bf5e0b604ffa3937c18d5530c2d56 (patch)
tree4c93378a2494ef44783a25a398dc9dae9a8afcee
parent3aaed31c05d6c5964c830b44550432cbfb7c15af (diff)
implement ImplFastBitmapConversion() for 8bit gray source
With some documents SvpSalGraphics::drawTransformedBitmap() ends up calling StretchAndConvert() with 8bit grayscale source bitmap (e.g. OutputDevice::DrawTransformBitmapExDirect() uses them as dummy alpha masks). But ImplFastBitmapConversion() doesn't handle this case, so StretchAndConvert() falls back to doing it manually, easily making this 3x slower. But 8bit grayscale bitmaps sort of are actually non-paletted, so this is easy to optimize. Change-Id: I93aa3f283c8a182d76f3aa267ebd471e63d945e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104129 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--vcl/source/gdi/bmpfast.cxx34
1 files changed, 22 insertions, 12 deletions
diff --git a/vcl/source/gdi/bmpfast.cxx b/vcl/source/gdi/bmpfast.cxx
index 76a5239d4ceb..5528d9fcf455 100644
--- a/vcl/source/gdi/bmpfast.cxx
+++ b/vcl/source/gdi/bmpfast.cxx
@@ -173,20 +173,21 @@ public:
}
};
+// This assumes the content uses the grayscale palette (needs to be checked
+// by code allowing the use of the format).
+// Only reading color is implemented, since e.g. 24bpp input couldn't be
+// easily guaranteed to be grayscale.
template <>
-class TrueColorPixelPtr<ScanlineFormat::N8BitTcMask> : public BasePixelPtr
+class TrueColorPixelPtr<ScanlineFormat::N8BitPal> : public BasePixelPtr
{
public:
void operator++() { mpPixel += 1; }
- PIXBYTE GetAlpha() const { return mpPixel[0]; }
-};
-// TODO: for some reason many Alpha maps are ScanlineFormat::N8BitPal
-// they should be ScanlineFormat::N8BitTcMask
-template <>
-class TrueColorPixelPtr<ScanlineFormat::N8BitPal>
-: public TrueColorPixelPtr<ScanlineFormat::N8BitTcMask>
-{};
+ PIXBYTE GetRed() const { return mpPixel[0]; }
+ PIXBYTE GetGreen() const { return mpPixel[0]; }
+ PIXBYTE GetBlue() const { return mpPixel[0]; }
+ static PIXBYTE GetAlpha() { return 255; }
+};
}
@@ -251,7 +252,8 @@ static void ImplBlendLines( const TrueColorPixelPtr<DSTFMT>& rDst,
TrueColorPixelPtr<SRCFMT> aSrc( rSrc );
while( --nPixelCount >= 0 )
{
- ImplBlendPixels(aDst, aSrc, aMsk.GetAlpha());
+ // VCL masks store alpha as color, hence the GetRed() and not GetAlpha().
+ ImplBlendPixels(aDst, aSrc, aMsk.GetRed());
++aDst;
++aSrc;
++aMsk;
@@ -424,7 +426,6 @@ bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc,
case ScanlineFormat::N1BitLsbPal:
case ScanlineFormat::N4BitMsnPal:
case ScanlineFormat::N4BitLsnPal:
- case ScanlineFormat::N8BitPal:
break;
case ScanlineFormat::N8BitTcMask:
@@ -433,6 +434,11 @@ bool ImplFastBitmapConversion( BitmapBuffer& rDst, const BitmapBuffer& rSrc,
// return ImplConvertFromBitmap<ScanlineFormat::N32BitTcMask>( rDst, rSrc );
break;
+ case ScanlineFormat::N8BitPal:
+ if(rSrc.maPalette.IsGreyPalette8Bit())
+ return ImplConvertFromBitmap<ScanlineFormat::N8BitPal>( rDst, rSrc );
+ break;
+
case ScanlineFormat::N24BitTcBgr:
return ImplConvertFromBitmap<ScanlineFormat::N24BitTcBgr>( rDst, rSrc );
case ScanlineFormat::N24BitTcRgb:
@@ -737,7 +743,6 @@ bool ImplFastBitmapBlending( BitmapWriteAccess const & rDstWA,
case ScanlineFormat::N1BitLsbPal:
case ScanlineFormat::N4BitMsnPal:
case ScanlineFormat::N4BitLsnPal:
- case ScanlineFormat::N8BitPal:
break;
case ScanlineFormat::N8BitTcMask:
@@ -746,6 +751,11 @@ bool ImplFastBitmapBlending( BitmapWriteAccess const & rDstWA,
// return ImplBlendFromBitmap<ScanlineFormat::N32BitTcMask>( rDst, rSrc );
break;
+ case ScanlineFormat::N8BitPal:
+ if(rSrc.maPalette.IsGreyPalette8Bit())
+ return ImplBlendFromBitmap<ScanlineFormat::N8BitPal>( rDst, rSrc, rMsk );
+ break;
+
case ScanlineFormat::N24BitTcBgr:
return ImplBlendFromBitmap<ScanlineFormat::N24BitTcBgr>( rDst, rSrc, rMsk );
case ScanlineFormat::N24BitTcRgb: