diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-11-11 14:01:55 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-11-16 10:38:54 +0100 |
commit | b5983dbe2c41f38e653201574cf20cd4bd76e950 (patch) | |
tree | a8254c2dc2b9ef2c7d91aa9dbf2b6994b3295645 /vcl/skia/salbmp.cxx | |
parent | 67669707e0c6c8a390d352e7060ad5862d727433 (diff) |
implement HiDPI support for Skia/Mac (tdf#144214)
The basic idea is the same as the 'aqua' backend, simply set up
a scaling matrix for all drawing. That will take care of the basic
drawing everything twice as large, which is twice the resolution.
And then blit this data to the window, which expects data this way.
Converting back from backing surface needs explicit coordinate
conversions, and when converting to a bitmap the bitmap needs
to be scaled down in order to appear normally sized. Fortunately
I've already implemented delayed scaling, which means that if
the bitmap is drawn later again without any modifications, no
data would be lost (to be done in a follow-up commit).
Unittests occassionally need special handling, as such scaling
down to bitmap not being smoothed, because they expect exact
color values.
Change-Id: Ieadf2c3693f7c9676c31c7394d46299addf7880c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125060
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/skia/salbmp.cxx')
-rw-r--r-- | vcl/skia/salbmp.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 31a369724259..c064f00ad565 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -422,6 +422,11 @@ bool SkiaSalBitmap::Scale(const double& rScaleX, const double& rScaleY, BmpScale case BmpScaleFlag::Fast: mScaleQuality = nScaleFlag; break; + case BmpScaleFlag::NearestNeighbor: + // We handle this the same way as Fast by mapping to Skia's nearest-neighbor, + // and it's needed for unittests (mScaling and testTdf132367()). + mScaleQuality = nScaleFlag; + break; case BmpScaleFlag::Default: if (mScaleQuality == BmpScaleFlag::BestQuality) mScaleQuality = nScaleFlag; @@ -781,7 +786,7 @@ const sk_sp<SkImage>& SkiaSalBitmap::GetSkImage() const paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha surface->getCanvas()->drawImageRect( mImage, SkRect::MakeWH(mSize.Width(), mSize.Height()), - makeSamplingOptions(mScaleQuality, imageSize(mImage), mSize), &paint); + makeSamplingOptions(mScaleQuality, imageSize(mImage), mSize, 1), &paint); SAL_INFO("vcl.skia.trace", "getskimage(" << this << "): image scaled " << Size(mImage->width(), mImage->height()) << "->" << mSize << ":" @@ -893,7 +898,7 @@ const sk_sp<SkImage>& SkiaSalBitmap::GetAlphaSkImage() const paint.setBlendMode(SkBlendMode::kSrc); // set as is, including alpha surface->getCanvas()->drawImageRect( mImage, SkRect::MakeWH(mSize.Width(), mSize.Height()), - scaling ? makeSamplingOptions(mScaleQuality, imageSize(mImage), mSize) + scaling ? makeSamplingOptions(mScaleQuality, imageSize(mImage), mSize, 1) : SkSamplingOptions(), &paint); if (scaling) @@ -1149,7 +1154,7 @@ void SkiaSalBitmap::EnsureBitmapData() if (imageSize(mImage) != mSize) // pending scaling? { canvas.drawImageRect(mImage, SkRect::MakeWH(mSize.getWidth(), mSize.getHeight()), - makeSamplingOptions(mScaleQuality, imageSize(mImage), mSize), + makeSamplingOptions(mScaleQuality, imageSize(mImage), mSize, 1), &paint); SAL_INFO("vcl.skia.trace", "ensurebitmapdata(" << this << "): image scaled " << imageSize(mImage) << "->" |