Gradient Optim


Hi Jules,

I was wondering if it would be possible to cache the CGShadingRef used in drawGradient when calling setFillType (eventually lazy evaluation if you don’t want to compute it there)

Currently if call multiple DrawLine with a gradient, it ends up being recomputed way to much times.



Thanks, good idea, I’ll take a look…


Hi Jules,

Did you had a chance to take a look at this ?



I did have a quick look, but it’s far more complicated that it seems, because there are callback functions and a stack of saved context states to worry about, so I chickened out. Have a go yourself if you want to, but I realised I was probably going to end up spending several hours getting it to work, and didn’t have time to do that.


Please check your email.

I’ve found an easy way to implement it.



Works fine.