Closed hecrj closed 1 year ago
Hi! I don't mind this change, but be aware that comparing patterns might be very expensive. Since you will be comparing pixmap bytes.
Also, since Paint
has a lifetime, you cannot really store it. So comparison becomes kinda useless.
The only way to make it easier is to store pattern's image in Arc
, but it might only increase the complexity.
Right, iced
doesn't support patterns so we are just using a 'static
paint for now. If we ever support it, we will probably write our own PartialEq
implementation to do shallow pointer equality only.
In any case, figured this could be a nice change since nothing seems to be in the way for these traits to be derived and may help others prototype ideas as well.
Thanks for the pointers!
I thought that we could add a custom PartialEq
for Pattern
that would compare only data pointers (aka as_ptr()
) + length, without comparing the actual data. But it might be too restrictive and confusing.
And it seems like the default PartialEq
implementation for slices is smart enough.
And since patterns are usually small I guess it should be fine.
I'm experimenting with diffing and incremental rendering in
iced
withtiny-skia
and I need to be able to comparePaint
types.