royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [royale-asjs] branch develop updated: Avoid measuring if not necessary
Date Tue, 10 Apr 2018 18:50:03 GMT
This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new ab65ff9  Avoid measuring if not necessary
ab65ff9 is described below

commit ab65ff9715ab710e156b53e9895032cd5e174f2b
Author: Harbs <harbs@in-tools.com>
AuthorDate: Tue Apr 10 21:49:53 2018 +0300

    Avoid measuring if not necessary
    
    Makes layout about twice as fast
---
 .../apache/royale/html/beads/layouts/TileLayout.as | 31 +++++++++++++---------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
index 0c36f38..ed3cd8c 100644
--- a/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
+++ b/frameworks/projects/Basic/src/main/royale/org/apache/royale/html/beads/layouts/TileLayout.as
@@ -127,11 +127,11 @@ package org.apache.royale.html.beads.layouts
          */
 		override public function layout():Boolean
 		{
-			var paddingMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getPaddingMetrics(host);
-			var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
+			// var paddingMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getPaddingMetrics(host);
 			
 			COMPILE::SWF
 			{
+				var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
 				var area:UIBase = layoutView as UIBase;
 
 				var xpos:Number = 0;
@@ -202,8 +202,6 @@ package org.apache.royale.html.beads.layouts
 				var ypos:Number;
 				var useWidth:Number;
 				var useHeight:Number;
-				var adjustedWidth:Number = Math.floor(host.width - borderMetrics.left - borderMetrics.right);
-				var adjustedHeight:Number = Math.floor(host.height - borderMetrics.top - borderMetrics.bottom);
 
 				var contentView:IParentIUIBase = layoutView as IParentIUIBase;
 				
@@ -225,15 +223,22 @@ package org.apache.royale.html.beads.layouts
 				ypos = 0;
 				useWidth = columnWidth;
 				useHeight = rowHeight;
-
-				if (isNaN(useWidth)) {
-					useWidth = Math.floor(adjustedWidth / numColumns); // + gap
-				}
-				if (isNaN(useHeight)) {
-					// given the width and total number of items, how many rows?
-					var numRows:Number = Math.ceil(realN / numColumns);
-					if (host.isHeightSizedToContent()) useHeight = 30; // default height
-					else useHeight = Math.floor(adjustedHeight / numRows);
+				var needWidth:Boolean = isNaN(useWidth);
+				var needHeight:Boolean = isNaN(useHeight);
+				if(needHeight || needWidth){
+					var borderMetrics:EdgeData = (ValuesManager.valuesImpl as IBorderPaddingMarginValuesImpl).getBorderMetrics(host);
+					var adjustedWidth:Number = Math.floor(host.width - borderMetrics.left - borderMetrics.right);
+					var adjustedHeight:Number = Math.floor(host.height - borderMetrics.top - borderMetrics.bottom);
+					if (needWidth)
+						useWidth = Math.floor(adjustedWidth / numColumns); // + gap
+					
+					if (needHeight)
+					{
+						// given the width and total number of items, how many rows?
+						var numRows:Number = Math.ceil(realN / numColumns);
+						if (host.isHeightSizedToContent()) useHeight = 30; // default height
+						else useHeight = Math.floor(adjustedHeight / numRows);
+					}
 				}
 
 				for (i = 0; i < n; i++)

-- 
To stop receiving notification emails like this one, please contact
harbs@apache.org.

Mime
View raw message