fix(Android): hardware acceleration issue (#854)
* Fix https://github.com/react-native-community/react-native-webview/issues/575 * Check if hardware acceleration is available also * Alternative way to check isHarewareAccelerated
This commit is contained in:
parent
a2440f0491
commit
9e25e42cee
|
@ -259,10 +259,13 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
|
||||||
|
|
||||||
@ReactProp(name = "androidHardwareAccelerationDisabled")
|
@ReactProp(name = "androidHardwareAccelerationDisabled")
|
||||||
public void setHardwareAccelerationDisabled(WebView view, boolean disabled) {
|
public void setHardwareAccelerationDisabled(WebView view, boolean disabled) {
|
||||||
if (disabled) {
|
ReactContext reactContext = (ReactContext) view.getContext();
|
||||||
|
final boolean isHardwareAccelerated = (reactContext.getCurrentActivity().getWindow()
|
||||||
|
.getAttributes().flags & WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED) != 0;
|
||||||
|
if (disabled || !isHardwareAccelerated) {
|
||||||
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||||
} else {
|
} else {
|
||||||
view.setLayerType(View.LAYER_TYPE_NONE, null);
|
view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue