Integrating CLs 11310084, 11341910, 11736184, 11751405 from //UE4/Dev-Editor

PIE sessions which launch a new standalone window no longer double render debug safe zones and all PIE options are more consistent with handling r.DebugSafeZone.XXXX cvars.

#Jira UE-89101 UE-89108 UE-87689
#rb lauren.barnes

#ROBOMERGE-SOURCE: CL 11968084 in //UE4/Release-4.25/...
#ROBOMERGE-BOT: RELEASE (Release-4.25 -> Release-4.25Plus) (v656-11643781)

[CL 11968102 by brooke hubert in 4.25-Plus branch]
This commit is contained in:
brooke hubert
2020-03-05 18:02:08 -05:00
parent c1dcac7650
commit f69d439a0a
10 changed files with 911 additions and 815 deletions

View File

@@ -3680,8 +3680,7 @@ FReply SDesignerView::HandleSwapAspectRatioClicked()
if (!PreviewOverrideName.IsEmpty())
{
ULevelEditorPlaySettings* PlaySettings = GetMutableDefault<ULevelEditorPlaySettings>();
DesignerSafeZoneOverride = PlaySettings->CalculateCustomUnsafeZones(CustomSafeZoneStarts, CustomSafeZoneDimensions, PreviewOverrideName, FVector2D(PreviewWidth, PreviewHeight));
DesignerSafeZoneOverride = PlayInSettings->CalculateCustomUnsafeZones(CustomSafeZoneStarts, CustomSafeZoneDimensions, PreviewOverrideName, FVector2D(PreviewWidth, PreviewHeight));
}
else
{

View File

@@ -543,7 +543,8 @@ public:
// End of UObject interface
#if WITH_EDITOR
void SwapSafeZoneTypes();
// Recalculates and broadcasts safe zone size changes based on device to emulate and r.DebugSafeZone.TitleRatio values.
void UpdateCustomSafeZones();
#endif
FMargin CalculateCustomUnsafeZones(TArray<FVector2D>& CustomSafeZoneStarts, TArray<FVector2D>& CustomSafeZoneDimensions, FString& DeviceType, FVector2D PreviewSize);

View File

@@ -154,22 +154,19 @@ void UEditorEngine::LaunchNewProcess(const FRequestPlaySessionParams& InParams,
// Ensure the executable writes out a differently named config file to avoid multiple instances overwriting each other.
// ToDo: Should this be on all multi-client launches?
CommandLine += TEXT(" -MultiprocessSaveConfig");
}
// In order for the mobile previewer to adjust its safe zone according to the device profile specified in the editor play settings,
// we need to pass the PIESafeZoneOverride's values as command line variables to the new process that we are about to launch.
FMargin PIESafeZoneOverride = InParams.EditorPlaySettings->PIESafeZoneOverride;
// In order for the previewer to adjust its safe zone according to the device profile specified in the editor play settings,
// we need to pass the PIESafeZoneOverride's values as command line variables to the new process that we are about to launch.
FMargin PIESafeZoneOverride = InParams.EditorPlaySettings->PIESafeZoneOverride;
if (!PIESafeZoneOverride.GetDesiredSize().IsZero())
{
CommandLine += FString::Printf(TEXT(" -SafeZonePaddingLeft=%f -SafeZonePaddingRight=%f -SafeZonePaddingTop=%f -SafeZonePaddingBottom=%f"),
PIESafeZoneOverride.Left,
PIESafeZoneOverride.Right,
PIESafeZoneOverride.Top,
PIESafeZoneOverride.Bottom
);
if (!PIESafeZoneOverride.GetDesiredSize().IsZero())
{
// Send -DrawUnSafeZones so that the red "unsafe" zones show up in the mobile previewer.
CommandLine += TEXT(" -DrawUnSafeZones");
}
}
if (InParams.SessionPreviewTypeOverride.Get(EPlaySessionPreviewType::NoPreview) == EPlaySessionPreviewType::VulkanPreview)

View File

@@ -513,7 +513,7 @@ void ULevelEditorPlaySettings::PostInitProperties()
NetworkEmulationSettings.OnPostInitProperties();
#if WITH_EDITOR
FCoreDelegates::OnSafeFrameChangedEvent.AddUObject(this, &ULevelEditorPlaySettings::SwapSafeZoneTypes);
FCoreDelegates::OnSafeFrameChangedEvent.AddUObject(this, &ULevelEditorPlaySettings::UpdateCustomSafeZones);
#endif
}
@@ -531,12 +531,25 @@ bool ULevelEditorPlaySettings::CanEditChange(const FProperty* InProperty) const
}
#if WITH_EDITOR
void ULevelEditorPlaySettings::SwapSafeZoneTypes()
void ULevelEditorPlaySettings::UpdateCustomSafeZones()
{
// Prefer to use r.DebugSafeZone.TitleRatio if it is set
if (FDisplayMetrics::GetDebugTitleSafeZoneRatio() < 1.f)
{
DeviceToEmulate = FString();
FSlateApplication::Get().ResetCustomSafeZone();
PIESafeZoneOverride = FMargin();
}
else
{
PIESafeZoneOverride = CalculateCustomUnsafeZones(CustomUnsafeZoneStarts, CustomUnsafeZoneDimensions, DeviceToEmulate, FVector2D(NewWindowWidth, NewWindowHeight));
}
FMargin SafeZoneRatio = PIESafeZoneOverride;
SafeZoneRatio.Left /= (NewWindowWidth / 2.0f);
SafeZoneRatio.Right /= (NewWindowWidth / 2.0f);
SafeZoneRatio.Bottom /= (NewWindowHeight / 2.0f);
SafeZoneRatio.Top /= (NewWindowHeight / 2.0f);
FSlateApplication::Get().OnDebugSafeZoneChanged.Broadcast(SafeZoneRatio, true);
}
#endif

