thrownewInvalidOperationException($"{nameof(AndroidPlatformOptions)}.{nameof(AndroidPlatformOptions.RenderingMode)} must not be empty or null");
}
publicsealedclassAndroidPlatformOptions
{
publicboolUseDeferredRendering{get;set;}=false;
publicboolUseGpu{get;set;}=true;
foreach(varrenderingModeinopts.RenderingMode)
{
if(renderingMode==AndroidRenderingMode.Software)
{
returnnull;
}
if(renderingMode==AndroidRenderingMode.Egl)
{
if(EglPlatformGraphics.TryCreate()is{}egl)
{
returnegl;
}
}
}
thrownewInvalidOperationException($"{nameof(AndroidPlatformOptions)}.{nameof(AndroidPlatformOptions.RenderingMode)} has a value of \"{string.Join(", ",opts.RenderingMode)}\", but no options were applied.");
thrownewInvalidOperationException($"{nameof(X11PlatformOptions)}.{nameof(X11PlatformOptions.RenderingMode)} has a value of \"{string.Join(", ",opts.RenderingMode)}\", but no options were applied.");
}
}
}
namespaceAvalonia
{
publicenumX11RenderingMode
{
/// <summary>
/// Avalonia is rendered into a framebuffer.
/// </summary>
Software=1,
/// <summary>
/// Enables Glx rendering.
/// </summary>
Glx=2,
/// <summary>
/// Enables native Linux EGL rendering.
/// </summary>
Egl=3
}
/// <summary>
/// Platform-specific options which apply to Linux.
/// </summary>
publicclassX11PlatformOptions
{
/// <summary>
/// Enables native Linux EGL when set to true. The default value is false.
/// Gets or sets Avalonia rendering modes with fallbacks.
/// The first element in the array has the highest priority.
/// The default value is: <see cref="X11RenderingMode.Glx"/>, <see cref="X11RenderingMode.Software"/>.
/// </summary>
publicboolUseEGL{get;set;}
/// <summary>
/// Determines whether to use GPU for rendering in your project. The default value is true.
/// </summary>
publicboolUseGpu{get;set;}=true;
/// <remarks>
/// If application should work on as wide range of devices as possible, at least add <see cref="X11RenderingMode.Software"/> as a fallback value.
/// </remarks>
/// <exception cref="System.InvalidOperationException">Thrown if no values were matched.</exception>