mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-22 04:08:12 +08:00
do not update GPU buffers if data has not changed (#1967)
Co-authored-by: maniarathi <mani.arathi@gmail.com> Co-authored-by: Severiano Badajoz <sbadajoz@chanzuckerberg.com>
This commit is contained in:
co-authored by
maniarathi
Severiano Badajoz
parent
23714bc9f8
commit
06b88cda20
@@ -730,14 +730,25 @@ class Graph extends React.Component {
|
||||
);
|
||||
});
|
||||
|
||||
updateReglAndRender(asyncProps) {
|
||||
updateReglAndRender(asyncProps, prevAsyncProps) {
|
||||
const { positions, colors, flags } = asyncProps;
|
||||
this.cachedAsyncProps = asyncProps;
|
||||
const { pointBuffer, colorBuffer, flagBuffer } = this.state;
|
||||
pointBuffer({ data: positions, dimension: 2 });
|
||||
colorBuffer({ data: colors, dimension: 3 });
|
||||
flagBuffer({ data: flags, dimension: 1 });
|
||||
this.renderCanvas();
|
||||
let needToRenderCanvas = false;
|
||||
|
||||
if (positions !== prevAsyncProps?.positions) {
|
||||
pointBuffer({ data: positions, dimension: 2 });
|
||||
needToRenderCanvas = true;
|
||||
}
|
||||
if (colors !== prevAsyncProps?.colors) {
|
||||
colorBuffer({ data: colors, dimension: 3 });
|
||||
needToRenderCanvas = true;
|
||||
}
|
||||
if (flags !== prevAsyncProps?.flags) {
|
||||
flagBuffer({ data: flags, dimension: 1 });
|
||||
needToRenderCanvas = true;
|
||||
}
|
||||
if (needToRenderCanvas) this.renderCanvas();
|
||||
}
|
||||
|
||||
updateColorTable(colors, colorDf) {
|
||||
@@ -906,7 +917,7 @@ class Graph extends React.Component {
|
||||
<Async.Fulfilled>
|
||||
{(asyncProps) => {
|
||||
if (regl && !shallowEqual(asyncProps, this.cachedAsyncProps)) {
|
||||
this.updateReglAndRender(asyncProps);
|
||||
this.updateReglAndRender(asyncProps, this.cachedAsyncProps);
|
||||
}
|
||||
return null;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user