--- vistaFace.js.orig 2007-09-05 12:11:28 +0900 +++ vistaFace.js 2008-03-27 12:00:00 +0900 @@ -18,7 +18,16 @@ this.isPowerLineStatusChanged = false; this.isWirelessStatusChanged = false; - + + // cache settings + this._cache = { + faceChanged : true, + cpuUsageIndex : -1, + memUsageIndex : -1, + marker1 : -1, + marker2 : -1 + }; + // default settings this.settings = { timerInterval : 1000 @@ -167,6 +176,7 @@ , loadFaceDef : function (name) { this.debugPrint("loadFaceDef: "+name); this.faceDefDir = name; + this._cache.faceChanged = true; return this.loadFaceDefPlist(name); } @@ -191,18 +201,34 @@ } , switchPattern : function (cpuUsageIndex, memUsageIndex, marker1, marker2) { + // compare cache + if (this._cache.cpuUsageIndex == cpuUsageIndex && + this._cache.memUsageIndex == memUsageIndex && + this._cache.marker1 == marker1 && + this._cache.marker2 == marker2) + { + return; + } + + // save cache + this._cache.cpuUsageIndex = cpuUsageIndex; + this._cache.memUsageIndex = memUsageIndex; + this._cache.marker1 = marker1; + this._cache.marker2 = marker2; + this.partsBackground.removeObjects(); - + for (var i = 0, n = this.currentFace.pattern[memUsageIndex][cpuUsageIndex].length; i < n; i++) { var partNum = this.currentFace.pattern[memUsageIndex][cpuUsageIndex][i]; var part = this.currentFace.parts[partNum]; - if (i == 0) { + if (i != 0) { + this.addPart(part); + } else if (this._cache.faceChanged) { + this._cache.faceChanged = false; this.partsBackground.src = this.faceDefDir + "\\" + part.filename; this.partsBackground.style.position = "absolute"; this.partsBackground.style.top = part['pos y']+"px"; this.partsBackground.style.left = part['pos x']+"px"; - } else { - this.addPart(part); } } if (marker1) { @@ -321,6 +347,7 @@ var cpuUsage = this.faceCPUIndexUsageProc(); var memUsage = this.faceMemIndexUsageProc(); + if (DEBUG) { // heavy load this.debugPrint((this.isPowerLineStatusChanged ? "!1," : "") + (this.isSignalStrengthChanged ? "!2," : "") + (System.Machine.PowerStatus.isPowerLineConnected ? "AC," : "") + @@ -333,7 +360,7 @@ ",S[C]:" + this.settings.cpuUsage + ",S[M]:" + this.settings.memUsage + ""); - + } this.switchPattern( this.getFaceCPUIndexByUsage(cpuUsage) // cpu ,this.getFaceMemIndexByUsage(memUsage) // mem