diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-09-14 16:05:38 +0100 |
---|---|---|
committer | Adolfo Jayme Barrientos <fitojb@ubuntu.com> | 2022-09-16 22:56:49 +0200 |
commit | c062358d7b58ce3a9b27681040d854ec7ea1868b (patch) | |
tree | c5c6e6973743f9e3766fc4ad3cce645658c902b0 | |
parent | tdf#106959: use table's first content node for cursor cleanup (diff) | |
download | core-c062358d7b58ce3a9b27681040d854ec7ea1868b.tar.gz core-c062358d7b58ce3a9b27681040d854ec7ea1868b.zip |
Resolves: tdf#144583 reuse lok hidpi icon scheme for gtk
and includes...
Related: tdf#144583 move current lok hidpi icon thing into SalGraphics
Change-Id: If34a2b15aebc5316783d72564ede23e02db04302
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139947
Tested-by: Jenkins
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r-- | vcl/headless/svpgdi.cxx | 9 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/image.h | 6 | ||||
-rw-r--r-- | vcl/inc/salgdi.hxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/salgdilayout.cxx | 7 | ||||
-rw-r--r-- | vcl/source/image/Image.cxx | 2 | ||||
-rw-r--r-- | vcl/source/image/ImplImage.cxx | 18 |
7 files changed, 41 insertions, 11 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index c97048dada12..322dab644f2a 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -51,6 +51,15 @@ void SvpSalGraphics::GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ) rDPIX = rDPIY = 96; } +bool SvpSalGraphics::ShouldDownscaleIconsAtSurface(double* pScaleOut) const +{ + if (comphelper::LibreOfficeKit::isActive()) + return SalGraphics::ShouldDownscaleIconsAtSurface(pScaleOut); + if (pScaleOut) + *pScaleOut = m_aCairoCommon.m_fScale; + return true; +} + #if ENABLE_CAIRO_CANVAS bool SvpSalGraphics::SupportsCairo() const { diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index a63e7f289abf..1abc2b05f1f6 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -95,6 +95,8 @@ public: GetTextLayout(int nFallbackLevel) override; virtual void DrawTextLayout( const GenericSalLayout& ) override; + virtual bool ShouldDownscaleIconsAtSurface(double* pScaleOut) const override; + virtual SystemGraphicsData GetGraphicsData() const override; #if ENABLE_CAIRO_CANVAS diff --git a/vcl/inc/image.h b/vcl/inc/image.h index 633c38c4a34e..a6b51f30a5b0 100644 --- a/vcl/inc/image.h +++ b/vcl/inc/image.h @@ -22,6 +22,8 @@ #include <vcl/bitmapex.hxx> +class SalGraphics; + class ImplImage { private: @@ -36,7 +38,7 @@ private: BitmapEx maBitmapEx; BitmapEx maDisabledBitmapEx; - bool loadStockAtScale(double fScale, BitmapEx &rBitmapEx); + bool loadStockAtScale(SalGraphics* pGraphics, BitmapEx &rBitmapEx); public: ImplImage(const BitmapEx& rBitmapEx); @@ -57,7 +59,7 @@ public: /// Legacy - the original bitmap BitmapEx const & getBitmapEx(bool bDisabled = false); /// Taking account of HiDPI scaling - BitmapEx const & getBitmapExForHiDPI(bool bDisabled = false); + BitmapEx const & getBitmapExForHiDPI(bool bDisabled, SalGraphics* pGraphics); bool isEqual(const ImplImage &ref) const; bool isSizeEmpty() const diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 75938afecece..8679d4a0a062 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -452,6 +452,14 @@ public: virtual SystemGraphicsData GetGraphicsData() const = 0; + // Backends like the svp/gtk ones use cairo and hidpi scale at the surface + // but bitmaps aren't hidpi, so if this returns true for the case that the + // surface is hidpi then pScaleOut contains the scaling factor. So we can + // create larger hires bitmaps which we know will be logically scaled down + // by this factor but physically just copied + virtual bool ShouldDownscaleIconsAtSurface(double* pScaleOut) const; + + #if ENABLE_CAIRO_CANVAS /// Check whether cairo will work diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 623afed8c1c6..c557912d826c 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -1087,4 +1087,11 @@ void SalGraphics::FillFontSubsetInfo(const vcl::TTGlobalFontInfo& rTTInfo, const rInfo.m_nDescent = -rTTInfo.descender; } +bool SalGraphics::ShouldDownscaleIconsAtSurface(double* pScaleOut) const +{ + if (pScaleOut) + *pScaleOut = comphelper::LibreOfficeKit::getDPIScale(); + return comphelper::LibreOfficeKit::isActive(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx index e32f7e54df22..2b0a9521c8c1 100644 --- a/vcl/source/image/Image.cxx +++ b/vcl/source/image/Image.cxx @@ -120,7 +120,7 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle Size aOutSize = pSize ? *pSize : pOutDev->PixelToLogic(mpImplData->getSizePixel()); - BitmapEx aRenderBmp = mpImplData->getBitmapExForHiDPI(bool(nStyle & DrawImageFlags::Disable)); + BitmapEx aRenderBmp = mpImplData->getBitmapExForHiDPI(bool(nStyle & DrawImageFlags::Disable), pOutDev->GetGraphics()); if (!(nStyle & DrawImageFlags::Disable) && (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight | diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx index a5637c3bb452..6448cb43f057 100644 --- a/vcl/source/image/ImplImage.cxx +++ b/vcl/source/image/ImplImage.cxx @@ -27,6 +27,7 @@ #include <comphelper/lok.hxx> #include <image.h> +#include <salgdi.hxx> ImplImage::ImplImage(const BitmapEx &rBitmapEx) : maBitmapChecksum(0) @@ -41,14 +42,15 @@ ImplImage::ImplImage(const OUString &aStockName) { } -bool ImplImage::loadStockAtScale(double fScale, BitmapEx &rBitmapEx) +bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, BitmapEx &rBitmapEx) { BitmapEx aBitmapEx; ImageLoadFlags eScalingFlags = ImageLoadFlags::NONE; sal_Int32 nScalePercentage = -1; - if (comphelper::LibreOfficeKit::isActive()) // scale at the surface + double fScale(1.0); + if (pGraphics && pGraphics->ShouldDownscaleIconsAtSurface(&fScale)) // scale at the surface { nScalePercentage = fScale * 100.0; eScalingFlags = ImageLoadFlags::IgnoreScalingFactor; @@ -93,7 +95,7 @@ Size ImplImage::getSizePixel() aRet = maSizePixel; else if (isStock()) { - if (loadStockAtScale(1.0, maBitmapEx)) + if (loadStockAtScale(nullptr, maBitmapEx)) { assert(maDisabledBitmapEx.IsEmpty()); assert(maBitmapChecksum == 0); @@ -137,16 +139,16 @@ bool ImplImage::isEqual(const ImplImage &ref) const return maBitmapEx == ref.maBitmapEx; } -BitmapEx const & ImplImage::getBitmapExForHiDPI(bool bDisabled) +BitmapEx const & ImplImage::getBitmapExForHiDPI(bool bDisabled, SalGraphics* pGraphics) { - if (isStock()) + if (isStock() && pGraphics) { // check we have the right bitmap cached. - // FIXME: DPI scaling should be tied to the outdev really ... - double fScale = comphelper::LibreOfficeKit::getDPIScale(); + double fScale = 1.0; + pGraphics->ShouldDownscaleIconsAtSurface(&fScale); Size aTarget(maSizePixel.Width()*fScale, maSizePixel.Height()*fScale); if (maBitmapEx.GetSizePixel() != aTarget) - loadStockAtScale(fScale, maBitmapEx); + loadStockAtScale(pGraphics, maBitmapEx); } return getBitmapEx(bDisabled); } |