View File

@@ -77,7 +77,10 @@ public:
UPROPERTY(Config)
int32 MaxSplitscreenPlayers = 4;
/** if true then the title safe border is drawn */
/** if true then the title safe border is drawn
* @deprecated - Use the cvar "r.DebugSafeZone.Mode=1".
*/
UE_DEPRECATED(4.26, "Use the cvar \"r.DebugSafeZone.Mode=1\".")
uint32 bShowTitleSafeZone:1;
/** If true, this viewport is a play in editor viewport */
@@ -115,8 +118,10 @@ public:
UFUNCTION(exec)
virtual void SSSwapControllers();
/** Exec for toggling the display of the title safe area */
UFUNCTION(exec)
/** Exec for toggling the display of the title safe area
* @deprecated Use the cvar "r.DebugSafeZone.Mode=1".
*/
UFUNCTION(exec, meta = (DeprecatedFunction, DeprecationMessage = "Use the cvar \"r.DebugSafeZone.Mode=1.\""))
virtual void ShowTitleSafeArea();
/** Sets the player which console commands will be executed in the context of. */
@@ -438,7 +443,7 @@ public:
bool CalculateDeadZoneForAllSides( ULocalPlayer* LPlayer, UCanvas* Canvas, float& fTopSafeZone, float& fBottomSafeZone, float& fLeftSafeZone, float& fRightSafeZone, bool bUseMaxPercent = false );
/**
* Draw the safe area using the current TitleSafeZone settings.
* Draws the safe area using the current r.DebugSafeZone.Mode=1 when there is not a valid PlayerController HUD.
*
* @param Canvas Canvas on which to draw
*/

View File

