using System; using System.Collections.Generic; using System.IO; using Avalonia.Media; using Avalonia.Media.Imaging; using Avalonia.Metadata; namespace Avalonia.Platform { /// /// Defines the main platform-specific interface for the rendering subsystem. /// [Unstable] public interface IPlatformRenderInterface { /// /// Creates an ellipse geometry implementation. /// /// The bounds of the ellipse. /// An ellipse geometry.. IGeometryImpl CreateEllipseGeometry(Rect rect); /// /// Creates a line geometry implementation. /// /// The start of the line. /// The end of the line. /// A line geometry. IGeometryImpl CreateLineGeometry(Point p1, Point p2); /// /// Creates a rectangle geometry implementation. /// /// The bounds of the rectangle. /// A rectangle. IGeometryImpl CreateRectangleGeometry(Rect rect); /// /// Creates a stream geometry implementation. /// /// An . IStreamGeometryImpl CreateStreamGeometry(); /// /// Creates a geometry group implementation. /// /// The fill rule. /// The geometries to group. /// A combined geometry. IGeometryImpl CreateGeometryGroup(FillRule fillRule, IReadOnlyList children); /// /// Creates a geometry group implementation. /// /// The combine mode /// The first geometry. /// The second geometry. /// A combined geometry. IGeometryImpl CreateCombinedGeometry(GeometryCombineMode combineMode, Geometry g1, Geometry g2); /// /// Created a geometry implementation for the glyph run. /// /// The glyph run to build a geometry from. /// The geometry returned contains the combined geometry of all glyphs in the glyph run. IGeometryImpl BuildGlyphRunGeometry(GlyphRun glyphRun); /// /// Creates a render target bitmap implementation. /// /// The size of the bitmap in device pixels. /// The DPI of the bitmap. /// An . IRenderTargetBitmapImpl CreateRenderTargetBitmap(PixelSize size, Vector dpi); /// /// Creates a writeable bitmap implementation. /// /// The size of the bitmap in device pixels. /// The DPI of the bitmap. /// Pixel format. /// Alpha format . /// An . IWriteableBitmapImpl CreateWriteableBitmap(PixelSize size, Vector dpi, PixelFormat format, AlphaFormat alphaFormat); /// /// Loads a bitmap implementation from a file.. /// /// The filename of the bitmap. /// An . IBitmapImpl LoadBitmap(string fileName); /// /// Loads a bitmap implementation from a file.. /// /// The stream to read the bitmap from. /// An . IBitmapImpl LoadBitmap(Stream stream); /// /// Loads a WriteableBitmap implementation from a stream to a specified width maintaining aspect ratio. /// /// The stream to read the bitmap from. /// The desired width of the resulting bitmap. /// The to use should resizing be required. /// An . IWriteableBitmapImpl LoadWriteableBitmapToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality); /// /// Loads a WriteableBitmap implementation from a stream to a specified height maintaining aspect ratio. /// /// The stream to read the bitmap from. /// The desired height of the resulting bitmap. /// The to use should resizing be required. /// An . IWriteableBitmapImpl LoadWriteableBitmapToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality); /// /// Loads a WriteableBitmap implementation from a file. /// /// The filename of the bitmap. /// An . IWriteableBitmapImpl LoadWriteableBitmap(string fileName); /// /// Loads a WriteableBitmap implementation from a file. /// /// The stream to read the bitmap from. /// An . IWriteableBitmapImpl LoadWriteableBitmap(Stream stream); /// /// Loads a bitmap implementation from a stream to a specified width maintaining aspect ratio. /// /// The stream to read the bitmap from. /// The desired width of the resulting bitmap. /// The to use should resizing be required. /// An . IBitmapImpl LoadBitmapToWidth(Stream stream, int width, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality); /// /// Loads a bitmap implementation from a stream to a specified height maintaining aspect ratio. /// /// The stream to read the bitmap from. /// The desired height of the resulting bitmap. /// The to use should resizing be required. /// An . IBitmapImpl LoadBitmapToHeight(Stream stream, int height, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality); IBitmapImpl ResizeBitmap(IBitmapImpl bitmapImpl, PixelSize destinationSize, BitmapInterpolationMode interpolationMode = BitmapInterpolationMode.HighQuality); /// /// Loads a bitmap implementation from a pixels in memory. /// /// The pixel format. /// The alpha format. /// The pointer to source bytes. /// The size of the bitmap in device pixels. /// The DPI of the bitmap. /// The number of bytes per row. /// An . IBitmapImpl LoadBitmap(PixelFormat format, AlphaFormat alphaFormat, IntPtr data, PixelSize size, Vector dpi, int stride); /// /// Creates a platform implementation of a glyph run. /// /// The glyph typeface. /// The font rendering em size. /// The glyph indices. /// The glyph advances. /// The glyph offsets. /// IGlyphRunImpl CreateGlyphRun(IGlyphTypeface glyphTypeface, double fontRenderingEmSize, IReadOnlyList glyphIndices, IReadOnlyList? glyphAdvances, IReadOnlyList? glyphOffsets); /// /// Creates a backend-specific object using a low-level API graphics context /// /// An underlying low-level graphics context (e. g. wrapped OpenGL context, Vulkan device, D3DDevice, etc) /// IPlatformRenderInterfaceContext CreateBackendContext(IPlatformGraphicsContext? graphicsApiContext); /// /// Gets a value indicating whether the platform directly supports rectangles with rounded corners. /// /// /// Some platform renderers can't directly handle rounded corners on rectangles. /// In this case, code that requires rounded corners must generate and retain a geometry instead. /// bool SupportsIndividualRoundRects { get; } /// /// Default used on this platform. /// public AlphaFormat DefaultAlphaFormat { get; } /// /// Default used on this platform. /// public PixelFormat DefaultPixelFormat { get; } } [Unstable] public interface IPlatformRenderInterfaceContext : IOptionalFeatureProvider, IDisposable { /// /// Creates a renderer. /// /// /// The list of native platform surfaces that can be used for output. /// /// An . IRenderTarget CreateRenderTarget(IEnumerable surfaces); /// /// Indicates that the context is no longer usable. This method should be thread-safe /// bool IsLost { get; } } }