craftyjs/Crafty — pull request #525 by starwed (2013-08-11 00:19:24+00:00)
Title: Viewport refactoring (round 1)

This refactors the scroll and scale viewport functions. They now simply update the appropriate viewport variables, and trigger an "InvalidateViewport" event.

The rendering functions now make any adjustment necessary to their render target. This should drastically improve perforamance, because I got rid of all unneeded calls to `drawAll()`.

* I fixed various and sundry bugs I noticed while implementing this, but I think there are probably many more. Several of the viewport functions don't seem to consider the possibility that the viewport might be scaled.

* I also fixed a small bug that meant drawAll wasn't catching rotated objects if their MBR was onscreen but their base coordinates weren't.

* I tested scale and scroll, as well as follow, and all seemed to work fine. I *think* the other's should still work, since in many places they implicitly rely on scroll. But no promises.

This is just round one; several of the other viewport functions need refactoring, but this is the base work that should make that easier!