You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Moved the existing atlas visualizer out of the Slate RHI renderer and instead made the resource manager for each renderer implement the ISlateAtlasProvider interface to provide information about its current texture atlases. FSlateFontCache implements ISlateAtlasProvider for the font atlas viewer. Improved the atlas visualizer and added support for zooming and panning of the atlas pages. This helps greatly when viewing font atlases as they can be as large as 2048x2048. #codereview Matt.Kuhlenschmidt [CL 2371483 by Jamie Dale in Main branch]
110 lines
2.4 KiB
C++
110 lines
2.4 KiB
C++
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "SlateRHIRendererPrivatePCH.h"
|
|
#include "Slate3DRenderer.h"
|
|
|
|
class FSlateRHIFontAtlasFactory : public ISlateFontAtlasFactory
|
|
{
|
|
public:
|
|
FSlateRHIFontAtlasFactory()
|
|
{
|
|
if (GIsEditor)
|
|
{
|
|
AtlasSize = 2048;
|
|
}
|
|
else
|
|
{
|
|
AtlasSize = 1024;
|
|
if (GConfig)
|
|
{
|
|
GConfig->GetInt(TEXT("SlateRenderer"), TEXT("FontAtlasSize"), AtlasSize, GEngineIni);
|
|
AtlasSize = FMath::Clamp(AtlasSize, 0, 2048);
|
|
}
|
|
}
|
|
}
|
|
|
|
virtual ~FSlateRHIFontAtlasFactory()
|
|
{
|
|
}
|
|
|
|
virtual FIntPoint GetAtlasSize() const override
|
|
{
|
|
return FIntPoint(AtlasSize, AtlasSize);
|
|
}
|
|
|
|
virtual TSharedRef<FSlateFontAtlas> CreateFontAtlas() const override
|
|
{
|
|
return MakeShareable(new FSlateFontAtlasRHI(AtlasSize, AtlasSize));
|
|
}
|
|
|
|
private:
|
|
/** Size of each font texture, width and height */
|
|
int32 AtlasSize;
|
|
};
|
|
|
|
|
|
/**
|
|
* Implements the Slate RHI Renderer module.
|
|
*/
|
|
class FSlateRHIRendererModule
|
|
: public ISlateRHIRendererModule
|
|
{
|
|
public:
|
|
|
|
// ISlateRHIRendererModule interface
|
|
virtual TSharedRef<FSlateRenderer> CreateSlateRHIRenderer( ) override
|
|
{
|
|
ConditionalCreateResources();
|
|
|
|
return MakeShareable( new FSlateRHIRenderer( ResourceManager, FontCache, FontMeasure ) );
|
|
}
|
|
|
|
virtual TSharedRef<ISlate3DRenderer> CreateSlate3DRenderer() override
|
|
{
|
|
ConditionalCreateResources();
|
|
|
|
return MakeShareable( new FSlate3DRenderer( ResourceManager, FontCache ) );
|
|
}
|
|
|
|
virtual TSharedRef<ISlateFontAtlasFactory> CreateSlateFontAtlasFactory() override
|
|
{
|
|
return MakeShareable(new FSlateRHIFontAtlasFactory);
|
|
}
|
|
|
|
virtual void StartupModule( ) override { }
|
|
virtual void ShutdownModule( ) override { }
|
|
|
|
private:
|
|
/** Creates resource managers if they do not exist */
|
|
void ConditionalCreateResources()
|
|
{
|
|
if( !ResourceManager.IsValid() )
|
|
{
|
|
ResourceManager = MakeShareable( new FSlateRHIResourceManager );
|
|
}
|
|
|
|
if( !FontCache.IsValid() )
|
|
{
|
|
FontCache = MakeShareable(new FSlateFontCache(MakeShareable(new FSlateRHIFontAtlasFactory)));
|
|
}
|
|
|
|
if( !FontMeasure.IsValid() )
|
|
{
|
|
FontMeasure = FSlateFontMeasure::Create(FontCache.ToSharedRef());
|
|
}
|
|
|
|
}
|
|
private:
|
|
/** Resource manager used for all renderers */
|
|
TSharedPtr<FSlateRHIResourceManager> ResourceManager;
|
|
|
|
/** Font cache used for all renderers */
|
|
TSharedPtr<FSlateFontCache> FontCache;
|
|
|
|
/** Font measure interface used for all renderers */
|
|
TSharedPtr<FSlateFontMeasure> FontMeasure;
|
|
};
|
|
|
|
|
|
IMPLEMENT_MODULE( FSlateRHIRendererModule, SlateRHIRenderer )
|