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:
@@ -346,9 +346,13 @@ void wxGDIImage::SetScaleFactor(double scale)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
|
wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
|
||||||
|
|
||||||
|
double& scaleCurrent = GetGDIImageData()->m_scaleFactor;
|
||||||
|
if ( scale != scaleCurrent )
|
||||||
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
GetGDIImageData()->m_scaleFactor = scale;
|
scaleCurrent = scale;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double wxGDIImage::GetScaleFactor() const
|
double wxGDIImage::GetScaleFactor() const
|
||||||
|
|||||||
Reference in New Issue
Block a user