Explorar el Código

Move numLayoutCalls and numRenderCalls to ADT

Popov72 hace 5 años
padre
commit
4f1afdaa78

+ 17 - 2
gui/src/2D/advancedDynamicTexture.ts

@@ -82,6 +82,21 @@ export class AdvancedDynamicTexture extends DynamicTexture {
     private _renderScale = 1;
     private _renderScale = 1;
     private _rootElement: Nullable<HTMLElement>;
     private _rootElement: Nullable<HTMLElement>;
     private _cursorChanged = false;
     private _cursorChanged = false;
+
+    /** @hidden */
+    public _numLayoutCalls = 0;
+    /** Gets the number of layout calls made the last time the ADT has been rendered */
+    public get numLayoutCalls(): number {
+        return this._numLayoutCalls;
+    }
+
+    /** @hidden */
+    public _numRenderCalls = 0;
+    /** Gets the number of render calls made the last time the ADT has been rendered */
+    public get numRenderCalls(): number {
+        return this._numRenderCalls;
+    }
+
     /**
     /**
     * Define type to string to ensure compatibility across browsers
     * Define type to string to ensure compatibility across browsers
     * Safari doesn't support DataTransfer constructor
     * Safari doesn't support DataTransfer constructor
@@ -550,7 +565,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
         // Layout
         // Layout
         this.onBeginLayoutObservable.notifyObservers(this);
         this.onBeginLayoutObservable.notifyObservers(this);
         var measure = new Measure(0, 0, renderWidth, renderHeight);
         var measure = new Measure(0, 0, renderWidth, renderHeight);
-        Control.NumLayoutCalls = 0;
+        this._numLayoutCalls = 0;
         this._rootContainer._layout(measure, context);
         this._rootContainer._layout(measure, context);
         this.onEndLayoutObservable.notifyObservers(this);
         this.onEndLayoutObservable.notifyObservers(this);
         this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
         this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
@@ -571,7 +586,7 @@ export class AdvancedDynamicTexture extends DynamicTexture {
 
 
         // Render
         // Render
         this.onBeginRenderObservable.notifyObservers(this);
         this.onBeginRenderObservable.notifyObservers(this);
-        Control.NumRenderCalls = 0;
+        this._numRenderCalls = 0;
         this._rootContainer._render(context, this._invalidatedRectangle);
         this._rootContainer._render(context, this._invalidatedRectangle);
         this.onEndRenderObservable.notifyObservers(this);
         this.onEndRenderObservable.notifyObservers(this);
         this._invalidatedRectangle = null;
         this._invalidatedRectangle = null;

+ 1 - 1
gui/src/2D/controls/container.ts

@@ -304,7 +304,7 @@ export class Container extends Control {
             return false;
             return false;
         }
         }
 
 
-        Control.NumLayoutCalls++;
+        this.host._numLayoutCalls++;
 
 
         if (this._isDirty) {
         if (this._isDirty) {
             this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
             this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);

+ 2 - 7
gui/src/2D/controls/control.ts

@@ -25,11 +25,6 @@ export class Control {
      */
      */
     public static AllowAlphaInheritance = false;
     public static AllowAlphaInheritance = false;
 
 
-    /** Gets the number of layout calls made the last time the ADT has been rendered */
-    public static NumLayoutCalls = 0;
-    /** Gets the number of render calls made the last time the ADT has been rendered */
-    public static NumRenderCalls = 0;
-
     private _alpha = 1;
     private _alpha = 1;
     private _alphaSet = false;
     private _alphaSet = false;
     private _zIndex = 0;
     private _zIndex = 0;
@@ -1364,7 +1359,7 @@ export class Control {
         }
         }
 
 
         if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
         if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
-            Control.NumLayoutCalls++;
+            this.host._numLayoutCalls++;
 
 
             this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
             this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
 
 
@@ -1607,7 +1602,7 @@ export class Control {
             return false;
             return false;
         }
         }
 
 
-        Control.NumRenderCalls++;
+        this.host._numRenderCalls++;
 
 
         context.save();
         context.save();
 
 

+ 1 - 1
gui/src/2D/controls/scrollViewers/scrollViewerWindow.ts

@@ -36,7 +36,7 @@ export class _ScrollViewerWindow extends Container {
 
 
         var measure = new Measure(0, 0, renderWidth, renderHeight);
         var measure = new Measure(0, 0, renderWidth, renderHeight);
 
 
-        Control.NumLayoutCalls = 0;
+        this.host._numLayoutCalls = 0;
 
 
         this.host._rootContainer._layout(measure, context);
         this.host._rootContainer._layout(measure, context);