s2maps-gpu
Version:
S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.
109 lines (108 loc) • 4.82 kB
TypeScript
import type { FillData } from 'workers/worker.spec.js';
import type { TileGPU as Tile } from 'source/tile.spec.js';
import type { WebGPUContext } from '../context/index.js';
import type { FillDefinition, FillStyle, FillWorkflowLayerGuideGPU, LayerDefinitionBase } from 'style/style.spec.js';
import type { FillFeature as FillFeatureSpec, FillSource, FillWorkflow as FillWorkflowSpec, MaskSource, TileMaskSource } from './workflow.spec.js';
/** Fill Feature is a standalone fill render storage unit that can be drawn to the GPU */
export declare class FillFeature implements FillFeatureSpec {
#private;
workflow: FillWorkflowSpec;
layerGuide: FillWorkflowLayerGuideGPU;
maskLayer: boolean;
source: FillSource | MaskSource;
count: number;
offset: number;
tile: Tile;
featureCodeBuffer: GPUBuffer;
fillTexturePositions: GPUBuffer;
fillInteractiveBuffer?: GPUBuffer | undefined;
featureCode: number[];
parent?: Tile | undefined;
type: "fill";
bindGroup: GPUBindGroup;
fillPatternBindGroup: GPUBindGroup;
fillInteractiveBindGroup?: GPUBindGroup | undefined;
/**
* @param workflow - the fill workflow
* @param layerGuide - the layer guide for this feature
* @param maskLayer - whether or not the layer is a mask type or not
* @param source - the fill or mask source
* @param count - the number of points
* @param offset - the offset of the points
* @param tile - the tile that the feature is drawn on
* @param featureCodeBuffer - the encoded feature code that tells the GPU how to compute it's properties
* @param fillTexturePositions - the fill texture positions
* @param fillInteractiveBuffer - if interactive, this buffer helps the GPU compute interactivity
* @param featureCode - the encoded feature code that tells the GPU how to compute it's properties
* @param parent - the parent tile if applicable
*/
constructor(workflow: FillWorkflowSpec, layerGuide: FillWorkflowLayerGuideGPU, maskLayer: boolean, source: FillSource | MaskSource, count: number, offset: number, tile: Tile, featureCodeBuffer: GPUBuffer, fillTexturePositions: GPUBuffer, fillInteractiveBuffer?: GPUBuffer | undefined, featureCode?: number[], parent?: Tile | undefined);
/** Draw the feature */
draw(): void;
/** Compute the feature's interactivity with the mouse */
compute(): void;
/** Update the shared texture's bind groups */
updateSharedTexture(): void;
/** Destroy and cleanup the feature */
destroy(): void;
/**
* Duplicate this point
* @param tile - the tile that is being duplicated
* @param parent - the parent tile if applicable
* @returns the duplicated feature
*/
duplicate(tile: Tile, parent?: Tile): FillFeature;
}
/** Fill Workflow */
export default class FillWorkflow implements FillWorkflowSpec {
#private;
context: WebGPUContext;
layerGuides: Map<number, FillWorkflowLayerGuideGPU>;
interactivePipeline: GPUComputePipeline;
maskPipeline: GPURenderPipeline;
fillPipeline: GPURenderPipeline;
maskFillPipeline: GPURenderPipeline;
invertPipeline: GPURenderPipeline;
fillInteractiveBindGroupLayout: GPUBindGroupLayout;
/** @param context - The WebGPU context */
constructor(context: WebGPUContext);
/** Setup the workflow */
setup(): Promise<void>;
/** Destroy and cleanup the workflow */
destroy(): void;
/**
* Build the layer definition for this workflow
* @param layerBase - the common layer attributes
* @param layer - the user defined layer attributes
* @returns a built layer definition that's ready to describe how to render a feature
*/
buildLayerDefinition(layerBase: LayerDefinitionBase, layer: FillStyle): FillDefinition;
/**
* given a set of layerIndexes that use Masks and the tile of interest
* @param definition - layer definition that uses masks
* @param tile - the tile that needs a mask
*/
buildMaskFeature(definition: FillDefinition, tile: Tile): void;
/**
* Build the source fill data into fill features
* @param fillData - the input fill data
* @param tile - the tile we are building the features for
*/
buildSource(fillData: FillData, tile: Tile): void;
/**
* Draw a fill feature to the GPU
* @param feature - fill feature guide
*/
draw(feature: FillFeatureSpec): void;
/**
* Draw a mask to the GPU
* @param mask - mask source
* @param feature - fill feature guide
*/
drawMask(mask: TileMaskSource, feature?: FillFeatureSpec): void;
/**
* Compute the interactive fill features in current view
* @param feature - fill feature guide
*/
computeInteractive(feature: FillFeatureSpec): void;
}