与硬件加速Android的预期部分无效不工作 [英] Android partial invalidation doesn't work as expected with hardware acceleration
问题描述
我知道这是很为<一个同样的问题href=\"http://stackoverflow.com/questions/7233830/partial-invalidation-in-custom-android-view-with-hardware-acceleration\">partial-invalidation-in-custom-android-view-with-hardware-acceleration但我想我会解释我的问题更多的相关详细,希望有人会就如何解决该问题的答案。
I know this is quite the same question as partial-invalidation-in-custom-android-view-with-hardware-acceleration but I thought I will explain my problem more detailled and hope someone will have an answer on how to solve the problem.
我写了一个简单的井字应用程序,它是在模拟器上正常工作。但不工作的设备上,因为我发现它是工作的设备上进行预期时,我禁用硬件加速。
I wrote a simple TicTacToe app which was working fine on the emulator. But wasn't working on the device since I found out it was working as expected on the device when I disabled hardware acceleration.
所有的字段都绘制 Canvas.drawBitmap()
,也有一个空的白色图像空领域。该线绘制 Canvas.drawLine()
我使用的部分无效与无效(矩形)
,因为我要重绘只有那些被选择去重新设置使用交叉/与根据成像圈面积 Canvas.drawBitmap()
。但随后整个区域无效,意味着我看到整个区域/屏幕是灰色(白色图像和线条消失了),只有图像为十字/圆设置在已选定的区域。
All the fields are drawn with Canvas.drawBitmap()
, also the "empty" fields with an empty white image. The lines are drawn with Canvas.drawLine()
I'm using partial invalidation with invalidate(Rect)
because I want to redraw only the area which was choosen to set a cross/circle with the according image using again Canvas.drawBitmap()
. But then the whole area is invalidated, means I see the whole area/screen is gray (the white images and lines disappeared) and only the image for the cross/circle is set in the choosen area.
当我打印出来与 Canvas.getClipBounds失效的领域矩形()
中的方法的onDraw()
,硬件加速它是整个区域(如0,0,320,407),并没有硬件加速我与无效(矩形)失效相同RECT
(如106135106135)
When I print out the invalidated field rect with Canvas.getClipBounds()
in the method onDraw()
, with hardware acceleration it is the whole area (example "0,0,320,407") and without hardware acceleration the same rect which I invalidated with invalidate(Rect)
(e.g. "106,135,106,135").
目前的解决办法我重绘蒙山的根据图像和线条的所有字段。我怎样才能prevent已经与硬件加速失效整个区域?
At the moment as workaround I redraw all the fields whith the according image and lines. How can I prevent to have the whole area invalidated with hardware acceleration?
如果该事项:我使用的是Android版本4.1.2三星Galaxy年轻二重奏S6312
If this matters: I'm using Android version 4.1.2 on Samsung Galaxy Young Duos S6312.
问候
桑德罗
推荐答案
我张贴我的答案在你给出的link.要理解这个问题,你应该知道的软件渲染和硬件渲染之间的差异。这真是我不会在这里介绍一个很大的话题。我认为最好的办法是阅读源$ C $ C (我做了同样的事几几天前)。关键的问题是什么是 DisplayList中
键,当它被用来
。在这里重复我的答案,在画布
在的onDraw
只是用于重建DisplayList中。这并不意味着一切都在您的视图将被重新绘制。
I have post my answer in your given link. To understand the problem , you should know the difference between software rendering and hardware rendering. That's really a big topic which I won't cover here. I think the best approach is to read the source code(I did the same thing a few days ago). The key question is "what is DisplayList
and when it is used"
. Repeat my answer here, the Canvas
in onDraw
is simply used to rebuild the DisplayList. That doesn't mean everything in your View will be redrawn.
这篇关于与硬件加速Android的预期部分无效不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!