This gives us a few main advantages:
1. It improves encapsulation and division of responsibility.
2. CocoaSpice can be used in other projects more easily.
3. It lays the foundation for better unit testing of key parts.
4. It cleans up the codebase.
Resolves#2376
There's a race condition caused by `drawRegion` using a `canvasData`
that has already been freed. So we make sure that the canvas is still
allocated.
Also refactor the CSDisplay code to use properties.
There was a misunderstanding previouly that the input code and
cursor drawing code should reside in the same class. This led to
one CocoaSpice class handling both the SPICE input and cursor
channel. The problem is that SPICE protocol specifies a 1-to-1
mapping of cursor channel and display channel (sharing the same
channel id). To implement support for multiple displays, we
would have to follow this convention.
Additionally, there was some akwardness in forcing CSInput to
comply with the UTMRenderSource protocol because it shared the
viewport size with CSDisplay. "Outside" code would have to
syncronize the display size.
As part of the refactor, we also tried to improve the code style
by first moving as many ivars to properties as possible and by
also renaming some methods and inits.
Previously, we were using viewports to handle translation and scaling. This
led to issues where if the VM display is larger than the device's display
then the screen would be cut off. We move the affine transformation to part
of the vertex shader now.
Fixes#181
Resolves#106
We draw the cursor as a second textured rectangle. Currently, we do not do
alpha blending so there is an ugly black border around the cursor.