|
@@ -346,39 +346,27 @@ export class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
this._useInvalidateRectOptimization = value;
|
|
|
}
|
|
|
|
|
|
- private _clearRectangle: Nullable<Measure> = null;
|
|
|
+ // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
|
|
|
private _invalidatedRectangle: Nullable<Measure> = null;
|
|
|
/**
|
|
|
* Invalidates a rectangle area on the gui texture
|
|
|
- * @param clearMinX left most position of the rectangle to clear in the texture
|
|
|
- * @param clearMinY top most position of the rectangle to clear in the texture
|
|
|
- * @param clearMaxX right most position of the rectangle to clear in the texture
|
|
|
- * @param clearMaxY bottom most position of the rectangle to clear in the texture
|
|
|
- * @param minX left most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
|
|
|
- * @param minY top most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
|
|
|
- * @param maxX right most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
|
|
|
- * @param maxY bottom most position of the rectangle to invalidate in absolute coordinates (not taking in account local transformation)
|
|
|
+ * @param invalidMinX left most position of the rectangle to invalidate in the texture
|
|
|
+ * @param invalidMinY top most position of the rectangle to invalidate in the texture
|
|
|
+ * @param invalidMaxX right most position of the rectangle to invalidate in the texture
|
|
|
+ * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
|
|
|
*/
|
|
|
- public invalidateRect(clearMinX: number, clearMinY: number, clearMaxX: number, clearMaxY: number, minX: number, minY: number, maxX: number, maxY: number) {
|
|
|
+ public invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number) {
|
|
|
if (!this._useInvalidateRectOptimization) {
|
|
|
return;
|
|
|
}
|
|
|
- if (!this._clearRectangle || !this._invalidatedRectangle) {
|
|
|
- this._clearRectangle = new Measure(clearMinX, clearMinY, clearMaxX - clearMinX + 1, clearMaxY - clearMinY + 1);
|
|
|
- this._invalidatedRectangle = new Measure(minX, minY, maxX - minX + 1, maxY - minY + 1);
|
|
|
+ if (!this._invalidatedRectangle) {
|
|
|
+ this._invalidatedRectangle = new Measure(invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
|
|
|
} else {
|
|
|
// Compute intersection
|
|
|
- var maxX = Math.ceil(Math.max(this._clearRectangle.left + this._clearRectangle.width - 1, clearMaxX));
|
|
|
- var maxY = Math.ceil(Math.max(this._clearRectangle.top + this._clearRectangle.height - 1, clearMaxY));
|
|
|
- this._clearRectangle.left = Math.floor(Math.min(this._clearRectangle.left, clearMinX));
|
|
|
- this._clearRectangle.top = Math.floor(Math.min(this._clearRectangle.top, clearMinY));
|
|
|
- this._clearRectangle.width = maxX - this._clearRectangle.left + 1;
|
|
|
- this._clearRectangle.height = maxY - this._clearRectangle.top + 1;
|
|
|
-
|
|
|
- maxX = Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, maxX);
|
|
|
- maxY = Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, maxY);
|
|
|
- this._invalidatedRectangle.left = Math.min(this._invalidatedRectangle.left, minX);
|
|
|
- this._invalidatedRectangle.top = Math.min(this._invalidatedRectangle.top, minY);
|
|
|
+ var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
|
|
|
+ var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
|
|
|
+ this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
|
|
|
+ this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
|
|
|
this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
|
|
|
this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
|
|
|
}
|
|
@@ -480,7 +468,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
this._rootContainer._markAllAsDirty();
|
|
|
}
|
|
|
}
|
|
|
- this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1, 0, 0, textureSize.width - 1, textureSize.height - 1);
|
|
|
+ this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
|
|
|
}
|
|
|
/** @hidden */
|
|
|
public _getGlobalViewport(scene: Scene): Viewport {
|
|
@@ -563,8 +551,8 @@ export class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
|
|
|
|
|
|
// Clear
|
|
|
- if (this._clearRectangle) {
|
|
|
- this._clearMeasure.copyFrom(this._clearRectangle);
|
|
|
+ if (this._invalidatedRectangle) {
|
|
|
+ this._clearMeasure.copyFrom(this._invalidatedRectangle);
|
|
|
} else {
|
|
|
this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
|
|
|
}
|
|
@@ -580,7 +568,6 @@ export class AdvancedDynamicTexture extends DynamicTexture {
|
|
|
this.onBeginRenderObservable.notifyObservers(this);
|
|
|
this._rootContainer._render(context, this._invalidatedRectangle);
|
|
|
this.onEndRenderObservable.notifyObservers(this);
|
|
|
- this._clearRectangle = null;
|
|
|
this._invalidatedRectangle = null;
|
|
|
}
|
|
|
/** @hidden */
|