对于来自两个画布对象的硬件加速,我的PhoneGap应用程序有一个问题。
我需要两个画布对象来比较两个不同的图像。在我的桌面/手持设备(浏览器)上,一切都很好,而且比较有效。
但是当我运行编译好的Android文件时,我会有一种奇怪的行为。当我选择第一个图像时,这将加载在我的第一个画布中,然后当我选择第二个画布时,我的第一个将被覆盖在两个画布中,并且只使用画布中的第二个上下文。
我发现这个线程硬件接入是市长的问题。
我还使用画布EaselJS,并在Android设备上测试以下代码
<!DOCTYPE html>
<html>
<head>
<script src="http://code.createjs.com/easeljs-0.7.0.min.js"></script>
<script>
function init() {
var stage = new createjs.Stage("canvas1");
var stage2 = new createjs.Stage("canvas2");
var circle = new createjs.Shape();
circle.graphics.beginFill("red").drawCircle(0, 0, 50);
circle.x = 100;
circle.y = 100;
stage.addChild(circle);
stage.update();
var circle2 = new createjs.Shape();
circle2.graphics.beginFill("blue").drawCircle(0, 0, 50);
circle2.x = 100;
circle2.y = 100;
stage2.addChild(circle);
stage2.update();
}
</script>
</head>
<body onLoad="init();">
<canvas id="canvas1" width="500" height="300">
alternate content
</canvas>
<canvas id="canvas2" width="500" height="300">
alternate content
</canvas>
</body>
</html>当硬件加速被激活时,我遇到了同样的问题,我得到了两个蓝色的圆圈,一个是红色的,另一个是蓝色的。
我有任何一种方法来激活硬件Accelartion和画布绘制,或者是PhoneGap或PhoneGap的问题?
发布于 2014-03-14 18:36:02
是的,你可以激活硬件加速。检查这个链接- 在android中控制硬件访问
https://stackoverflow.com/questions/22382401
复制相似问题