Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: displaylist based drawing of Morphs #25

Open
davidedc opened this issue Mar 1, 2015 · 1 comment
Open

improvement: displaylist based drawing of Morphs #25

davidedc opened this issue Mar 1, 2015 · 1 comment

Comments

@davidedc
Copy link

davidedc commented Mar 1, 2015

each morphic.js' morph currently completely draws itself in a backing buffer, which is then blitted onto the damaged parts of the screen.

These changes below introduce a displaylist-based drawing for the FrameMorph and the BoxMorph:

davidedc/Fizzygum@f8b1dc0
davidedc/Fizzygum@73a332e
davidedc/Fizzygum@daeef2a

The BoxMorph is interesting because it requires the use of a further clipping mask (8 lines of code) and the rewriting of the hit test method (currently named isTransparentAt, 27 lines of code that can be refactored into a third of that size).

The advantage of having a displaylist-based redraw is a) reduced memory usage (just the desktop itself, in retina display and 800x600 , would need a backing buffer of 7.5MB) and b) it works better with affine transforms than the buffer-based method.

Note that the PenMorph can only be used on a dedicated CanvasMorph now - which exposes its "raster" nature - other morphs won't expose their buffer. I could have put a different mechanism in place where Morphs switch from one redraw mode to the other in case a Pen is attached to them but I was happy with this solution...

Some refactoring and renaming will follow, and more Morphs will be moved over to the new system.

@ghost
Copy link

ghost commented Mar 8, 2015

Good idea, Davide! I've done it in my Starlings game via a display list called requests in StarlingsManagerMorph.prototype.step().
The display list is a list of 9-tuples.

Element # Function
0 The image element to draw
1 The clipping X position
2 The clipping Y position
3 The clipping width
4 The clipping height
5 The X position on the StarlingsManagerMorph to draw the image
6 The Y position on the StarlingsManagerMorph to draw the image
7 The desired width to draw the image
8 The desired height to draw the image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant