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

* add device.supportsHardwareRendering and display a message if true

* Address some comments
This commit is contained in:
Jonah Williams 2018-03-08 10:41:29 -08:00 committed by GitHub
parent 69c33a321a
commit afabdfecf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 2 deletions

View File

@ -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) {

View File

@ -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);