[Sie-announce] SIEコード [2346] SVGPathElementのマトリックス処理に関して、大幅な軽量化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 1月 30日 (日) 23:22:40 JST


Revision: 2346
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2346
Author:   dhrname
Date:     2011-01-30 23:22:40 +0900 (Sun, 30 Jan 2011)

Log Message:
-----------
SVGPathElementのマトリックス処理に関して、大幅な軽量化

Modified Paths:
--------------
    branches/06x/069/org/w3c/dom/svg.js

Modified: branches/06x/069/org/w3c/dom/svg.js
===================================================================
--- branches/06x/069/org/w3c/dom/svg.js	2011-01-30 13:16:50 UTC (rev 2345)
+++ branches/06x/069/org/w3c/dom/svg.js	2011-01-30 14:22:40 UTC (rev 2346)
@@ -2650,42 +2650,32 @@
        *SVGのd属性をVMLに変換していく処理である。
        */
       var tar = evt.target, matrix = tar.getScreenCTM(), tlist = tar.normalizedPathSegList, _parseInt = parseInt;
-      var dat = [], ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f;
-      var isZ = tar._com._isZ, isM = tar._com._isM, isL = tar._com._isL, isC = tar._com._isC;
+      var t = "", ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f;
+      var cname = tar._com._nameCom, isZ = tar._com._isZ, isC = tar._com._isC;
       for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
         var ti = tlist.getItem(i), tps = ti.pathSegTypeAsLetter;
-        /*IE6の高速化のために、以下では、x += "";のような文字連結ではなくて、
-         *x[data.length] = "";という形をとった
-         */
-        if (isZ[tps]) {
-          dat[dat.length] = " x ";
-        } else {
-          if (isM[tps]) {
-            dat[dat.length] = "m";
-          } else if (isL[tps]) {
-            dat[dat.length] = "l";
-          } else if (isC[tps]) {
-            dat[dat.length] = "c";
-            /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
-             *[ma mc me]   [x]
-             *[mb md mf] * [y]
-             *[0  0  1 ]   [1]
-             */
-
-            dat[dat.length] = _parseInt(ma*ti.x1 + mc*ti.y1 + me, 10)+ " " +_parseInt(mb*ti.x1 + md*ti.y1 + mf, 10);
-            dat[dat.length] = _parseInt(ma*ti.x2 + mc*ti.y2 + me, 10)+ " " +_parseInt(mb*ti.x2 + md*ti.y2 + mf, 10);
-          }
-          dat[dat.length] = _parseInt(ma*ti.x + mc*ti.y + me, 10)+ " " +_parseInt(mb*ti.x + md*ti.y + mf, 10);
+        t += cname[tps];
+        if (isC[tps]) {
+          /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
+           *[ma mc me]   [x]
+           *[mb md mf] * [y]
+           *[0  0  1 ]   [1]
+           */
+          t += _parseInt(ma*ti.x1 + mc*ti.y1 + me, 10)+ " " +_parseInt(mb*ti.x1 + md*ti.y1 + mf, 10)+ " ";
+          t += _parseInt(ma*ti.x2 + mc*ti.y2 + me, 10)+ " " +_parseInt(mb*ti.x2 + md*ti.y2 + mf, 10)+ " ";
+          t += _parseInt(ma*ti.x + mc*ti.y + me, 10)+ " " +_parseInt(mb*ti.x + md*ti.y + mf, 10)+ " ";
+        } else if (!isZ[tps]) {
+          t += _parseInt(ma*ti.x + mc*ti.y + me, 10)+ " " +_parseInt(mb*ti.x + md*ti.y + mf, 10)+ " ";
         }
       }
       var vi = tar.ownerDocument.documentElement;
       var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
-      dat[dat.length] = " e";
-      tar._tar.path = dat.join(" ");
+      t += " e";
+      tar._tar.path = t;
       tar._tar.coordsize = w + " " + h;
       NAIBU._setPaint(tar, matrix);
       delete tar._cacheMatrix, tar._currentStyle;
-      evt = tar = dat = w = h = matrix = tlist = x = y = _parseInt = ma = mb = mc = md = me = mf = vi = isZ = isM = isL = isC = i = tli = tps = ti = null;
+      evt = tar = t = w = h = matrix = tlist = x = y = _parseInt = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = null;
     }, false);
     evt = tar = null;
   }, false);
@@ -2694,6 +2684,13 @@
 SVGPathElement.constructor = SVGElement;
 SVGPathElement.prototype = new SVGElement();
 SVGPathElement.prototype._com = {
+  _nameCom : {
+    z : " x ",
+    Z : " x ",
+    C : "c",
+    L : "l",
+    M : "m"
+  },
   _isZ : {
     z : 1,
     Z : 1




Sie-announce メーリングリストの案内
Back to archive index