From 90d2b08a278dfe3d9a010403316e15fca3c9e4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20Zag=C3=B3rski?= Date: Fri, 18 Oct 2024 14:16:55 +0200 Subject: [PATCH] carto: RasterLayer fix perf issue caused by spurious data changes --- modules/carto/src/layers/raster-layer.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/carto/src/layers/raster-layer.ts b/modules/carto/src/layers/raster-layer.ts index 6d529a19455..5e177254e74 100644 --- a/modules/carto/src/layers/raster-layer.ts +++ b/modules/carto/src/layers/raster-layer.ts @@ -81,6 +81,15 @@ type _RasterLayerProps = { tileIndex: bigint; }; +type RasterColumnLayerData = { + data: Raster; + length: number; +}; + +function wrappedDataComparator(oldData: RasterColumnLayerData, newData: RasterColumnLayerData) { + return oldData.data === newData.data && oldData.length === newData.length; +} + // Adapter layer around RasterColumnLayer that converts data & accessors into correct format export default class RasterLayer extends CompositeLayer< Required> & ExtraProps @@ -91,6 +100,7 @@ export default class RasterLayer extends Composite state!: { highlightedObjectIndex: number; highlightColor: number[]; + dataWrapper?: {data: Raster; length: number}; }; renderLayers(): Layer | null | LayersList { @@ -130,6 +140,7 @@ export default class RasterLayer extends Composite data, // Pass through data for getSubLayerAccessor() length: blockSize * blockSize }, + dataComparator: wrappedDataComparator, offset, lineWidthScale, // Re-use widthScale prop to pass cell scale, highlightedObjectIndex,