mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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:
parent
69c33a321a
commit
afabdfecf9
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user