Avoid unnecessarily unsharing bitmaps in wxMSW

Only call AllocExclusive() if really need to modify the bitmap and avoid
doing it if the scale factor doesn't actually change, as this saves on
unnecessary expensive bitmap copy.

This also avoids the problem of getting wrong background for SVG images
since this call to AllocExclusive() was added in d943d6f6cf (Ensure
wxBitmap::SetScaleFactor() doesn't change bitmap copies, 2022-01-22)
when not using high DPI, although the problem still remains in the high
DPI case as bitmap alpha channel is still copied incorrectly when we do
have to copy it.
This commit is contained in:
Vadim Zeitlin
2022-02-02 20:54:06 +00:00
parent 03efe56cf9
commit 2ae80673ff

View File

@@ -346,9 +346,13 @@ void wxGDIImage::SetScaleFactor(double scale)
{
wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
double& scaleCurrent = GetGDIImageData()->m_scaleFactor;
if ( scale != scaleCurrent )
{
AllocExclusive();
GetGDIImageData()->m_scaleFactor = scale;
scaleCurrent = scale;
}
}
double wxGDIImage::GetScaleFactor() const