UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

86 lines (85 loc) 3.6 kB
import { IDGen } from './process.spec.js'; import ImageStore from './imageStore.js'; import type { Glyph } from './glyph/familySource.js'; import type { GlyphMetadata } from 'workers/source/glyphSource.js'; import type { ImageSourceMetadata } from 'workers/source/imageSource.js'; import type { GPUType, LayerDefinition, StylePackage, WorkerLayer } from 'style/style.spec.js'; import type { TileRequest } from '../worker.spec.js'; import type { VTTile, Workers } from './process.spec.js'; /** * # Process Manager * * A managment class for all input vector/raster work for the Tile Worker thread. * Handles all input data cases and handles shipping the resultant render data back to the main thread */ export default class ProcessManager { #private; id: number; gpuType: GPUType; idGen: IDGen; experimental: boolean; messagePort: MessageChannel['port1']; sourceWorker: MessageChannel['port2']; textDecoder: TextDecoder; layers: Record<string, WorkerLayer[]>; workers: Workers; imageStore: ImageStore; mapStyles: Record<string, StylePackage>; /** * Internal function to build the id generator * @param totalWorkers - the total number of tile workers */ _buildIDGen(totalWorkers: number): void; /** * Setup a map style * @param mapID - the id of the map to setup the style for * @param style - the style to setup */ setupStyle(mapID: string, style: StylePackage): void; /** * Setup a style layer into a "worker layer" that can process input data into renderable data * @param layer - the layer to setup * @returns the worker layer */ setupLayer(layer: LayerDefinition): undefined | WorkerLayer; /** * Process the input vector data * @param mapID - the map that made the request * @param tile - the tile request * @param sourceName - the name of the source the data belongs to * @param vectorTile - the input vector tile to parse */ processVector(mapID: string, tile: TileRequest, sourceName: string, vectorTile: VTTile): Promise<void>; /** * Flush all data produced from a tile input. * @param mapID - the map that made the request * @param tile - the tile request * @param sourceName - the name of the source the data belongs to * @param layers - the layers that were built */ flush(mapID: string, tile: TileRequest, sourceName: string, layers: Record<number, number>): void; /** * Process RGBA based data * @param mapID - the map that made the request * @param tile - the tile request * @param sourceName - the name of the source the data belongs to * @param data - the input data * @param size - the size of the input data */ processRaster(mapID: string, tile: TileRequest, sourceName: string, data: ArrayBuffer, size: number): void; /** * Process glyph/icon/sprite/image metadata * @param mapID - the map that made the request * @param glyphMetadata - the glyph/icon metadatas * @param imageMetadata - the sprite/image metadatas */ processMetadata(mapID: string, glyphMetadata: GlyphMetadata[], imageMetadata: ImageSourceMetadata[]): void; /** * Process glyph/icon response from the source worker * @param mapID - the map that made the request * @param reqID - the id of the request * @param glyphMetadata - the glyph metadata * @param familyName - the name of the family */ processGlyphResponse(mapID: string, reqID: string, glyphMetadata: Glyph[], familyName: string): void; }