summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-11-11 15:52:51 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-11-11 20:36:14 +0100
commitc3da84a10260b3260ee42df900e2ff01119e4f7c (patch)
tree0de88d7f184bd74b14e6fd30393354bb0280d666 /vcl
parentc2c37eadf32c80bcd8f168b9fc67f32002b3cb07 (diff)
Resolves: tdf#151898 get hidpi font/highlight color icons
Most of this wouldn't be necessary if we could solve the split alpha problem. In the meantime, let Image take a MetaFile as an arg, record what we want to do in the metafile, and play it back when we need to generate the bitmap for to render the image. That way we don't have alpha to worry about during the recording, and we only have one alpha in the final rendering, as opposed to having two alphas in a source and in destination VirtualDevice, which is problematic in most backends. Change-Id: I5b0d7c498473271f4ab2743f75614b1b93a0e9c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142593 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/image.h5
-rw-r--r--vcl/source/image/Image.cxx2
-rw-r--r--vcl/source/image/ImplImage.cxx24
3 files changed, 28 insertions, 3 deletions
diff --git a/vcl/inc/image.h b/vcl/inc/image.h
index 5d0cc9fcb671..cb75b45b837d 100644
--- a/vcl/inc/image.h
+++ b/vcl/inc/image.h
@@ -21,6 +21,7 @@
#define INCLUDED_VCL_INC_IMAGE_H
#include <vcl/bitmapex.hxx>
+#include <vcl/gdimtf.hxx>
class SalGraphics;
@@ -32,7 +33,8 @@ private:
Size maSizePixel;
/// If set - defines the bitmap via images.zip*
OUString maStockName;
-
+ /// rare case of dynamically created Image contents
+ std::unique_ptr<GDIMetaFile> mxMetaFile;
/// Original bitmap - or cache of a potentially scaled bitmap
BitmapEx maBitmapEx;
@@ -42,6 +44,7 @@ private:
public:
ImplImage(const BitmapEx& rBitmapEx);
+ ImplImage(const GDIMetaFile& rMetaFile);
ImplImage(OUString aStockName);
bool isStock() const
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index 2b0a9521c8c1..06937ab7f1e5 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -47,6 +47,8 @@ Image::Image(uno::Reference<graphic::XGraphic> const & rxGraphic)
OUString aPath;
if (aGraphic.getOriginURL().startsWith("private:graphicrepository/", &aPath))
mpImplData = std::make_shared<ImplImage>(aPath);
+ else if (aGraphic.GetType() == GraphicType::GdiMetafile)
+ mpImplData = std::make_shared<ImplImage>(aGraphic.GetGDIMetaFile());
else
ImplInit(aGraphic.GetBitmapEx());
}
diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx
index 7883c3b1e6f6..20469d8b4292 100644
--- a/vcl/source/image/ImplImage.cxx
+++ b/vcl/source/image/ImplImage.cxx
@@ -21,7 +21,9 @@
#include <utility>
#include <vcl/svapp.hxx>
#include <vcl/bitmapex.hxx>
+#include <vcl/gdimtf.hxx>
#include <vcl/settings.hxx>
+#include <vcl/virdev.hxx>
#include <vcl/BitmapFilter.hxx>
#include <vcl/ImageTree.hxx>
#include <bitmap/BitmapDisabledImageFilter.hxx>
@@ -43,6 +45,13 @@ ImplImage::ImplImage(OUString aStockName)
{
}
+ImplImage::ImplImage(const GDIMetaFile& rMetaFile)
+ : maBitmapChecksum(0)
+ , maSizePixel(rMetaFile.GetPrefSize())
+ , mxMetaFile(new GDIMetaFile(rMetaFile))
+{
+}
+
bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, BitmapEx &rBitmapEx)
{
BitmapEx aBitmapEx;
@@ -142,14 +151,25 @@ bool ImplImage::isEqual(const ImplImage &ref) const
BitmapEx const & ImplImage::getBitmapExForHiDPI(bool bDisabled, SalGraphics* pGraphics)
{
- if (isStock() && pGraphics)
+ if ((isStock() || mxMetaFile) && pGraphics)
{ // check we have the right bitmap cached.
double fScale = 1.0;
pGraphics->ShouldDownscaleIconsAtSurface(&fScale);
Size aTarget(maSizePixel.Width()*fScale,
maSizePixel.Height()*fScale);
if (maBitmapEx.GetSizePixel() != aTarget)
- loadStockAtScale(pGraphics, maBitmapEx);
+ {
+ if (isStock())
+ loadStockAtScale(pGraphics, maBitmapEx);
+ else // if (mxMetaFile)
+ {
+ ScopedVclPtrInstance<VirtualDevice> aVDev(DeviceFormat::DEFAULT, DeviceFormat::DEFAULT);
+ aVDev->SetOutputSizePixel(aTarget);
+ mxMetaFile->WindStart();
+ mxMetaFile->Play(*aVDev, Point(), aTarget);
+ maBitmapEx = aVDev->GetBitmapEx(Point(), aTarget);
+ }
+ }
}
return getBitmapEx(bDisabled);
}