Add auto context restoration

This commit is contained in:
schmelczerandras 2020-09-27 16:10:52 +02:00
parent 40b9644171
commit 2e57f090e6
14 changed files with 352 additions and 136 deletions

View file

@ -1,7 +1,7 @@
import { DrawableDescriptor } from './drawables/drawable-descriptor';
import { Insights } from './graphics/rendering/insights';
import { Renderer } from './graphics/rendering/renderer';
import { RendererImplementation } from './graphics/rendering/renderer-implementation';
import { ContextAwareRenderer } from './graphics/rendering/renderer/context-aware-renderer';
import { Renderer } from './graphics/rendering/renderer/renderer';
import { StartupSettings } from './graphics/rendering/settings/startup-settings';
import { applyArrayPlugins } from './helper/array';
@ -12,7 +12,7 @@ export { Flashlight } from './drawables/lights/flashlight';
export { Circle } from './drawables/shapes/circle';
export { InvertedTunnel } from './drawables/shapes/inverted-tunnel';
export { Tunnel } from './drawables/shapes/tunnel';
export { Renderer } from './graphics/rendering/renderer';
export { Renderer } from './graphics/rendering/renderer/renderer';
declare global {
interface Array<T> {
@ -31,11 +31,13 @@ applyArrayPlugins();
export async function compile(
canvas: HTMLCanvasElement,
descriptors: Array<DrawableDescriptor>,
settings: Partial<StartupSettings> = {}
settingsOverrides: Partial<StartupSettings> = {}
): Promise<Renderer> {
// enableContextLostSimulator(canvas);
return Insights.measureFunction('startup', async () => {
const renderer = new RendererImplementation(canvas, descriptors);
await renderer.initialize(settings);
const renderer = new ContextAwareRenderer(canvas, descriptors, settingsOverrides);
await renderer.initializedPromise;
return renderer;
});
}