summaryrefslogtreecommitdiffstats
path: root/vcl/skia
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:03:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 05:09:28 +0000
commit97ac77f067910fa5e8206d75160fa63546a9358d (patch)
treee6fa64b43e8150ef65578afa4f1f40f3e19f7fa3 /vcl/skia
parentReleasing progress-linux version 4:24.2.2-3~progress7.99u1. (diff)
downloadlibreoffice-97ac77f067910fa5e8206d75160fa63546a9358d.tar.xz
libreoffice-97ac77f067910fa5e8206d75160fa63546a9358d.zip
Merging upstream version 4:24.2.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/skia')
-rw-r--r--vcl/skia/gdiimpl.cxx20
-rw-r--r--vcl/skia/osx/gdiimpl.cxx21
2 files changed, 31 insertions, 10 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index d7028b9598..dce3175feb 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1490,6 +1490,26 @@ void SkiaSalGraphicsImpl::invert(basegfx::B2DPolygon const& rPoly, SalInvert eFl
aPaint.setShader(
aBitmap.makeShader(SkTileMode::kRepeat, SkTileMode::kRepeat, SkSamplingOptions()));
}
+
+#ifdef SK_METAL
+ // tdf#153306 prevent subpixel shifting of X coordinate
+ // HACK: for some unknown reason, if the X coordinate of the
+ // path's bounds is more than 1024, SkBlendMode::kExclusion will
+ // shift by about a half a pixel to the right with Skia/Metal on
+ // a Retina display. Weirdly, if the same polygon is repeatedly
+ // drawn, the total shift is cumulative so if the drawn polygon
+ // is more than a few pixels wide, the blinking cursor in Writer
+ // will exhibit this bug but only for one thin vertical slice at
+ // a time. Apparently, shifting drawing a very tiny amount to
+ // the left seems to be enough to quell this runaway cumulative
+ // X coordinate shift.
+ if (isGPU())
+ {
+ SkMatrix aMatrix;
+ aMatrix.set(SkMatrix::kMTransX, -0.001);
+ getDrawCanvas()->concat(aMatrix);
+ }
+#endif
}
getDrawCanvas()->drawPath(aPath, aPaint);
postDraw();
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index c4bd751842..9b511ad446 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -37,12 +37,6 @@
using namespace SkiaHelper;
-static void releaseInstalledPixels(void* pAddr, void*)
-{
- if (pAddr)
- delete[] static_cast<sal_uInt8*>(pAddr);
-}
-
AquaSkiaSalGraphicsImpl::AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent,
AquaSharedAttributes& rShared)
: SkiaSalGraphicsImpl(rParent, rShared.mpFrame)
@@ -251,6 +245,7 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
if (!context)
{
SAL_WARN("vcl.skia", "drawNativeControl(): Failed to allocate bitmap context");
+ delete[] data;
return false;
}
// Setup context state for drawing (performDrawNativeControl() e.g. fills background in some cases).
@@ -287,12 +282,9 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
if (!bitmap.installPixels(SkImageInfo::Make(width, height,
mSurface->imageInfo().colorType(),
kPremul_SkAlphaType),
- data, width * 4, releaseInstalledPixels, nullptr))
+ data, width * 4, nullptr, nullptr))
abort();
- // Make bitmap immutable to avoid making a copy in bitmap.asImage()
- bitmap.setImmutable();
-
preDraw();
SAL_INFO("vcl.skia.trace", "drawnativecontrol(" << this << "): " << rControlRegion << ":"
<< int(nType) << "/" << int(nPart));
@@ -312,6 +304,15 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n
++pendingOperationsToFlush; // tdf#136369
postDraw();
}
+ // Related: tdf#159529 eliminate possible memory leak
+ // Despite confirming that the release function passed to
+ // SkBitmap.bitmap.installPixels() does get called for every
+ // data array that has been allocated, Apple's Instruments
+ // indicates that the data is leaking. While it is likely a
+ // false positive, it makes leak analysis difficult so leave
+ // the bitmap mutable. That causes SkBitmap.asImage() to make
+ // a copy of the data and the data can be safely deleted here.
+ delete[] data;
return bOK;
}