mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 15:41:30 -07:00
js: Simplify drawing context management
There's not much point in re-requesting the drawing context from the offscreen canvas at the start of each drawing operation. The canvas keeps the context around and returns it on every call to getContext(), so we may as well just keep our reference to it too. This does mean that the front-end won't detect puzzles drawing outside of a redraw operation, but I think it's the mid-end's job to assert things like that. Rumours that I'm doing this because I had a mysterious bug whereby ctx was unexpectedly null are entirely true.
This commit is contained in:
@ -224,7 +224,6 @@ mergeInto(LibraryManager.library, {
|
||||
* Prepare to do some drawing on the canvas.
|
||||
*/
|
||||
js_canvas_start_draw: function() {
|
||||
ctx = offscreen_canvas.getContext('2d', { alpha: false });
|
||||
update_xmin = update_xmax = update_ymin = update_ymax = undefined;
|
||||
},
|
||||
|
||||
@ -267,7 +266,6 @@ mergeInto(LibraryManager.library, {
|
||||
update_xmax - update_xmin,
|
||||
update_ymax - update_ymin);
|
||||
}
|
||||
ctx = null;
|
||||
},
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user