部分无效在定制的Andr​​oid硬件加速浏览部分、硬件加速、Andr、oid

2023-09-12 06:22:24 作者:挺like的

我有我的应用程序自定义视图,填补了整个活动。

I've got a custom View in my application which fills the entire activity.

在大多数情况下,当我想刷新我所说的控制无效()不带任何参数。

In most cases, when I want to refresh the control I call invalidate() without any parameters.

然而,在某些情况下,如果我只是改变控制的一小块区域,我称之为无效(矩形),以避免重绘整个屏幕。这是重要的,因为在这些情况下,我 需要更新以尽可能快。

However, in certain circumstances, where I'm only changing a small area of the control, I call invalidate(Rect) to avoid redrawing the entire screen. This is important because in these situations I need the update to be as fast as possible.

这似乎做工精细,但是,当我启用硬件加速的蜂窝(即设置安卓hardwareAccelerated =真正的在AndroidManifest.xml中),部分重绘似乎并没有工作。

This seems to work fine, however, when I enable hardware acceleration in Honeycomb (i.e. set android:hardwareAccelerated="true"in AndroidManifest.xml), the partial redraw does not seem to work.

如果我这样做 Log.d(富,canvas.getClipBounds())在我的的OnDraw()方法;输出只显示了整个控制正在更新,而使用硬件加速禁用,我得到了正确的区域被输出。

This can be seen if I do Log.d("FOO", canvas.getClipBounds()) in my onDraw() method; the output simply shows that the whole control is being updated, whereas with hardware acceleration disabled, I get the correct region being output.

有没有办法使用硬件acceleraton时,使部分无效的工作?

Is there any way to make partial invalidation work when using hardware acceleraton?

非常感谢,马特

推荐答案

部分重绘工作得很好,屏幕只有指定区域将得到重​​新绘制。什么也不会然而,做的是改变画布上的片段边界。所有的绘图操作将被记录下来,但只有那些与脏区相交实际上将被执行。

Partial redraw works just fine, only the specified region of the screen will get redrawn. What it won't do however is change the clip bounds on the Canvas. All the drawing operations will be recorded but only the ones intersecting with the dirty region will actually be executed.