调用canvas.drawBitmap时系统会发生什么?
我有一个可滚动和可缩放的地图,它具有地图的低分辨率副本,该副本在缩放比例较小时绘制,并且在用户放大超过某个点时绘制平铺系统。我遇到的问题是,第一次绘制图块时会出现短暂但明显的滞后。在最初的滞后之后,一切都很顺利。 GC 未运行,所有位图均在启动时加载。知道到底发生了什么以便我可以解决延迟问题吗?或者有什么办法可以解决吗?谢谢。下面是代码:
canvas.drawBitmap(map, null, bgRect,paint);
if(matrix[0]>.9){
mapPicture = makeMyMap(xScale,yScale); //make/update our map.
mapPicture.draw(canvas);
}
I have a scrollable and zoomable map which has a low res copy of the map which is drawn when the zoom scale is small and a tile system when the user zooms in past a certain point. The problem im having is that the very first time the tiles are drawn there is a short, but noticable lag. After that initial lag everything is smooth. The GC isnt running, and all the bitmaps are loaded at launch time. Any idea what exactly is going on so i can take care of the lag? Or any way for a work around? Thanks. Heres the code below:
canvas.drawBitmap(map, null, bgRect,paint);
if(matrix[0]>.9){
mapPicture = makeMyMap(xScale,yScale); //make/update our map.
mapPicture.draw(canvas);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 DDMS 打开跟踪,以确定哪些方法在第一次绘制时需要很长时间,并查看它们与后续绘制的比较情况。
drawBitmap 有可能在第一次绘制而不是加载时触发平台级别的图像放大/缩小 - 但这是我的猜测。
Try switching on tracing with DDMS to establish which methods take a long time on the first draw and see how they compare with the subsequent draws.
It's possible that drawBitmap is triggering the platform level up-scale / down-scale of the images on first draw rather than load - but that's speculation on my part.