How to enable skia with GPU backend on JB

ぐ巨炮叔叔 提交于 2019-12-12 05:29:34

问题


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.


回答1:


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

Apologies if you are already aware of the implementation of HWUI.

There are four levels of control available to you:

Application level, Activity level, Window level and View level.

Application 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>

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>

Window level

Note: You can only enable HWUI at window level not disable.

In your src:

getWindow().setFlags(
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);

View level

Note: You cannot enable HWUI from view only disable. In your src:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

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.

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.



来源:https://stackoverflow.com/questions/15285782/how-to-enable-skia-with-gpu-backend-on-jb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!