diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-12-10 13:44:05 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2015-12-11 11:49:02 +0100 |
commit | 1cc30679765ce996a009865e6bad3e5b74b96b41 (patch) | |
tree | efac886e5782325eb4f07aece08f8b7f045488c8 | |
parent | 8a498fad249b3a92f275f33b683f242cb8d68b7b (diff) |
tdf#94851 can't use OpenGLSalBitmap with WinSalGraphics
Printing is done with the WinSalGraphics and not with
WinOpenGLSalGraphics on Windows even when OpenGL is enabled, but
the SalBitmap is still using the OpenGLSalBitmap which can't be
used with WinSalGraphics. So detect when the implementation of
SalGraphic is "wrong" and convert.
Change-Id: I99cd6b6403e9bd42d6f5b7d7cb07f48588c17ab8
-rw-r--r-- | vcl/win/gdi/salgdi2.cxx | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx index 64516c248569..aa08d9145568 100644 --- a/vcl/win/gdi/salgdi2.cxx +++ b/vcl/win/gdi/salgdi2.cxx @@ -34,6 +34,8 @@ #include "vcl/bmpacc.hxx" #include "outdata.hxx" #include "salgdiimpl.hxx" +#include "opengl/win/gdiimpl.hxx" + bool WinSalGraphics::supportsOperation( OutDevSupportType eType ) const { @@ -71,7 +73,35 @@ void WinSalGraphics::copyArea( long nDestX, long nDestY, void WinSalGraphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) { - mpImpl->drawBitmap( rPosAry, rSalBitmap ); + 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); + + sal_uInt8* pSource(pRead->mpBits); + sal_uInt8* pDestination(pWrite->mpBits); + + for (long y = 0; y < pRead->mnHeight; y++) + { + memcpy(pDestination, pSource, pRead->mnScanlineSize); + pSource += pRead->mnScanlineSize; + pDestination += pWrite->mnScanlineSize; + } + pWinSalBitmap->ReleaseBuffer(pWrite, BITMAP_WRITE_ACCESS); + + rConstBitmap.ReleaseBuffer(pRead, BITMAP_READ_ACCESS); + + mpImpl->drawBitmap(rPosAry, *pWinSalBitmap.get()); + } + else + { + mpImpl->drawBitmap(rPosAry, rSalBitmap); + } } void WinSalGraphics::drawBitmap( const SalTwoRect& rPosAry, |