vcl/win/gdi/salgdi2.cxx | 50 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-)
New commits: commit 917d59a84124d1022bd1912874e7a53c674784f1 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Sat Dec 12 10:15:34 2015 +0100 tdf#94851 check SalBitmap & convert in all drawBitmap methods Change-Id: I040dd62737237ad7e016201a798ee42e27853556 Reviewed-on: https://gerrit.libreoffice.org/20656 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx index aa08d91..91b97db 100644 --- a/vcl/win/gdi/salgdi2.cxx +++ b/vcl/win/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); 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); + + + std::unique_ptr<WinSalBitmap> pWinTransparentSalBitmap(new WinSalBitmap()); + SalBitmap& rConstTransparentBitmap = const_cast<SalBitmap&>(rSTransparentBitmap); + convertToWinSalBitmap(rConstTransparentBitmap, *pWinTransparentSalBitmap); + + mpImpl->drawBitmap(rPosAry, *pWinSalBitmap, *pWinTransparentSalBitmap); + } + else + { + mpImpl->drawBitmap(rPosAry, rSSalBitmap, rSTransparentBitmap); + } } bool WinSalGraphics::drawAlphaRect( long nX, long nY, long nWidth,
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits