This notably fixes crash with SVGs using 1 stop gradients.
Relax the check in a test added in #24064 as it doesn't quite pass with
the new version -- this is somewhat suspicious but as it wasn't really
clear where did the original tolerance of 3 come from, it doesn't seem
to be a huge problem to increase it to 4 neither.
Closes#24213.
This function should be used instead of CreateWithDIPSize() in portable
code, the latter is currently often used to do what this function is
doing, but this only works correctly in wxOSX and wxGTK3 but not wxMSW.
All previous relevant platform-specific tests have been changed to use this
symbol. Also, samples/image now premultiplies conditionally, correcting a
visual anomaly on wxGTK.
This seems to be the only way to fix using this class, which is
fundamentally incompatible with high DPI support, with bitmaps of
different logical but identical physical sizes.
By using physical size we ensure that the code chopping up the provided
bitmap in multiple images doesn't do it with the bitmap having the same
physical size but a different logical size from all the other bitmaps.
And, conceptually, logical size of the bitmaps in it really shouldn't
matter to the image list as it doesn't have a scaling factor and so
can't do anything useful with the logical size.
Moreover, we can't add wxImageList::SetScaleFactor() neither because
this class is, by design, supposed to be shareable between different
controls which may use different scale factors, so it doesn't make sense
to speak of the scale factor of the image list itself.
This undoes the changes made in the generic implementation back in
c374eefd34 (Fold wxOSX-specific wxImageList into generic version,
2018-10-30) and also eb52e86553 (Take into account scale factor of
images added to wxImageList, 2021-04-03).
Also update a couple of places where wxImageList is still used to use
physical sizes. Unfortunately some others can't be easily fixed, e.g.
global wxFileIconsTable would have to be completely rewritten.
Finally, add a unit test checking that things work as expected now:
previously the size of 24x24 bitmap in the image list containing
(scaled) 32x32 bitmaps would be 21x21 due to sub-bitmap extraction
kicking in.
Closes#23994.
When using non-integer scale factor, we need to round the result of the
multiplication by it instead of truncating it for consistency with the
behaviour of wxBitmap::CreateWithDIPSize() and the other places where we
do this, including wxOSX version of this function.
Add a simple unit test checking that this works correctly (it would fail
with wxGTK before).
No real changes, just don't put the test not using raw bitmap access
inside the section guarded by "#if wxHAS_RAW_BITMAP".
This commit is best viewed with Git --color-moved option.
Don't delete the art provider object in Remove() as this contradicted
its contract and do restore the call to Remove() from wxArtProvider dtor
as it's actually documented to work.
This fixes a regression due to the changes of 4a294caacd (Stop using
macro-based wxList in wxArtProvider code, 2023-04-11).
Closes#23513.
Closes#23529.
wxGraphicsContext::ResetClip (wxOSX)
Using native CGContextResetClip() to reset the clip causes some
drawing glitches - especially with drawing text with CT - see
https://github.com/wxWidgets/wxWidgets/issues/22629#issuecomment-1399554002
For the time being we have to revert to the previous code
with emulated resetting based on restoring the graphics context state.
We also have to disable a unit tests that fails with emulated
resetting the clip.
See #22629.
With delay after refreshing testing window added in 808bbe8341 ("Fix
executing wxPaintDC-related tests under wxGTK", 2023-01-04) wxPaintDC
tests work also under wxOSX.
Some of wxImageList methods asserted when called on an invalid image
list while others just failed silently.
Assert in all of them now for consistency and to help detecting problems
in the code using invalid wxImageList objects.
Extend the documentation and the tests.
This is a combination of running clang-tidy with modernize-use-nullptr
check for some ports (GTK, X11, OSX) and manual changes to the ports for
which it couldn't be used easily (MSW, DFB) and also manually updating
the docs.
Also replace NULL with null or nullptr in the comments as this is more
consistent with the use of nullptr in the code and makes it simpler to
grep for the remaining occurrences of NULL itself.
And also use null in the assert messages.
Only a few occurrences of "NULL" are still left in non-C files, mostly
corresponding to unclear comments or string output which it might not be
safe to change.
Only define the test using wxBitmapBundle::FromSVGFile() when wxHAS_SVG
is on.
This fixes the build breakage after the parent commit.
This commit is best viewed with --color-moved Git option.
It doesn't seem to be useful and wasn't really specified in 2 out of 3
existing calls to this function and was probably wrongly specified in
the remaining one, so just remove it for now, it can always be added
later if we decide what exactly should it do.
Only assign known good values of the index to "indexLast" as otherwise
we could end up returning an invalid index value from it if "indexBest"
was never set and the last index wasn't a valid one, as it happened in
wxBitmapBundleImplSet containing an original bitmap and a x2 scaled copy
of it, which shouldn't be used for further scaling.
Add a unit test checking that this bug is fixed now.
Always rounding non-integer scale when upscaling is wrong, as we could
be able to upscale an existing x1.5 image to e.g. 300% DPI scaling with
relatively good results, so only do it if there is no available scale
that exactly divides the requested one.
Add a previously failing unit test which passes now.
It's not necessarily the largest bitmap, but one which may be scaled
using an integer factor.
Fix the tests to expect the correct results, now that they actually
pass.