Skip to content

Implement better (more maintainable) way to redraw gl canvases on incremental updates #2562

Closed
@etpinard

Description

@etpinard

Now that we have multiple regl-based traces sharing the same gl canvases and relying on the same global src/lib/clear_gl_canvases.js routine, we'll need a better way to redraw things on updates (e.g. on selections but also restyle and relayout calls).

Here's an example from #2505, style here is called during selections:

function style(gd, cds) {
if(!cds) return;
var fullLayout = gd._fullLayout;
var cd0 = cds[0];
var scene0 = cd0[0].t._scene;
scene0.matrix.regl.clear({color: true, depth: true});
if(fullLayout._splomGrid) {
fullLayout._splomGrid.draw();
}
for(var i = 0; i < cds.length; i++) {
var scene = cds[i][0].t._scene;
scene.draw();
}
// redraw all subplot with scattergl traces,
// as we cleared the whole canvas above
if(fullLayout._has('cartesian')) {
for(var k in fullLayout._plots) {
var sp = fullLayout._plots[k];
if(sp._scene) sp._scene.draw();
}
}
}

Here, we clear the canvases and redraw splom things with new selected/unselected batches, but then ooops we also need to add logic for scattergl traces in the splom method so that they don't disappear on splom updates.


So, I propose (and I'm sure @dy will find a way to improve this proposal) to store a graph-wide queue of regl module draw calls (e.g. fullLayout._reglDrawQueue) that we could call everything we clear the canvases to update something. The new update sequence will (1) clear the canvases (or only parts of it if we can) (2) update selected buffers (3) call reglDrawQueue to redraw all things.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions