I tried to post this question a couple minutes ago, but it looks like it didn't go through. Trying again...
When drawing gradients, is it preferable to use a Pattern or GC#fillGradientRectangle()? I assume a pattern will be more efficient but I'd just like to confirm.
Also, when disposing a gradient Pattern, is it necessary to also dispose the Color values passed to the constructor? I assume yes since it doesn't look like Pattern#dispose() will do it, but again just want to confirm.
Lakshmi Shanmugam Messages: 271 Registered: July 2009 Location: India
Senior Member
Hi,
If you have created the Color (i.e, using new Color) then you should dispose it. If you have not created it, but have got it from somewhere (for eg, display.getSystemColor()) then you should not dispose it.
This article on management of OS resources in SWT may be useful --> http://www.eclipse.org/articles/swt-design-2/swt-design-2.ht ml
I have read that article - just wanted to confirm that the Colors used by the gradient Pattern should also be disposed. That is what I am currently doing in my code.