javascript - CreateJS filter performance -


i have been developing game using createjs , noticed significant performance drop when filter applied image. created small test case showcase problem:

var isinitialized = false;  function start(preload) {      egg = preload.getresult("kiausinis");      center = new vector(stage.canvas.width/2,stage.canvas.height/2);      eggimg = new createjs.bitmap(egg);     stage.addchild(eggimg);     eggimg.x = center.x-300;     eggimg.y = center.y;     centerorigin(eggimg);     eggimg.on("click",applyfilters);      eggimg2 = new createjs.bitmap(egg);     stage.addchild(eggimg2);     eggimg2.x = center.x;     eggimg2.y = center.y;     centerorigin(eggimg2);      eggimg3 = new createjs.bitmap(egg);     stage.addchild(eggimg3);     eggimg3.x = center.x+300;     eggimg3.y = center.y;     centerorigin(eggimg3);      fpslabel = new createjs.text("fps:","150px verdana","black");     fpslabel.linewidth = 200;     fpslabel.textalign = "center";     fpslabel.x = center.x;     fpslabel.y = center.y;     stage.addchild(fpslabel);      isinitialized = true;  }  function update(){      if(!isinitialized) return;      fpslabel.text= "fps: " + math.round(createjs.ticker.getmeasuredfps(3));     stage.update();  }  function centerorigin(img){      img.regx = img.getbounds().width/2;     img.regy = img.getbounds().height/2;  }  function applyfilters(){      changeimgcolor(eggimg,1,0.8,0.7,1);     changeimgcolor(eggimg2,1,0.8,0.7,1);     changeimgcolor(eggimg3,1,0.8,0.7,1);  }  function changeimgcolor(img, r, g, b, a){      img.filters = [          new createjs.colorfilter(r, g, b, a)      ];      img.cache(0,0,img.getbounds().width,img.getbounds().height);     img.updatecache();  } 

code shows primitive set up. add 3 images stage , when 1 of them clicked apply color filter of them. before applying filter arround 200fps on desktop , mobile. after filter applied instantly drops around 5fps on mobile. though framerate drops 5fps counter still shows 200fps (you can tell framerate dropped because fps counter refreshes now).

a live demo can seen here: http://spaceout.bugs3.com/performancetest/

what happening here? doing wrong? has else encountered similar problems?

thank you.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -