|
@@ -95,13 +95,6 @@ class WebGPUTextureUtils {
|
|
|
*/
|
|
*/
|
|
|
this._samplerCache = new Map();
|
|
this._samplerCache = new Map();
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * A set of HTMLTextures that need paint updates.
|
|
|
|
|
- *
|
|
|
|
|
- * @type {Set<HTMLTexture>}
|
|
|
|
|
- */
|
|
|
|
|
- this._htmlTextures = new Set();
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -364,8 +357,6 @@ class WebGPUTextureUtils {
|
|
|
|
|
|
|
|
if ( textureData.msaaTexture !== undefined ) textureData.msaaTexture.destroy();
|
|
if ( textureData.msaaTexture !== undefined ) textureData.msaaTexture.destroy();
|
|
|
|
|
|
|
|
- this._htmlTextures.delete( texture );
|
|
|
|
|
-
|
|
|
|
|
backend.delete( texture );
|
|
backend.delete( texture );
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -583,14 +574,10 @@ class WebGPUTextureUtils {
|
|
|
|
|
|
|
|
if ( typeof device.queue.copyElementImageToTexture !== 'function' ) return;
|
|
if ( typeof device.queue.copyElementImageToTexture !== 'function' ) return;
|
|
|
|
|
|
|
|
- // Set up paint callback if not already done.
|
|
|
|
|
|
|
+ // Skip the first frame — the element needs a paint record first.
|
|
|
if ( ! textureData.hasPaintCallback ) {
|
|
if ( ! textureData.hasPaintCallback ) {
|
|
|
|
|
|
|
|
textureData.hasPaintCallback = true;
|
|
textureData.hasPaintCallback = true;
|
|
|
-
|
|
|
|
|
- this._addHTMLTexture( texture );
|
|
|
|
|
-
|
|
|
|
|
- // Wait for the browser to paint the element before uploading.
|
|
|
|
|
canvas.requestPaint();
|
|
canvas.requestPaint();
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
@@ -700,46 +687,12 @@ class WebGPUTextureUtils {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Registers an HTMLTexture for paint updates.
|
|
|
|
|
- * Sets up a single shared `onpaint` handler on the canvas
|
|
|
|
|
- * that notifies all registered HTMLTextures.
|
|
|
|
|
- *
|
|
|
|
|
- * @private
|
|
|
|
|
- * @param {HTMLTexture} texture - The HTMLTexture to register.
|
|
|
|
|
- */
|
|
|
|
|
- _addHTMLTexture( texture ) {
|
|
|
|
|
-
|
|
|
|
|
- this._htmlTextures.add( texture );
|
|
|
|
|
-
|
|
|
|
|
- const canvas = this.backend.renderer.domElement;
|
|
|
|
|
- const htmlTextures = this._htmlTextures;
|
|
|
|
|
-
|
|
|
|
|
- canvas.onpaint = ( event ) => {
|
|
|
|
|
-
|
|
|
|
|
- const changed = event.changedElements;
|
|
|
|
|
-
|
|
|
|
|
- for ( const t of htmlTextures ) {
|
|
|
|
|
-
|
|
|
|
|
- if ( changed.includes( t.image ) ) {
|
|
|
|
|
-
|
|
|
|
|
- t.needsUpdate = true;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Frees all internal resources.
|
|
* Frees all internal resources.
|
|
|
*/
|
|
*/
|
|
|
dispose() {
|
|
dispose() {
|
|
|
|
|
|
|
|
this._samplerCache.clear();
|
|
this._samplerCache.clear();
|
|
|
- this._htmlTextures.clear();
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|