部分无效在定制的Andr​​oid硬件加速浏览 [英] Partial invalidation in custom Android view with hardware acceleration

查看:86
本文介绍了部分无效在定制的Andr​​oid硬件加速浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

这篇关于部分无效在定制的Andr​​oid硬件加速浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