[ue4] Subclass FSlateBrush directly and do not clean up resources manually. The FSlateMaterialBrush implementation in UE 4.22 and below wrongfully frees resources it should not, leading to flickering artifacts on mobile. This was fixed in UE 4.23.1+. The fix in this commits emulates the engine source fix for lower UE4 versions. Closes #1458.

This commit is contained in:
badlogic 2019-11-21 16:35:55 +01:00
parent 572560d313
commit 11d32da100
2 changed files with 12 additions and 1 deletions

View File

@ -58,3 +58,5 @@ SyncSceneSmoothingFactor=0.000000
InitialAverageFrameRate=0.016667
PhysXTreeRebuildRate=10
DefaultBroadphaseSettings=(bUseMBPOnClient=False,bUseMBPOnServer=False,MBPBounds=(Min=(X=0.000000,Y=0.000000,Z=0.000000),Max=(X=0.000000,Y=0.000000,Z=0.000000),IsValid=0),MBPNumSubdivs=2)

View File

@ -45,6 +45,15 @@
using namespace spine;
// Workaround for https://github.com/EsotericSoftware/spine-runtimes/issues/1458
// See issue comments for more information.
struct SpineSlateMaterialBrush : public FSlateBrush {
SpineSlateMaterialBrush(class UMaterialInterface &InMaterial, const FVector2D &InImageSize)
: FSlateBrush(ESlateBrushDrawType::Image, FName(TEXT("None")), FMargin(0), ESlateBrushTileType::NoTile, ESlateBrushImageType::FullColor, InImageSize, FLinearColor::White, &InMaterial) {
ResourceName = FName(*InMaterial.GetFullName());
}
};
void SSpineWidget::Construct(const FArguments& args) {
}
@ -196,7 +205,7 @@ void SSpineWidget::Flush(int32 LayerId, FSlateWindowElementList& OutDrawElements
brush = &widget->Brush;
if (Material) {
renderData.Brush = MakeShareable(new FSlateMaterialBrush(*Material, FVector2D(64, 64)));
renderData.Brush = MakeShareable(new SpineSlateMaterialBrush(*Material, FVector2D(64, 64)));
renderData.RenderingResourceHandle = FSlateApplication::Get().GetRenderer()->GetResourceHandle(*renderData.Brush);
}