Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing the framebuffer FPS + Respect IRendererFactory #6652

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,17 @@ public FramebufferToplevelImpl(IOutputBackend outputBackend, IInputBackend input

public IRenderer CreateRenderer(IRenderRoot root)
{
return new DeferredRenderer(root, AvaloniaLocator.Current.GetService<IRenderLoop>())
{

};
var factory = AvaloniaLocator.Current.GetService<IRendererFactory>();
var renderLoop = AvaloniaLocator.Current.GetService<IRenderLoop>();
return factory?.Create(root, renderLoop) ?? new DeferredRenderer(root, renderLoop);
}

public void Dispose()
{
throw new NotSupportedException();
}


public void Invalidate(Rect rect)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@ void Initialize()
Threading = new InternalPlatformThreadingInterface();
if (_fb is IGlOutputBackend gl)
AvaloniaLocator.CurrentMutable.Bind<IPlatformOpenGlInterface>().ToConstant(gl.PlatformOpenGlInterface);

var opts = AvaloniaLocator.Current.GetService<LinuxFramebufferPlatformOptions>();

AvaloniaLocator.CurrentMutable
.Bind<IPlatformThreadingInterface>().ToConstant(Threading)
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(60))
.Bind<IRenderTimer>().ToConstant(new DefaultRenderTimer(opts?.Fps ?? 60))
.Bind<IRenderLoop>().ToConstant(new RenderLoop())
.Bind<ICursorFactory>().ToTransient<CursorFactoryStub>()
.Bind<IKeyboardDevice>().ToConstant(new KeyboardDevice())
.Bind<IPlatformSettings>().ToSingleton<PlatformSettings>()
.Bind<PlatformHotkeyConfiguration>().ToSingleton<PlatformHotkeyConfiguration>();

}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Avalonia.LinuxFramebuffer
{
/// <summary>
/// Platform-specific options which apply to the Linux framebuffer.
/// </summary>
public class LinuxFramebufferPlatformOptions
{
/// <summary>
/// Gets or sets the number of frames per second at which the renderer should run.
/// Default 60.
/// </summary>
public int Fps { get; set; } = 60;
}
}