summaryrefslogtreecommitdiff
path: root/vcl/unx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2023-01-05 16:40:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2023-01-06 08:47:00 +0000
commit1fd19c798243ee46606331ad96b9803b96581a2e (patch)
tree833418e0b58c53c1d14976cb4efe99f6e10bfa89 /vcl/unx
parente8effd1c4c0a4dd389054d311f432c42f26a3a6b (diff)
use current known geometry for surface size instead of SAL_MAX_INT16
which appears to be why getPixel failed Change-Id: I088ed0c01bdd0e9971ff52a1f70a030f0921e497 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145108 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx')
-rw-r--r--vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx14
-rw-r--r--vcl/unx/generic/gdi/gdiimpl.hxx3
-rw-r--r--vcl/unx/generic/gdi/salgdi.cxx11
-rw-r--r--vcl/unx/generic/gdi/x11cairotextrender.cxx2
4 files changed, 17 insertions, 13 deletions
diff --git a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx
index f1b7f172150b..c45990b35263 100644
--- a/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx
+++ b/vcl/unx/generic/gdi/X11CairoSalGraphicsImpl.cxx
@@ -61,7 +61,7 @@ bool X11CairoSalGraphicsImpl::drawPolyPolygon(const basegfx::B2DHomMatrix& rObje
aPolyPolygon = basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyPolygon);
}
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
for (auto const& rPolygon : std::as_const(aPolyPolygon))
@@ -132,7 +132,7 @@ void X11CairoSalGraphicsImpl::drawPixel(tools::Long nX, tools::Long nY)
void X11CairoSalGraphicsImpl::drawPixel(tools::Long nX, tools::Long nY, Color nColor)
{
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
CairoCommon::drawPixel(cr, nullptr, nColor, nX, nY);
@@ -143,7 +143,7 @@ void X11CairoSalGraphicsImpl::drawPixel(tools::Long nX, tools::Long nY, Color nC
void X11CairoSalGraphicsImpl::drawLine(tools::Long nX1, tools::Long nY1, tools::Long nX2,
tools::Long nY2)
{
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
CairoCommon::drawLine(cr, nullptr, mnPenColor, getAntiAlias(), nX1, nY1, nX2, nY2);
@@ -163,7 +163,7 @@ bool X11CairoSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectT
if (0 == rPolyLine.count() || fTransparency < 0.0 || fTransparency >= 1.0)
return true;
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
// Use the now available static drawPolyLine from the Cairo-Headless-Fallback
@@ -180,7 +180,7 @@ bool X11CairoSalGraphicsImpl::drawPolyLine(const basegfx::B2DHomMatrix& rObjectT
bool X11CairoSalGraphicsImpl::drawAlphaRect(tools::Long nX, tools::Long nY, tools::Long nWidth,
tools::Long nHeight, sal_uInt8 nTransparency)
{
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
const bool bRetval(CairoCommon::drawAlphaRect(cr, nullptr, mnPenColor, mnFillColor, nX, nY,
@@ -194,7 +194,7 @@ bool X11CairoSalGraphicsImpl::drawAlphaRect(tools::Long nX, tools::Long nY, tool
bool X11CairoSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPolygon,
const Gradient& rGradient)
{
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
const bool bRetval(
@@ -208,7 +208,7 @@ bool X11CairoSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPolygo
bool X11CairoSalGraphicsImpl::implDrawGradient(basegfx::B2DPolyPolygon const& rPolyPolygon,
SalGradient const& rGradient)
{
- cairo_t* cr = mrX11Common.getCairoContext();
+ cairo_t* cr = mrX11Common.getCairoContext(mrParent.GetGeometryProvider());
clipRegion(cr);
const bool bRetval(
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 0963a85892cd..bec45a01dd31 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -40,9 +40,10 @@ class Gradient;
class X11SalGraphicsImpl : public SalGraphicsImpl, public X11GraphicsImpl
{
-private:
+protected:
X11SalGraphics& mrParent;
+private:
Color mnBrushColor;
GC mpBrushGC; // Brush attributes
Pixel mnBrushPixel;
diff --git a/vcl/unx/generic/gdi/salgdi.cxx b/vcl/unx/generic/gdi/salgdi.cxx
index 7ee133d2c87f..c4919e49229b 100644
--- a/vcl/unx/generic/gdi/salgdi.cxx
+++ b/vcl/unx/generic/gdi/salgdi.cxx
@@ -68,12 +68,15 @@ X11Common::X11Common()
, m_pExternalSurface(nullptr)
{}
-cairo_t* X11Common::getCairoContext()
+cairo_t* X11Common::getCairoContext(const SalGeometryProvider* pGeom)
{
if (m_pExternalSurface)
return cairo_create(m_pExternalSurface);
- cairo_surface_t* surface = cairo_xlib_surface_create(GetXDisplay(), m_hDrawable, GetVisual().visual, SAL_MAX_INT16, SAL_MAX_INT16);
+ SAL_WARN_IF(!pGeom, "vcl", "No geometry available");
+ int nWidth = pGeom ? pGeom->GetWidth() : SAL_MAX_INT16;
+ int nHeight = pGeom ? pGeom->GetHeight() : SAL_MAX_INT16;
+ cairo_surface_t* surface = cairo_xlib_surface_create(GetXDisplay(), m_hDrawable, GetVisual().visual, nWidth, nHeight);
cairo_t *cr = cairo_create(surface);
cairo_surface_destroy(surface);
@@ -463,9 +466,9 @@ SalGeometryProvider *X11SalGraphics::GetGeometryProvider() const
return static_cast< SalGeometryProvider * >(m_pVDev);
}
-cairo_t* X11SalGraphics::getCairoContext()
+cairo_t* X11SalGraphics::getCairoContext(const SalGeometryProvider* pGeom)
{
- return maX11Common.getCairoContext();
+ return maX11Common.getCairoContext(pGeom);
}
void X11SalGraphics::releaseCairoContext(cairo_t* cr)
diff --git a/vcl/unx/generic/gdi/x11cairotextrender.cxx b/vcl/unx/generic/gdi/x11cairotextrender.cxx
index 6bbbbc1bff87..7a1d4b9fcbf7 100644
--- a/vcl/unx/generic/gdi/x11cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/x11cairotextrender.cxx
@@ -32,7 +32,7 @@ X11CairoTextRender::X11CairoTextRender(X11SalGraphics& rParent)
cairo_t* X11CairoTextRender::getCairoContext()
{
- return mrParent.getCairoContext();
+ return mrParent.getCairoContext(mrParent.GetGeometryProvider());
}
void X11CairoTextRender::getSurfaceOffset( double& nDX, double& nDY )