チェンジセット 1525

差分発生行の前後
無視リスト:
コミット日時:
2008/10/06 03:04:28 (3 年前)
コミッタ:
gyuque
ログメッセージ:

optimized?

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • ruby/jsplash/trunk/client2/index.xml

    r1517 r1525  
    5454                <div id="progbar"><div>  </div></div> 
    5555                <p id="statusout"> </p> 
    56                 <p id="sout"><em>JSplash Player</em> 0.4.4<br />-------------------------------------<br /></p> 
     56                <p id="sout"><em>JSplash Player</em> 0.4.5<br />-------------------------------------<br /></p> 
    5757                <svg id="svgrt" xmlns="http://www.w3.org/2000/svg" style="width: 100px; height: 100px;"> 
    5858                </svg> 
  • ruby/jsplash/trunk/client2/jsplash/executor.js

    r1517 r1525  
    88                this.targets = {}; 
    99                this.reservedActions = null; 
     10                this.executed_stat = 0; 
    1011 
    1112                this.additionals = null; 
     
    7475         
    7576        tick: function() { 
     77                this.executed_stat = 0; 
    7678                var eid, tlist = this.targets; 
    7779                var mobj; 
     
    125127//                              JSplash.$putstat("view objects: " + topsvg.length + " / " + icounts.join(' ')); 
    126128 
    127                                 JSplash.$putstat("top level views: " + topsvg.length + "   total shapes: " + JSplash.gPlayer.disposer.stats); 
     129                                JSplash.$putstat("top level views: " + topsvg.length + "   total shapes: " + JSplash.gPlayer.disposer.stats + "  executed tags: "+this.executed_stat ); 
    128130 
    129131                } 
    130132//////////////////////////////////// debug 
    131133                 
    132                 t = Math.floor(1000 / this.frameRate); 
     134                t = Math.floor(950 / this.frameRate); 
    133135                 
    134136                 
     
    140142         
    141143        advanceFrame: function(mobj, jumps) { 
     144                if (mobj.sleeping) 
     145                        return; 
     146         
    142147                if (this.executed[mobj.instance_uid] && !jumps && mobj.context.tagC) 
    143148                        return; 
     
    146151                for(;jumps>=0;jumps--) { 
    147152                        while(1) { 
     153this.executed_stat++; 
    148154                                var res = mobj.executeNextTag(jumps != 0); 
    149155                                if (res == JSplash.EXECUTED_SHOWFRAME) break; 
    150156                        } 
    151157                } 
     158        }, 
     159         
     160        sleepAll: function() { 
     161                var eid, tlist = this.targets; 
     162                for (eid in tlist) 
     163                        tlist[eid].sleep(); 
    152164        }, 
    153165         
  • ruby/jsplash/trunk/client2/jsplash/objects.js

    r1520 r1525  
    6161         
    6262        getProxy: function() { 
     63                if (this.klass.isShapeObject) 
     64                        return null; 
     65         
    6366                if (!this.proxy) 
    6467                        this.proxy = new JSplash.MovieClipProxy(this); 
     
    128131         
    129132                        this.sleeping = false; 
    130                         this.play(); 
    131                         this.rewind(); 
     133                        if (!this.klass.isShapeObject) 
     134                        { 
     135                                this.play(); 
     136                                this.rewind(); 
     137                        } 
    132138                } 
    133139 
     
    180186        }, 
    181187         
    182         placeObject: function(depth, oid, iname, clip_depth, inherit_transform) { 
     188        placeObject: function(depth, oid, iname, clip_depth, replace_flg, inherit_transform) { 
    183189                if (clip_depth) 
    184190                        this.clipMap[depth] = clip_depth; 
     
    219225                        /* when replace previous frame */ 
    220226                        var g_before = null; 
    221                         if (inherit_transform && inst && replaced) { 
    222                                 inst.copyTransformFrom(replaced); 
     227                        if (replace_flg && inst && replaced) { 
     228                                if (inherit_transform) 
     229                                        inst.copyTransformFrom(replaced); 
    223230                                g_before = replaced.g; /* to correct draw order*/ 
    224231                        } 
     
    239246                        { 
    240247//try    { 
    241 try{ 
    242                                 this.g.insertBefore(inst.g, g_before); 
    243 }catch(e){return null;} 
     248 
     249                                if (this.taglist.length > JSplash.ObjectInstance.REMOVE_THRESH) 
     250                                { 
     251                                        this.g.replaceChild(inst.g, g_before); 
     252                                        replaced.appended = false; 
     253                                } 
     254                                else 
     255                                        this.g.insertBefore(inst.g, g_before); 
     256 
    244257//} catch (e) { 
    245258//this.trace(); 
     
    348361                        this.hideClippers(); 
    349362 
    350                 if (this.g && this.g.childNodes.length > 0
     363                if (this.g && this.g.childNodes.length > 0 && !this.klass.isShapeObject
    351364                        this.updateProxy(); 
    352365        }, 
     
    381394                        } 
    382395                } 
    383          
     396 
    384397                this.context.frameC = 0; 
    385398                this.context.tagC   = 0; 
     
    526539                 
    527540                this.updateTransform(); 
    528                 this.updateProxy(); 
     541                 
     542                if (!this.klass.isShapeObject) 
     543                        this.updateProxy(); 
    529544        }, 
    530545         
     
    538553                 
    539554                this.updateTransform(); 
    540                 this.updateProxy(); 
     555                 
     556                if (!this.klass.isShapeObject) 
     557                        this.updateProxy(); 
    541558        },       
    542559         
     
    633650        s.label_map = label_map; 
    634651        s.mouse_down = false; 
     652        s.is_stage = true; 
    635653         
    636654        Object.extend(s, { 
  • ruby/jsplash/trunk/client2/jsplash/player.js

    r1517 r1525  
    5151        onTopMouseDown: function(e) { 
    5252                if (Event.isLeftClick(e)) 
     53                { 
    5354                        this.stage.setMouseDown(); 
     55                        e.preventDefault(); 
     56                } 
    5457        }, 
    5558 
  • ruby/jsplash/trunk/client2/jsplash/shaperenderer.js

    r1494 r1525  
    1414                this.te_id = 0; 
    1515                this.fillDefMap = {}; 
     16                this.hitCount  = 0; 
     17                this.pathCache = null; 
     18                this.do_cache = false; 
    1619        }, 
    1720         
     
    5356                { 
    5457                        attrs.r  = 819; 
     58                        attrs.fx = 0; 
     59                        attrs.fy = 0; 
    5560                } 
    5661                 
     
    279284                return a.index - b.index; 
    280285        }, 
    281          
     286        /* 
    282287        buildFills: function(g) { 
    283288                var loopss = this.fillLoops; 
     
    289294                        this.buildAFill(loopss[i].loops, this.fillStyles[loopss[i].fill_index-1], g); 
    290295                } 
    291                 /* 
    292                  
    293                 var elist   = this.edgeList; 
    294                 var next_fi = null; 
    295                 var edge_start = 0; 
    296                 var edge_end   = elist.length; 
    297                  
    298                 if (this.layerStartIndices.length) 
    299                 { 
    300                         next_fi = this.layerStartIndices[0].fi; 
    301                         edge_end   = this.layerStartIndices[0].ei; 
    302                         this.layerStartIndices.shift(); 
    303                 } 
    304                  
    305          
    306                 for (var i = 0;i < len;i++) { 
    307                         if (next_fi && loopss[i].fill_index >= next_fi) { 
    308                                 this.buildEdges(g, edge_start, edge_end); 
    309                          
    310                                 edge_start = edge_end; 
    311                                 if (this.layerStartIndices.length) { 
    312                                         next_fi    = this.layerStartIndices[0].fi; 
    313                                         edge_end   = this.layerStartIndices[0].ei; 
    314                                         this.layerStartIndices.shift(); 
    315                                 } 
    316                                 else { 
    317                                         next_fi  = null; 
    318                                         edge_end = elist.length; 
    319                                 } 
    320  
    321                         } 
    322                  
    323                         this.buildAFill(loopss[i].loops, this.fillStyles[loopss[i].fill_index-1], g); 
    324                 } 
    325                  
    326                 this.buildEdges(g, edge_start, edge_end);*/ 
    327         }, 
     296        }, 
     297*/ 
    328298 
    329299        buildAFill: function(list, fi, g) { 
     
    339309                if (!style_str) return; 
    340310 
    341                  
    342311                var len = list.length; 
    343312                var commands = [], lp, k, llen, E; 
     
    371340                        attrs.opacity = style.a; 
    372341                } 
    373                 g.appendChild( JSplash.$svg('path', attrs) ); 
    374         }, 
    375  
     342 
     343                var elem = JSplash.$svg('path', attrs); 
     344                if (this.do_cache) 
     345                        this.pathCache.stock(elem); 
     346                g.appendChild( elem ); 
     347        }, 
     348/* 
    376349        buildALoop: function(lp, style, g) { 
    377350                if (!style) return; 
     
    402375                g.appendChild( JSplash.$svg('path', {d: commands.join(' '), fill: style_str}) ); 
    403376        }, 
    404          
     377        */ 
    405378        buildEdges: function(g, edge_start, edge_end) { 
    406                 var E
     379                var E, elem
    407380                var edges = this.edgeList; 
    408381                var len = edges.length; 
     
    432405                                                attrs = {d: commands.join(' '), fill: 'none', stroke: curStyle, 'stroke-width': curWidth}; 
    433406                                                if (curAlpha != undefined) attrs['stroke-opacity'] = curAlpha; 
     407 
     408                                                elem = JSplash.$svg('path', attrs); 
     409                                                if (this.do_cache) 
     410                                                        this.pathCache.stock(elem); 
    434411                                         
    435                                                 paths.push(JSplash.$svg('path', attrs)); 
     412                                                paths.push(elem); 
    436413                                        } 
    437414                                } 
     
    469446                        if (curAlpha != undefined) attrs['stroke-opacity'] = curAlpha; 
    470447 
    471                         paths.push(JSplash.$svg('path', attrs)); 
     448                        elem = JSplash.$svg('path', attrs); 
     449                        if (this.do_cache) 
     450                                this.pathCache.stock(elem); 
     451 
     452                        paths.push(elem); 
    472453                } 
    473454                for (;paths.length;) 
     
    476457         
    477458        buildSVG: function(g) { 
    478                 this.buildDrawOrder(); 
    479                 this.renderDisplayList(g); 
     459                if (this.hitCount == 2) { 
     460                        this.pathCache = new JSplash.ShapeRenderer.PathCache(); 
     461                        this.do_cache = true; 
     462                } 
     463 
     464                if (this.pathCache && !this.do_cache) 
     465                        this.pathCache.tearOff(g); 
     466                else { 
     467                        this.buildDrawOrder(); 
     468                        this.renderDisplayList(g); 
     469                } 
     470                 
     471                this.do_cache = false; 
     472                this.hitCount++; 
    480473                return g; 
    481474        }, 
     
    509502                        var lps = this.makeLoop(collected_edges, fi); 
    510503                        if (lps.length > 0) { 
    511                                 this.fillLoops.push({fill_index: fi, loops: lps}); 
     504                                this.fillLoops.push({fill_index: fi, loops: lps /* cache: undefined */ }); 
    512505                        } 
    513506                } 
     
    704697        } 
    705698} 
     699 
     700JSplash.ShapeRenderer.PathCache = Class.create(); 
     701JSplash.ShapeRenderer.PathCache.prototype = { 
     702        initialize: function() { 
     703                this.stocks = []; 
     704        }, 
     705 
     706        stock: function(elem) { 
     707                this.stocks.push(elem /* not clone! don't modify... */ ); 
     708        }, 
     709         
     710        tearOff: function(target) { 
     711                var len = this.stocks.length; 
     712                for (var i = 0;i < len;i++) 
     713                        target.appendChild( this.stocks[i].cloneNode(false) ); 
     714        } 
     715} 
  • ruby/jsplash/trunk/client2/jsplash/tags.js

    r1494 r1525  
    1111 
    1212                tPlaceObject2: function(data, owner) { 
    13                         var inst = owner.placeObject(data.d, data.id, data.name, data.cl, data.r); 
     13                        var has_trans = (data.mov || data.scl || data.skw); 
     14                 
     15                        var inst = owner.placeObject(data.d, data.id, data.name, data.cl, data.r, (data.r && !has_trans)); 
    1416                        if (!inst) { 
    1517                                console.warn("WARNING: unregistered object id="+data.d); 
    1618                                return; 
    1719                        } 
    18                         if (data.mov || data.scl || data.skw) { 
     20                        if (has_trans) { 
    1921                                var tx = 0, ty = 0; 
    2022                                var sx = 1, sy = 1;