Cordova Slack Digest

Sat, 13 Nov 2021 08:21:15 GMT

User count: 4676

Join the conversation at slack.cordova.io

Channel #cordova-android (2 messages)


Sat, 13 Nov 2021 00:39:26 GMT

@ucheozoemena says

Hi folks, is there a way to toggle the hardwareAccelerated property during an app session i.e. after the app has launched? So for instance if the app is compiled with the value set to "true", I would like to update that to "false" at various points during the app session, and return to "true" at other points. The closest thing I‘ve found is the https://developer.android.com/reference/android/view/View#setLayoutDirection(int)|setLayerType function for views, but the docs for https://developer.android.com/reference/android/view/View#LAYER_TYPE_HARDWARE|LAYER_TYPE_HARDWARE suggest that the behavior of this layer type is affected by whether hardware acceleration is disabled, so it seems that’s not the right way to actually disable hardware acceleration itself.

Sat, 13 Nov 2021 03:34:35 GMT

@norman137 says

I interpret that LAYER_TYPE_HARDWARE means hardware will be used when painting, assuming hardware is available enabled. If hardware is not enabled or is disabled (via OS settings perhaps) then LAYER_TYPE_HARDWARE will behave exactly like LAYER_TYPE_SOFTWARE.

In otherwords, if you setLayerType(LAYER_TYPE_HARDWARE) you may not actually get hardware rendering.

You can setLayerType(LAYER_TYPE_SOFTWARE) and use software based rendering even if hardware is enabled, but this is probably not desirable.

setLayerType api is a little bit more complicated -- it requires Paint object, but generally speaking if there is a runtime API, then you can probably implement a plugin to do what you want to do.