r.MobileContentScaleFactor

r.MobileContentScaleFactor

#Overview

name: r.MobileContentScaleFactor

The value of this variable can be defined or overridden in .ini config files. 59 .ini config files referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 18 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.MobileContentScaleFactor is to control the content scale multiplier for mobile devices, particularly to support high-resolution displays such as Retina displays on iOS devices.

Regarding the associated variable CVarMobileContentScaleFactor:

When working with either r.MobileContentScaleFactor or CVarMobileContentScaleFactor, developers should ensure they understand the impact on rendering performance and visual quality, and test thoroughly on target devices.

#Setting Variables

#References In INI files

<Workspace>/Engine/Config/BaseDeviceProfiles.ini:326, section: [iPhone6S DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:337, section: [iPhone6SPlus DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:348, section: [iPhoneSE DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:357, section: [iPhone7 DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:365, section: [iPhone7Plus DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:519, section: [iPodTouch7 DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:545, section: [iPadPro DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:794, section: [Android DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:827, section: [Android_Low DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:843, section: [Android_Mid DeviceProfile]
<Workspace>/Engine/Config/BaseDeviceProfiles.ini:868, section: [Android_High DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:111, section: [IOS_Mid DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:166, section: [iPhone6S DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:171, section: [iPhone6SPlus DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:175, section: [iPhoneSE DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:179, section: [iPad5 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:184, section: [iPadAir2 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:189, section: [iPadMini4 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:193, section: [AppleTV DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:202, section: [iPodTouch7 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:206, section: [iPhone7 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:210, section: [iPhone7Plus DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:214, section: [iPadPro129 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:218, section: [iPadPro97 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:222, section: [iPad6 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:226, section: [AppleTV4K DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:236, section: [iPhone8 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:242, section: [iPhone8Plus DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:247, section: [iPadPro2_129 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:251, section: [iPadPro105 DeviceProfile]
<Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:255, section: [iPhoneX DeviceProfile]


... omitting 29 locations ...

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3883

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarMobileContentScaleFactor(
	TEXT("r.MobileContentScaleFactor"),
	1.0f,
	TEXT("Content scale multiplier (equates to iOS's contentScaleFactor to support Retina displays"),
	ECVF_Default);

static TAutoConsoleVariable<int32> CVarMobileDesiredResX(
	TEXT("r.Mobile.DesiredResX"),

#Loc: <Workspace>/Engine/Source/Editor/PIEPreviewDeviceProfileSelector/Private/PIEPreviewDevice.cpp:155

Scope (from outer to inner):

file
function     void FPIEPreviewDevice::ComputeContentScaledResolution

Source code excerpt:

			case EPIEPreviewDeviceType::IOS:
			{
				static IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MobileContentScaleFactor"));
				float RequestedContentScaleFactor = CVar->GetFloat();

				if (FMath::IsNearlyZero(RequestedContentScaleFactor))
				{
					RequestedContentScaleFactor = DeviceSpecs->IOSProperties.NativeScaleFactor;
				}

#Loc: <Workspace>/Engine/Source/Editor/PIEPreviewDeviceProfileSelector/Private/PIEPreviewDevice.h:41

Scope (from outer to inner):

file
class        class FPIEPreviewDevice

Source code excerpt:

	bool bShowBezel = true;

	/** when true r.MobileContentScaleFactor is ignored */
	bool bIgnoreContentScaleFactor = false;

	class UTexture2D* BezelTexture = nullptr;

private:
	// utility function that will attempt to determine the supported device orientations

#Loc: <Workspace>/Engine/Source/Editor/PIEPreviewDeviceProfileSelector/Private/PIEPreviewDevice.h:113

Scope (from outer to inner):

file
class        class FPIEPreviewDevice

Source code excerpt:

	void ComputeDeviceResolution(int32& ScreenWidth, int32& ScreenHeight);

	// utility function that computes the resolution after applying r.MobileContentScaleFactor
	void ComputeContentScaledResolution(int32& ScreenWidth, int32& ScreenHeight);

	FString GetProfile() const;

	bool GetSelectorPropertyValue(const FName& PropertyType, FString& PropertyValueOUT) const;

#Loc: <Workspace>/Engine/Source/Editor/UMGEditor/Private/Designer/SDesignerView.cpp:3500

Scope (from outer to inner):

file
function     bool SDesignerView::HandleIsCommonResolutionSelected

Source code excerpt:

	if (!PreviewOverrideName.IsEmpty() || !InResolution.ProfileName.IsEmpty())
	{
		// Would have the same r.MobileContentScaleFactor and original size
		return InResolution.ProfileName.Equals(PreviewOverrideName) && bSizeMatches;
	}

	return bSizeMatches;
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:707

Scope (from outer to inner):

file
function     FMargin ULevelEditorPlaySettings::CalculateCustomUnsafeZones

Source code excerpt:


				bool bShouldScale = false;
				float CVarMobileContentScaleFactor = FCString::Atof(*DeviceProfile->GetCVarValue(TEXT("r.MobileContentScaleFactor")));
				if (CVarMobileContentScaleFactor != 0)
				{
					bShouldScale = true;
				}
				else
				{
					if (DeviceProfile->GetConsolidatedCVarValue(TEXT("r.MobileContentScaleFactor"), CVarMobileContentScaleFactor, true))
					{
						bShouldScale = true;
					}
				}
				if (bShouldScale)
				{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:805

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::RescaleForMobilePreview

Source code excerpt:

	bool bShouldScale = false;
	float CVarMobileContentScaleFactor = 0.0f;
	const FString ScaleFactorString = DeviceProfile->GetCVarValue(TEXT("r.MobileContentScaleFactor"));
	if (ScaleFactorString != FString())
	{
		CVarMobileContentScaleFactor = FCString::Atof(*ScaleFactorString);

		if (!FMath::IsNearlyEqual(CVarMobileContentScaleFactor, 0.0f))
		{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:820

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::RescaleForMobilePreview

Source code excerpt:

		TMap<FString, FString> ParentValues;
		DeviceProfile->GatherParentCVarInformationRecursively(ParentValues);
		const FString* ParentScaleFactorPtr = ParentValues.Find(TEXT("r.MobileContentScaleFactor"));
		if (ParentScaleFactorPtr != nullptr)
		{
			FString CompleteString = *ParentScaleFactorPtr;
			FString DiscardString;
			FString ValueString;
			CompleteString.Split(TEXT("="), &DiscardString, &ValueString);

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/Android/AndroidWindow.cpp:555

Scope (from outer to inner):

file
function     FPlatformRect FAndroidWindow::GetScreenRect

Source code excerpt:


	// CSF is a multiplier to 1280x720
	static IConsoleVariable* CVarScale = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MobileContentScaleFactor"));
	// If the app is for Oculus Mobile then always use 0 as ScaleFactor (to match window size).
	float RequestedContentScaleFactor = bIsOculusMobileApp ? 0.0f : CVarScale->GetFloat();

	FString CmdLineCSF;
	if (FParse::Value(FCommandLine::Get(), TEXT("mcsf="), CmdLineCSF, false))
	{

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/IOS/IOSWindow.cpp:69

Scope: file

Source code excerpt:

	FIOSView* View = AppDelegate.IOSView;
		
	// If r.MobileContentScaleFactor is set by a console command, clear out the r.mobile.DesiredResX/Y CVars
	if ((CVar->GetFlags() & ECVF_SetByMask) == ECVF_SetByConsole)
	{
		IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
		IConsoleVariable* CVarResY = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResY"));
		
		// If CVarResX/Y needs to be reset, let that CVar callback handle the layout change

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/IOS/IOSWindow.h:33

Scope (from outer to inner):

file
function     class APPLICATIONCORE_API FIOSWindow : public FGenericWindow { public: ~FIOSWindow

Source code excerpt:

	virtual bool GetFullScreenInfo( int32& X, int32& Y, int32& Width, int32& Height ) const override;

	/** Callbacks for Cvar changes "r.MobileContentScaleFactor" and "r.Mobile.DesiredResX/Y" respectively */
	static void OnScaleFactorChanged(IConsoleVariable* CVar);
	static void OnConsoleResolutionChanged(IConsoleVariable* CVar);
		
protected:
	/** @return true if the native window is currently in fullscreen mode, false otherwise */
	virtual EWindowMode::Type GetWindowMode() const override { return EWindowMode::Fullscreen; }

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Public/Android/AndroidWindowUtils.h:35

Scope (from outer to inner):

file
namespace    AndroidWindowUtils
function     void ApplyContentScaleFactor

Source code excerpt:

	{
		// CSF is a multiplier to 1280x720
		static IConsoleVariable* CVarScale = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MobileContentScaleFactor"));
		float RequestedContentScaleFactor = CVarScale->GetFloat();

		static IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
		static IConsoleVariable* CVarResY = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResY"));
		int32 RequestedResX = CVarResX->GetInt();
		int32 RequestedResY = CVarResY->GetInt();

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/IOS/IOSPlatformMisc.cpp:76

Scope (from outer to inner):

file
function     void FIOSPlatformMisc::PlatformInit

Source code excerpt:

{
	// PlatformInit() starts the UI thread which creates the framebuffer and it requires
	// "r.MobileContentScaleFactor" and "r.Mobile.DesiredResX/Y" to be available before 
	// it's creation, so need to cache those value now.
	[[IOSAppDelegate GetDelegate] LoadScreenResolutionModifiers];
		
	FAppEntry::PlatformInit();

	// Increase the maximum number of simultaneously open files

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/Android/AndroidEventManager.cpp:210

Scope (from outer to inner):

file
function     FAppEventManager::FAppEventManager

Source code excerpt:

	pthread_mutex_init(&QueueMutex, NULL);

	IConsoleVariable* CVarScale = IConsoleManager::Get().FindConsoleVariable(TEXT("r.MobileContentScaleFactor"));
	check(CVarScale);
	CVarScale->SetOnChangedCallback(FConsoleVariableDelegate::CreateStatic(&FAppEventManager::OnScaleFactorChanged));

	IConsoleVariable* CVarResX = IConsoleManager::Get().FindConsoleVariable(TEXT("r.Mobile.DesiredResX"));
	if (CVarResX != nullptr)
	{

#Associated Variable and Callsites

This variable is associated with another variable named CVarMobileContentScaleFactor. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:707

Scope (from outer to inner):

file
function     FMargin ULevelEditorPlaySettings::CalculateCustomUnsafeZones

Source code excerpt:


				bool bShouldScale = false;
				float CVarMobileContentScaleFactor = FCString::Atof(*DeviceProfile->GetCVarValue(TEXT("r.MobileContentScaleFactor")));
				if (CVarMobileContentScaleFactor != 0)
				{
					bShouldScale = true;
				}
				else
				{
					if (DeviceProfile->GetConsolidatedCVarValue(TEXT("r.MobileContentScaleFactor"), CVarMobileContentScaleFactor, true))
					{
						bShouldScale = true;
					}
				}
				if (bShouldScale)
				{
					Start *= CVarMobileContentScaleFactor;
					Dimensions *= CVarMobileContentScaleFactor;
				}

				if (!bAdjustsToDeviceRotation && ((Orientation.Contains(TEXT("L")) && bPreviewIsPortrait) ||
					(Orientation.Contains(TEXT("P")) && !bPreviewIsPortrait)))
				{
					double Placeholder = Start.X;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:804

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::RescaleForMobilePreview

Source code excerpt:

{
	bool bShouldScale = false;
	float CVarMobileContentScaleFactor = 0.0f;
	const FString ScaleFactorString = DeviceProfile->GetCVarValue(TEXT("r.MobileContentScaleFactor"));
	if (ScaleFactorString != FString())
	{
		CVarMobileContentScaleFactor = FCString::Atof(*ScaleFactorString);

		if (!FMath::IsNearlyEqual(CVarMobileContentScaleFactor, 0.0f))
		{
			bShouldScale = true;
			ScaleFactor = CVarMobileContentScaleFactor;
		}
	}
	else
	{
		TMap<FString, FString> ParentValues;
		DeviceProfile->GatherParentCVarInformationRecursively(ParentValues);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:827

Scope (from outer to inner):

file
function     void ULevelEditorPlaySettings::RescaleForMobilePreview

Source code excerpt:

			FString ValueString;
			CompleteString.Split(TEXT("="), &DiscardString, &ValueString);
			CVarMobileContentScaleFactor = FCString::Atof(*ValueString);
			if (!FMath::IsNearlyEqual(CVarMobileContentScaleFactor, 0.0f))
			{
				bShouldScale = true;
				ScaleFactor = CVarMobileContentScaleFactor;
			}
		}
	}
	if (bShouldScale)
	{
		if (DeviceProfile->DeviceType == TEXT("Android"))

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:3882

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_RenderThreadSafe);

static TAutoConsoleVariable<float> CVarMobileContentScaleFactor(
	TEXT("r.MobileContentScaleFactor"),
	1.0f,
	TEXT("Content scale multiplier (equates to iOS's contentScaleFactor to support Retina displays"),
	ECVF_Default);

static TAutoConsoleVariable<int32> CVarMobileDesiredResX(