Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Force GPU Rendering How to enable and disable?

I am building an app that requires a lot of drawing on the canvas. I notice that the app is a bit laggy in devices with high resolution (nexus 7 for example). I saw there is a Force GPU option in the developer option. When Force GPU is enabled, my app runs absolutely smooth.

I have read that this Force GPU option is called Hardware Acceleration and it is available only for Android 3.0 and above.

My app is targeting Android 2.3 and above.

Is it possible to programmatically enable Hardware Accelerated (or Force GPU--whatever the magic is called) on any Android 3.0 or above devices?

Something like:

if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB){

    Turn On Hardware Accelerate HERE but How can i do this?
    any code snippet would be welcome/helpful/thanks

}
like image 471
xiaowoo Avatar asked Mar 03 '13 20:03

xiaowoo


People also ask

How do I enable Force GPU rendering?

Tap on Build number 7 times until you get a message saying “You are now a developer“. Go back to Settings, scroll down and you should be able to see a new option called Developer options. Tap on it. Scroll down to the Hardware accelerated rendering and enable the toggle next to Force GPU rendering.

How do I change GPU rendering on Android?

On your device, go to Settings and tap Developer Options. In the Monitoring section, select Profile GPU Rendering or Profile HWUI rendering, depending on the version of Android running on the device. In the Profile GPU Rendering dialog, choose On screen as bars to overlay the graphs on the screen of your device.

Should I enable Force GPU rendering?

On certain devices, GPU consumes more power the CPU, hence you may observe 5-15% lower battery life with option enabled. I would recommend having this option enabled on devices with weaker CPUs e.g. You should seldom need to enable this on dual-core 1.4ghz ARM CPU.

Is Disable HW overlays a Force GPU rendering?

Turning off HW overlays is a setting that can be used to increase performance on some games. Disabling this setting may cause some games to crash or not work properly. It will also reduce the battery life of your device because it forces the GPU to render graphics at a higher resolution than necessary.


1 Answers

I assume you've already added android:hardwareAccelerated to your Manifest file?

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

That is what enables hardware acceleration within your application per the guide on hardware acceleration and should do exactly what forcing GPU does at a system level.

like image 73
ianhanniballake Avatar answered Sep 22 '22 18:09

ianhanniballake