Files
UnrealEngineUWP/Engine/Source/Runtime/SlateNullRenderer/Private/SlateNullRendererModule.cpp

158 lines
4.6 KiB
C++
Raw Normal View History

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340) #lockdown Nick.Penwarden #rb none ========================== MAJOR FEATURES + CHANGES ========================== Change 3209340 on 2016/11/23 by Ben.Marsh Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h. Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms. * Every header now includes everything it needs to compile. * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first. * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h. * Every .cpp file includes its matching .h file first. * This helps validate that each header is including everything it needs to compile. * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more. * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there. * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible. * No engine code explicitly includes a precompiled header any more. * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies. * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files. Tool used to generate this transform is at Engine\Source\Programs\IncludeTool. [CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
#include "Textures/SlateShaderResource.h"
#include "Textures/TextureAtlas.h"
#include "Rendering/ShaderResourceManager.h"
#include "Fonts/FontTypes.h"
#include "Fonts/FontCache.h"
#include "Rendering/DrawElements.h"
#include "Rendering/SlateRenderer.h"
#include "TextureResource.h"
#include "Interfaces/ISlateNullRendererModule.h"
#include "SlateNullRenderer.h"
class FSlateNullShaderResourceManager : public ISlateAtlasProvider, public FSlateShaderResourceManager
{
public:
// ISlateAtlasProvider interface
virtual int32 GetNumAtlasPages() const override { return 0; }
virtual FIntPoint GetAtlasPageSize() const override { return FIntPoint(0, 0); }
virtual class FSlateShaderResource* GetAtlasPageResource(const int32 InIndex) const override { return nullptr; }
virtual bool IsAtlasPageResourceAlphaOnly() const override { return false; }
// FSlateShaderResourceManager interface
virtual FSlateShaderResourceProxy* GetShaderResource( const FSlateBrush& InBrush ) override { return nullptr; }
virtual FSlateResourceHandle GetResourceHandle( const FSlateBrush& InBrush ) override { return FSlateResourceHandle(); }
virtual ISlateAtlasProvider* GetTextureAtlasProvider() { return this; }
};
/** A null font texture resource to represent fonts */
class FSlateFontTextureNull : public FSlateShaderResource
#if WITH_ENGINE
, public FTextureResource
#endif
{
public:
FSlateFontTextureNull() {}
/** FSlateShaderResource interface */
virtual uint32 GetWidth() const override { return 0; }
virtual uint32 GetHeight() const override { return 0; }
virtual ESlateShaderResource::Type GetType() const override
{
return ESlateShaderResource::NativeTexture;
}
#if WITH_ENGINE
/** FTextureResource interface */
virtual uint32 GetSizeX() const override { return 0; }
virtual uint32 GetSizeY() const override { return 0; }
virtual FString GetFriendlyName() const override { return TEXT("FSlateFontTextureNull"); }
#endif
};
/** A null font atlas store null font textures */
class FSlateFontAtlasNull : public FSlateFontAtlas
{
public:
FSlateFontAtlasNull(float AtlasSize)
: FSlateFontAtlas(AtlasSize, AtlasSize)
{}
virtual class FSlateShaderResource* GetSlateTexture() override { return &NullFontTexture; }
virtual class FTextureResource* GetEngineTexture() override
{
#if WITH_ENGINE
return &NullFontTexture;
#else
return nullptr;
#endif
}
virtual void ConditionalUpdateTexture() override {}
virtual void ReleaseResources() override {}
static FSlateFontTextureNull NullFontTexture;
};
FSlateFontTextureNull FSlateFontAtlasNull::NullFontTexture;
/** A null font atlas factory to generate a null font atlas */
class FSlateNullFontAtlasFactory : public ISlateFontAtlasFactory
{
public:
FSlateNullFontAtlasFactory()
: AtlasSize(2048)
{}
virtual ~FSlateNullFontAtlasFactory() {}
virtual FIntPoint GetAtlasSize() const override
{
return FIntPoint(AtlasSize, AtlasSize);
}
virtual TSharedRef<FSlateFontAtlas> CreateFontAtlas() const override
{
return MakeShareable(new FSlateFontAtlasNull(AtlasSize));
}
Copying //UE4/Dev-Editor to Dev-Main (//UE4/Dev-Main) #lockdown nick.penwarden Change 2889481 on 2016/03/02 by Richard.TalbotWatkin Fixed socket preview component in Static Mesh Editor so that it remains correctly attached if the socket is renamed (Contributed by Manny-MADE). PR #2094 #jira UE-27338 - GitHub 2094 : BUGFIX: Socket preview component broken in Static Mesh Editor FSlateAtlasedTextureResource Made changes to the Perforce source control provider so that operations can be cancelled with immediate effect if there is an issue connecting to the server. #jira UE-24632 - "Updating file(s) source control status..." dialog doesn't allow Cancel #RB Thomas.Sarkanen Change 2890359 on 2016/03/02 by Nick.Darnell Jira Mirroring - Adding some tools for matching gits sha to perforce commits. Also adding the program for scraping jira issues and pushing them elsewhere. Change 2892008 on 2016/03/03 by Richard.TalbotWatkin Back out changelist 2813475 Change 2892086 on 2016/03/03 by Richard.TalbotWatkin Back out changelist 2813457 Change 2892117 on 2016/03/03 by Richard.TalbotWatkin Back out changelist 2812830 Change 2892316 on 2016/03/03 by Richard.TalbotWatkin Fixed conversion of brushes to volumes so that the original transform isn't lost. #jira UE-24404 - Convert Actor from BSP to volume can affect the actor transform Change 2892765 on 2016/03/03 by Andrew.Rodham Changed public facing level editor classes to use ILevelEditor instead of SLevelEditor #codereview Mike.Fricker Change 2894154 on 2016/03/04 by Richard.TalbotWatkin Fixed error in USplineComponent::GetSegmentLength when the segment is linear or constant. Change 2894481 on 2016/03/04 by Cody.Albert #jira UE-27830 Fixed mismatched layout name Change 2896339 on 2016/03/06 by Richard.TalbotWatkin Fixed undo issues in texture paint mode. #jira UE-21206 - Texture Painting bugs Change 2896713 on 2016/03/07 by Joe.Conley Replacing #ifndef with #pragma once Change 2896955 on 2016/03/07 by Cody.Albert #jira UE-27711 Added initialization for LastHighlightInteractionTime Change 2898895 on 2016/03/08 by Richard.TalbotWatkin More optimizations to editing actors with a large number of components. Improved performance when executing construction scripts. #jira UE-24821 - Blueprints with thousands of components perform very badly when selected in the Level Viewport Change 2900770 on 2016/03/09 by Joe.Conley Change #ifndef to #pragma once for headers under Runtime/Engine/Public Change 2900835 on 2016/03/09 by Richard.TalbotWatkin Fixed issues with scrolling items into view in STileView. Also fixed bugs in STileView::ReGenerateItems. #jira UE-20441 - Hitting F2 to rename an asset in the Content Browser moves the asset out of view if the CB is at default size and location #jira UE-20807 - Browse to Asset in Content Browser focuses just on the text #codereview Nick.Atamas Change 2900837 on 2016/03/09 by Richard.TalbotWatkin Added an OnKeyDownHandler to SSearchBox and SAssetSearchBox so that functionality for handling keypresses which is normally handled by SEditableText can be overridden. Added custom behavior to SAssetPicker and SAssetSearchBox so that up/down cursor keys can be used to change focus from the text box to the menu. #jira UE-20567 - UX Regression on Open Asset Panel This also addresses a similar issue with the auto-complete popup in the Content Browser search bar. Change 2900847 on 2016/03/09 by Richard.TalbotWatkin Fixed include dependency. Change 2900951 on 2016/03/09 by Richard.TalbotWatkin Fixed non-dependent name lookup for superclass member access. Change 2901325 on 2016/03/09 by Jamie.Dale PR #2107: Output Log Filtering (Contributed by phoboz-net) Change 2901391 on 2016/03/09 by Jamie.Dale Some more output log filter improvements We now defer the search until you finish typing, and the filter list itself now uses toggle buttons (like the content browser) so that you can toggle multiple filters without having to re-open the menu. Change 2901736 on 2016/03/09 by Alexis.Matte #jira UE-14632 Export staticmeshactor which are base on blueprint class as a blueprint instead of exporting it as an actor. #codereview nick.darnell Change 2903162 on 2016/03/10 by Alexis.Matte Fbx scene importer, Fix crash when changing the material base path in the material tab page #codereview nick.darnell Change 2903903 on 2016/03/10 by Richard.TalbotWatkin Fixed crash when attempting to paste an object from the level viewport into the content browser. #jira UE-26100 - Crash when attempting to copy an object from the world into the content browser Change 2903947 on 2016/03/10 by Richard.TalbotWatkin [CL 2937134 by Nick Darnell in Main branch]
2016-04-07 16:16:52 -04:00
virtual TSharedPtr<ISlateFontTexture> CreateNonAtlasedTexture(const uint32 InWidth, const uint32 InHeight, const TArray<uint8>& InRawData) const override
{
return nullptr;
}
private:
/** Size of each font texture, width and height. Only used to return sane numbers */
int32 AtlasSize;
};
/**
* Implements the Slate Null Renderer module.
*/
class FSlateNullRendererModule
: public ISlateNullRendererModule
{
public:
// ISlateNullRendererModule interface
virtual TSharedRef<FSlateRenderer> CreateSlateNullRenderer( ) override
{
ConditionalCreateResources();
return MakeShareable( new FSlateNullRenderer(SlateFontServices.ToSharedRef()) );
}
virtual TSharedRef<ISlateFontAtlasFactory> CreateSlateFontAtlasFactory() override
{
return MakeShareable( new FSlateNullFontAtlasFactory );
}
virtual void StartupModule( ) override { }
virtual void ShutdownModule( ) override { }
private:
void ConditionalCreateResources()
{
if (!SlateFontServices.IsValid())
{
const TSharedRef<FSlateFontCache> FontCache = MakeShareable(new FSlateFontCache(MakeShareable(new FSlateNullFontAtlasFactory)));
SlateFontServices = MakeShareable(new FSlateFontServices(FontCache, FontCache));
}
if (!ResourceManager.IsValid())
{
ResourceManager = MakeShareable(new FSlateNullShaderResourceManager);
FSlateDataPayload::ResourceManager = ResourceManager.Get();
}
}
private:
TSharedPtr<FSlateFontServices> SlateFontServices;
TSharedPtr<FSlateShaderResourceManager> ResourceManager;
};
IMPLEMENT_MODULE( FSlateNullRendererModule, SlateNullRenderer )