【发布时间】:2013-07-23 07:39:17
【问题描述】:
我正在使用 GWT 画布用 requestAnimationFrame 全屏绘制 50 个相同的 16x16 图像(在 draw() 中),主循环如下:
AnimationScheduler.get().requestAnimationFrame(new AnimationCallback() {
public void execute(double timestamp) {
mainLoop(deltaTimeInMs);
AnimationScheduler.get().requestAnimationFrame(this,canvasElem);
}
}, canvasElem);
void mainLoop(double deltaTime) {
calcFPS(deltaTime);
clearContext();
update(deltaTime);
draw();
}
我使用ClientBundle 将图像存储为DataResources。它们被转换为图像和ImageElement 以便能够调用 context.draw。
渲染 50 张图像之前的 FPS 约为 60FPS。当它们被渲染时,FPS 大约是 20FPS。 (在 chrome 和 mozilla 中)在 DEV 模式下。
我认为图像加载可能有问题。
【问题讨论】:
-
运行如此缓慢的原因是 DEV 模式。在 GWT 2.5+ 版本中,它在 SDM(超级开发模式)上运行良好。
标签: gwt canvas image-loading requestanimationframe