office-gobmx/vcl/headless/svpgdi.cxx
Armin Le Grand (allotropia) 9ea9cd14ff tdf#163457 CairoSDPR: Need to apply 'damage' to gtk
If a CairoSDPR does directly render to a Window the changes
do not get reliably visualized due to the Cairo backend
and gtk/QT usage being dependent of being told what
'damage' is done to refresh the window accordingly.
The VCLCairoBackend is doing that, but without reach
from the outside.
Note that this is a rare case, in fact the 1st one discovered
where a CairoSDPR is painting to a Window directly, see
comments in the task. Even this occasion should not do
that - showing the Comments in Calc on the Overlay would
be major to just painting to the Window roughly.
There are other possible workarounds (also see comments in
the task), but just adding to be able to set the needed
'damage' in case target is a Window is simplest and
potentially the fastest way to do this.
Since usage of CairoSDPR is bound to use GetSystemGfxData
anyways it is okay to react there and call a method
ApplyFullDamage that exists on Graphics when the flag
USE_HEADLESS_CODE is active. That forwards to the
CairoCommon being responsible for that Window and does
the minimal necessary to apply 'damage' to the full
Window.
This is done when constructing the CairoSDPR, thus
from the timing that incarnation can then paint anything
and it seems that at the next occasion something can
handle the callback from gtk all is painted. If that
should change it may get necessary to separate
the usage of ApplyFullDamage from GetSystemGfxData,
but works as intended for now.

Change-Id: I5442f3413e43418954da29a18d66dea27e25e655
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175794
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
2024-10-31 12:25:26 +01:00

99 lines
3 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <headless/svpgdi.hxx>
#include <comphelper/lok.hxx>
SvpSalGraphics::SvpSalGraphics()
: m_aTextRenderImpl(m_aCairoCommon)
, m_pBackend(new SvpGraphicsBackend(m_aCairoCommon))
{
bool bLOKActive = comphelper::LibreOfficeKit::isActive();
initWidgetDrawBackends(bLOKActive);
}
SvpSalGraphics::~SvpSalGraphics()
{
ReleaseFonts();
}
void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize)
{
m_aCairoCommon.m_pSurface = pSurface;
m_aCairoCommon.m_aFrameSize = rSize;
dl_cairo_surface_get_device_scale(pSurface, &m_aCairoCommon.m_fScale, nullptr);
GetImpl()->ResetClipRegion();
}
void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY )
{
rDPIX = rDPIY = 96;
}
bool SvpSalGraphics::ShouldDownscaleIconsAtSurface(double& rScaleOut) const
{
if (comphelper::LibreOfficeKit::isActive())
return SalGraphics::ShouldDownscaleIconsAtSurface(rScaleOut);
rScaleOut = m_aCairoCommon.m_fScale;
return true;
}
#if ENABLE_CAIRO_CANVAS
bool SvpSalGraphics::SupportsCairo() const
{
return false;
}
cairo::SurfaceSharedPtr SvpSalGraphics::CreateSurface(const cairo::CairoSurfaceSharedPtr& /*rSurface*/) const
{
return cairo::SurfaceSharedPtr();
}
cairo::SurfaceSharedPtr SvpSalGraphics::CreateSurface(const OutputDevice& /*rRefDevice*/, int /*x*/, int /*y*/, int /*width*/, int /*height*/) const
{
return cairo::SurfaceSharedPtr();
}
cairo::SurfaceSharedPtr SvpSalGraphics::CreateBitmapSurface(const OutputDevice& /*rRefDevice*/, const BitmapSystemData& /*rData*/, const Size& /*rSize*/) const
{
return cairo::SurfaceSharedPtr();
}
css::uno::Any SvpSalGraphics::GetNativeSurfaceHandle(cairo::SurfaceSharedPtr& /*rSurface*/, const basegfx::B2ISize& /*rSize*/) const
{
return css::uno::Any();
}
#endif // ENABLE_CAIRO_CANVAS
SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
{
SystemGraphicsData aGraphicsData;
aGraphicsData.pSurface = m_aCairoCommon.m_pSurface;
return aGraphicsData;
}
#if USE_HEADLESS_CODE
void SvpSalGraphics::ApplyFullDamage() const
{
m_aCairoCommon.applyFullDamage();
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */