UNPKG

s2maps-gpu

Version:

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

84 lines (83 loc) 3.09 kB
import { WebGPUContext } from './context/index.js'; import type { ColorMode } from 's2/s2Map.js'; import type { GlyphImages } from 'workers/source/glyphSource.js'; import type { MapOptions } from 'ui/s2mapUI.js'; import type { Projector } from 'ui/camera/projector/index.js'; import type { TileGPU as Tile } from 'source/tile.spec.js'; import type TimeCache from 'ui/camera/timeCache.js'; import type { WorkflowType, Workflows } from './workflows/workflow.spec.js'; import type { PainterData, SpriteImageMessage } from 'workers/worker.spec.js'; /** * # GPU Painter * * ## Description * The GPU painter is the main entry point to the GPU features. */ export default class Painter { #private; context: WebGPUContext; workflows: Workflows; dirty: boolean; /** * @param context - the GPU context wrapper * @param options - map options to pull out the options that impact the painter and GPU */ constructor(context: GPUCanvasContext, options: MapOptions); /** called once to properly prepare the context */ prepare(): Promise<void>; /** * Given a tile, build the feature data associated with it * @param tile - the tile to inject the features into * @param data - the collection of data to sift through and build features */ buildFeatureData(tile: Tile, data: PainterData): void; /** * Build all workflows used by the style layers * @param buildSet - the set of workflows to build */ buildWorkflows(buildSet: Set<WorkflowType>): Promise<void>; /** @returns a Uint8ClampedArray screen capture */ getScreen(): Promise<Uint8ClampedArray>; /** * Set the colorblind mode * @param mode - colorblind mode to set */ setColorMode(mode: ColorMode): void; /** * Inject a glyph image to the GPU * @param maxHeight - the maximum height of the texture * @param images - the glyph images * @param tiles - the tiles to update */ injectGlyphImages(maxHeight: number, images: GlyphImages, tiles: Tile[]): void; /** * Inject a sprite image to the GPU * @param data - the raw image data of the sprite * @param tiles - the tiles to update */ injectSpriteImage(data: SpriteImageMessage, tiles: Tile[]): void; /** * Inject a time cache for the sensor workflow * @param timeCache - the time cache to inject */ injectTimeCache(timeCache: TimeCache): void; /** * Resize the canvas * @param width - new width * @param height - new height */ resize(width: number, height: number): void; /** * Paint all the tiles in view * @param projector - the camera and what it currently sees * @param tiles - all the tiles in view to paint */ paint(projector: Projector, tiles: Tile[]): void; /** * Compute the interactive features in current view * @param tiles - current view tiles that we need to sift through for interactive features */ computeInteractive(tiles: Tile[]): void; /** Delete the GPU instance */ delete(): void; }