summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2019-10-03 19:45:20 +0100
committerCaolán McNamara <caolanm@redhat.com>2019-10-04 20:51:56 +0200
commit6e2a7571e8ee4960f54610ba790394202c4d7aed (patch)
tree4c75d39ee79382bd27ff9f7011e6c91b5acedf17 /vcl/qt5
parentc6f0192114f1d09a9247199ef05149e75cfacb36 (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/qt5')
-rw-r--r--vcl/qt5/Qt5Instance.cxx12
-rw-r--r--vcl/qt5/Qt5SvpSurface.cxx21
-rw-r--r--vcl/qt5/Qt5SvpVirtualDevice.hxx5
3 files changed, 30 insertions, 8 deletions
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 64481b64108e..129eb8e5c221 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -288,16 +288,20 @@ void Qt5Instance::DestroyObject(SalObject* pObject)
}
}
-std::unique_ptr<SalVirtualDevice>
-Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics, long& nDX, long& nDY, DeviceFormat eFormat,
- const SystemGraphicsData* /* pData */)
+std::unique_ptr<SalVirtualDevice> Qt5Instance::CreateVirtualDevice(SalGraphics* pGraphics,
+ long& nDX, long& nDY,
+ DeviceFormat eFormat,
+ const SystemGraphicsData* pGd)
{
if (m_bUseCairo)
{
SvpSalGraphics* pSvpSalGraphics = dynamic_cast<Qt5SvpGraphics*>(pGraphics);
assert(pSvpSalGraphics);
+ // tdf#127529 see SvpSalInstance::CreateVirtualDevice for the rare case of a non-null pPreExistingTarget
+ cairo_surface_t* pPreExistingTarget
+ = pGd ? static_cast<cairo_surface_t*>(pGd->pSurface) : nullptr;
std::unique_ptr<SalVirtualDevice> pVD(
- new Qt5SvpVirtualDevice(eFormat, pSvpSalGraphics->getSurface()));
+ new Qt5SvpVirtualDevice(eFormat, pSvpSalGraphics->getSurface(), pPreExistingTarget));
pVD->SetSize(nDX, nDY);
return pVD;
}
diff --git a/vcl/qt5/Qt5SvpSurface.cxx b/vcl/qt5/Qt5SvpSurface.cxx
index 3e300755a992..21e0ca03b5b2 100644
--- a/vcl/qt5/Qt5SvpSurface.cxx
+++ b/vcl/qt5/Qt5SvpSurface.cxx
@@ -19,6 +19,18 @@
#include <vcl/window.hxx>
#include <basegfx/vector/b2isize.hxx>
+namespace
+{
+Size get_surface_size(cairo_surface_t* surface)
+{
+ cairo_t* cr = cairo_create(surface);
+ double x1, x2, y1, y2;
+ cairo_clip_extents(cr, &x1, &y1, &x2, &y2);
+ cairo_destroy(cr);
+ return Size(x2 - x1, y2 - y1);
+}
+}
+
namespace cairo
{
Qt5SvpSurface::Qt5SvpSurface(const CairoSurfaceSharedPtr& pSurface)
@@ -65,8 +77,13 @@ void Qt5SvpSurface::flush() const
VclPtr<VirtualDevice> Qt5SvpSurface::createVirtualDevice() const
{
- //TODO allow creating a VirtualDevice to draw to the current surface
- return VclPtrInstance<VirtualDevice>(DeviceFormat::DEFAULT);
+ SystemGraphicsData aSystemGraphicsData;
+
+ aSystemGraphicsData.nSize = sizeof(SystemGraphicsData);
+ aSystemGraphicsData.pSurface = m_pSurface.get();
+
+ return VclPtr<VirtualDevice>::Create(aSystemGraphicsData, get_surface_size(m_pSurface.get()),
+ DeviceFormat::DEFAULT);
}
} // namespace cairo
diff --git a/vcl/qt5/Qt5SvpVirtualDevice.hxx b/vcl/qt5/Qt5SvpVirtualDevice.hxx
index 75c446bafb33..0eb4ed26ed2f 100644
--- a/vcl/qt5/Qt5SvpVirtualDevice.hxx
+++ b/vcl/qt5/Qt5SvpVirtualDevice.hxx
@@ -25,8 +25,9 @@
class VCL_DLLPUBLIC Qt5SvpVirtualDevice : public SvpSalVirtualDevice
{
public:
- Qt5SvpVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface)
- : SvpSalVirtualDevice(eFormat, pRefSurface)
+ Qt5SvpVirtualDevice(DeviceFormat eFormat, cairo_surface_t* pRefSurface,
+ cairo_surface_t* pPreExistingTarget)
+ : SvpSalVirtualDevice(eFormat, pRefSurface, pPreExistingTarget)
{
}