diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-10-03 19:45:20 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-10-04 20:51:56 +0200 |
commit | 6e2a7571e8ee4960f54610ba790394202c4d7aed (patch) | |
tree | 4c75d39ee79382bd27ff9f7011e6c91b5acedf17 /vcl/headless | |
parent | c6f0192114f1d09a9247199ef05149e75cfacb36 (diff) |
tdf#127529 vertical text not drawn in slideshow canvas
because the canvas text drawing impl falls back to using an OutputDevice view
of the canvas to use the vcl text drawing apis to achieve vertical text
To get an OutputDevice view of the canvas there is a specific VirtualDevice
ctor available to create a VirtualDevice that, unlike the normal case, doesn't
have its own specific backing buffer, but instead draws to the underlying target
provided via the SystemGraphicsData arg
The svp/gtk impl missed that understanding and provided an ordinary
VirtualDevice with its own backing buffer, not a VirtualDevice that would draw
to the expected target surface of the canvas. So the vertical text was drawn to
a different surface than the intended one, and was just discarded.
The cairo use in the canvas long precedes the use of cairo in vcl itself.
Seeing as text is now rendered with cairo in all cases where the canvas uses
cairo its probably now pointless for canvas to have its own text rendering
path.
Change-Id: Ie3b0a43ca2b746cbfe25e2d0415315b3d5403cd2
Reviewed-on: https://gerrit.libreoffice.org/80162
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpinst.cxx | 10 | ||||
-rw-r--r-- | vcl/headless/svpvd.cxx | 15 |
2 files changed, 16 insertions, 9 deletions
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx index 2070f68e1663..6b415d39135f 100644 --- a/vcl/headless/svpinst.cxx +++ b/vcl/headless/svpinst.cxx @@ -240,14 +240,18 @@ void SvpSalInstance::DestroyObject( SalObject* pObject ) #ifndef IOS -std::unique_ptr<SalVirtualDevice> SvpSalInstance::CreateVirtualDevice( SalGraphics* pGraphics, +std::unique_ptr<SalVirtualDevice> SvpSalInstance::CreateVirtualDevice(SalGraphics* pGraphics, long &nDX, long &nDY, DeviceFormat eFormat, - const SystemGraphicsData* /* pData */ ) + const SystemGraphicsData* pGd) { SvpSalGraphics *pSvpSalGraphics = dynamic_cast<SvpSalGraphics*>(pGraphics); assert(pSvpSalGraphics); - std::unique_ptr<SalVirtualDevice> pNew(new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface())); + // tdf#127529 normally pPreExistingTarget is null and we are a true virtualdevice drawing to a backing buffer. + // Occasionally, for canvas/slideshow, pPreExistingTarget is pre-provided as a hack to use the vcl drawing + // apis to render onto a preexisting cairo surface. The necessity for that precedes the use of cairo in vcl proper + cairo_surface_t* pPreExistingTarget = pGd ? static_cast<cairo_surface_t*>(pGd->pSurface) : nullptr; + std::unique_ptr<SalVirtualDevice> pNew(new SvpSalVirtualDevice(eFormat, pSvpSalGraphics->getSurface(), pPreExistingTarget)); pNew->SetSize( nDX, nDY ); return pNew; } diff --git a/vcl/headless/svpvd.cxx b/vcl/headless/svpvd.cxx index 686587f9deab..70ac5785ec71 100644 --- a/vcl/headless/svpvd.cxx +++ b/vcl/headless/svpvd.cxx @@ -31,17 +31,19 @@ using namespace basegfx; -SvpSalVirtualDevice::SvpSalVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface) +SvpSalVirtualDevice::SvpSalVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface, cairo_surface_t* pPreExistingTarget) : m_eFormat(eFormat) , m_pRefSurface(pRefSurface) - , m_pSurface(nullptr) + , m_pSurface(pPreExistingTarget) + , m_bOwnsSurface(!pPreExistingTarget) { cairo_surface_reference(m_pRefSurface); } SvpSalVirtualDevice::~SvpSalVirtualDevice() { - cairo_surface_destroy(m_pSurface); + if (m_bOwnsSurface) + cairo_surface_destroy(m_pSurface); cairo_surface_destroy(m_pRefSurface); } @@ -70,8 +72,6 @@ bool SvpSalVirtualDevice::SetSize( long nNewDX, long nNewDY ) void SvpSalVirtualDevice::CreateSurface(long nNewDX, long nNewDY, sal_uInt8 *const pBuffer) { - m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); - if (m_pSurface) { cairo_surface_destroy(m_pSurface); @@ -121,7 +121,10 @@ bool SvpSalVirtualDevice::SetSizeUsingBuffer( long nNewDX, long nNewDY, { m_aFrameSize = basegfx::B2IVector(nNewDX, nNewDY); - CreateSurface(nNewDX, nNewDY, pBuffer); + if (m_bOwnsSurface) + CreateSurface(nNewDX, nNewDY, pBuffer); + + assert(m_pSurface); // update device in existing graphics for (auto const& graphic : m_aGraphics) |