diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 8541b5dce10..ec95d130e3b 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -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) { diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 0adeb372568..1c5b2a78877 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -192,6 +192,25 @@ abstract class Device { /// Whether it is an emulated device running on localhost. Future get isLocalEmulator; + /// Whether the device is a simulator on a platform which supports hardware rendering. + Future 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 isAppInstalled(ApplicationPackage app);