IPlatformRenderInterface.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright (c) The Avalonia Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using Avalonia.Media;
  7. namespace Avalonia.Platform
  8. {
  9. /// <summary>
  10. /// Defines the main platform-specific interface for the rendering subsystem.
  11. /// </summary>
  12. public interface IPlatformRenderInterface
  13. {
  14. /// <summary>
  15. /// Creates a formatted text implementation.
  16. /// </summary>
  17. /// <param name="text">The text.</param>
  18. /// <param name="typeface">The base typeface.</param>
  19. /// <param name="fontSize">The font size.</param>
  20. /// <param name="textAlignment">The text alignment.</param>
  21. /// <param name="wrapping">The text wrapping mode.</param>
  22. /// <param name="constraint">The text layout constraints.</param>
  23. /// <param name="spans">The style spans.</param>
  24. /// <returns>An <see cref="IFormattedTextImpl"/>.</returns>
  25. IFormattedTextImpl CreateFormattedText(
  26. string text,
  27. Typeface typeface,
  28. double fontSize,
  29. TextAlignment textAlignment,
  30. TextWrapping wrapping,
  31. Size constraint,
  32. IReadOnlyList<FormattedTextStyleSpan> spans);
  33. /// <summary>
  34. /// Creates an ellipse geometry implementation.
  35. /// </summary>
  36. /// <param name="rect">The bounds of the ellipse.</param>
  37. /// <returns>An ellipse geometry..</returns>
  38. IGeometryImpl CreateEllipseGeometry(Rect rect);
  39. /// <summary>
  40. /// Creates a line geometry implementation.
  41. /// </summary>
  42. /// <param name="p1">The start of the line.</param>
  43. /// <param name="p2">The end of the line.</param>
  44. /// <returns>A line geometry.</returns>
  45. IGeometryImpl CreateLineGeometry(Point p1, Point p2);
  46. /// <summary>
  47. /// Creates a rectangle geometry implementation.
  48. /// </summary>
  49. /// <param name="rect">The bounds of the rectangle.</param>
  50. /// <returns>A rectangle.</returns>
  51. IGeometryImpl CreateRectangleGeometry(Rect rect);
  52. /// <summary>
  53. /// Creates a stream geometry implementation.
  54. /// </summary>
  55. /// <returns>An <see cref="IStreamGeometryImpl"/>.</returns>
  56. IStreamGeometryImpl CreateStreamGeometry();
  57. /// <summary>
  58. /// Creates a renderer.
  59. /// </summary>
  60. /// <param name="surfaces">
  61. /// The list of native platform surfaces that can be used for output.
  62. /// </param>
  63. /// <returns>An <see cref="IRenderTarget"/>.</returns>
  64. IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces);
  65. /// <summary>
  66. /// Creates a render target bitmap implementation.
  67. /// </summary>
  68. /// <param name="size">The size of the bitmap in device pixels.</param>
  69. /// <param name="dpi">The DPI of the bitmap.</param>
  70. /// <returns>An <see cref="IRenderTargetBitmapImpl"/>.</returns>
  71. IRenderTargetBitmapImpl CreateRenderTargetBitmap(PixelSize size, Vector dpi);
  72. /// <summary>
  73. /// Creates a writeable bitmap implementation.
  74. /// </summary>
  75. /// <param name="size">The size of the bitmap in device pixels.</param>
  76. /// <param name="dpi">The DPI of the bitmap.</param>
  77. /// <param name="format">Pixel format (optional).</param>
  78. /// <returns>An <see cref="IWriteableBitmapImpl"/>.</returns>
  79. IWriteableBitmapImpl CreateWriteableBitmap(PixelSize size, Vector dpi, PixelFormat? format = null);
  80. /// <summary>
  81. /// Loads a bitmap implementation from a file..
  82. /// </summary>
  83. /// <param name="fileName">The filename of the bitmap.</param>
  84. /// <returns>An <see cref="IBitmapImpl"/>.</returns>
  85. IBitmapImpl LoadBitmap(string fileName);
  86. /// <summary>
  87. /// Loads a bitmap implementation from a file..
  88. /// </summary>
  89. /// <param name="stream">The stream to read the bitmap from.</param>
  90. /// <returns>An <see cref="IBitmapImpl"/>.</returns>
  91. IBitmapImpl LoadBitmap(Stream stream);
  92. /// <summary>
  93. /// Loads a bitmap implementation from a pixels in memory.
  94. /// </summary>
  95. /// <param name="format">The pixel format.</param>
  96. /// <param name="data">The pointer to source bytes.</param>
  97. /// <param name="size">The size of the bitmap in device pixels.</param>
  98. /// <param name="dpi">The DPI of the bitmap.</param>
  99. /// <param name="stride">The number of bytes per row.</param>
  100. /// <returns>An <see cref="IBitmapImpl"/>.</returns>
  101. IBitmapImpl LoadBitmap(PixelFormat format, IntPtr data, PixelSize size, Vector dpi, int stride);
  102. /// <summary>
  103. /// Creates a platform implementation of a glyph run.
  104. /// </summary>
  105. /// <param name="glyphRun">The glyph run.</param>
  106. /// <param name="width">The glyph run's width.</param>
  107. /// <returns></returns>
  108. IGlyphRunImpl CreateGlyphRun(GlyphRun glyphRun, out double width);
  109. }
  110. }