Skip to content

Commit

Permalink
carto: RasterLayer fix perf issue caused by spurious data changes (#9218
Browse files Browse the repository at this point in the history
)
  • Loading branch information
zbigg authored Oct 21, 2024
1 parent 065816e commit c7f1a66
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modules/carto/src/layers/raster-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataT = any, ExtraProps = {}> extends CompositeLayer<
Required<RasterLayerProps<DataT>> & ExtraProps
Expand Down Expand Up @@ -130,6 +139,7 @@ export default class RasterLayer<DataT = any, ExtraProps = {}> extends Composite
data, // Pass through data for getSubLayerAccessor()
length: blockSize * blockSize
},
dataComparator: wrappedDataComparator,
offset,
lineWidthScale, // Re-use widthScale prop to pass cell scale,
highlightedObjectIndex,
Expand Down

0 comments on commit c7f1a66

Please sign in to comment.