瀏覽代碼

Canvas2D: minor fix

Get rid of the markAsDirty method which is not needed
nockawa 9 年之前
父節點
當前提交
413ecac4c4
共有 2 個文件被更改,包括 10 次插入18 次删除
  1. 7 7
      src/Canvas2d/babylon.prim2dBase.ts
  2. 3 11
      src/Canvas2d/babylon.smartPropertyPrim.ts

+ 7 - 7
src/Canvas2d/babylon.prim2dBase.ts

@@ -1725,7 +1725,7 @@
                 return;
             }
             this._position = value;
-            this.markAsDirty("actualPosition");
+            this._triggerPropertyChanged(Prim2DBase.actualPositionProperty, value);
         }
 
         /**
@@ -1752,8 +1752,8 @@
             }
 
             this._position.x = value;
-            this.markAsDirty("position");
-            this.markAsDirty("actualPosition");
+            this._triggerPropertyChanged(Prim2DBase.positionProperty, value);
+            this._triggerPropertyChanged(Prim2DBase.actualPositionProperty, value);
         }
 
         /**
@@ -1780,8 +1780,8 @@
             }
 
             this._position.y = value;
-            this.markAsDirty("position");
-            this.markAsDirty("actualPosition");
+            this._triggerPropertyChanged(Prim2DBase.positionProperty, value);
+            this._triggerPropertyChanged(Prim2DBase.actualPositionProperty, value);
         }
 
         private static boundinbBoxReentrency = false;
@@ -1842,7 +1842,7 @@
             }
 
             this.size.width = value;
-            this.markAsDirty("size");
+            this._triggerPropertyChanged(Prim2DBase.sizeProperty, value);
             this._positioningDirty();
         }
 
@@ -1868,7 +1868,7 @@
             }
 
             this.size.height = value;
-            this.markAsDirty("size");
+            this._triggerPropertyChanged(Prim2DBase.sizeProperty, value);
             this._positioningDirty();
         }
 

+ 3 - 11
src/Canvas2d/babylon.smartPropertyPrim.ts

@@ -316,25 +316,16 @@
             return false;
         }
 
-        private static propChangedInfo = new PropertyChangedInfo();
-
-        public markAsDirty(propertyName: string) {
+        protected _triggerPropertyChanged(propInfo: Prim2DPropInfo, newValue: any) {
             if (this.isDisposed) {
                 return;
             }
 
-            let i = propertyName.indexOf(".");
-            if (i !== -1) {
-                propertyName = propertyName.substr(0, i);
-            }
-
-            var propInfo = this.propDic.get(propertyName);
             if (!propInfo) {
                 return;
             }
 
-            var newValue = this[propertyName];
-            this._handlePropChanged(undefined, newValue, propertyName, propInfo, propInfo.typeLevelCompare);
+            this._handlePropChanged(undefined, newValue, propInfo.name, propInfo, propInfo.typeLevelCompare);
         }
 
         protected _boundingBoxDirty() {
@@ -361,6 +352,7 @@
             }
         }
 
+        private static propChangedInfo = new PropertyChangedInfo();
         private _handlePropChanged<T>(curValue: T, newValue: T, propName: string, propInfo: Prim2DPropInfo, typeLevelCompare: boolean) {
             // If the property change also dirty the boundingInfo, update the boundingInfo dirty flags
             if (propInfo.dirtyBoundingInfo) {