Forum Discussion
TheEndless
15 years agoChannel Surfer
"kbenson" wrote:"TheEndless" wrote:
One test in particular that reveals a lot about how the canvas works, you may be interested in trying...
Draw a full screen image in one go and time it. Then draw the same image in three sections (to the same layer) with the appropriately different TargetRects and SourceRects, so you're essentially drawing the exact same data, from the exact same file, to the screen. I was surprised at the results.
I haven't tested yet, but are you scaling? We've found that if you can get away with smaller source images, it's much quicker.
Also, if you haven't already, take a two pixel PNG with different colors for each pixel, and scale that up. You get interpolation between the color differences. Easy, super small way to do color gradients.
I'm not scaling, but I get the same performance result whether I paint the full image three times (squashed vertically), or I paint different SourceRects of the image. I mentioned in another post that the cutoff seems to be around 598 pixels. I got significantly different paint times painting the image at 598 pixels high than I did at 599 pixels. Very strange...
In the end, I just cut my background image into 3 separate images, and paint them each on the "background" layer. I get the same visual results as having a single image, with much better performance. I haven't actually tested to see if cutting them down further will make a difference, because I basically needed a refresh under a second for updates to my onscreen timer, but I'd be willing to bet that it does.
The gradient thing is awesome! I might just use that!