One of the things I have often seen, mostly with novice developers but occasionally with those who should know better is complex operations in the paint routine.
Paint routines, like interrupt routines and for the same reasons, should do the minimum operations necessary for the job. This means no calculations and certainly no loading of image files!
All the time you are in the paint routine you are hogging the UI thread but even worse you are making your application look slow and sluggish. Also you are not the only thing controlling the calling of the paint routing, they are many good reasons why it may be called by the system without your intervention, at which point you are needlessly performing all those calculations.
All the paint routines should contain is the various draw operations: any choices, sizes and positions should be pre-calculated, any text, images or other visual elements should be pre-loaded preferably on another thread.
Try it, you'll find your graphics look much faster.
Oh, and desktop developers, this one works for you too!
Paint routines, like interrupt routines and for the same reasons, should do the minimum operations necessary for the job. This means no calculations and certainly no loading of image files!
All the time you are in the paint routine you are hogging the UI thread but even worse you are making your application look slow and sluggish. Also you are not the only thing controlling the calling of the paint routing, they are many good reasons why it may be called by the system without your intervention, at which point you are needlessly performing all those calculations.
All the paint routines should contain is the various draw operations: any choices, sizes and positions should be pre-calculated, any text, images or other visual elements should be pre-loaded preferably on another thread.
Try it, you'll find your graphics look much faster.
Oh, and desktop developers, this one works for you too!