Track texture usage and keep gradients cache within limits
When the gradient had more than 2 stops and stop position or color
change to combination which doesn't yet exist, a new texture gets
created. Until now these haven't been managed, so animating multi-stop
gradients could create a big amount of textures.
Fix this by:
- Enable texture tracking by default. Add
QCPAINTER_DISABLE_TEXTURE_USAGE_TRACKING env variable to disable this.
Disabling can be useful to avoid overhead when user knows that
gradients do not cause memory usage issues in the target system.
- Add also QCPAINTER_MAX_TEXTURES env variable to control when the
cleaning kicks in. By default this is at 1024 unique textures.
Pick-to: 6.11
Change-Id: I4c02ecc5ca57250d052bbd3e747f4481bf6cea41
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Owais Akhtar <owais.akhtar@qt.io>