mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 14:18:11 +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;
|
const { positions, colors, flags } = asyncProps;
|
||||||
this.cachedAsyncProps = asyncProps;
|
this.cachedAsyncProps = asyncProps;
|
||||||
const { pointBuffer, colorBuffer, flagBuffer } = this.state;
|
const { pointBuffer, colorBuffer, flagBuffer } = this.state;
|
||||||
pointBuffer({ data: positions, dimension: 2 });
|
let needToRenderCanvas = false;
|
||||||
colorBuffer({ data: colors, dimension: 3 });
|
|
||||||
flagBuffer({ data: flags, dimension: 1 });
|
if (positions !== prevAsyncProps?.positions) {
|
||||||
this.renderCanvas();
|
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) {
|
updateColorTable(colors, colorDf) {
|
||||||
@@ -906,7 +917,7 @@ class Graph extends React.Component {
|
|||||||
<Async.Fulfilled>
|
<Async.Fulfilled>
|
||||||
{(asyncProps) => {
|
{(asyncProps) => {
|
||||||
if (regl && !shallowEqual(asyncProps, this.cachedAsyncProps)) {
|
if (regl && !shallowEqual(asyncProps, this.cachedAsyncProps)) {
|
||||||
this.updateReglAndRender(asyncProps);
|
this.updateReglAndRender(asyncProps, this.cachedAsyncProps);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user