mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
js: keep colour strings in JavaScript rather than in C
The drawing routines in JavaScript used to take pointers to a C string containing a CSS colour name. That meant that JavaScript had to create a new JavaScript string on ever call to a drawing function, which seemed ugly. So now we instead pass colour numbers all the way down into JavaScript and keep an array of JavaScript strings there that can be re-used. The conversion from RGB triples to strings is still done in C, though. This doesn't seem to have fixed either of the bugs I hoped it would, but it does measurably improve drawing performance so I think it's worth doing.
This commit is contained in:
@ -41,6 +41,10 @@ var ctx;
|
||||
// by js_canvas_end_draw.
|
||||
var update_xmin, update_xmax, update_ymin, update_ymax;
|
||||
|
||||
// Colour strings to use when drawing, to save converting them from C
|
||||
// every time.
|
||||
var colours = [];
|
||||
|
||||
// Module object for Emscripten. We fill in these parameters to ensure
|
||||
// that when main() returns nothing will get cleaned up so we remain
|
||||
// able to call the puzzle's various callbacks.
|
||||
|
Reference in New Issue
Block a user