How to enable skia with GPU backend on JB

3.3k Views Asked by At

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

There are 1 best solutions below

0
On

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.