3 ms·
Gruber linked to a developer who doubled the iPhone 4's framerate (to 45 FPS) with a simple optimization: http://daringfireball.net/linked/2010/09/20/not-so-fas
by rryyan 16y ago
Gruber linked to a developer who doubled the iPhone 4's framerate (to 45 FPS) with a simple optimization: http://daringfireball.net/linked/2010/09/20/not-so-fast http://daringfireball.net/linked/2010/09/20/not-so-fast
Looks like the improved version erases just the previous frame's ball, instead of clearing the whole canvas (just my best interpretation -- I'm not familiar with the canvas API).
EDIT: This link details what's going on here:
One important optimization rule to follow is to reuse as many pixels as possible between frames. What I mean by that is the fewer pixels that need to be processed each frame, the faster your program will run. A good example of this is when erasing pixels with the clearRect(x,y,w,h)method, it is very beneficial to clear and redraw only the pixels that have changed and not, for instance, a full screen 1920x1280 sized canvas. Unlike the Flash Player’s redraw regions, this management of "dirty rectangles" needs to be done manually for canvas. [http://www.kontain.com/fi/entries/94636/ http://www.kontain.com/fi/entries/94636/]
Apparently Flash Player optimizes the reuse of pixels automatically, and MobileSafari does not.