|
|
@ -15,14 +15,25 @@ namespace Avalonia.Skia |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Skia platform render interface.
|
|
|
/// Skia platform render interface.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public class PlatformRenderInterface : IPlatformRenderInterface |
|
|
internal class PlatformRenderInterface : IPlatformRenderInterface |
|
|
{ |
|
|
{ |
|
|
|
|
|
private readonly ICustomSkiaGpu _customSkiaGpu; |
|
|
|
|
|
|
|
|
private GRContext GrContext { get; } |
|
|
private GRContext GrContext { get; } |
|
|
|
|
|
|
|
|
public IEnumerable<string> InstalledFontNames => SKFontManager.Default.FontFamilies; |
|
|
public IEnumerable<string> InstalledFontNames => SKFontManager.Default.FontFamilies; |
|
|
|
|
|
|
|
|
public PlatformRenderInterface() |
|
|
public PlatformRenderInterface(ICustomSkiaGpu customSkiaGpu) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (customSkiaGpu != null) |
|
|
|
|
|
{ |
|
|
|
|
|
_customSkiaGpu = customSkiaGpu; |
|
|
|
|
|
|
|
|
|
|
|
GrContext = _customSkiaGpu.GrContext; |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var gl = AvaloniaLocator.Current.GetService<IWindowingPlatformGlFeature>(); |
|
|
var gl = AvaloniaLocator.Current.GetService<IWindowingPlatformGlFeature>(); |
|
|
if (gl != null) |
|
|
if (gl != null) |
|
|
{ |
|
|
{ |
|
|
@ -32,12 +43,11 @@ namespace Avalonia.Skia |
|
|
? GRGlInterface.AssembleGlInterface((_, proc) => display.GlInterface.GetProcAddress(proc)) |
|
|
? GRGlInterface.AssembleGlInterface((_, proc) => display.GlInterface.GetProcAddress(proc)) |
|
|
: GRGlInterface.AssembleGlesInterface((_, proc) => display.GlInterface.GetProcAddress(proc))) |
|
|
: GRGlInterface.AssembleGlesInterface((_, proc) => display.GlInterface.GetProcAddress(proc))) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
GrContext = GRContext.Create(GRBackend.OpenGL, iface); |
|
|
GrContext = GRContext.Create(GRBackend.OpenGL, iface); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
public IFormattedTextImpl CreateFormattedText( |
|
|
public IFormattedTextImpl CreateFormattedText( |
|
|
string text, |
|
|
string text, |
|
|
@ -98,13 +108,23 @@ namespace Avalonia.Skia |
|
|
DisableTextLcdRendering = false, |
|
|
DisableTextLcdRendering = false, |
|
|
GrContext = GrContext |
|
|
GrContext = GrContext |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
return new SurfaceRenderTarget(createInfo); |
|
|
return new SurfaceRenderTarget(createInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
/// <inheritdoc />
|
|
|
public virtual IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces) |
|
|
public IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces) |
|
|
{ |
|
|
{ |
|
|
|
|
|
if (_customSkiaGpu != null) |
|
|
|
|
|
{ |
|
|
|
|
|
ICustomSkiaRenderTarget customRenderTarget = _customSkiaGpu.TryCreateRenderTarget(surfaces); |
|
|
|
|
|
|
|
|
|
|
|
if (customRenderTarget != null) |
|
|
|
|
|
{ |
|
|
|
|
|
return new CustomRenderTarget(customRenderTarget); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
foreach (var surface in surfaces) |
|
|
foreach (var surface in surfaces) |
|
|
{ |
|
|
{ |
|
|
if (surface is IGlPlatformSurface glSurface && GrContext != null) |
|
|
if (surface is IGlPlatformSurface glSurface && GrContext != null) |
|
|
|