MCPcopy
hub / github.com/pixijs/pixijs / GraphicsContextSystem

Class GraphicsContextSystem

src/scene/graphics/shared/GraphicsContextSystem.ts:133–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 * @advanced
132 */
133export class GraphicsContextSystem implements System<GraphicsContextSystemOptions>
134{
135 /** @ignore */
136 public static extension = {
137 type: [
138 ExtensionType.WebGLSystem,
139 ExtensionType.WebGPUSystem,
140 ],
141 name: 'graphicsContext'
142 } as const;
143
144 /** The default options for the GraphicsContextSystem. */
145 public static readonly defaultOptions: GraphicsContextSystemOptions = {
146 /**
147 * A value from 0 to 1 that controls the smoothness of bezier curves (the higher the smoother)
148 * @default 0.5
149 */
150 bezierSmoothness: 0.5,
151 };
152
153 private readonly _renderer: Renderer;
154 private readonly _managedContexts: GCManagedHash<GraphicsContext>;
155
156 constructor(renderer: Renderer)
157 {
158 this._renderer = renderer;
159 this._managedContexts = new GCManagedHash({ renderer, type: 'resource', name: 'graphicsContext' });
160 }
161
162 /**
163 * Runner init called, update the default options
164 * @ignore
165 */
166 public init(options?: GraphicsContextSystemOptions)
167 {
168 GraphicsContextSystem.defaultOptions.bezierSmoothness = options?.bezierSmoothness
169 ?? GraphicsContextSystem.defaultOptions.bezierSmoothness;
170 }
171
172 /**
173 * Returns the render data for a given GraphicsContext.
174 * @param context - The GraphicsContext to get the render data for.
175 * @internal
176 */
177 public getContextRenderData(context: GraphicsContext): GraphicsContextRenderData
178 {
179 return context._gpuData[this._renderer.uid].graphicsData || this._initContextRenderData(context);
180 }
181
182 /**
183 * Updates the GPU context for a given GraphicsContext.
184 * If the context is dirty, it will rebuild the batches and geometry data.
185 * @param context - The GraphicsContext to update.
186 * @returns The updated GpuGraphicsContext.
187 * @internal
188 */
189 public updateGpuContext(context: GraphicsContext)
190 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected