首页 > 代码库 > Hardware Acceleration

Hardware Acceleration

硬件加速学习:

参考:http://blog.csdn.net/thinkinwm/article/details/8854649

硬件加速的级别:

Application:

可以打开和关闭硬件加速

<application android:hardwareAccelerated="true" ...>

Activity:

可以打开和关闭硬件加速

<application android:hardwareAccelerated="true">    <activity ... />    <activity android:hardwareAccelerated="false" /></application>

Window:

只能打开,不能关闭

1 getWindow().setFlags(2     WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,3     WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

View:

只能关闭,不能打开

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

判断是否打开了硬件加速:

  • View.isHardwareAccelerated() returns true if the View is attached to a hardware accelerated window.
  • Canvas.isHardwareAccelerated() returns true if the Canvas is hardware accelerated

If you must do this check in your drawing code, use Canvas.isHardwareAccelerated() instead ofView.isHardwareAccelerated() when possible. When a view is attached to a hardware accelerated window, it can still be drawn using a non-hardware accelerated Canvas. This happens, for instance, when drawing a view into a bitmap for caching purposes.

Hardware Acceleration