mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-08 17:46:35 +08:00
Add property to force HW acceleration on Android for modal windows
Summary: When using React Native on Android on top of a game as an overlay, dialog windows sometimes get created with hardware acceleration disabled. This causes the UI to be unresponsive and anything that uses a TextureView stops working. Added a property for the modal view to make sure hardware acceleration flag is enabled when it's set to true. **Test plan (required)** set `hardwareAccelerated` property for Modal to force hardware acceleration on dialog windows on Android. Does nothing on iOS. Closes https://github.com/facebook/react-native/pull/11421 Differential Revision: D4312912 Pulled By: andreicoman11 fbshipit-source-id: 9db6b2eca361421b92b24234b3501b5de0eecea7
This commit is contained in:
committed by
Facebook Github Bot
parent
db63537eb5
commit
3785db2fb1
@@ -66,6 +66,11 @@ public class ReactModalHostManager extends ViewGroupManager<ReactModalHostView>
|
||||
view.setTransparent(transparent);
|
||||
}
|
||||
|
||||
@ReactProp(name = "hardwareAccelerated")
|
||||
public void setHardwareAccelerated(ReactModalHostView view, boolean hardwareAccelerated) {
|
||||
view.setHardwareAccelerated(hardwareAccelerated);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addEventEmitters(
|
||||
ThemedReactContext reactContext,
|
||||
|
||||
@@ -61,6 +61,7 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
||||
private @Nullable Dialog mDialog;
|
||||
private boolean mTransparent;
|
||||
private String mAnimationType;
|
||||
private boolean mHardwareAccelerated;
|
||||
// Set this flag to true if changing a particular property on the view requires a new Dialog to
|
||||
// be created. For instance, animation does since it affects Dialog creation through the theme
|
||||
// but transparency does not since we can access the window to update the property.
|
||||
@@ -153,6 +154,11 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
||||
mPropertyRequiresNewDialog = true;
|
||||
}
|
||||
|
||||
protected void setHardwareAccelerated(boolean hardwareAccelerated) {
|
||||
mHardwareAccelerated = hardwareAccelerated;
|
||||
mPropertyRequiresNewDialog = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
// We show the dialog again when the host resumes
|
||||
@@ -237,6 +243,9 @@ public class ReactModalHostView extends ViewGroup implements LifecycleEventListe
|
||||
});
|
||||
|
||||
mDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
if (mHardwareAccelerated) {
|
||||
mDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
|
||||
}
|
||||
mDialog.show();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user