Unverified Commit afabdfec authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Display a message if hardware rendering is supported (#15266)

* add device.supportsHardwareRendering and display a message if true

* Address some comments
parent 69c33a32
......@@ -284,8 +284,26 @@ class RunCommand extends RunCommandBase {
}
for (Device device in devices) {
if (await device.isLocalEmulator && !isEmulatorBuildMode(getBuildMode()))
throwToolExit('${toTitleCase(getModeName(getBuildMode()))} mode is not supported for emulators.');
if (await device.isLocalEmulator) {
if (await device.supportsHardwareRendering) {
final bool enableSoftwareRendering = argResults['enable-software-rendering'] == true;
if (enableSoftwareRendering) {
printStatus(
'Using software rendering with device ${device.name}. You may get better performance'
'with hardware mode by configuring hardware rendering for your device.'
);
} else {
printStatus(
'Using hardware rendering with device ${device.name}. If you get graphics artifacts,'
'consider enabling software rendering with "--enable-software-rendering".'
);
}
}
if (!isEmulatorBuildMode(getBuildMode())) {
throwToolExit('${toTitleCase(getModeName(getBuildMode()))} mode is not supported for emulators.');
}
}
}
if (hotMode) {
......
......@@ -192,6 +192,25 @@ abstract class Device {
/// Whether it is an emulated device running on localhost.
Future<bool> get isLocalEmulator;
/// Whether the device is a simulator on a platform which supports hardware rendering.
Future<bool> get supportsHardwareRendering async {
assert(await isLocalEmulator);
switch (await targetPlatform) {
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.android_x86:
return true;
case TargetPlatform.ios:
case TargetPlatform.darwin_x64:
case TargetPlatform.linux_x64:
case TargetPlatform.windows_x64:
case TargetPlatform.fuchsia:
default:
return false;
}
}
/// Check if a version of the given app is already installed
Future<bool> isAppInstalled(ApplicationPackage app);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment