Files
UnrealEngineUWP/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateUTextureResource.cpp
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

61 lines
1.5 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "SlateUTextureResource.h"
FSlateBaseUTextureResource::FSlateBaseUTextureResource(UTexture* InTexture)
: TextureObject(InTexture)
{
}
FSlateBaseUTextureResource::~FSlateBaseUTextureResource()
{
}
uint32 FSlateBaseUTextureResource::GetWidth() const
{
return TextureObject->GetSurfaceWidth();
}
uint32 FSlateBaseUTextureResource::GetHeight() const
{
return TextureObject->GetSurfaceHeight();
}
ESlateShaderResource::Type FSlateBaseUTextureResource::GetType() const
{
return ESlateShaderResource::TextureObject;
}
TSharedPtr<FSlateUTextureResource> FSlateUTextureResource::NullResource = MakeShareable( new FSlateUTextureResource(nullptr) );
FSlateUTextureResource::FSlateUTextureResource(UTexture* InTexture)
: FSlateBaseUTextureResource(InTexture)
, Proxy(new FSlateShaderResourceProxy)
{
if(TextureObject)
{
Proxy->ActualSize = FIntPoint(InTexture->GetSurfaceWidth(), InTexture->GetSurfaceHeight());
Proxy->Resource = this;
}
}
FSlateUTextureResource::~FSlateUTextureResource()
{
if ( Proxy )
{
delete Proxy;
}
}
void FSlateUTextureResource::UpdateRenderResource(FTexture* InFTexture)
{
if ( InFTexture )
{
// If the RHI data has changed, it's possible the underlying size of the texture has changed,
// if that's true we need to update the actual size recorded on the proxy as well, otherwise
// the texture will continue to render using the wrong size.
Proxy->ActualSize = FIntPoint(InFTexture->GetSizeX(), InFTexture->GetSizeY());
}
}