You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
This had been done for texture atlas pages, but missed for font atlas pages. #codereview Matt.Kuhlenschmidt [CL 2367428 by Jamie Dale in Main branch]
105 lines
2.3 KiB
C++
105 lines
2.3 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 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 )
|