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-12 09:29:13 +0100 |
commit | 28c2c141cb084f37d27e50a8b673206967932c2b (patch) | |
tree | 7ac521f905b530694ea014330b08896b512f2803 | |
parent | 0791cf35eeaccc86b597c3c0f4b32439d2d4d189 (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
(cherry picked from commit 1cc30679765ce996a009865e6bad3e5b74b96b41)
-rw-r--r-- | vcl/win/source/gdi/salgdi2.cxx | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/vcl/win/source/gdi/salgdi2.cxx b/vcl/win/source/gdi/salgdi2.cxx index 64516c248569..aa08d9145568 100644 --- a/vcl/win/source/gdi/salgdi2.cxx +++ b/vcl/win/source/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, |