1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Read-from-memory fixes, render target improvements

This commit is contained in:
Brian Fiete 2025-02-06 08:45:21 -08:00
parent 818ca48759
commit 60988fda8f
13 changed files with 87 additions and 17 deletions

View file

@ -110,7 +110,7 @@ namespace Beefy
public virtual void PreDraw(Graphics g)
{
g.PushDrawLayer(mDefaultDrawLayer);
g.PushDrawLayer(mDefaultDrawLayer);
}
public virtual void PostDraw(Graphics g)

View file

@ -13,6 +13,8 @@ namespace Beefy.gfx
#if !STUDIO_CLIENT
public class DrawLayer
{
public static List<DrawLayer> sDrawLayers = new .() ~ delete _;
[CallingConvention(.Stdcall), CLink]
static extern void* DrawLayer_Create(void* window);
@ -33,10 +35,12 @@ namespace Beefy.gfx
public this(BFWindow window)
{
mNativeDrawLayer = DrawLayer_Create((window != null) ? (window.mNativeWindow) : null);
sDrawLayers.Add(this);
}
public ~this()
{
sDrawLayers.Remove(this);
DrawLayer_Delete(mNativeDrawLayer);
}

View file

@ -6,6 +6,7 @@ using Beefy.geom;
using Beefy.utils;
using System.Diagnostics;
using System.Threading;
using res;
namespace Beefy.gfx
{
@ -515,6 +516,14 @@ namespace Beefy.gfx
void GetFontPath(StringView fontName, String path)
{
if (fontName.StartsWith('['))
{
path.Set(fontName);
if (FilePackManager.TryMakeMemoryString(path))
return;
path.Clear();
}
if (fontName.Contains('.'))
{
Path.GetAbsolutePath(fontName, BFApp.sApp.mInstallDir, path);
@ -1014,6 +1023,8 @@ namespace Beefy.gfx
}
CharData charData = GetCharData(c);
if (charData == null)
continue;
float drawX = curX + charData.mXOffset;
float drawY = curY + charData.mYOffset;

View file

@ -561,9 +561,10 @@ static class FilePackManager
{
if (TryGetMemory(path) case .Ok(let val))
{
String prevPath = scope .()..Append(path);
var ext = Path.GetExtension(path, .. scope .());
path.Set(scope $"@{(int)(void*)val.Ptr:X}:{val.Length}");
path.Append(ext);
path.Set(scope $"@{(int)(void*)val.Ptr:X}:{val.Length}:{prevPath}");
return true;
}
return false;

View file

@ -14,7 +14,7 @@ namespace Beefy.theme.dark
public float mLabelYOfs;
[DesignEditable(DefaultEditString=true)]
public String Label
public StringView Label
{
get
{

View file

@ -69,6 +69,7 @@ namespace Beefy.widgets
public bool mWantsUpdateF;
public bool mTempWantsUpdateF;
public Image mContentRenderTarget ~ delete _;
public int32 mContentClientWidth;
public int32 mContentClientHeight;
@ -229,11 +230,31 @@ namespace Beefy.widgets
public override void PreDraw(Graphics g)
{
base.PreDraw(g);
if (mContentRenderTarget != null)
{
g.mMatrix.Set(Matrix.IdentityMatrix);
}
else
{
g.mMatrix.Set(mScaleMatrix);
}
g.mMatrix.Set(mScaleMatrix);
g.mMatrixStack[g.mMatrixStackIdx] = g.mMatrix;
}
public override void PostDraw(Graphics g)
{
base.PostDraw(g);
if (mContentRenderTarget != null)
{
for (var drawLayer in DrawLayer.sDrawLayers)
drawLayer.DrawToRenderTarget(mContentRenderTarget);
g.DrawQuad(mContentRenderTarget, 0, 0, 0, 0, mClientWidth, mClientHeight, 1, 1);
}
}
public override void RehupSize()
{
base.RehupSize();
@ -880,8 +901,14 @@ namespace Beefy.widgets
mMouseFlags = default;
}
public void SetContentSize(int width, int height)
public void SetContentSize(int width, int height, bool createRenderTarget = false)
{
DeleteAndNullify!(mContentRenderTarget);
if (createRenderTarget)
{
mContentRenderTarget = Image.CreateRenderTarget((.)width, (.)height);
}
mContentClientWidth = (.)width;
mContentClientHeight = (.)height;
RehupSize();