diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-12-12 10:15:34 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-12-12 12:43:46 +0100 |
commit | 8f63516df72b49e9347d90750f6d3ef3d4a1813f (patch) | |
tree | 6768b1150378f0feb1e3f18fccb8b4e3dedee223 | |
parent | 1762a625db256758e23c7f9ec846b46af0ec145b (diff) |
tdf#94851 check SalBitmap & convert in all drawBitmap methods
Reviewed-on: https://gerrit.libreoffice.org/20656
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 917d59a84124d1022bd1912874e7a53c674784f1)
Change-Id: I040dd62737237ad7e016201a798ee42e27853556
-rw-r--r-- | vcl/win/source/gdi/salgdi2.cxx | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/vcl/win/source/gdi/salgdi2.cxx b/vcl/win/source/gdi/salgdi2.cxx index aa08d9145568..6f0e5d4a1eb9 100644 --- a/vcl/win/source/gdi/salgdi2.cxx +++ b/vcl/win/source/gdi/salgdi2.cxx @@ -71,17 +71,15 @@ void WinSalGraphics::copyArea( long nDestX, long nDestY, nSrcWidth, nSrcHeight, nFlags ); } -void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) +namespace { - if (dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get()) == nullptr && - dynamic_cast<const WinSalBitmap*>(&rSalBitmap) == nullptr) - { - SalBitmap& rConstBitmap = const_cast<SalBitmap&>(rSalBitmap); - BitmapBuffer* pRead = rConstBitmap.AcquireBuffer(BITMAP_READ_ACCESS); - std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap()); - pWinSalBitmap->Create(rConstBitmap.GetSize(), rConstBitmap.GetBitCount(), BitmapPalette()); - BitmapBuffer* pWrite = pWinSalBitmap->AcquireBuffer(BITMAP_WRITE_ACCESS); +void convertToWinSalBitmap(SalBitmap& rSalBitmap, WinSalBitmap& rWinSalBitmap) +{ + BitmapBuffer* pRead = rSalBitmap.AcquireBuffer(BITMAP_READ_ACCESS); + + rWinSalBitmap.Create(rSalBitmap.GetSize(), rSalBitmap.GetBitCount(), BitmapPalette()); + BitmapBuffer* pWrite = rWinSalBitmap.AcquireBuffer(BITMAP_WRITE_ACCESS); sal_uInt8* pSource(pRead->mpBits); sal_uInt8* pDestination(pWrite->mpBits); @@ -92,10 +90,21 @@ void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSal pSource += pRead->mnScanlineSize; pDestination += pWrite->mnScanlineSize; } - pWinSalBitmap->ReleaseBuffer(pWrite, BITMAP_WRITE_ACCESS); + rWinSalBitmap.ReleaseBuffer(pWrite, BITMAP_WRITE_ACCESS); + + rSalBitmap.ReleaseBuffer(pRead, BITMAP_READ_ACCESS); +} - rConstBitmap.ReleaseBuffer(pRead, BITMAP_READ_ACCESS); +} // end anonymous namespace +void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) +{ + if (dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get()) == nullptr && + dynamic_cast<const WinSalBitmap*>(&rSalBitmap) == nullptr) + { + std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap()); + SalBitmap& rConstBitmap = const_cast<SalBitmap&>(rSalBitmap); + convertToWinSalBitmap(rConstBitmap, *pWinSalBitmap.get()); mpImpl->drawBitmap(rPosAry, *pWinSalBitmap.get()); } else @@ -108,7 +117,24 @@ void WinSalGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSSalBitmap, const SalBitmap& rSTransparentBitmap ) { - mpImpl->drawBitmap( rPosAry, rSSalBitmap, rSTransparentBitmap ); + if (dynamic_cast<WinOpenGLSalGraphicsImpl*>(mpImpl.get()) == nullptr && + dynamic_cast<const WinSalBitmap*>(&rSSalBitmap) == nullptr) + { + std::unique_ptr<WinSalBitmap> pWinSalBitmap(new WinSalBitmap()); + SalBitmap& rConstBitmap = const_cast<SalBitmap&>(rSSalBitmap); + convertToWinSalBitmap(rConstBitmap, *pWinSalBitmap.get()); + + + std::unique_ptr<WinSalBitmap> pWinTransparentSalBitmap(new WinSalBitmap()); + SalBitmap& rConstTransparentBitmap = const_cast<SalBitmap&>(rSTransparentBitmap); + convertToWinSalBitmap(rConstTransparentBitmap, *pWinTransparentSalBitmap.get()); + + mpImpl->drawBitmap(rPosAry, *pWinSalBitmap.get(), *pWinTransparentSalBitmap.get()); + } + else + { + mpImpl->drawBitmap(rPosAry, rSSalBitmap, rSTransparentBitmap); + } } bool WinSalGraphics::drawAlphaRect( long nX, long nY, long nWidth, |