perf(web): eliminate putImageData via WebGL2 quad, sync frame pacing, and add PWA/Service Worker

Replaces `ctx2d.putImageData` with a WebGL2 texture quad in both 117HD and SD modes, aligns the TeaVM game loop with `requestAnimationFrame`, and adds PWA manifest and Service Worker asset caching for mobile/iOS Safari.

### WebGL2 Compositing & SD/HD Rendering
- `WebHd117Renderer.java`, `WebGL2.java`:
  - Decoupled `ensureOverlayContext()` / `ensureOverlayReady()` so the WebGL2 2D overlay quad initializes without compiling 3D shadow/scene shaders when 117HD is off.
  - Added `drawHudPixels` and `drawHudCanvas` compositing onto `#gl-canvas` with `useBlend` control (disabling `GL_BLEND` for opaque SD frames).
- `RSImageProducer.java`, `DesktopHooks.java`:
  - Routed `RSImageProducer.drawGraphics` and modern HUD draws (`drawModernMinimap`, `drawModernChat`, `drawModernTab`) through the WebGL2 quad whenever `ensureOverlayReady()` succeeds, clearing `#game-canvas` once to avoid `putImageData` overhead.

### Frame Pacing & Mobile PWA
- `RSApplet.java`:
  - Added TeaVM `@Async` `awaitAnimationFrame()` backed by `window.requestAnimationFrame` for `delay <= 16` and capped catch-up ticks per frame (`loopTicks >= 2`).
- `index.html`, `manifest.webmanifest`, `sw.js`:
  - Added Apple Web App meta tags, `manifest.webmanifest`, and `sw.js` Service Worker registration with shell precaching, network-first navigation, and stale-while-revalidate static asset caching.
This commit is contained in:
Dark98 committed 2026-11-30 21:54:39 +00:00
1 parent 3331ab745b
commit 33235cec55
8 files changed
+412 -41

No files matched your search

+4 -1
View File
@@ -14,7 +14,9 @@ public interface WebGL2 extends JSObject {
int COLOR_BUFFER_BIT = 0x00004000;
int DEPTH_BUFFER_BIT = 0x00000100;
int TRIANGLES = 0x0004;
int TRIANGLE_STRIP = 0x0005;
int LEQUAL = 0x0203;
int ONE = 1;
int SRC_ALPHA = 0x0302;
int ONE_MINUS_SRC_ALPHA = 0x0303;
int DEPTH_TEST = 0x0B71;
@@ -63,7 +65,7 @@ public interface WebGL2 extends JSObject {
interface UniformLocation extends JSObject {}
@JSBody(params = {"canvas"}, script =
"return canvas.getContext('webgl2', { alpha: true, antialias: false, preserveDrawingBuffer: false });")
"return canvas.getContext('webgl2', { alpha: false, antialias: false, preserveDrawingBuffer: false, powerPreference: 'high-performance', desynchronized: true });")
static WebGL2 getContext(HTMLCanvasElement canvas) {
return null;
}
@@ -114,6 +116,7 @@ public interface WebGL2 extends JSObject {
void bindTexture(int target, Texture texture);
void texParameteri(int target, int pname, int param);
void texImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Uint8Array pixels);
void texImage2D(int target, int level, int internalformat, int format, int type, HTMLCanvasElement canvas);
void texImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, Uint8Array pixels);
void generateMipmap(int target);