Mercurial > hg > forks > multipaint-js
diff multipaint.pde @ 72:5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
This is experimental and might be broken, and could get reverted.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Jul 2018 12:45:03 +0300 |
parents | 3d40683b367a |
children | d2a89e88f958 |
line wrap: on
line diff
--- a/multipaint.pde Thu Jul 05 12:41:35 2018 +0300 +++ b/multipaint.pde Thu Jul 05 12:45:03 2018 +0300 @@ -23,7 +23,7 @@ int g_active, g_tooltrigger, g_prevtool; int g_rband, g_rbang, g_boxreconstruct, g_sorsaa, g_charlimit; int g_animx, g_animy, g_animframes, g_animno, g_animtime, g_animspeed; -int g_omag, g_bordh, g_bordv, g_keymacpos; +int g_omag, g_bordh, g_bordv, g_keymacpos, g_dirty; boolean fileselect = false, saveas = false, refselect = false, g_control = false, g_shift = false, exporttxt = false, @@ -90,6 +90,7 @@ void setup() { int i, x, y; + g_dirty = true; frameRate(40); for (i = 0; i < g_data.length; i++) @@ -404,6 +405,12 @@ g_shift = false; } + // If there should be no update, do not update. + if (!g_dirty) + return; + g_dirty = false; + + // Animate animbrush if (g_data[int('n')] == 1) { if (++g_animtime > 8 - g_animspeed * 2) { animbrush_do(); @@ -411,10 +418,6 @@ } } - if (moicon(16 * 16 * g_uizoom, height - 32 * g_uizoom, 16 * g_uizoom, 24 * g_uizoom)) help(int('<')); - if (moicon(16 * 16 * g_uizoom, height - 8 * g_uizoom, 16 * g_uizoom, 8 * g_uizoom)) help(int('>')); - if (moicon(0, height - 32 * g_uizoom, 15 * 16 * g_uizoom, 32 * g_uizoom)) help(TAB); - if (moicon(width - 32 * g_uizoom, 0, 32 * g_uizoom, 16 * g_uizoom)) help(int('.')); // Update some mouse variables if (g_data[int('m')] == 0 && g_data[int('M')] == 0) {