@@ -160,9 +160,6 @@ void UGameViewportClient::UpdateCsvCameraStats(const FSceneView* View)
UGameViewportClient::UGameViewportClient(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
#if WITH_EDITOR
, bShowTitleSafeZone(true)
#endif
, EngineShowFlags(ESFIM_Game)
, CurrentBufferVisualizationMode(NAME_None)
, HighResScreenshotDialog(NULL)
@@ -248,9 +245,6 @@ UGameViewportClient::UGameViewportClient(const FObjectInitializer& ObjectInitial
UGameViewportClient::UGameViewportClient(FVTableHelper& Helper)
: Super(Helper)
#if WITH_EDITOR
, bShowTitleSafeZone(true)
#endif
, EngineShowFlags(ESFIM_Game)
, CurrentBufferVisualizationMode(NAME_None)
, HighResScreenshotDialog(NULL)
@@ -1966,12 +1960,8 @@ bool UGameViewportClient::IsOrtho() const
void UGameViewportClient::PostRender(UCanvas* Canvas)
{
#if WITH_EDITOR
if(bShowTitleSafeZone)
{
DrawTitleSafeArea(Canvas);
}
DrawTitleSafeArea(Canvas);
#endif
// Draw the transition screen.
DrawTransition(Canvas);
}
@@ -2013,9 +2003,19 @@ void UGameViewportClient::SSSwapControllers()
void UGameViewportClient::ShowTitleSafeArea()
{
#if !UE_BUILD_SHIPPING
bShowTitleSafeZone = !bShowTitleSafeZone;
#endif
static IConsoleVariable* DebugSafeZoneModeCvar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DebugSafeZone.Mode"));
if (DebugSafeZoneModeCvar)
{
const int32 DebugSafeZoneMode = DebugSafeZoneModeCvar->GetInt();
if (DebugSafeZoneMode != 1)
{
DebugSafeZoneModeCvar->Set(1);
}
else
{
DebugSafeZoneModeCvar->Set(0);
}
}
}
void UGameViewportClient::SetConsoleTarget(int32 PlayerIndex)
@@ -2440,19 +2440,36 @@ bool UGameViewportClient::CalculateDeadZoneForAllSides( ULocalPlayer* LPlayer, U
void UGameViewportClient::DrawTitleSafeArea( UCanvas* Canvas )
{
#if WITH_EDITOR
// If we have a valid player hud, then the title area has already rendered.
APlayerController* FirstPlayerController = GetWorld()->GetFirstPlayerController();
if (FirstPlayerController && FirstPlayerController->GetHUD())
{
return;
}
// If r.DebugSafeZone.Mode isn't set to draw title area, don't draw it.
static IConsoleVariable* SafeZoneModeCvar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DebugSafeZone.Mode"));
if (SafeZoneModeCvar && (SafeZoneModeCvar->GetInt() != 1))
{
return;
}
FMargin SafeZone;
const ULevelEditorPlaySettings* PlayInSettings = GetDefault<ULevelEditorPlaySettings>();
float Width, Height;
GetPixelSizeOfScreen(Width, Height, Canvas, 0);
const FLinearColor UnsafeZoneColor(1.0f, 0.0f, 0.0f, 0.25f);
FLinearColor UnsafeZoneColor(1.0f, 0.0f, 0.0f, 0.25f);
static IConsoleVariable* AlphaCvar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.DebugSafeZone.OverlayAlpha"));
if (AlphaCvar)
{
UnsafeZoneColor.A = AlphaCvar->GetFloat();
}
FCanvasTileItem TileItem(FVector2D::ZeroVector, GWhiteTexture, UnsafeZoneColor);
TileItem.BlendMode = SE_BLEND_Translucent;
// Command line override used by mobile PIE.
static bool bDrawUnSafeZones = FParse::Param(FCommandLine::Get(), TEXT("DrawUnSafeZones"));
// CalculateSafeZoneValues() can be slow, so we only want to run it if we have boundaries to draw
if (FDisplayMetrics::GetDebugTitleSafeZoneRatio() < 1.f)
{
@@ -2478,7 +2495,7 @@ void UGameViewportClient::DrawTitleSafeArea( UCanvas* Canvas )
TileItem.Size = FVector2D(SafeZone.Right, HeightOfSides);
Canvas->DrawItem(TileItem);
}
else if (!FSlateApplication::Get().GetCustomSafeZone().GetDesiredSize().IsZero() || bDrawUnSafeZones)
else if (!FSlateApplication::Get().GetCustomSafeZone().GetDesiredSize().IsZero())
{
ULevelEditorPlaySettings* PlaySettings = GetMutableDefault<ULevelEditorPlaySettings>();
PlaySettings->CalculateCustomUnsafeZones(PlaySettings->CustomUnsafeZoneStarts, PlaySettings->CustomUnsafeZoneDimensions, PlaySettings->DeviceToEmulate, FVector2D(Width, Height));

View File

@@ -1465,19 +1465,6 @@ void FSceneViewport::ResizeViewport(uint32 NewSizeX, uint32 NewSizeY, EWindowMod
bIsResizing = true;
UpdateViewportRHI(false, NewSizeX, NewSizeY, NewWindowMode, PF_Unknown);
#if WITH_EDITOR
FMargin SafeMargin;
if (FDisplayMetrics::GetDebugTitleSafeZoneRatio() < 1.f || !FSlateApplication::Get().GetCustomSafeZone().GetDesiredSize().IsZero())
{
FSlateApplication::Get().GetSafeZoneSize(SafeMargin, FVector2D(NewSizeX, NewSizeY));
SafeMargin.Left /= (NewSizeX / 2.0f);
SafeMargin.Right /= (NewSizeX / 2.0f);
SafeMargin.Bottom /= (NewSizeY / 2.0f);
SafeMargin.Top /= (NewSizeY / 2.0f);
}
FSlateApplication::Get().OnDebugSafeZoneChanged.Broadcast(SafeMargin, false);
#endif
FCoreDelegates::OnSafeFrameChangedEvent.Broadcast();
if (ViewportClient)

View File

@@ -560,8 +560,12 @@ protected:
{
FDisplayMetrics DisplayMetrics;
GetDisplayMetrics(DisplayMetrics);
CustomSafeZoneRatio = FMargin();
OnDebugSafeZoneChanged.Broadcast(FMargin(), false);
if (FDisplayMetrics::GetDebugTitleSafeZoneRatio() < 1.0f)
{
CustomSafeZoneRatio = FMargin();
OnDebugSafeZoneChanged.Broadcast(FMargin(), false);
}
}
#endif