问题描述
我听说在Android 3.0中添加了Skia GPU acc,但是自从Android 4.0以来,它似乎是默认禁用的,这可能是因为转向了HWUI(Canvas的openGL实现).我如何才能仅出于基准测试目的而再次启用它.
I heard Skia GPU acc was added in Android 3.0 but seems it was default disabled since Android 4.0 probably because of the shift to HWUI (openGL implementation of Canvas). How could I enable that again just for benchmark purpose.
推荐答案
我不知道Skia的任何其他硬件加速方法.尽管对于HWUI,开发人员文档在此处概述了这一点: http://developer.android.com/guide/topics/graphics/hardware -accel.html
I am unaware of any other method of hardware acceleration of Skia. Though for HWUI the developers documentation outlines this here:http://developer.android.com/guide/topics/graphics/hardware-accel.html
很抱歉,如果您已经知道HWUI的实现.
Apologies if you are already aware of the implementation of HWUI.
应用程序级别,活动级别,窗口级别和视图级别.
Application level, Activity level, Window level and View level.
在清单中向应用程序添加以下属性:
In your manifest add the following attribute to your application:
<application android:hardwareAccelerated="true" ...>`
活动级别
在清单中向活动添加以下属性:
Activity level
In your manifest add the following attribute to your activity:
<application...>
<activity android:hardwareAccelerated="true" />
</application>
您还可以混合和匹配应用程序和活动级别,以仅在某些活动上启用HWUI,例如:
You can also mix and match the application and activity level to only enable HWUI on some activities, like so:
<application android:hardwareAccelerated="true">
<activity ... />
<activity android:hardwareAccelerated="false" />
</application>
窗口级别
注意:您只能在窗口级别启用HWUI,而不能禁用.
Window level
Note: You can only enable HWUI at window level not disable.
在您的src中:
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
查看水平
注意:您不能从仅视图禁用中启用HWUI.在您的src中:
View level
Note: You cannot enable HWUI from view only disable.In your src:
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
关于HWUI,您也是正确的:
Android Honeycomb(3.0)在所有应用程序中都增加了HWUI(硬件加速)选项,而无需任何额外的绘制代码.系统将为所有兼容的渲染方法自动运行预定义的OpenGL ES功能,而不是SKIA.
Also you are correct about HWUI:
Android Honeycomb (3.0) saw the addition of HWUI (Hardware Acceleration) as an option for all applications without any extra draw code. The system will automatically run predefined OpenGL ES functions for all compatible rendering methods, instead of SKIA.
从Android Ice Cream Sandwich(4.0)开始,HWUI是默认设置.因此,所有4.0+设备必须具有支持OpenGL ES 2.0的GPU.
From Android Ice Cream Sandwich (4.0), HWUI is default. Due to this, all 4.0+ devices must have an OpenGL ES 2.0 capable GPU.
这篇关于如何在JB上使用GPU后端启用Skia的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!