The managed SkiaSharp now builds again.

This commit is contained in:
Matthew Leibowitz 2018-07-08 00:12:16 +02:00
Родитель 7f35c022d5
Коммит f2a51f8ae9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3650EBE4AA155AF9
22 изменённых файлов: 987 добавлений и 908 удалений

Просмотреть файл

@ -9,15 +9,17 @@ namespace SkiaSharp
public enum SKCodecResult {
Success,
IncompleteInput,
ErrorInInput,
InvalidConversion,
InvalidScale,
InvalidParameters,
InvalidInput,
CouldNotRewind,
InternalError,
Unimplemented,
}
public enum SKCodecOrigin {
public enum SKEncodedOrigin {
TopLeft = 1,
TopRight = 2,
BottomRight = 3,
@ -26,6 +28,7 @@ namespace SkiaSharp
RightTop = 6,
RightBottom = 7,
LeftBottom = 8,
Default = TopLeft,
}
public enum SKEncodedImageFormat {
@ -42,14 +45,6 @@ namespace SkiaSharp
Dng,
}
[Flags]
public enum SKTypefaceStyle {
Normal = 0,
Bold = 0x01,
Italic = 0x02,
BoldItalic = 0x03
}
public enum SKFontStyleWeight {
Invisible = 0,
Thin = 100,
@ -118,8 +113,10 @@ namespace SkiaSharp
Rgb565,
Argb4444,
Rgba8888,
Rgb888x,
Bgra8888,
Index8,
Rgba1010102,
Rgb101010x,
Gray8,
RgbaF16
}
@ -139,14 +136,6 @@ namespace SkiaSharp
Normal, Solid, Outer, Inner
}
[Flags]
public enum SKBlurMaskFilterFlags {
None = 0x00,
IgnoreTransform = 0x01,
HighQuality = 0x02,
All = IgnoreTransform | HighQuality,
}
public enum SKBlendMode {
Clear,
Src,
@ -187,14 +176,6 @@ namespace SkiaSharp
BgrVertical
}
public enum SKBitmapResizeMethod {
Box,
Triangle,
Lanczos3,
Hamming,
Mitchell
}
[Flags]
public enum SKSurfacePropsFlags {
None = 0,
@ -205,7 +186,7 @@ namespace SkiaSharp
Utf8, Utf16, Utf32
}
public static class SkiaExtensions {
public static partial class SkiaExtensions {
public static bool IsBgr (this SKPixelGeometry pg)
{
return pg == SKPixelGeometry.BgrHorizontal || pg == SKPixelGeometry.BgrVertical;
@ -353,7 +334,7 @@ namespace SkiaSharp
public SKZeroInitialized fZeroInitialized;
public SKRectI* fSubset;
public int fFrameIndex;
public byte fHasPriorFrame;
public int fPriorFrame;
public SKTransferFunctionBehavior fPremulBehavior;
public static unsafe SKCodecOptionsInternal FromManaged (ref SKCodecOptions managed)
@ -362,7 +343,7 @@ namespace SkiaSharp
fZeroInitialized = managed.ZeroInitialized,
fSubset = null,
fFrameIndex = managed.FrameIndex,
fHasPriorFrame = managed.HasPriorFrame ? (byte) 1 : (byte) 0,
fPriorFrame = managed.PriorFrame,
fPremulBehavior = managed.PremulBehavior,
};
if (managed.HasSubset) {
@ -384,44 +365,51 @@ namespace SkiaSharp
ZeroInitialized = zeroInitialized;
Subset = null;
FrameIndex = 0;
HasPriorFrame = false;
PriorFrame = 0;
PremulBehavior = SKTransferFunctionBehavior.Respect;
}
public SKCodecOptions (SKZeroInitialized zeroInitialized, SKRectI subset) {
ZeroInitialized = zeroInitialized;
Subset = subset;
FrameIndex = 0;
HasPriorFrame = false;
PriorFrame = 0;
PremulBehavior = SKTransferFunctionBehavior.Respect;
}
public SKCodecOptions (SKRectI subset) {
ZeroInitialized = SKZeroInitialized.No;
Subset = subset;
FrameIndex = 0;
HasPriorFrame = false;
PriorFrame = 0;
PremulBehavior = SKTransferFunctionBehavior.Respect;
}
public SKCodecOptions (int frameIndex, bool hasPriorFrame) {
public SKCodecOptions (int frameIndex, int priorFrame) {
ZeroInitialized = SKZeroInitialized.No;
Subset = null;
FrameIndex = frameIndex;
HasPriorFrame = hasPriorFrame;
PriorFrame = priorFrame;
PremulBehavior = SKTransferFunctionBehavior.Respect;
}
public SKZeroInitialized ZeroInitialized { get; set; }
public SKRectI? Subset { get; set; }
public bool HasSubset => Subset != null;
public int FrameIndex { get; set; }
public bool HasPriorFrame { get; set; }
public int PriorFrame { get; set; }
public SKTransferFunctionBehavior PremulBehavior { get; set; }
}
public enum SKCodecAnimationDisposalMethod {
Keep = 1,
RestoreBackgroundColor = 2,
ResturePrevious = 3,
}
[StructLayout(LayoutKind.Sequential)]
public struct SKCodecFrameInfo {
private int requiredFrame;
private int duration;
private byte fullyRecieved;
private SKAlphaType alphaType;
private SKCodecAnimationDisposalMethod disposalMethod;
public int RequiredFrame {
get { return requiredFrame; }
@ -442,6 +430,11 @@ namespace SkiaSharp
get { return alphaType; }
set { alphaType = value; }
}
public SKCodecAnimationDisposalMethod DisposalMethod {
get { return disposalMethod; }
set { disposalMethod = value; }
}
}
[StructLayout(LayoutKind.Sequential)]
@ -1562,6 +1555,11 @@ namespace SkiaSharp
[StructLayout(LayoutKind.Sequential)]
public struct SKFontMetrics
{
private const uint flagsUnderlineThicknessIsValid = (1U << 0);
private const uint flagsUnderlinePositionIsValid = (1U << 1);
private const uint flagsStrikeoutThicknessIsValid = (1U << 2);
private const uint flagsStrikeoutPositionIsValid = (1U << 3);
uint flags; // Bit field to identify which values are unknown
float top; // The greatest distance above the baseline for any glyph (will be <= 0)
float ascent; // The recommended distance above the baseline (will be <= 0)
@ -1576,9 +1574,8 @@ namespace SkiaSharp
float capHeight; // The cap height (> 0), or 0 if cannot be determined.
float underlineThickness; // underline thickness, or 0 if cannot be determined
float underlinePosition; // underline position, or 0 if cannot be determined
const uint flagsUnderlineThicknessIsValid = (1U << 0);
const uint flagsUnderlinePositionIsValid = (1U << 1);
float strikeoutThickness;
float strikeoutPosition;
public float Top
{
@ -1635,24 +1632,17 @@ namespace SkiaSharp
get { return capHeight; }
}
public float? UnderlineThickness
{
get {
if ((flags & flagsUnderlineThicknessIsValid) != 0)
return underlineThickness;
else
return null;
}
}
public float? UnderlineThickness => GetIfValid(underlineThickness, flagsUnderlineThicknessIsValid);
public float? UnderlinePosition => GetIfValid(underlinePosition, flagsUnderlinePositionIsValid);
public float? StrikeoutThickness => GetIfValid(strikeoutThickness, flagsStrikeoutThicknessIsValid);
public float? StrikeoutPosition => GetIfValid(strikeoutPosition, flagsStrikeoutPositionIsValid);
public float? UnderlinePosition
private float? GetIfValid(float value, uint flag)
{
get {
if ((flags & flagsUnderlinePositionIsValid) != 0)
return underlinePosition;
else
return null;
}
if ((flags & flag) == flag)
return value;
else
return null;
}
}
@ -1670,26 +1660,29 @@ namespace SkiaSharp
Concave,
};
public enum SKLatticeFlags {
public enum SKLatticeRectType {
Default,
Transparent = 1 << 0,
Transparent,
FixedColor,
};
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct SKLatticeInternal {
public int* fXDivs;
public int* fYDivs;
public SKLatticeFlags* fFlags;
public SKLatticeRectType* fRectTypes;
public int fXCount;
public int fYCount;
public SKRectI* fBounds;
public SKColor* fColors;
}
public struct SKLattice {
public int[] XDivs { get; set; }
public int[] YDivs { get; set; }
public SKLatticeFlags[] Flags { get; set; }
public SKLatticeRectType[] RectTypes { get; set; }
public SKRectI? Bounds { get; set; }
public SKColor[] Colors { get; set; }
}
[StructLayout(LayoutKind.Sequential)]
@ -1741,129 +1734,6 @@ namespace SkiaSharp
public DateTime? Modified { get; set; }
}
public struct SKEncodedInfo {
private SKEncodedInfoColor color;
private SKEncodedInfoAlpha alpha;
private byte bitsPerComponent;
public SKEncodedInfo (SKEncodedInfoColor color) {
this.color = color;
this.bitsPerComponent = 8;
switch (color) {
case SKEncodedInfoColor.Gray:
case SKEncodedInfoColor.Rgb:
case SKEncodedInfoColor.Bgr:
case SKEncodedInfoColor.Bgrx:
case SKEncodedInfoColor.Yuv:
case SKEncodedInfoColor.InvertedCmyk:
case SKEncodedInfoColor.Ycck:
this.alpha = SKEncodedInfoAlpha.Opaque;
break;
case SKEncodedInfoColor.GrayAlpha:
case SKEncodedInfoColor.Palette:
case SKEncodedInfoColor.Rgba:
case SKEncodedInfoColor.Bgra:
case SKEncodedInfoColor.Yuva:
this.alpha = SKEncodedInfoAlpha.Unpremul;
break;
default:
throw new ArgumentOutOfRangeException (nameof (color));
}
}
public SKEncodedInfo (SKEncodedInfoColor color, SKEncodedInfoAlpha alpha, byte bitsPerComponent) {
if (bitsPerComponent != 1 && bitsPerComponent != 2 && bitsPerComponent != 4 && bitsPerComponent != 8 && bitsPerComponent != 16) {
throw new ArgumentException ("The bits per component must be 1, 2, 4, 8 or 16.", nameof (bitsPerComponent));
}
switch (color) {
case SKEncodedInfoColor.Gray:
if (alpha != SKEncodedInfoAlpha.Opaque)
throw new ArgumentException ("The alpha must be opaque.", nameof (alpha));
break;
case SKEncodedInfoColor.GrayAlpha:
if (alpha == SKEncodedInfoAlpha.Opaque)
throw new ArgumentException ("The alpha must not be opaque.", nameof (alpha));
break;
case SKEncodedInfoColor.Palette:
if (bitsPerComponent == 16)
throw new ArgumentException ("The bits per component must be 1, 2, 4 or 8.", nameof (bitsPerComponent));
break;
case SKEncodedInfoColor.Rgb:
case SKEncodedInfoColor.Bgr:
case SKEncodedInfoColor.Bgrx:
if (alpha != SKEncodedInfoAlpha.Opaque)
throw new ArgumentException ("The alpha must be opaque.", nameof (alpha));
if (bitsPerComponent < 8)
throw new ArgumentException ("The bits per component must be 8 or 16.", nameof (bitsPerComponent));
break;
case SKEncodedInfoColor.Yuv:
case SKEncodedInfoColor.InvertedCmyk:
case SKEncodedInfoColor.Ycck:
if (alpha != SKEncodedInfoAlpha.Opaque)
throw new ArgumentException ("The alpha must be opaque.", nameof (alpha));
if (bitsPerComponent != 8)
throw new ArgumentException ("The bits per component must be 8.", nameof (bitsPerComponent));
break;
case SKEncodedInfoColor.Rgba:
if (alpha == SKEncodedInfoAlpha.Opaque)
throw new ArgumentException ("The alpha must not be opaque.", nameof (alpha));
if (bitsPerComponent < 8)
throw new ArgumentException ("The bits per component must be 8 or 16.", nameof (bitsPerComponent));
break;
case SKEncodedInfoColor.Bgra:
case SKEncodedInfoColor.Yuva:
if (alpha == SKEncodedInfoAlpha.Opaque)
throw new ArgumentException ("The alpha must not be opaque.", nameof (alpha));
if (bitsPerComponent != 8)
throw new ArgumentException ("The bits per component must be 8.", nameof (bitsPerComponent));
break;
default:
throw new ArgumentOutOfRangeException (nameof (color));
}
this.color = color;
this.alpha = alpha;
this.bitsPerComponent = bitsPerComponent;
}
public SKEncodedInfoColor Color => color;
public SKEncodedInfoAlpha Alpha => alpha;
public byte BitsPerComponent => bitsPerComponent;
public byte BitsPerPixel {
get {
switch (color) {
case SKEncodedInfoColor.Gray:
return bitsPerComponent;
case SKEncodedInfoColor.GrayAlpha:
return (byte)(2 * bitsPerComponent);
case SKEncodedInfoColor.Palette:
return bitsPerComponent;
case SKEncodedInfoColor.Rgb:
case SKEncodedInfoColor.Bgr:
case SKEncodedInfoColor.Yuv:
return (byte)(3 * bitsPerComponent);
case SKEncodedInfoColor.Rgba:
case SKEncodedInfoColor.Bgra:
case SKEncodedInfoColor.Bgrx:
case SKEncodedInfoColor.Yuva:
case SKEncodedInfoColor.InvertedCmyk:
case SKEncodedInfoColor.Ycck:
return (byte)(4 * bitsPerComponent);
default:
return (byte)0;
}
}
}
}
public enum SKEncodedInfoAlpha {
Opaque,
Unpremul,
Binary,
}
public enum SKColorSpaceGamut {
Srgb,
AdobeRgb,
@ -1882,21 +1752,6 @@ namespace SkiaSharp
Srgb,
}
public enum SKEncodedInfoColor {
Gray,
GrayAlpha,
Palette,
Rgb,
Rgba,
Bgr,
Bgrx,
Bgra,
Yuv,
Yuva,
InvertedCmyk,
Ycck,
}
public enum SKMaskFormat {
BW,
A8,
@ -1993,6 +1848,7 @@ namespace SkiaSharp
private SKPngEncoderFilterFlags fFilterFlags;
private int fZLibLevel;
private SKTransferFunctionBehavior fUnpremulBehavior;
private IntPtr fComments; // TODO: get and set comments
public static readonly SKPngEncoderOptions Default;
@ -2006,6 +1862,7 @@ namespace SkiaSharp
fFilterFlags = filterFlags;
fZLibLevel = zLibLevel;
fUnpremulBehavior = SKTransferFunctionBehavior.Respect;
fComments = IntPtr.Zero;
}
public SKPngEncoderOptions (SKPngEncoderFilterFlags filterFlags, int zLibLevel, SKTransferFunctionBehavior unpremulBehavior)
@ -2013,6 +1870,7 @@ namespace SkiaSharp
fFilterFlags = filterFlags;
fZLibLevel = zLibLevel;
fUnpremulBehavior = unpremulBehavior;
fComments = IntPtr.Zero;
}
public SKPngEncoderFilterFlags FilterFlags {

Просмотреть файл

@ -0,0 +1,72 @@
using System;
namespace SkiaSharp
{
public class GRBackendRenderTarget : SKObject
{
[Preserve]
internal GRBackendRenderTarget (IntPtr handle, bool owns)
: base (handle, owns)
{
}
public GRBackendRenderTarget (GRBackend backend, GRBackendRenderTargetDesc desc)
: this (IntPtr.Zero, true)
{
switch (backend) {
case GRBackend.Metal:
throw new NotSupportedException ();
case GRBackend.OpenGL:
var glInfo = new GRGlFramebufferInfo ((uint)desc.RenderTargetHandle);
CreateGl (desc.Width, desc.Height, desc.SampleCount, desc.StencilBits, glInfo);
break;
case GRBackend.Vulkan:
throw new NotSupportedException ();
default:
throw new ArgumentOutOfRangeException (nameof(backend));
}
}
public GRBackendRenderTarget (int width, int height, int sampleCount, int stencilBits, GRGlFramebufferInfo glInfo)
: this (IntPtr.Zero, true)
{
CreateGl (width, height, sampleCount, stencilBits, glInfo);
}
private void CreateGl (int width, int height, int sampleCount, int stencilBits, GRGlFramebufferInfo glInfo)
{
Handle = SkiaApi.gr_backendrendertarget_new_gl (width, height, sampleCount, stencilBits, ref glInfo);
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException ("Unable to create a new GRBackendRenderTarget instance.");
}
}
protected override void Dispose (bool disposing)
{
if (Handle != IntPtr.Zero && OwnsHandle) {
SkiaApi.gr_backendrendertarget_delete (Handle);
}
base.Dispose (disposing);
}
public bool IsValid => SkiaApi.gr_backendrendertarget_is_valid (Handle);
public int Width => SkiaApi.gr_backendrendertarget_get_width (Handle);
public int Height => SkiaApi.gr_backendrendertarget_get_height (Handle);
public int SampleCount => SkiaApi.gr_backendrendertarget_get_samples (Handle);
public int StencilBits => SkiaApi.gr_backendrendertarget_get_stencils (Handle);
public GRBackend Backend => SkiaApi.gr_backendrendertarget_get_backend (Handle);
public GRGlFramebufferInfo GetGlFramebufferInfo ()
{
if (GetGlFramebufferInfo (out var info))
return info;
return default (GRGlFramebufferInfo);
}
public bool GetGlFramebufferInfo (out GRGlFramebufferInfo glInfo)
{
return SkiaApi.gr_backendrendertarget_get_gl_framebufferinfo (Handle, out glInfo);
}
}
}

Просмотреть файл

@ -0,0 +1,61 @@
using System;
namespace SkiaSharp
{
public class GRBackendTexture : SKObject
{
[Preserve]
internal GRBackendTexture (IntPtr handle, bool owns)
: base (handle, owns)
{
}
public GRBackendTexture (GRGlBackendTextureDesc desc)
: this (IntPtr.Zero, true)
{
var glInfo = new GRGlTextureInfo (desc.TextureHandle.Target, desc.TextureHandle.Id, desc.TextureHandle.Format);
CreateGl (desc.Width, desc.Height, false, glInfo);
}
public GRBackendTexture (int width, int height, bool mipmapped, GRGlTextureInfo glInfo)
: this (IntPtr.Zero, true)
{
CreateGl (width, height, mipmapped, glInfo);
}
private void CreateGl (int width, int height, bool mipmapped, GRGlTextureInfo glInfo)
{
Handle = SkiaApi.gr_backendtexture_new_gl (width, height, mipmapped, ref glInfo);
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException ("Unable to create a new GRBackendTexture instance.");
}
}
protected override void Dispose (bool disposing)
{
if (Handle != IntPtr.Zero && OwnsHandle) {
SkiaApi.gr_backendtexture_delete (Handle);
}
base.Dispose (disposing);
}
public bool IsValid => SkiaApi.gr_backendtexture_is_valid (Handle);
public int Width => SkiaApi.gr_backendtexture_get_width (Handle);
public int Height => SkiaApi.gr_backendtexture_get_height (Handle);
public bool HasMipMaps => SkiaApi.gr_backendtexture_has_mipmaps (Handle);
public GRBackend Backend => SkiaApi.gr_backendtexture_get_backend (Handle);
public GRGlTextureInfo GetGlTextureInfo ()
{
if (GetGlTextureInfo (out var info))
return info;
return default (GRGlTextureInfo);
}
public bool GetGlTextureInfo (out GRGlTextureInfo glInfo)
{
return SkiaApi.gr_backendtexture_get_gl_textureinfo (Handle, out glInfo);
}
}
}

Просмотреть файл

@ -12,35 +12,44 @@ namespace SkiaSharp
public static GRContext Create (GRBackend backend)
{
return Create (backend, IntPtr.Zero);
}
public static GRContext Create (GRBackend backend, IntPtr backendContext)
{
return GetObject<GRContext> (SkiaApi.gr_context_create_with_defaults (backend, backendContext));
switch (backend) {
case GRBackend.Metal:
throw new NotSupportedException ();
case GRBackend.OpenGL:
return CreateGl ();
case GRBackend.Vulkan:
throw new NotSupportedException ();
default:
throw new ArgumentOutOfRangeException (nameof (backend));
}
}
public static GRContext Create (GRBackend backend, GRGlInterface backendContext)
{
if (backendContext == null) {
throw new ArgumentNullException (nameof (backendContext));
switch (backend) {
case GRBackend.Metal:
throw new NotSupportedException ();
case GRBackend.OpenGL:
return CreateGl (backendContext);
case GRBackend.Vulkan:
throw new NotSupportedException ();
default:
throw new ArgumentOutOfRangeException (nameof (backend));
}
return GetObject<GRContext> (SkiaApi.gr_context_create_with_defaults (backend, backendContext.Handle));
}
public static GRContext Create (GRBackend backend, IntPtr backendContext, GRContextOptions options)
public static GRContext CreateGl ()
{
return GetObject<GRContext> (SkiaApi.gr_context_create (backend, backendContext, ref options));
return CreateGl (null);
}
public static GRContext Create (GRBackend backend, GRGlInterface backendContext, GRContextOptions options)
public static GRContext CreateGl (GRGlInterface backendContext)
{
if (backendContext == null) {
throw new ArgumentNullException (nameof (backendContext));
}
return GetObject<GRContext> (SkiaApi.gr_context_create (backend, backendContext.Handle, ref options));
return GetObject<GRContext> (SkiaApi.gr_context_make_gl (backendContext == null ? IntPtr.Zero : backendContext.Handle));
}
public GRBackend Backend => SkiaApi.gr_context_get_backend (Handle);
public void AbandonContext (bool releaseResources = false)
{
if (releaseResources) {
@ -89,9 +98,9 @@ namespace SkiaSharp
SkiaApi.gr_context_flush (Handle);
}
public int GetRecommendedSampleCount (GRPixelConfig config, float dpi)
public int GetMaxSurfaceSampleCountForColorType (SKColorType colorType)
{
return SkiaApi.gr_context_get_recommended_sample_count (Handle, config, dpi);
return SkiaApi.gr_context_get_max_surface_sample_count_for_color_type (Handle, colorType);
}
protected override void Dispose (bool disposing)

Просмотреть файл

@ -2,13 +2,12 @@
using System.Runtime.InteropServices;
using GRBackendObject = System.IntPtr;
using GRBackendContext = System.IntPtr;
namespace SkiaSharp
{
public enum GRSurfaceOrigin
{
TopLeft = 1,
TopLeft,
BottomLeft,
}
@ -20,61 +19,34 @@ namespace SkiaSharp
Rgb565,
Rgba4444,
Rgba8888,
Rgb888,
Bgra8888,
Srgba8888,
Sbgra8888,
Rgba8888SInt,
Rgba1010102,
RgbaFloat,
RgFloat,
AlphaHalf,
RgbaHalf,
}
[StructLayout (LayoutKind.Sequential)]
[Obsolete("Use GRBackendRenderTarget instead.")]
public struct GRBackendRenderTargetDesc
{
private int width;
private int height;
private GRPixelConfig config;
private GRSurfaceOrigin origin;
private int sampleCount;
private int stencilBits;
private GRBackendObject renderTargetHandle;
public int Width {
get { return width; }
set { width = value; }
}
public int Height {
get { return height; }
set { height = value; }
}
public GRPixelConfig Config {
get { return config; }
set { config = value; }
}
public GRSurfaceOrigin Origin {
get { return origin; }
set { origin = value; }
}
public int SampleCount {
get { return sampleCount; }
set { sampleCount = value; }
}
public int StencilBits {
get { return stencilBits; }
set { stencilBits = value; }
}
public GRBackendObject RenderTargetHandle {
get { return renderTargetHandle; }
set { renderTargetHandle = value; }
}
public SKSizeI Size => new SKSizeI (width, height);
public SKRectI Rect => new SKRectI (0, 0, width, height);
public int Width { get; set; }
public int Height { get; set; }
public GRPixelConfig Config { get; set; }
public GRSurfaceOrigin Origin { get; set; }
public int SampleCount { get; set; }
public int StencilBits { get; set; }
public GRBackendObject RenderTargetHandle { get; set; }
public SKSizeI Size => new SKSizeI (Width, Height);
public SKRectI Rect => new SKRectI (0, 0, Width, Height);
}
public enum GRBackend
{
Metal,
OpenGL,
Vulkan,
}
@ -105,11 +77,32 @@ namespace SkiaSharp
All = 0xffffffff,
}
[Flags]
public enum GRBackendTextureDescFlags
[StructLayout (LayoutKind.Sequential)]
public struct GRGlFramebufferInfo
{
None = 0,
RenderTarget = 1,
private uint fboId;
private uint format;
public GRGlFramebufferInfo (uint fboId)
{
this.fboId = fboId;
this.format = 0;
}
public GRGlFramebufferInfo (uint fboId, uint format)
{
this.fboId = fboId;
this.format = format;
}
public uint FramebufferObjectId {
get => fboId;
set => fboId = value;
}
public uint Format {
get => format;
set => format = value;
}
}
[StructLayout (LayoutKind.Sequential)]
@ -117,6 +110,14 @@ namespace SkiaSharp
{
private uint fTarget;
private uint fID;
private uint fFormat;
public GRGlTextureInfo (uint target, uint id, uint format)
{
fTarget = target;
fID = id;
fFormat = format;
}
public uint Target {
get { return fTarget; }
@ -126,52 +127,15 @@ namespace SkiaSharp
get { return fID; }
set { fID = value; }
}
public uint Format {
get { return fFormat; }
set { fFormat = value; }
}
};
[StructLayout (LayoutKind.Sequential)]
public struct GRBackendTextureDesc
{
private GRBackendTextureDescFlags flags;
private GRSurfaceOrigin origin;
private int width;
private int height;
private GRPixelConfig config;
private int sampleCount;
private GRBackendObject textureHandle;
public GRBackendTextureDescFlags Flags {
get { return flags; }
set { flags = value; }
}
public GRSurfaceOrigin Origin {
get { return origin; }
set { origin = value; }
}
public int Width {
get { return width; }
set { width = value; }
}
public int Height {
get { return height; }
set { height = value; }
}
public GRPixelConfig Config {
get { return config; }
set { config = value; }
}
public int SampleCount {
get { return sampleCount; }
set { sampleCount = value; }
}
public GRBackendObject TextureHandle {
get { return textureHandle; }
set { textureHandle = value; }
}
}
[Obsolete("Use GRBackendTexture instead.")]
public struct GRGlBackendTextureDesc
{
public GRBackendTextureDescFlags Flags { get; set; }
public GRSurfaceOrigin Origin { get; set; }
public int Width { get; set; }
public int Height { get; set; }
@ -180,139 +144,43 @@ namespace SkiaSharp
public GRGlTextureInfo TextureHandle { get; set; }
}
public enum GRContextOptionsGpuPathRenderers
public static partial class SkiaExtensions
{
None = 0,
DashLine = 1 << 0,
StencilAndCover = 1 << 1,
Msaa = 1 << 2,
AaHairline = 1 << 3,
AaConvex = 1 << 4,
AaLinearizing = 1 << 5,
Small = 1 << 6,
Tessellating = 1 << 7,
Default = 1 << 8,
All = GRContextOptionsGpuPathRenderers.Default | (GRContextOptionsGpuPathRenderers.Default - 1)
}
[StructLayout (LayoutKind.Sequential)]
public struct GRContextOptions
{
private byte fSuppressPrints;
private int fMaxTextureSizeOverride;
private int fMaxTileSizeOverride;
private byte fSuppressDualSourceBlending;
private int fBufferMapThreshold;
private byte fUseDrawInsteadOfPartialRenderTargetWrite;
private byte fImmediateMode;
private byte fUseShaderSwizzling;
private byte fDoManualMipmapping;
private byte fEnableInstancedRendering;
private byte fAllowPathMaskCaching;
private byte fRequireDecodeDisableForSRGB;
private byte fDisableGpuYUVConversion;
private byte fSuppressPathRendering;
private byte fWireframeMode;
private GRContextOptionsGpuPathRenderers fGpuPathRenderers;
private float fGlyphCacheTextureMaximumBytes;
private byte fAvoidStencilBuffers;
public bool SuppressPrints {
get { return fSuppressPrints != 0; }
set { fSuppressPrints = value ? (byte)1 : (byte)0; }
}
public int MaxTextureSizeOverride {
get { return fMaxTextureSizeOverride; }
set { fMaxTextureSizeOverride = value; }
}
public int MaxTileSizeOverride {
get { return fMaxTileSizeOverride; }
set { fMaxTileSizeOverride = value; }
}
public bool SuppressDualSourceBlending {
get { return fSuppressDualSourceBlending != 0; }
set { fSuppressDualSourceBlending = value ? (byte)1 : (byte)0; }
}
public int BufferMapThreshold {
get { return fBufferMapThreshold; }
set { fBufferMapThreshold = value; }
}
public bool UseDrawInsteadOfPartialRenderTargetWrite {
get { return fUseDrawInsteadOfPartialRenderTargetWrite != 0; }
set { fUseDrawInsteadOfPartialRenderTargetWrite = value ? (byte)1 : (byte)0; }
}
public bool ImmediateMode {
get { return fImmediateMode != 0; }
set { fImmediateMode = value ? (byte)1 : (byte)0; }
}
public bool UseShaderSwizzling {
get { return fUseShaderSwizzling != 0; }
set { fUseShaderSwizzling = value ? (byte)1 : (byte)0; }
}
public bool DoManualMipmapping {
get { return fDoManualMipmapping != 0; }
set { fDoManualMipmapping = value ? (byte)1 : (byte)0; }
}
public bool EnableInstancedRendering {
get { return fEnableInstancedRendering != 0; }
set { fEnableInstancedRendering = value ? (byte)1 : (byte)0; }
}
public bool AllowPathMaskCaching {
get { return fAllowPathMaskCaching != 0; }
set { fAllowPathMaskCaching = value ? (byte)1 : (byte)0; }
}
public bool RequireDecodeDisableForSrgb {
get { return fRequireDecodeDisableForSRGB != 0; }
set { fRequireDecodeDisableForSRGB = value ? (byte)1 : (byte)0; }
}
public bool DisableGpuYuvConversion {
get { return fDisableGpuYUVConversion != 0; }
set { fDisableGpuYUVConversion = value ? (byte)1 : (byte)0; }
}
public bool SuppressPathRendering {
get { return fSuppressPathRendering != 0; }
set { fSuppressPathRendering = value ? (byte)1 : (byte)0; }
}
public bool WireframeMode {
get { return fWireframeMode != 0; }
set { fWireframeMode = value ? (byte)1 : (byte)0; }
}
public GRContextOptionsGpuPathRenderers GpuPathRenderers {
get { return fGpuPathRenderers; }
set { fGpuPathRenderers = value; }
}
public float GlyphCacheTextureMaximumBytes {
get { return fGlyphCacheTextureMaximumBytes; }
set { fGlyphCacheTextureMaximumBytes = value; }
}
public bool AvoidStencilBuffers {
get { return fAvoidStencilBuffers != 0; }
set { fAvoidStencilBuffers = value ? (byte)1 : (byte)0; }
}
public static GRContextOptions Default {
get {
return new GRContextOptions {
fSuppressPrints = 0,
fMaxTextureSizeOverride = 0x7FFFFFFF,
fMaxTileSizeOverride = 0,
fSuppressDualSourceBlending = 0,
fBufferMapThreshold = -1,
fUseDrawInsteadOfPartialRenderTargetWrite = 0,
fImmediateMode = 0,
fUseShaderSwizzling = 0,
fDoManualMipmapping = 0,
fEnableInstancedRendering = 0,
fAllowPathMaskCaching = 0,
fRequireDecodeDisableForSRGB = 1,
fDisableGpuYUVConversion = 0,
fSuppressPathRendering = 0,
fWireframeMode = 0,
fGpuPathRenderers = GRContextOptionsGpuPathRenderers.All,
fGlyphCacheTextureMaximumBytes = 2048 * 1024 * 4,
fAvoidStencilBuffers = 0,
};
public static SKColorType ToColorType (this GRPixelConfig config)
{
switch (config) {
case GRPixelConfig.Unknown:
return SKColorType.Unknown;
case GRPixelConfig.Alpha8:
return SKColorType.Alpha8;
case GRPixelConfig.Gray8:
return SKColorType.Gray8;
case GRPixelConfig.Rgb565:
return SKColorType.Rgb565;
case GRPixelConfig.Rgba4444:
return SKColorType.Argb4444;
case GRPixelConfig.Rgba8888:
return SKColorType.Rgba8888;
case GRPixelConfig.Rgb888:
return SKColorType.Rgb888x;
case GRPixelConfig.Bgra8888:
return SKColorType.Bgra8888;
case GRPixelConfig.Srgba8888:
return SKColorType.Rgba8888;
case GRPixelConfig.Sbgra8888:
return SKColorType.Bgra8888;
case GRPixelConfig.Rgba1010102:
return SKColorType.Rgba1010102;
case GRPixelConfig.RgbaFloat:
return SKColorType.Unknown;
case GRPixelConfig.RgFloat:
return SKColorType.Unknown;
case GRPixelConfig.AlphaHalf:
return SKColorType.Unknown;
case GRPixelConfig.RgbaHalf:
return SKColorType.RgbaF16;
default:
throw new ArgumentOutOfRangeException (nameof (config));
}
}
}

Просмотреть файл

@ -117,11 +117,6 @@ namespace SkiaSharp
}
}
public GRGlInterface Clone ()
{
return GetObject<GRGlInterface> (SkiaApi.gr_glinterface_clone (Handle));
}
public bool Validate ()
{
return SkiaApi.gr_glinterface_validate (Handle);

Просмотреть файл

@ -5,6 +5,36 @@ using System.Runtime.InteropServices;
namespace SkiaSharp
{
[Obsolete]
public enum SKBitmapResizeMethod
{
Box,
Triangle,
Lanczos3,
Hamming,
Mitchell
}
public static partial class SkiaExtensions
{
[Obsolete]
public static SKFilterQuality ToFilterQuality (this SKBitmapResizeMethod method)
{
switch (method) {
case SKBitmapResizeMethod.Box:
case SKBitmapResizeMethod.Triangle:
return SKFilterQuality.Low;
case SKBitmapResizeMethod.Lanczos3:
return SKFilterQuality.Medium;
case SKBitmapResizeMethod.Hamming:
case SKBitmapResizeMethod.Mitchell:
return SKFilterQuality.High;
default:
return SKFilterQuality.Medium;
}
}
}
// public delegates
public delegate void SKBitmapReleaseDelegate (IntPtr address, object context);
@ -69,23 +99,30 @@ namespace SkiaSharp
}
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use SKBitmap(SKImageInfo, SKBitmapAllocFlags) instead.")]
public SKBitmap (SKImageInfo info, SKColorTable ctable, SKBitmapAllocFlags flags)
: this (info, SKBitmapAllocFlags.None)
{
}
public SKBitmap (SKImageInfo info, SKBitmapAllocFlags flags)
: this ()
{
if (!TryAllocPixels (info, ctable, flags)) {
if (!TryAllocPixels (info, flags)) {
throw new Exception (UnableToAllocatePixelsMessage);
}
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use SKBitmap(SKImageInfo) instead.")]
public SKBitmap (SKImageInfo info, SKColorTable ctable)
: this (info, ctable, SKBitmapAllocFlags.None)
: this (info, SKBitmapAllocFlags.None)
{
}
private bool TryAllocPixels (SKImageInfo info, SKColorTable ctable, SKBitmapAllocFlags flags = SKBitmapAllocFlags.None)
private bool TryAllocPixels (SKImageInfo info, SKBitmapAllocFlags flags = SKBitmapAllocFlags.None)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_bitmap_try_alloc_pixels_with_color_table (Handle, ref cinfo, ctable != null ? ctable.Handle : IntPtr.Zero, flags);
return SkiaApi.sk_bitmap_try_alloc_pixels_with_flags (Handle, ref cinfo, flags);
}
protected override void Dispose (bool disposing)
@ -134,10 +171,6 @@ namespace SkiaSharp
public void SetPixel (int x, int y, SKColor color)
{
if (ColorType == SKColorType.Index8)
{
throw new NotSupportedException ("This method is not supported for bitmaps with ColorTypes of Index8.");
}
SkiaApi.sk_bitmap_set_pixel_color (Handle, x, y, color);
}
@ -158,6 +191,9 @@ namespace SkiaSharp
case SKColorType.Rgb565:
case SKColorType.Rgba8888:
case SKColorType.Bgra8888:
case SKColorType.Rgb888x:
case SKColorType.Rgba1010102:
case SKColorType.Rgb101010x:
case SKColorType.RgbaF16:
break;
case SKColorType.Gray8:
@ -168,8 +204,7 @@ namespace SkiaSharp
case SKColorType.Argb4444:
return
sameConfigs ||
srcCT == SKImageInfo.PlatformColorType ||
srcCT == SKColorType.Index8;
srcCT == SKImageInfo.PlatformColorType;
default:
return false;
}
@ -237,7 +272,7 @@ namespace SkiaSharp
}
var tmpDst = new SKBitmap ();
if (!tmpDst.TryAllocPixels (dstInfo, colorType == SKColorType.Index8 ? ColorTable : null)) {
if (!tmpDst.TryAllocPixels (dstInfo)) {
return false;
}
@ -355,17 +390,19 @@ namespace SkiaSharp
public void SetPixels(IntPtr pixels)
{
SetPixels (pixels, ColorTable);
SkiaApi.sk_bitmap_set_pixels (Handle, pixels);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use SetPixels(IntPtr) instead.")]
public void SetPixels(IntPtr pixels, SKColorTable ct)
{
SkiaApi.sk_bitmap_set_pixels (Handle, pixels, ct != null ? ct.Handle : IntPtr.Zero);
SetPixels (pixels);
}
public void SetColorTable(SKColorTable ct)
[Obsolete ("The Index8 color type and color table is no longer supported.")]
public void SetColorTable (SKColorTable ct)
{
SetPixels (GetPixels (), ct);
// no-op due to unsupperted action
}
public byte[] Bytes {
@ -411,9 +448,8 @@ namespace SkiaSharp
set { SkiaApi.sk_bitmap_set_volatile (Handle, value); }
}
public SKColorTable ColorTable {
get { return GetObject<SKColorTable> (SkiaApi.sk_bitmap_get_colortable (Handle), false); }
}
[Obsolete ("The Index8 color type and color table is no longer supported.")]
public SKColorTable ColorTable => null;
public static SKImageInfo DecodeBounds (Stream stream)
{
@ -469,18 +505,10 @@ namespace SkiaSharp
throw new ArgumentNullException (nameof (codec));
}
// construct a color table for the decode if necessary
SKColorTable colorTable = null;
int colorCount = 0;
if (bitmapInfo.ColorType == SKColorType.Index8)
{
colorTable = new SKColorTable ();
}
// read the pixels and color table
var bitmap = new SKBitmap (bitmapInfo, colorTable);
var bitmap = new SKBitmap (bitmapInfo);
IntPtr length;
var result = codec.GetPixels (bitmapInfo, bitmap.GetPixels (out length), colorTable, ref colorCount);
var result = codec.GetPixels (bitmapInfo, bitmap.GetPixels (out length));
if (result != SKCodecResult.Success && result != SKCodecResult.IncompleteInput) {
bitmap.Dispose ();
bitmap = null;
@ -612,28 +640,39 @@ namespace SkiaSharp
public bool InstallPixels (SKImageInfo info, IntPtr pixels)
{
return InstallPixels (info, pixels, info.RowBytes);
return InstallPixels (info, pixels, info.RowBytes, null, null);
}
public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes)
{
return InstallPixels (info, pixels, rowBytes, null);
return InstallPixels (info, pixels, rowBytes, null, null);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use InstallPixels(SKImageInfo, IntPtr, int) instead.")]
public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
{
return InstallPixels (info, pixels, rowBytes, ctable, null, null);
return InstallPixels (info, pixels, rowBytes, null, null);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use InstallPixels(SKImageInfo, IntPtr, int, SKBitmapReleaseDelegate, object) instead.")]
public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable, SKBitmapReleaseDelegate releaseProc, object context)
{
return InstallPixels (info, pixels, rowBytes, null, null);
}
public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc)
{
return InstallPixels (info, pixels, rowBytes, releaseProc, null);
}
public bool InstallPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKBitmapReleaseDelegate releaseProc, object context)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
IntPtr ct = ctable == null ? IntPtr.Zero : ctable.Handle;
if (releaseProc == null) {
return SkiaApi.sk_bitmap_install_pixels (Handle, ref cinfo, pixels, (IntPtr)rowBytes, ct, IntPtr.Zero, IntPtr.Zero);
return SkiaApi.sk_bitmap_install_pixels (Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero);
} else {
var ctx = new NativeDelegateContext (context, releaseProc);
return SkiaApi.sk_bitmap_install_pixels (Handle, ref cinfo, pixels, (IntPtr)rowBytes, ct, releaseDelegate, ctx.NativeContext);
return SkiaApi.sk_bitmap_install_pixels (Handle, ref cinfo, pixels, (IntPtr)rowBytes, releaseDelegate, ctx.NativeContext);
}
}
@ -672,6 +711,7 @@ namespace SkiaSharp
return SkiaApi.sk_bitmap_peek_pixels (Handle, pixmap.Handle);
}
[Obsolete]
public SKBitmap Resize (SKImageInfo info, SKBitmapResizeMethod method)
{
var dst = new SKBitmap (info);
@ -684,11 +724,13 @@ namespace SkiaSharp
}
}
[Obsolete]
public bool Resize (SKBitmap dst, SKBitmapResizeMethod method)
{
return Resize (dst, this, method);
}
[Obsolete]
public static bool Resize (SKBitmap dst, SKBitmap src, SKBitmapResizeMethod method)
{
using (var srcPix = src.PeekPixels ())

Просмотреть файл

@ -651,8 +651,6 @@ namespace SkiaSharp
public void DrawBitmapLattice (SKBitmap bitmap, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null)
{
var lattice = new SKLattice {
Bounds = null,
Flags = null,
XDivs = xDivs,
YDivs = yDivs
};
@ -662,8 +660,6 @@ namespace SkiaSharp
public void DrawImageLattice (SKImage image, int[] xDivs, int[] yDivs, SKRect dst, SKPaint paint = null)
{
var lattice = new SKLattice {
Bounds = null,
Flags = null,
XDivs = xDivs,
YDivs = yDivs
};
@ -682,14 +678,16 @@ namespace SkiaSharp
unsafe {
fixed (int* x = &lattice.XDivs[0])
fixed (int* y = &lattice.YDivs[0])
fixed (SKLatticeFlags* f = &lattice.Flags[0]) {
fixed (SKLatticeRectType* r = &lattice.RectTypes[0])
fixed (SKColor* c = &lattice.Colors[0]) {
var nativeLattice = new SKLatticeInternal {
fBounds = null,
fFlags = f,
fRectTypes = r,
fXCount = lattice.XDivs.Length,
fXDivs = x,
fYCount = lattice.YDivs.Length,
fYDivs = y,
fColors = c,
};
if (lattice.Bounds != null) {
var bounds = lattice.Bounds.Value;
@ -700,7 +698,7 @@ namespace SkiaSharp
}
}
public unsafe void DrawImageLattice (SKImage image, SKLattice lattice, SKRect dst, SKPaint paint = null)
public void DrawImageLattice (SKImage image, SKLattice lattice, SKRect dst, SKPaint paint = null)
{
if (image == null)
throw new ArgumentNullException (nameof (image));
@ -712,14 +710,16 @@ namespace SkiaSharp
unsafe {
fixed (int* x = &lattice.XDivs[0])
fixed (int* y = &lattice.YDivs[0])
fixed (SKLatticeFlags* f = &lattice.Flags[0]) {
fixed (SKLatticeRectType* r = &lattice.RectTypes[0])
fixed (SKColor* c = &lattice.Colors[0]) {
var nativeLattice = new SKLatticeInternal {
fBounds = null,
fFlags = f,
fRectTypes = r,
fXCount = lattice.XDivs.Length,
fXDivs = x,
fYCount = lattice.YDivs.Length,
fYDivs = y,
fColors = c,
};
if (lattice.Bounds != null) {
var bounds = lattice.Bounds.Value;

Просмотреть файл

@ -36,15 +36,7 @@ namespace SkiaSharp
}
}
public SKEncodedInfo EncodedInfo {
get {
SKEncodedInfo info;
SkiaApi.sk_codec_get_encodedinfo (Handle, out info);
return info;
}
}
public SKCodecOrigin Origin {
public SKEncodedOrigin Origin {
get { return SkiaApi.sk_codec_get_origin (Handle); }
}
@ -82,7 +74,7 @@ namespace SkiaSharp
public SKCodecFrameInfo[] FrameInfo {
get {
var length = SkiaApi.sk_codec_get_frame_count (Handle);
var info = new SKCodecFrameInfo [length];
var info = new SKCodecFrameInfo[length];
SkiaApi.sk_codec_get_frame_info (Handle, info);
return info;
}
@ -112,83 +104,89 @@ namespace SkiaSharp
}
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options)
{
var colorTableCount = 0;
return GetPixels (info, pixels, rowBytes, options, IntPtr.Zero, ref colorTableCount);
}
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, IntPtr colorTable, ref int colorTableCount)
{
if (pixels == IntPtr.Zero)
throw new ArgumentNullException (nameof (pixels));
var nativeOptions = SKCodecOptionsInternal.FromManaged (ref options);
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_get_pixels (Handle, ref cinfo, pixels, (IntPtr)rowBytes, ref nativeOptions, colorTable, ref colorTableCount);
var nOptions = SKCodecOptionsInternal.FromManaged (ref options);
var nInfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_get_pixels (Handle, ref nInfo, pixels, (IntPtr)rowBytes, ref nOptions);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use GetPixels(SKImageInfo, IntPtr, int, SKCodecOptions) instead.")]
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, IntPtr colorTable, ref int colorTableCount)
{
return GetPixels (info, pixels, rowBytes, options);
}
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, SKCodecOptions options)
{
var colorTableCount = 0;
return GetPixels (info, pixels, options, IntPtr.Zero, ref colorTableCount);
return GetPixels (info, pixels, info.RowBytes, options);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use GetPixels(SKImageInfo, IntPtr, SKCodecOptions) instead.")]
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, SKCodecOptions options, IntPtr colorTable, ref int colorTableCount)
{
return GetPixels (info, pixels, info.RowBytes, options, colorTable, ref colorTableCount);
return GetPixels (info, pixels, info.RowBytes, options);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use GetPixels(SKImageInfo, IntPtr) instead.")]
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, IntPtr colorTable, ref int colorTableCount)
{
return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default, colorTable, ref colorTableCount);
return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default);
}
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels)
{
int colorTableCount = 0;
return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default, IntPtr.Zero, ref colorTableCount);
return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use GetPixels(SKImageInfo, IntPtr, int, SKCodecOptions) instead.")]
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
{
return GetPixels (info, pixels, rowBytes, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors (), ref colorTableCount);
return GetPixels (info, pixels, rowBytes, options);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use GetPixels(SKImageInfo, IntPtr, SKCodecOptions) instead.")]
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
{
return GetPixels (info, pixels, info.RowBytes, options, colorTable, ref colorTableCount);
return GetPixels (info, pixels, info.RowBytes, options);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use GetPixels(SKImageInfo, IntPtr) instead.")]
public SKCodecResult GetPixels (SKImageInfo info, IntPtr pixels, SKColorTable colorTable, ref int colorTableCount)
{
return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default, colorTable, ref colorTableCount);
return GetPixels (info, pixels, info.RowBytes, SKCodecOptions.Default);
}
public SKCodecResult StartIncrementalDecode(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, IntPtr colorTable, ref int colorTableCount)
[Obsolete ("The Index8 color type and color table is no longer supported. Use StartIncrementalDecode(SKImageInfo, IntPtr, int, SKCodecOptions) instead.")]
public SKCodecResult StartIncrementalDecode (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, IntPtr colorTable, ref int colorTableCount)
{
if (pixels == IntPtr.Zero)
throw new ArgumentNullException (nameof (pixels));
var nativeOptions = SKCodecOptionsInternal.FromManaged (ref options);
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_incremental_decode (Handle, ref cinfo, pixels, (IntPtr)rowBytes, ref nativeOptions, colorTable, ref colorTableCount);
return StartIncrementalDecode (info, pixels, rowBytes, options);
}
public SKCodecResult StartIncrementalDecode (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options)
{
int colorTableCount = 0;
return StartIncrementalDecode (info, pixels, rowBytes, options, IntPtr.Zero, ref colorTableCount);
if (pixels == IntPtr.Zero)
throw new ArgumentNullException (nameof (pixels));
var nOptions = SKCodecOptionsInternal.FromManaged (ref options);
var nInfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_incremental_decode (Handle, ref nInfo, pixels, (IntPtr)rowBytes, ref nOptions);
}
public SKCodecResult StartIncrementalDecode (SKImageInfo info, IntPtr pixels, int rowBytes)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_incremental_decode (Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
return SkiaApi.sk_codec_start_incremental_decode (Handle, ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero);
}
public SKCodecResult StartIncrementalDecode(SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
[Obsolete ("The Index8 color type and color table is no longer supported. Use StartIncrementalDecode(SKImageInfo, IntPtr, int, SKCodecOptions) instead.")]
public SKCodecResult StartIncrementalDecode (SKImageInfo info, IntPtr pixels, int rowBytes, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
{
return StartIncrementalDecode (info, pixels, rowBytes, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors (), ref colorTableCount);
return StartIncrementalDecode (info, pixels, rowBytes, options);
}
public SKCodecResult IncrementalDecode (out int rowsDecoded)
@ -198,32 +196,33 @@ namespace SkiaSharp
public SKCodecResult IncrementalDecode ()
{
int rowsDecoded;
return SkiaApi.sk_codec_incremental_decode (Handle, out rowsDecoded);
return SkiaApi.sk_codec_incremental_decode (Handle, out var rowsDecoded);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use StartScanlineDecode(SKImageInfo, SKCodecOptions) instead.")]
public SKCodecResult StartScanlineDecode (SKImageInfo info, SKCodecOptions options, IntPtr colorTable, ref int colorTableCount)
{
var nativeOptions = SKCodecOptionsInternal.FromManaged (ref options);
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_scanline_decode (Handle, ref cinfo, ref nativeOptions, colorTable, ref colorTableCount);
return StartScanlineDecode (info, options);
}
public SKCodecResult StartScanlineDecode (SKImageInfo info, SKCodecOptions options)
{
int colorTableCount = 0;
return StartScanlineDecode (info, options, IntPtr.Zero, ref colorTableCount);
var nOptions = SKCodecOptionsInternal.FromManaged (ref options);
var nInfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_scanline_decode (Handle, ref nInfo, ref nOptions);
}
public SKCodecResult StartScanlineDecode (SKImageInfo info)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return SkiaApi.sk_codec_start_scanline_decode (Handle, ref cinfo, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
return SkiaApi.sk_codec_start_scanline_decode (Handle, ref cinfo, IntPtr.Zero);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use StartScanlineDecode(SKImageInfo, SKCodecOptions) instead.")]
public SKCodecResult StartScanlineDecode (SKImageInfo info, SKCodecOptions options, SKColorTable colorTable, ref int colorTableCount)
{
return StartScanlineDecode (info, options, colorTable == null ? IntPtr.Zero : colorTable.ReadColors (), ref colorTableCount);
return StartScanlineDecode (info, options);
}
public int GetScanlines (IntPtr dst, int countLines, int rowBytes)
@ -243,10 +242,15 @@ namespace SkiaSharp
public int GetOutputScanline (int inputScanline) => SkiaApi.sk_codec_output_scanline (Handle, inputScanline);
public static SKCodec Create (SKStream stream)
{
return Create (stream, out var result);
}
public static SKCodec Create (SKStream stream, out SKCodecResult result)
{
if (stream == null)
throw new ArgumentNullException (nameof (stream));
var codec = GetObject<SKCodec> (SkiaApi.sk_codec_new_from_stream (stream.Handle));
var codec = GetObject<SKCodec> (SkiaApi.sk_codec_new_from_stream (stream.Handle, out result));
stream.RevokeOwnership ();
return codec;
}

Просмотреть файл

@ -87,16 +87,28 @@ namespace SkiaSharp
return doc;
}
public static SKDocument CreatePdf (SKWStream stream, float dpi = DefaultRasterDpi)
[Obsolete("Use CreatePdf(SKWStream) instead.")]
public static SKDocument CreatePdf (SKWStream stream, float dpi)
{
return CreatePdf (stream);
}
public static SKDocument CreatePdf (SKWStream stream)
{
if (stream == null) {
throw new ArgumentNullException (nameof(stream));
}
return GetObject<SKDocument> (SkiaApi.sk_document_create_pdf_from_stream (stream.Handle, dpi));
return GetObject<SKDocument> (SkiaApi.sk_document_create_pdf_from_stream (stream.Handle));
}
public static SKDocument CreatePdf (SKWStream stream, SKDocumentPdfMetadata metadata, float dpi = DefaultRasterDpi)
[Obsolete("Use CreatePdf(SKWStream, SKDocumentPdfMetadata) instead.")]
public static SKDocument CreatePdf (SKWStream stream, SKDocumentPdfMetadata metadata, float dpi)
{
return CreatePdf (stream, metadata);
}
public static SKDocument CreatePdf (SKWStream stream, SKDocumentPdfMetadata metadata)
{
if (stream == null) {
throw new ArgumentNullException (nameof(stream));
@ -128,7 +140,7 @@ namespace SkiaSharp
cmetadata.Modified = &modified;
}
return GetObject<SKDocument> (SkiaApi.sk_document_create_pdf_from_stream_with_metadata (stream.Handle, dpi, ref cmetadata));
return GetObject<SKDocument> (SkiaApi.sk_document_create_pdf_from_stream_with_metadata (stream.Handle, ref cmetadata));
}
}
}

Просмотреть файл

@ -20,7 +20,6 @@ namespace SkiaSharp
// TODO: `FromAdoptedTexture` with `GRBackendTexture` [and color space]
// TODO: `MakeFromYUVTexturesCopy` and `MakeFromNV12TexturesCopy`
// TODO: `FromPicture` with bit depth and color space
// TODO: `ColorSpace` property
// TODO: `IsValid`
// TODO: `GetTextureHandle`
// TODO: `ToTextureImage`
@ -61,6 +60,8 @@ namespace SkiaSharp
{
}
// create brand new image
public static SKImage Create (SKImageInfo info)
{
var pixels = Marshal.AllocCoTaskMem (info.BytesSize);
@ -70,25 +71,26 @@ namespace SkiaSharp
}
}
// create a new image from a copy of pixel data
public static SKImage FromPixelCopy (SKImageInfo info, IntPtr pixels)
{
return FromPixelCopy (info, pixels, info.RowBytes, null);
return FromPixelCopy (info, pixels, info.RowBytes);
}
public static SKImage FromPixelCopy (SKImageInfo info, IntPtr pixels, int rowBytes)
{
return FromPixelCopy (info, pixels, rowBytes, null);
}
public static SKImage FromPixelCopy (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
{
if (pixels == IntPtr.Zero)
throw new ArgumentNullException (nameof (pixels));
var ct = (ctable == null ? IntPtr.Zero : ctable.Handle);
var cinfo = SKImageInfoNative.FromManaged (ref info);
var handle = SkiaApi.sk_image_new_raster_copy_with_colortable (ref cinfo, pixels, (IntPtr) rowBytes, ct);
return GetObject<SKImage> (handle);
var nInfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKImage> (SkiaApi.sk_image_new_raster_copy (ref nInfo, pixels, (IntPtr)rowBytes));
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use FromPixelCopy(SKImageInfo, IntPtr, int) instead.")]
public static SKImage FromPixelCopy (SKImageInfo info, IntPtr pixels, int rowBytes, SKColorTable ctable)
{
return FromPixelCopy (info, pixels, rowBytes);
}
public static SKImage FromPixelCopy (SKPixmap pixmap)
@ -98,6 +100,8 @@ namespace SkiaSharp
return GetObject<SKImage> (SkiaApi.sk_image_new_raster_copy_with_pixmap (pixmap.Handle));
}
// create a new image around existing pixel data
public static SKImage FromPixelData (SKImageInfo info, SKData data, int rowBytes)
{
if (data == null)
@ -145,6 +149,8 @@ namespace SkiaSharp
}
}
// create a new image from encoded data
public static SKImage FromEncodedData (SKData data, SKRectI subset)
{
if (data == null)
@ -161,6 +167,8 @@ namespace SkiaSharp
return GetObject<SKImage> (handle);
}
// create a new image from a bitmap
public static SKImage FromBitmap (SKBitmap bitmap)
{
if (bitmap == null)
@ -169,14 +177,16 @@ namespace SkiaSharp
return GetObject<SKImage> (handle);
}
// create a new image from a GPU texture
public static SKImage FromTexture (GRContext context, GRGlBackendTextureDesc desc)
{
return FromTexture (context, desc, SKAlphaType.Premul);
return FromTexture (context, desc, SKAlphaType.Premul, null, null);
}
public static SKImage FromTexture (GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha)
{
return FromTexture (context, desc, alpha, null);
return FromTexture (context, desc, alpha, null, null);
}
public static SKImage FromTexture (GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc)
@ -185,48 +195,27 @@ namespace SkiaSharp
}
public static SKImage FromTexture (GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
{
unsafe {
var h = desc.TextureHandle;
var hPtr = &h;
var d = new GRBackendTextureDesc {
Flags = desc.Flags,
Origin = desc.Origin,
Width = desc.Width,
Height = desc.Height,
Config = desc.Config,
SampleCount = desc.SampleCount,
TextureHandle = (IntPtr)hPtr,
};
return FromTexture (context, d, alpha, releaseProc, releaseContext);
}
}
public static SKImage FromTexture (GRContext context, GRBackendTextureDesc desc)
{
return FromTexture (context, desc, SKAlphaType.Premul);
}
public static SKImage FromTexture (GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha)
{
return FromTexture (context, desc, alpha, null);
}
public static SKImage FromTexture (GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc)
{
return FromTexture (context, desc, alpha, releaseProc, null);
}
public static SKImage FromTexture (GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
var texture = new GRBackendTexture (desc);
return FromTexture (context, texture, desc.Origin, desc.Config.ToColorType (), alpha, null, releaseProc, releaseContext);
}
public static SKImage FromTexture (GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace, SKImageTextureReleaseDelegate releaseProc, object releaseContext)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (texture == null)
throw new ArgumentNullException (nameof (texture));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
if (releaseProc == null) {
return GetObject<SKImage> (SkiaApi.sk_image_new_from_texture (context.Handle, ref desc, alpha, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
return GetObject<SKImage> (SkiaApi.sk_image_new_from_texture (context.Handle, texture.Handle, origin, colorType, alpha, cs, IntPtr.Zero, IntPtr.Zero));
} else {
var ctx = new NativeDelegateContext (releaseContext, releaseProc);
return GetObject<SKImage> (SkiaApi.sk_image_new_from_texture (context.Handle, ref desc, alpha, IntPtr.Zero, textureReleaseDelegate, ctx.NativeContext));
return GetObject<SKImage> (SkiaApi.sk_image_new_from_texture (context.Handle, texture.Handle, origin, colorType, alpha, cs, textureReleaseDelegate, ctx.NativeContext));
}
}
@ -236,36 +225,27 @@ namespace SkiaSharp
}
public static SKImage FromAdoptedTexture (GRContext context, GRGlBackendTextureDesc desc, SKAlphaType alpha)
{
unsafe {
var h = desc.TextureHandle;
var hPtr = &h;
var d = new GRBackendTextureDesc {
Flags = desc.Flags,
Origin = desc.Origin,
Width = desc.Width,
Height = desc.Height,
Config = desc.Config,
SampleCount = desc.SampleCount,
TextureHandle = (IntPtr)hPtr,
};
return FromAdoptedTexture (context, d, alpha);
}
}
public static SKImage FromAdoptedTexture (GRContext context, GRBackendTextureDesc desc)
{
return FromAdoptedTexture (context, desc, SKAlphaType.Premul);
}
public static SKImage FromAdoptedTexture (GRContext context, GRBackendTextureDesc desc, SKAlphaType alpha)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
return GetObject<SKImage> (SkiaApi.sk_image_new_from_adopted_texture (context.Handle, ref desc, alpha, IntPtr.Zero));
var texture = new GRBackendTexture (desc);
return FromAdoptedTexture (context, texture, desc.Origin, desc.Config.ToColorType (), alpha, null);
}
public static SKImage FromAdoptedTexture (GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, SKColorSpace colorspace)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (texture == null)
throw new ArgumentNullException (nameof (texture));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKImage> (SkiaApi.sk_image_new_from_adopted_texture (context.Handle, texture.Handle, origin, colorType, alpha, cs));
}
// create a new image from a picture
public static SKImage FromPicture (SKPicture picture, SKSizeI dimensions)
{
return FromPicture (picture, dimensions, null);
@ -304,7 +284,38 @@ namespace SkiaSharp
if (serializer == null)
throw new ArgumentNullException (nameof (serializer));
return GetObject<SKData> (SkiaApi.sk_image_encode_with_serializer (Handle, serializer.Handle));
// try old data
var encoded = EncodedData;
if (encoded != null) {
if (serializer.UseEncodedData (encoded.Data, (ulong)encoded.Size)) {
return encoded;
} else {
encoded.Dispose ();
encoded = null;
}
}
// get new data (raster)
if (!IsTextureBacked) {
using (var pixmap = PeekPixels ()) {
return serializer.Encode (pixmap);
}
}
// get new data (texture / gpu)
// this involves a copy from gpu to cpu first
if (IsTextureBacked) {
var info = new SKImageInfo (Width, Height, ColorType, AlphaType, ColorSpace);
using (var temp = new SKBitmap (info))
using (var pixmap = temp.PeekPixels ()) {
if (pixmap != null && ReadPixels (pixmap, 0, 0)) {
return serializer.Encode (pixmap);
}
}
}
// some error
return null;
}
public SKData Encode (SKEncodedImageFormat format, int quality)
@ -316,7 +327,10 @@ namespace SkiaSharp
public int Height => SkiaApi.sk_image_get_height (Handle);
public uint UniqueId => SkiaApi.sk_image_get_unique_id (Handle);
public SKAlphaType AlphaType => SkiaApi.sk_image_get_alpha_type (Handle);
public SKColorType ColorType => SkiaApi.sk_image_get_color_type (Handle);
public SKColorSpace ColorSpace => GetObject<SKColorSpace> (SkiaApi.sk_image_get_colorspace (Handle));
public bool IsAlphaOnly => SkiaApi.sk_image_is_alpha_only(Handle);
public SKData EncodedData => GetObject<SKData> (SkiaApi.sk_image_ref_encoded (Handle));
public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY)
{

Просмотреть файл

@ -112,23 +112,33 @@ namespace SkiaSharp
return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_matrix_convolution(ref kernelSize, kernel, gain, bias, ref kernelOffset, tileMode, convolveAlpha, input == null ? IntPtr.Zero : input.Handle, cropRect == null ? IntPtr.Zero : cropRect.Handle));
}
[Obsolete("Use CreateMerge(SKImageFilter, SKImageFilter, SKImageFilter.CropRect) instead.")]
public static SKImageFilter CreateMerge(SKImageFilter first, SKImageFilter second, SKBlendMode mode, SKImageFilter.CropRect cropRect = null)
{
return CreateMerge(new [] { first, second }, new [] { mode, mode }, cropRect);
}
public static SKImageFilter CreateMerge(SKImageFilter first, SKImageFilter second, SKImageFilter.CropRect cropRect = null)
{
return CreateMerge(new [] { first, second }, cropRect);
}
[Obsolete("Use CreateMerge(SKImageFilter[], SKImageFilter.CropRect) instead.")]
public static SKImageFilter CreateMerge(SKImageFilter[] filters, SKBlendMode[] modes = null, SKImageFilter.CropRect cropRect = null)
{
return CreateMerge (filters, cropRect);
}
public static SKImageFilter CreateMerge(SKImageFilter[] filters, SKImageFilter.CropRect cropRect = null)
{
if (filters == null)
throw new ArgumentNullException(nameof(filters));
if (modes != null && modes.Length != filters.Length)
throw new ArgumentException("The numbers of modes must match the number of filters.", nameof(modes));
var f = new IntPtr[filters.Length];
for (int i = 0; i < filters.Length; i++)
{
f[i] = filters[i].Handle;
}
return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_merge(f, filters.Length, modes, cropRect == null ? IntPtr.Zero : cropRect.Handle));
return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_merge(f, filters.Length, cropRect == null ? IntPtr.Zero : cropRect.Handle));
}
public static SKImageFilter CreateDilate(int radiusX, int radiusY, SKImageFilter input = null, SKImageFilter.CropRect cropRect = null)
@ -160,13 +170,6 @@ namespace SkiaSharp
return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_picture_with_croprect(picture.Handle, ref cropRect));
}
public static SKImageFilter CreatePictureForLocalspace(SKPicture picture, SKRect cropRect, SKFilterQuality filterQuality)
{
if (picture == null)
throw new ArgumentNullException(nameof(picture));
return GetObject<SKImageFilter>(SkiaApi.sk_imagefilter_new_picture_for_localspace(picture.Handle, ref cropRect, filterQuality));
}
public static SKImageFilter CreateTile(SKRect src, SKRect dst, SKImageFilter input)
{
if (input == null)

Просмотреть файл

@ -119,7 +119,6 @@ namespace SkiaSharp
case SKColorType.Unknown:
return 0;
case SKColorType.Alpha8:
case SKColorType.Index8:
case SKColorType.Gray8:
return 1;
case SKColorType.Rgb565:
@ -127,6 +126,9 @@ namespace SkiaSharp
return 2;
case SKColorType.Bgra8888:
case SKColorType.Rgba8888:
case SKColorType.Rgb888x:
case SKColorType.Rgba1010102:
case SKColorType.Rgb101010x:
return 4;
case SKColorType.RgbaF16:
return 8;
@ -141,7 +143,6 @@ namespace SkiaSharp
case SKColorType.Unknown:
return 0;
case SKColorType.Alpha8:
case SKColorType.Index8:
case SKColorType.Gray8:
return 8;
case SKColorType.Rgb565:
@ -149,6 +150,9 @@ namespace SkiaSharp
return 16;
case SKColorType.Bgra8888:
case SKColorType.Rgba8888:
case SKColorType.Rgb888x:
case SKColorType.Rgba1010102:
case SKColorType.Rgb101010x:
return 32;
case SKColorType.RgbaF16:
return 64;

Просмотреть файл

@ -1,62 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace SkiaSharp
{
public abstract class SKManagedPixelSerializer : SKPixelSerializer
{
// delegate declarations
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate bool use_delegate (IntPtr serializer, IntPtr buffer, IntPtr size);
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate IntPtr encode_delegate (IntPtr serializer, IntPtr pixmap);
// so the GC doesn't collect the delegate
private static readonly use_delegate fUse;
private static readonly encode_delegate fEncode;
static SKManagedPixelSerializer ()
{
fUse = new use_delegate (UseInternal);
fEncode = new encode_delegate (EncodeInternal);
SkiaApi.sk_managedpixelserializer_set_delegates (
Marshal.GetFunctionPointerForDelegate (fUse),
Marshal.GetFunctionPointerForDelegate (fEncode));
}
[Preserve]
internal SKManagedPixelSerializer (IntPtr x, bool owns)
: base (x, owns)
{
}
public SKManagedPixelSerializer ()
: base (SkiaApi.sk_managedpixelserializer_new (), true)
{
}
protected abstract bool OnUseEncodedData (IntPtr data, IntPtr length);
protected abstract SKData OnEncode (SKPixmap pixmap);
// internal proxy
[MonoPInvokeCallback (typeof (use_delegate))]
private static bool UseInternal (IntPtr cserializer, IntPtr buffer, IntPtr size)
{
var serializer = GetObject<SKManagedPixelSerializer> (cserializer, false);
return serializer.OnUseEncodedData (buffer, size);
}
[MonoPInvokeCallback (typeof (encode_delegate))]
private static IntPtr EncodeInternal (IntPtr cserializer, IntPtr pixmap)
{
var serializer = GetObject<SKManagedPixelSerializer> (cserializer, false);
var data = serializer.OnEncode (GetObject<SKPixmap> (pixmap, false));
return data == null ? IntPtr.Zero : data.Handle;
}
}
}

Просмотреть файл

@ -2,6 +2,17 @@
namespace SkiaSharp
{
[Flags]
[Obsolete]
public enum SKBlurMaskFilterFlags
{
None = 0x00,
IgnoreTransform = 0x01,
HighQuality = 0x02,
All = IgnoreTransform | HighQuality,
}
// TODO: `getFormat`
// TODO: `computeFastBounds`
@ -39,19 +50,26 @@ namespace SkiaSharp
return GetObject<SKMaskFilter> (SkiaApi.sk_maskfilter_new_blur (blurStyle, sigma));
}
[Obsolete("Use CreateBlur(SKBlurStyle, float) instead.")]
public static SKMaskFilter CreateBlur (SKBlurStyle blurStyle, float sigma, SKBlurMaskFilterFlags flags)
{
return CreateBlur (blurStyle, sigma, SKRect.Empty, flags);
return CreateBlur (blurStyle, sigma, SKRect.Empty, true);
}
public static SKMaskFilter CreateBlur (SKBlurStyle blurStyle, float sigma, SKRect occluder)
{
return CreateBlur (blurStyle, sigma, occluder, SKBlurMaskFilterFlags.None);
return CreateBlur (blurStyle, sigma, occluder, true);
}
[Obsolete("Use CreateBlur(SKBlurStyle, float, SKRect) instead.")]
public static SKMaskFilter CreateBlur (SKBlurStyle blurStyle, float sigma, SKRect occluder, SKBlurMaskFilterFlags flags)
{
return GetObject<SKMaskFilter> (SkiaApi.sk_maskfilter_new_blur_with_flags (blurStyle, sigma, ref occluder, flags));
return CreateBlur (blurStyle, sigma, occluder, true);
}
public static SKMaskFilter CreateBlur (SKBlurStyle blurStyle, float sigma, SKRect occluder, bool respectCTM)
{
return GetObject<SKMaskFilter> (SkiaApi.sk_maskfilter_new_blur_with_flags (blurStyle, sigma, ref occluder, respectCTM));
}
public static SKMaskFilter CreateTable(byte[] table)

Просмотреть файл

@ -54,11 +54,6 @@ namespace SkiaSharp
return GetObject<SKPathEffect>(SkiaApi.sk_path_effect_create_corner(radius));
}
public static SKPathEffect CreateArcTo(float radius)
{
return GetObject<SKPathEffect>(SkiaApi.sk_path_effect_create_arc_to(radius));
}
public static SKPathEffect Create1DPath(SKPath path, float advance, float phase, SKPath1DPathEffectStyle style)
{
if (path == null)

Просмотреть файл

@ -2,29 +2,14 @@
namespace SkiaSharp
{
public class SKPixelSerializer : SKObject
public abstract class SKPixelSerializer
{
protected override void Dispose (bool disposing)
{
if (Handle != IntPtr.Zero && OwnsHandle) {
SkiaApi.sk_pixelserializer_unref (Handle);
}
base.Dispose (disposing);
}
[Preserve]
internal SKPixelSerializer (IntPtr x, bool owns)
: base (x, owns)
{
}
public bool UseEncodedData (IntPtr data, ulong length)
{
if (SizeOf<IntPtr> () == 4 && length > UInt32.MaxValue)
if (SKObject.SizeOf<IntPtr> () == 4 && length > UInt32.MaxValue)
throw new ArgumentOutOfRangeException (nameof (length), "The length exceeds the size of pointers.");
return SkiaApi.sk_pixelserializer_use_encoded_data (Handle, data, (IntPtr)length);
return OnUseEncodedData (data, (IntPtr)length);
}
public SKData Encode (SKPixmap pixmap)
@ -32,9 +17,13 @@ namespace SkiaSharp
if (pixmap == null)
throw new ArgumentNullException (nameof (pixmap));
return GetObject<SKData> (SkiaApi.sk_pixelserializer_encode (Handle, pixmap.Handle));
return OnEncode (pixmap);
}
protected abstract bool OnUseEncodedData (IntPtr data, IntPtr length);
protected abstract SKData OnEncode (SKPixmap pixmap);
public static SKPixelSerializer Create (Func<SKPixmap, SKData> onEncode)
{
return new SKSimplePixelSerializer (null, onEncode);
@ -46,7 +35,7 @@ namespace SkiaSharp
}
}
internal class SKSimplePixelSerializer : SKManagedPixelSerializer
internal class SKSimplePixelSerializer : SKPixelSerializer
{
private readonly Func<IntPtr, IntPtr, bool> onUseEncodedData;
private readonly Func<SKPixmap, SKData> onEncode;
@ -67,4 +56,9 @@ namespace SkiaSharp
return onUseEncodedData?.Invoke (data, length) ?? false;
}
}
[Obsolete ("Use SKPixelSerializer instead.")]
public abstract class SKManagedPixelSerializer : SKPixelSerializer
{
}
}

Просмотреть файл

@ -27,11 +27,17 @@ namespace SkiaSharp
{
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use SKPixmap(SKImageInfo, IntPtr, int) instead.")]
public SKPixmap (SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable = null)
: this (info, addr, info.RowBytes)
{
}
public SKPixmap (SKImageInfo info, IntPtr addr, int rowBytes)
: this (IntPtr.Zero, true)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
Handle = SkiaApi.sk_pixmap_new_with_params (ref cinfo, addr, (IntPtr)rowBytes, ctable == null ? IntPtr.Zero : ctable.Handle);
Handle = SkiaApi.sk_pixmap_new_with_params (ref cinfo, addr, (IntPtr)rowBytes);
if (Handle == IntPtr.Zero) {
throw new InvalidOperationException (UnableToCreateInstanceMessage);
}
@ -51,10 +57,16 @@ namespace SkiaSharp
SkiaApi.sk_pixmap_reset (Handle);
}
[Obsolete ("The Index8 color type and color table is no longer supported. Use Reset(SKImageInfo, IntPtr, int) instead.")]
public void Reset (SKImageInfo info, IntPtr addr, int rowBytes, SKColorTable ctable = null)
{
Reset (info, addr, rowBytes);
}
public void Reset (SKImageInfo info, IntPtr addr, int rowBytes)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
SkiaApi.sk_pixmap_reset_with_params (Handle, ref cinfo, addr, (IntPtr)rowBytes, ctable == null ? IntPtr.Zero : ctable.Handle);
SkiaApi.sk_pixmap_reset_with_params (Handle, ref cinfo, addr, (IntPtr)rowBytes);
}
public SKImageInfo Info {
@ -98,13 +110,26 @@ namespace SkiaSharp
return SkiaApi.sk_pixmap_get_pixels (Handle);
}
public SKColorTable ColorTable {
get { return GetObject<SKColorTable> (SkiaApi.sk_pixmap_get_colortable (Handle), false); }
}
[Obsolete ("The Index8 color type and color table is no longer supported.")]
public SKColorTable ColorTable => null;
[Obsolete("Use ScalePixels(SKPixmap, SKFilterQuality) instead.")]
public static bool Resize (SKPixmap dst, SKPixmap src, SKBitmapResizeMethod method)
{
return SkiaApi.sk_bitmapscaler_resize (dst.Handle, src.Handle, method);
if (dst == null)
throw new ArgumentNullException (nameof (dst));
if (src == null)
throw new ArgumentNullException (nameof (src));
return src.ScalePixels (dst, method.ToFilterQuality ());
}
public bool ScalePixels (SKPixmap destination, SKFilterQuality quality)
{
if (destination == null)
throw new ArgumentNullException (nameof (destination));
return SkiaApi.sk_pixmap_scale_pixels (Handle, destination.Handle, quality);
}
public bool ReadPixels (SKImageInfo dstInfo, IntPtr dstPixels, int dstRowBytes, int srcX, int srcY)
@ -234,17 +259,17 @@ namespace SkiaSharp
public SKPixmap WithColorType (SKColorType newColorType)
{
return new SKPixmap (Info.WithColorType (newColorType), GetPixels (), RowBytes, ColorTable);
return new SKPixmap (Info.WithColorType (newColorType), GetPixels (), RowBytes);
}
public SKPixmap WithColorSpace (SKColorSpace newColorSpace)
{
return new SKPixmap (Info.WithColorSpace (newColorSpace), GetPixels (), RowBytes, ColorTable);
return new SKPixmap (Info.WithColorSpace (newColorSpace), GetPixels (), RowBytes);
}
public SKPixmap WithAlphaType (SKAlphaType newAlphaType)
{
return new SKPixmap (Info.WithAlphaType (newAlphaType), GetPixels (), RowBytes, ColorTable);
return new SKPixmap (Info.WithAlphaType (newAlphaType), GetPixels (), RowBytes);
}
}
}

Просмотреть файл

@ -1,32 +1,67 @@
using System;
using System.Runtime.InteropServices;
namespace SkiaSharp
{
// public delegates
public delegate void SKSurfaceReleaseDelegate (IntPtr address, object context);
// internal proxy delegates
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
internal delegate void SKSurfaceReleaseDelegateInternal (IntPtr address, IntPtr context);
public class SKSurface : SKObject
{
[Obsolete ("Use Create(SKImageInfo) instead.")]
public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType) => Create (new SKImageInfo (width, height, colorType, alphaType));
[Obsolete ("Use Create(SKImageInfo, SKSurfaceProps) instead.")]
public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType, SKSurfaceProps props) => Create (new SKImageInfo (width, height, colorType, alphaType), props);
[Obsolete ("Use Create(SKImageInfo, IntPtr, int) instead.")]
public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType, IntPtr pixels, int rowBytes) => Create (new SKImageInfo (width, height, colorType, alphaType), pixels, rowBytes);
[Obsolete ("Use Create(SKImageInfo, IntPtr, int, SKSurfaceProps) instead.")]
public static SKSurface Create (int width, int height, SKColorType colorType, SKAlphaType alphaType, IntPtr pixels, int rowBytes, SKSurfaceProps props) => Create (new SKImageInfo (width, height, colorType, alphaType), pixels, rowBytes, props);
// so the GC doesn't collect the delegate
private static readonly SKSurfaceReleaseDelegateInternal releaseDelegateInternal;
private static readonly IntPtr releaseDelegate;
static SKSurface ()
{
releaseDelegateInternal = new SKSurfaceReleaseDelegateInternal (SKSurfaceReleaseInternal);
releaseDelegate = Marshal.GetFunctionPointerForDelegate (releaseDelegateInternal);
}
[Preserve]
internal SKSurface (IntPtr h, bool owns)
: base (h, owns)
{
}
// RASTER surface
public static SKSurface Create (SKImageInfo info)
{
return Create (info, 0);
}
public static SKSurface Create (SKImageInfo info, int rowBytes)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster (ref cinfo, IntPtr.Zero));
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster (ref cinfo, (IntPtr)rowBytes, IntPtr.Zero));
}
public static SKSurface Create (SKImageInfo info, SKSurfaceProps props)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster (ref cinfo, ref props));
return Create (info, 0, props);
}
public static SKSurface Create (SKImageInfo info, int rowBytes, SKSurfaceProps props)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster (ref cinfo, (IntPtr)rowBytes, ref props));
}
// convenience RASTER DIRECT to use a SKPixmap instead of SKImageInfo and IntPtr
public static SKSurface Create (SKPixmap pixmap)
{
if (pixmap == null) {
@ -35,12 +70,6 @@ namespace SkiaSharp
return Create (pixmap.Info, pixmap.GetPixels (), pixmap.RowBytes);
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, int rowBytes)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero));
}
public static SKSurface Create (SKPixmap pixmap, SKSurfaceProps props)
{
if (pixmap == null) {
@ -49,135 +78,225 @@ namespace SkiaSharp
return Create (pixmap.Info, pixmap.GetPixels (), pixmap.RowBytes, props);
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, int rowBytes, SKSurfaceProps props)
// RASTER DIRECT surface
public static SKSurface Create (SKImageInfo info, IntPtr pixels)
{
return Create (info, pixels, info.RowBytes, null, null);
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, int rowBytes)
{
return Create (info, pixels, rowBytes, null, null);
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, int rowBytes, SKSurfaceReleaseDelegate releaseProc, object context)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref cinfo, pixels, (IntPtr)rowBytes, ref props));
if (releaseProc == null) {
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
} else {
var ctx = new NativeDelegateContext (context, releaseProc);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref cinfo, pixels, (IntPtr)rowBytes, releaseDelegate, ctx.NativeContext, IntPtr.Zero));
}
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, SKSurfaceProps props)
{
return Create (info, pixels, info.RowBytes, null, null, props);
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, int rowBytes, SKSurfaceProps props)
{
return Create (info, pixels, rowBytes, null, null, props);
}
public static SKSurface Create (SKImageInfo info, IntPtr pixels, int rowBytes, SKSurfaceReleaseDelegate releaseProc, object context, SKSurfaceProps props)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
if (releaseProc == null) {
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref cinfo, pixels, (IntPtr)rowBytes, IntPtr.Zero, IntPtr.Zero, ref props));
} else {
var ctx = new NativeDelegateContext (context, releaseProc);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_raster_direct (ref cinfo, pixels, (IntPtr)rowBytes, releaseDelegate, ctx.NativeContext, ref props));
}
}
// GPU BACKEND RENDER TARGET surface
public static SKSurface Create (GRContext context, GRBackendRenderTarget renderTarget, GRSurfaceOrigin origin, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProps props)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (renderTarget == null)
throw new ArgumentNullException (nameof (renderTarget));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_render_target (context.Handle, renderTarget.Handle, origin, colorType, cs, ref props));
}
public static SKSurface Create (GRContext context, GRBackendRenderTargetDesc desc, SKSurfaceProps props)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_render_target (context.Handle, ref desc, ref props));
if (context == null)
throw new ArgumentNullException (nameof (context));
var renderTarget = new GRBackendRenderTarget (context.Backend, desc);
return Create (context, renderTarget, desc.Origin, desc.Config.ToColorType (), null, props);
}
public static SKSurface Create (GRContext context, GRBackendRenderTarget renderTarget, GRSurfaceOrigin origin, SKColorType colorType, SKColorSpace colorspace)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (renderTarget == null)
throw new ArgumentNullException (nameof (renderTarget));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_render_target (context.Handle, renderTarget.Handle, origin, colorType, cs, IntPtr.Zero));
}
public static SKSurface Create (GRContext context, GRBackendRenderTargetDesc desc)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_render_target (context.Handle, ref desc, IntPtr.Zero));
if (context == null)
throw new ArgumentNullException (nameof (context));
var renderTarget = new GRBackendRenderTarget (context.Backend, desc);
return Create (context, renderTarget, desc.Origin, desc.Config.ToColorType (), null);
}
// GPU BACKEND TEXTURE surface
public static SKSurface Create (GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProps props)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (texture == null)
throw new ArgumentNullException (nameof (texture));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture (context.Handle, texture.Handle, origin, sampleCount, colorType, cs, ref props));
}
public static SKSurface Create (GRContext context, GRGlBackendTextureDesc desc, SKSurfaceProps props)
{
unsafe {
var h = desc.TextureHandle;
var hPtr = &h;
var d = new GRBackendTextureDesc {
Flags = desc.Flags,
Origin = desc.Origin,
Width = desc.Width,
Height = desc.Height,
Config = desc.Config,
SampleCount = desc.SampleCount,
TextureHandle = (IntPtr)hPtr,
};
return Create (context, d, props);
}
if (context == null)
throw new ArgumentNullException (nameof (context));
var texture = new GRBackendTexture (desc);
return Create (context, texture, desc.Origin, desc.SampleCount, desc.Config.ToColorType(), null, props);
}
public static SKSurface Create (GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (texture == null)
throw new ArgumentNullException (nameof (texture));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture (context.Handle, texture.Handle, origin, sampleCount, colorType, cs, IntPtr.Zero));
}
public static SKSurface Create (GRContext context, GRGlBackendTextureDesc desc)
{
unsafe {
var h = desc.TextureHandle;
var hPtr = &h;
var d = new GRBackendTextureDesc
{
Flags = desc.Flags,
Origin = desc.Origin,
Width = desc.Width,
Height = desc.Height,
Config = desc.Config,
SampleCount = desc.SampleCount,
TextureHandle = (IntPtr)hPtr,
};
return Create (context, d);
}
if (context == null)
throw new ArgumentNullException (nameof (context));
var texture = new GRBackendTexture (desc);
return Create (context, texture, desc.Origin, desc.SampleCount, desc.Config.ToColorType (), null);
}
// GPU BACKEND TEXTURE AS RENDER TARGET surface
public static SKSurface CreateAsRenderTarget (GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace, SKSurfaceProps props)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (texture == null)
throw new ArgumentNullException (nameof (texture));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture_as_render_target (context.Handle, texture.Handle, origin, sampleCount, colorType, cs, ref props));
}
public static SKSurface CreateAsRenderTarget (GRContext context, GRGlBackendTextureDesc desc, SKSurfaceProps props)
{
unsafe {
var h = desc.TextureHandle;
var hPtr = &h;
var d = new GRBackendTextureDesc
{
Flags = desc.Flags,
Origin = desc.Origin,
Width = desc.Width,
Height = desc.Height,
Config = desc.Config,
SampleCount = desc.SampleCount,
TextureHandle = (IntPtr)hPtr,
};
return CreateAsRenderTarget (context, d, props);
}
if (context == null)
throw new ArgumentNullException (nameof (context));
var texture = new GRBackendTexture (desc);
return CreateAsRenderTarget (context, texture, desc.Origin, desc.SampleCount, desc.Config.ToColorType (), null, props);
}
public static SKSurface CreateAsRenderTarget (GRContext context, GRBackendTexture texture, GRSurfaceOrigin origin, int sampleCount, SKColorType colorType, SKColorSpace colorspace)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
if (texture == null)
throw new ArgumentNullException (nameof (texture));
var cs = colorspace == null ? IntPtr.Zero : colorspace.Handle;
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture_as_render_target (context.Handle, texture.Handle, origin, sampleCount, colorType, cs, IntPtr.Zero));
}
public static SKSurface CreateAsRenderTarget (GRContext context, GRGlBackendTextureDesc desc)
{
unsafe {
var h = desc.TextureHandle;
var hPtr = &h;
var d = new GRBackendTextureDesc
{
Flags = desc.Flags,
Origin = desc.Origin,
Width = desc.Width,
Height = desc.Height,
Config = desc.Config,
SampleCount = desc.SampleCount,
TextureHandle = (IntPtr)hPtr,
};
return CreateAsRenderTarget (context, d);
}
if (context == null)
throw new ArgumentNullException (nameof (context));
var texture = new GRBackendTexture (desc);
return CreateAsRenderTarget (context, texture, desc.Origin, desc.SampleCount, desc.Config.ToColorType (), null);
}
public static SKSurface Create (GRContext context, GRBackendTextureDesc desc, SKSurfaceProps props)
// GPU NEW surface
public static SKSurface Create (GRContext context, bool budgeted, SKImageInfo info, int sampleCount, GRSurfaceOrigin origin, SKSurfaceProps props, bool shouldCreateWithMips)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture (context.Handle, ref desc, ref props));
if (context == null)
throw new ArgumentNullException (nameof (context));
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_render_target (context.Handle, budgeted, ref cinfo, sampleCount, origin, ref props, shouldCreateWithMips));
}
public static SKSurface Create (GRContext context, GRBackendTextureDesc desc)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture (context.Handle, ref desc, IntPtr.Zero));
}
public static SKSurface CreateAsRenderTarget (GRContext context, GRBackendTextureDesc desc, SKSurfaceProps props)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture_as_render_target (context.Handle, ref desc, ref props));
}
public static SKSurface CreateAsRenderTarget (GRContext context, GRBackendTextureDesc desc)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_backend_texture_as_render_target (context.Handle, ref desc, IntPtr.Zero));
}
public static SKSurface Create (GRContext context, bool budgeted, SKImageInfo info, int sampleCount, SKSurfaceProps props)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_render_target (context.Handle, budgeted, ref cinfo, sampleCount, ref props));
return Create (context, budgeted, info, sampleCount, GRSurfaceOrigin.BottomLeft, props, false);
}
public static SKSurface Create (GRContext context, bool budgeted, SKImageInfo info, SKSurfaceProps props)
{
return Create (context, budgeted, info, 0, GRSurfaceOrigin.BottomLeft, props, false);
}
public static SKSurface Create (GRContext context, bool budgeted, SKImageInfo info, int sampleCount, GRSurfaceOrigin origin)
{
if (context == null)
throw new ArgumentNullException (nameof (context));
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_render_target (context.Handle, budgeted, ref cinfo, sampleCount, origin, IntPtr.Zero, false));
}
public static SKSurface Create (GRContext context, bool budgeted, SKImageInfo info, int sampleCount)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_render_target (context.Handle, budgeted, ref cinfo, sampleCount, IntPtr.Zero));
return Create (context, budgeted, info, sampleCount, GRSurfaceOrigin.BottomLeft);
}
public static SKSurface Create (GRContext context, bool budgeted, SKImageInfo info)
{
var cinfo = SKImageInfoNative.FromManaged (ref info);
return GetObject<SKSurface> (SkiaApi.sk_surface_new_render_target (context.Handle, budgeted, ref cinfo, 0, IntPtr.Zero));
return Create (context, budgeted, info, 0, GRSurfaceOrigin.BottomLeft);
}
// NULL surface
public static SKSurface CreateNull (int width, int height)
{
return GetObject<SKSurface> (SkiaApi.sk_surface_new_null (width, height));
}
//
protected override void Dispose (bool disposing)
{
if (Handle != IntPtr.Zero && OwnsHandle) {
@ -239,6 +358,16 @@ namespace SkiaSharp
var cinfo = SKImageInfoNative.FromManaged (ref dstInfo);
return SkiaApi.sk_surface_read_pixels (Handle, ref cinfo, dstPixels, (IntPtr)dstRowBytes, srcX, srcY);
}
// internal proxy
[MonoPInvokeCallback (typeof (SKSurfaceReleaseDelegateInternal))]
private static void SKSurfaceReleaseInternal (IntPtr address, IntPtr context)
{
using (var ctx = NativeDelegateContext.Unwrap (context)) {
ctx.GetDelegate<SKSurfaceReleaseDelegate> () (address, ctx.ManagedContext);
}
}
}
}

Просмотреть файл

@ -4,6 +4,15 @@ using System.Runtime.InteropServices;
namespace SkiaSharp
{
[Flags]
[Obsolete("Use SKFontStyleWeight and SKFontStyleSlant instead.")]
public enum SKTypefaceStyle {
Normal = 0,
Bold = 0x01,
Italic = 0x02,
BoldItalic = 0x03
}
public class SKTypeface : SKObject
{
[Preserve]
@ -21,9 +30,13 @@ namespace SkiaSharp
base.Dispose (disposing);
}
[Obsolete ("Use FromFamilyName(string, SKFontStyleWeight, SKFontStyleWidth, SKFontStyleSlant) instead.")]
public static SKTypeface FromFamilyName (string familyName, SKTypefaceStyle style = SKTypefaceStyle.Normal)
{
return GetObject<SKTypeface> (SkiaApi.sk_typeface_create_from_name (familyName, style));
var weight = style.HasFlag (SKTypefaceStyle.Bold) ? SKFontStyleWeight.Bold : SKFontStyleWeight.Normal;
var slant = style.HasFlag (SKTypefaceStyle.Italic) ? SKFontStyleSlant.Italic : SKFontStyleSlant.Upright;
return FromFamilyName (familyName, weight, SKFontStyleWidth.Normal, slant);
}
public static SKTypeface FromFamilyName (string familyName, int weight, int width, SKFontStyleSlant slant)
@ -36,11 +49,12 @@ namespace SkiaSharp
return FromFamilyName(familyName, (int)weight, (int)width, slant);
}
[Obsolete ("Use FromFamilyName(string, SKFontStyleWeight, SKFontStyleWidth, SKFontStyleSlant) instead.")]
public static SKTypeface FromTypeface (SKTypeface typeface, SKTypefaceStyle style = SKTypefaceStyle.Normal)
{
if (typeface == null)
throw new ArgumentNullException (nameof (typeface));
return GetObject<SKTypeface> (SkiaApi.sk_typeface_create_from_typeface (typeface.Handle, style));
return FromFamilyName (typeface.FamilyName, style);
}
public static SKTypeface FromFile (string path, int index = 0)
@ -153,7 +167,18 @@ namespace SkiaSharp
public int FontWeight => SkiaApi.sk_typeface_get_font_weight (Handle);
public int FontWidth => SkiaApi.sk_typeface_get_font_width (Handle);
public SKFontStyleSlant FontSlant => SkiaApi.sk_typeface_get_font_slant (Handle);
public SKTypefaceStyle Style => SkiaApi.sk_typeface_get_style (Handle);
[Obsolete ("Use FontWeight and FontSlant instead.")]
public SKTypefaceStyle Style {
get {
var style = SKTypefaceStyle.Normal;
if (FontWeight >= (int)SKFontStyleWeight.SemiBold)
style |= SKTypefaceStyle.Bold;
if (FontSlant != (int)SKFontStyleSlant.Upright)
style |= SKTypefaceStyle.Italic;
return style;
}
}
public int UnitsPerEm => SkiaApi.sk_typeface_get_units_per_em(Handle);

Просмотреть файл

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Runtime.InteropServices;
using GRBackendObject = System.IntPtr;
using GRBackendContext = System.IntPtr;
using sk_surface_t = System.IntPtr;
using sk_canvas_t = System.IntPtr;
@ -32,8 +31,6 @@ using sk_wstream_dynamicmemorystream_t = System.IntPtr;
using sk_wstream_filestream_t = System.IntPtr;
using sk_bitmap_t = System.IntPtr;
using sk_pixmap_t = System.IntPtr;
using sk_pixelserializer_t = System.IntPtr;
using sk_managedpixelserializer_t = System.IntPtr;
using sk_codec_t = System.IntPtr;
using sk_imagefilter_croprect_t = System.IntPtr;
using sk_imagefilter_t = System.IntPtr;
@ -57,9 +54,13 @@ using sk_color_t = System.UInt32;
using sk_pmcolor_t = System.UInt32;
using sk_vertices_t = System.IntPtr;
using sk_rrect_t = System.IntPtr;
using gr_backendtexture_t = System.IntPtr;
using gr_backendrendertarget_t = System.IntPtr;
namespace SkiaSharp
{
#pragma warning disable IDE1006 // Naming Styles
internal static class SkiaApi
{
#if __TVOS__ && __UNIFIED__
@ -128,53 +129,40 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKColorType sk_colortype_get_default_8888();
// Pixel Serializer
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_pixelserializer_unref(sk_pixelserializer_t cserializer);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_pixelserializer_use_encoded_data(sk_pixelserializer_t cserializer, IntPtr data, IntPtr len);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_data_t sk_pixelserializer_encode(sk_pixelserializer_t cserializer, sk_pixmap_t cpixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_managedpixelserializer_t sk_managedpixelserializer_new();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_managedpixelserializer_set_delegates(IntPtr pUse, IntPtr pEncode);
// Surface
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_null(int width, int height);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_surface_unref(sk_surface_t t);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_raster(ref SKImageInfoNative info, ref SKSurfaceProps pros);
public extern static sk_surface_t sk_surface_new_raster(ref SKImageInfoNative info, IntPtr rowBytes, ref SKSurfaceProps props);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_raster(ref SKImageInfoNative info, IntPtr propsZero);
public extern static sk_surface_t sk_surface_new_raster(ref SKImageInfoNative info, IntPtr rowBytes, IntPtr propsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_raster_direct(ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, ref SKSurfaceProps props);
public extern static sk_surface_t sk_surface_new_raster_direct(ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, IntPtr releaseProc, IntPtr context, ref SKSurfaceProps props);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_raster_direct(ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, IntPtr propsZero);
public extern static sk_surface_t sk_surface_new_raster_direct(ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, IntPtr releaseProc, IntPtr context, IntPtr propsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_canvas_t sk_surface_get_canvas(sk_surface_t t);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_surface_new_image_snapshot(sk_surface_t t);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_backend_render_target (gr_context_t context, ref GRBackendRenderTargetDesc desc, ref SKSurfaceProps props);
public extern static sk_surface_t sk_surface_new_backend_render_target(gr_context_t context, gr_backendrendertarget_t target, GRSurfaceOrigin origin, SKColorType colorType, sk_colorspace_t colorspace, ref SKSurfaceProps props);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_backend_render_target (gr_context_t context, ref GRBackendRenderTargetDesc desc, IntPtr propsZero);
public extern static sk_surface_t sk_surface_new_backend_render_target(gr_context_t context, gr_backendrendertarget_t target, GRSurfaceOrigin origin, SKColorType colorType, sk_colorspace_t colorspace, IntPtr propsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_backend_texture (gr_context_t context, ref GRBackendTextureDesc desc, ref SKSurfaceProps props);
public extern static sk_surface_t sk_surface_new_backend_texture(gr_context_t context, gr_backendtexture_t texture, GRSurfaceOrigin origin, int samples, SKColorType colorType, sk_colorspace_t colorspace, ref SKSurfaceProps props);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_backend_texture (gr_context_t context, ref GRBackendTextureDesc desc, IntPtr propsZero);
public extern static sk_surface_t sk_surface_new_backend_texture(gr_context_t context, gr_backendtexture_t texture, GRSurfaceOrigin origin, int samples, SKColorType colorType, sk_colorspace_t colorspace, IntPtr propsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_backend_texture_as_render_target (gr_context_t context, ref GRBackendTextureDesc desc, ref SKSurfaceProps props);
public extern static sk_surface_t sk_surface_new_backend_texture_as_render_target(gr_context_t context, gr_backendtexture_t texture, GRSurfaceOrigin origin, int samples, SKColorType colorType, sk_colorspace_t colorspace, ref SKSurfaceProps props);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_backend_texture_as_render_target (gr_context_t context, ref GRBackendTextureDesc desc, IntPtr propsZero);
public extern static sk_surface_t sk_surface_new_backend_texture_as_render_target(gr_context_t context, gr_backendtexture_t texture, GRSurfaceOrigin origin, int samples, SKColorType colorType, sk_colorspace_t colorspace, IntPtr propsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_render_target (gr_context_t context, [MarshalAs(UnmanagedType.I1)] bool budgeted, ref SKImageInfoNative info, int sampleCount, ref SKSurfaceProps props);
public extern static sk_surface_t sk_surface_new_render_target(gr_context_t context, [MarshalAs(UnmanagedType.I1)] bool budgeted, ref SKImageInfoNative info, int sampleCount, GRSurfaceOrigin origin, ref SKSurfaceProps props, [MarshalAs(UnmanagedType.I1)] bool shouldCreateWithMips);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_surface_t sk_surface_new_render_target (gr_context_t context, [MarshalAs(UnmanagedType.I1)] bool budgeted, ref SKImageInfoNative info, int sampleCount, IntPtr propsZero);
public extern static sk_surface_t sk_surface_new_render_target(gr_context_t context, [MarshalAs(UnmanagedType.I1)] bool budgeted, ref SKImageInfoNative info, int sampleCount, GRSurfaceOrigin origin, IntPtr propsZero, [MarshalAs(UnmanagedType.I1)] bool shouldCreateWithMips);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_surface_draw(sk_surface_t surface, sk_canvas_t canvas, float x, float y, sk_paint_t paint);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -524,8 +512,6 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_raster_copy_with_pixmap(sk_pixmap_t pixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_raster_copy_with_colortable(ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, sk_colortable_t ctable);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_raster_data(ref SKImageInfoNative info, sk_data_t pixels, IntPtr rowBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_raster(sk_pixmap_t pixmap, IntPtr releaseProc, IntPtr context);
@ -536,9 +522,9 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_from_encoded(sk_data_t encoded, IntPtr subsetZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_from_texture(gr_context_t context, ref GRBackendTextureDesc desc, SKAlphaType alpha, sk_colorspace_t colorSpace, IntPtr releaseProc, IntPtr releaseContext);
public extern static sk_image_t sk_image_new_from_texture(gr_context_t context, gr_backendtexture_t texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, sk_colorspace_t colorSpace, IntPtr releaseProc, IntPtr releaseContext);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_from_adopted_texture(gr_context_t context, ref GRBackendTextureDesc desc, SKAlphaType alpha, sk_colorspace_t colorSpace);
public extern static sk_image_t sk_image_new_from_adopted_texture(gr_context_t context, gr_backendtexture_t texture, GRSurfaceOrigin origin, SKColorType colorType, SKAlphaType alpha, sk_colorspace_t colorSpace);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_image_t sk_image_new_from_picture(sk_picture_t picture, ref SKSizeI dimensions, ref SKMatrix matrix, sk_paint_t paint);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -552,6 +538,10 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKAlphaType sk_image_get_alpha_type(sk_image_t image);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKColorType sk_image_get_color_type(sk_image_t image);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_colorspace_t sk_image_get_colorspace(sk_image_t image);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_image_is_alpha_only(sk_image_t image);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -577,9 +567,9 @@ namespace SkiaSharp
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_image_scale_pixels(sk_image_t image, sk_pixmap_t dst, SKFilterQuality quality, SKImageCachingHint cachingHint);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_data_t sk_image_encode(sk_image_t image);
public extern static sk_data_t sk_image_ref_encoded(sk_image_t image);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_data_t sk_image_encode_with_serializer(sk_image_t image, sk_pixelserializer_t serializer);
public extern static sk_data_t sk_image_encode(sk_image_t image);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_data_t sk_image_encode_specific(sk_image_t image, SKEncodedImageFormat encoder, int quality);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -783,7 +773,7 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_maskfilter_t sk_maskfilter_new_blur(SKBlurStyle style, float sigma);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_maskfilter_t sk_maskfilter_new_blur_with_flags(SKBlurStyle style, float sigma, ref SKRect occluder, SKBlurMaskFilterFlags flags);
public extern static sk_maskfilter_t sk_maskfilter_new_blur_with_flags(SKBlurStyle style, float sigma, ref SKRect occluder, bool respectCTM);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_maskfilter_t sk_maskfilter_new_table(byte[] table /*[256]*/);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -837,7 +827,7 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_matrix_convolution(ref SKSizeI kernelSize, float[] kernel, float gain, float bias, ref SKPointI kernelOffset, SKMatrixConvolutionTileMode tileMode, [MarshalAs(UnmanagedType.I1)] bool convolveAlpha, sk_imagefilter_t input /*NULL*/, sk_imagefilter_croprect_t cropRect /*NULL*/);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_merge(sk_imagefilter_t[] filters, int count, SKBlendMode[] modes /*NULL*/, sk_imagefilter_croprect_t cropRect /*NULL*/);
public extern static sk_imagefilter_t sk_imagefilter_new_merge(sk_imagefilter_t[] filters, int count, sk_imagefilter_croprect_t cropRect /*NULL*/);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_dilate(int radiusX, int radiusY, sk_imagefilter_t input /*NULL*/, sk_imagefilter_croprect_t cropRect /*NULL*/);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -849,8 +839,6 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_picture_with_croprect(sk_picture_t picture, ref SKRect cropRect);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_picture_for_localspace(sk_picture_t picture, ref SKRect cropRect, SKFilterQuality filterQuality);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_tile(ref SKRect src, ref SKRect dst, sk_imagefilter_t input);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_imagefilter_t sk_imagefilter_new_xfermode(SKBlendMode mode, sk_imagefilter_t background, sk_imagefilter_t foreground /*NULL*/, sk_imagefilter_croprect_t cropRect /*NULL*/);
@ -1012,12 +1000,8 @@ namespace SkiaSharp
// Typeface
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_typeface_t sk_typeface_create_from_name([MarshalAs(UnmanagedType.LPStr)] string str, SKTypefaceStyle style);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_typeface_t sk_typeface_create_from_name_with_font_style([MarshalAs(UnmanagedType.LPStr)] string familyName, int weight, int width, SKFontStyleSlant slant);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_typeface_t sk_typeface_create_from_typeface(sk_typeface_t typeface, SKTypefaceStyle style);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_typeface_t sk_typeface_create_from_file([MarshalAs(UnmanagedType.LPStr)] string path, int index);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1043,14 +1027,14 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKFontStyleSlant sk_typeface_get_font_slant(sk_typeface_t typeface);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKTypefaceStyle sk_typeface_get_style(sk_typeface_t typeface);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_stream_assetstream_t sk_typeface_open_stream(sk_typeface_t typeface, out int ttcIndex);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int sk_typeface_get_units_per_em(sk_typeface_t typeface);
// FontMgr
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_fontmgr_t sk_fontmgr_create_default();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_fontmgr_t sk_fontmgr_ref_default();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_fontmgr_unref(sk_fontmgr_t fontmgr);
@ -1220,11 +1204,9 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_document_unref(sk_document_t document);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_document_t sk_document_create_pdf_from_stream(sk_wstream_t stream, float dpi);
public extern static sk_document_t sk_document_create_pdf_from_stream(sk_wstream_t stream);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_document_t sk_document_create_pdf_from_stream_with_metadata(sk_wstream_t stream, float dpi, ref SKDocumentPdfMetadataInternal metadata);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_document_t sk_document_create_pdf_from_filename([MarshalAs(UnmanagedType.LPStr)] string path, float dpi);
public extern static sk_document_t sk_document_create_pdf_from_stream_with_metadata(sk_wstream_t stream, ref SKDocumentPdfMetadataInternal metadata);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_document_t sk_document_create_xps_from_stream(sk_wstream_t stream, float dpi);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1242,7 +1224,7 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static IntPtr sk_codec_min_buffered_bytes_needed();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_codec_t sk_codec_new_from_stream(sk_stream_t stream);
public extern static sk_codec_t sk_codec_new_from_stream(sk_stream_t stream, out SKCodecResult result);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_codec_t sk_codec_new_from_data(sk_data_t data);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1250,9 +1232,7 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_codec_get_info(sk_codec_t codec, out SKImageInfoNative info);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_codec_get_encodedinfo(sk_codec_t codec, out SKEncodedInfo info);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecOrigin sk_codec_get_origin(sk_codec_t codec);
public extern static SKEncodedOrigin sk_codec_get_origin(sk_codec_t codec);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_codec_get_scaled_dimensions(sk_codec_t codec, float desiredScale, out SKSizeI dimensions);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1261,15 +1241,13 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKEncodedImageFormat sk_codec_get_encoded_format(sk_codec_t codec);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_get_pixels(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, ref SKCodecOptionsInternal options, IntPtr ctable, ref int ctableCount);
public extern static SKCodecResult sk_codec_get_pixels(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, ref SKCodecOptionsInternal options);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_get_pixels_using_defaults(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_start_incremental_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, ref SKCodecOptionsInternal options, IntPtr ctable, ref int ctableCount);
public extern static SKCodecResult sk_codec_start_incremental_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, ref SKCodecOptionsInternal options);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_start_incremental_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, ref SKCodecOptionsInternal options, IntPtr ctableZero, IntPtr ctableCountZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_start_incremental_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, IntPtr optionsZero, IntPtr ctableZero, IntPtr ctableCountZero);
public extern static SKCodecResult sk_codec_start_incremental_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr pixels, IntPtr rowBytes, IntPtr optionsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_incremental_decode(sk_codec_t codec, out int rowsDecoded);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1279,11 +1257,9 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_codec_get_frame_info(sk_codec_t codec, [Out] SKCodecFrameInfo[] frameInfo);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_start_scanline_decode(sk_codec_t codec, ref SKImageInfoNative info, ref SKCodecOptionsInternal options, IntPtr ctable, ref int ctableCount);
public extern static SKCodecResult sk_codec_start_scanline_decode(sk_codec_t codec, ref SKImageInfoNative info, ref SKCodecOptionsInternal options);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_start_scanline_decode(sk_codec_t codec, ref SKImageInfoNative info, ref SKCodecOptionsInternal options, IntPtr ctableZero, IntPtr ctableCountZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static SKCodecResult sk_codec_start_scanline_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr optionsZero, IntPtr ctableZero, IntPtr ctableCountZero);
public extern static SKCodecResult sk_codec_start_scanline_decode(sk_codec_t codec, ref SKImageInfoNative info, IntPtr optionsZero);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int sk_codec_get_scanlines(sk_codec_t codec, IntPtr dst, int countLines, IntPtr rowBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1351,7 +1327,7 @@ namespace SkiaSharp
public extern static bool sk_bitmap_ready_to_draw(sk_bitmap_t b);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_install_pixels(sk_bitmap_t cbitmap, ref SKImageInfoNative cinfo, IntPtr pixels, IntPtr rowBytes, sk_colortable_t ctable, IntPtr releaseProc, IntPtr context);
public extern static bool sk_bitmap_install_pixels(sk_bitmap_t cbitmap, ref SKImageInfoNative cinfo, IntPtr pixels, IntPtr rowBytes, IntPtr releaseProc, IntPtr context);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_install_pixels_with_pixmap(sk_bitmap_t cbitmap, sk_pixmap_t cpixmap);
@ -1363,19 +1339,14 @@ namespace SkiaSharp
public extern static bool sk_bitmap_try_alloc_pixels(sk_bitmap_t cbitmap, ref SKImageInfoNative requestedInfo, IntPtr rowBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_try_alloc_pixels_with_color_table(sk_bitmap_t cbitmap, ref SKImageInfoNative requestedInfo, sk_colortable_t ctable, SKBitmapAllocFlags flags);
public extern static bool sk_bitmap_try_alloc_pixels_with_flags(sk_bitmap_t cbitmap, ref SKImageInfoNative requestedInfo, SKBitmapAllocFlags flags);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_colortable_t sk_bitmap_get_colortable(sk_bitmap_t cbitmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_bitmap_set_pixels(sk_bitmap_t cbitmap, IntPtr pixels, sk_colortable_t ctable);
public extern static void sk_bitmap_set_pixels(sk_bitmap_t cbitmap, IntPtr pixels);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_peek_pixels(sk_bitmap_t cbitmap, sk_pixmap_t cpixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmapscaler_resize(sk_pixmap_t cdst, sk_pixmap_t csrc, SKBitmapResizeMethod method);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_bitmap_extract_subset(sk_bitmap_t cbitmap, sk_bitmap_t cdst, ref SKRectI subset);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
@ -1407,19 +1378,17 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_pixmap_t sk_pixmap_new();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_pixmap_t sk_pixmap_new_with_params(ref SKImageInfoNative cinfo, IntPtr addr, IntPtr rowBytes, sk_colortable_t ctable);
public extern static sk_pixmap_t sk_pixmap_new_with_params(ref SKImageInfoNative cinfo, IntPtr addr, IntPtr rowBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_pixmap_reset(sk_pixmap_t cpixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_pixmap_reset_with_params(sk_pixmap_t cpixmap, ref SKImageInfoNative cinfo, IntPtr addr, IntPtr rowBytes, sk_colortable_t ctable);
public extern static void sk_pixmap_reset_with_params(sk_pixmap_t cpixmap, ref SKImageInfoNative cinfo, IntPtr addr, IntPtr rowBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_pixmap_get_info(sk_pixmap_t cpixmap, out SKImageInfoNative cinfo);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static IntPtr sk_pixmap_get_row_bytes(sk_pixmap_t cpixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static IntPtr sk_pixmap_get_pixels(sk_pixmap_t cpixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_colortable_t sk_pixmap_get_colortable(sk_pixmap_t cpixmap);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
@ -1427,6 +1396,9 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool sk_pixmap_read_pixels(sk_pixmap_t cpixmap, ref SKImageInfoNative dstInfo, IntPtr dstPixels, IntPtr dstRowBytes, int srcX, int srcY);
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs (UnmanagedType.I1)]
public extern static bool sk_pixmap_scale_pixels (sk_pixmap_t cpixmap, sk_pixmap_t dst, SKFilterQuality quality);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void sk_swizzle_swap_rb(IntPtr dest, IntPtr src, int count);
@ -1603,8 +1575,6 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_path_effect_t sk_path_effect_create_corner(float radius);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_path_effect_t sk_path_effect_create_arc_to(float radius);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_path_effect_t sk_path_effect_create_1d_path(sk_path_t path, float advance, float phase, SKPath1DPathEffectStyle style);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_path_effect_t sk_path_effect_create_2d_line(float width, ref SKMatrix matrix);
@ -1629,9 +1599,7 @@ namespace SkiaSharp
// GRContext
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_context_t gr_context_create (GRBackend backend, GRBackendContext backendContext, ref GRContextOptions options);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_context_t gr_context_create_with_defaults (GRBackend backend, GRBackendContext backendContext);
public extern static gr_context_t gr_context_make_gl (gr_glinterface_t glInterface);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_context_unref (gr_context_t context);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1645,14 +1613,16 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_context_get_resource_cache_usage (gr_context_t context, out int maxResources, out IntPtr maxResourceBytes);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_context_get_recommended_sample_count (gr_context_t context, GRPixelConfig config, float dpi);
public extern static int gr_context_get_max_surface_sample_count_for_color_type (gr_context_t context, SKColorType colorType);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_context_flush (gr_context_t context);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_context_reset_context (gr_context_t context, UInt32 state);
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static GRBackend gr_context_get_backend (gr_context_t context);
// GLInterface
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_glinterface_t gr_glinterface_assemble_interface (IntPtr ctx, IntPtr get);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
@ -1660,20 +1630,61 @@ namespace SkiaSharp
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_glinterface_t gr_glinterface_assemble_gles_interface (IntPtr ctx, IntPtr get);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_glinterface_t gr_glinterface_default_interface ();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_glinterface_t gr_glinterface_create_native_interface ();
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_glinterface_unref (gr_glinterface_t glInterface);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_glinterface_t gr_glinterface_clone (gr_glinterface_t glInterface);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_glinterface_validate (gr_glinterface_t glInterface);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_glinterface_has_extension (gr_glinterface_t glInterface, [MarshalAs(UnmanagedType.LPStr)] string extension);
// GRBackendTexture
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_backendtexture_t gr_backendtexture_new_gl(int width, int height, [MarshalAs(UnmanagedType.I1)] bool mipmapped, ref GRGlTextureInfo glInfo);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_backendtexture_delete(gr_backendtexture_t texture);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_backendtexture_is_valid(gr_backendtexture_t texture);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_backendtexture_get_width(gr_backendtexture_t texture);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_backendtexture_get_height(gr_backendtexture_t texture);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_backendtexture_has_mipmaps(gr_backendtexture_t texture);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static GRBackend gr_backendtexture_get_backend(gr_backendtexture_t texture);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_backendtexture_get_gl_textureinfo(gr_backendtexture_t texture, out GRGlTextureInfo glInfo);
// GRBackendRenderTarget
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static gr_backendrendertarget_t gr_backendrendertarget_new_gl(int width, int height, int samples, int stencils, ref GRGlFramebufferInfo glInfo);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static void gr_backendrendertarget_delete(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_backendrendertarget_is_valid(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_backendrendertarget_get_width(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_backendrendertarget_get_height(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_backendrendertarget_get_samples(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static int gr_backendrendertarget_get_stencils(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static GRBackend gr_backendrendertarget_get_backend(gr_backendrendertarget_t rendertarget);
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
public extern static bool gr_backendrendertarget_get_gl_framebufferinfo(gr_backendrendertarget_t rendertarget, out GRGlFramebufferInfo glInfo);
// XML
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)]
public extern static sk_xmlstreamwriter_t sk_xmlstreamwriter_new (sk_wstream_t stream);
@ -1773,4 +1784,6 @@ namespace SkiaSharp
[return: MarshalAs (UnmanagedType.I1)]
public extern static bool sk_rrect_transform (sk_rrect_t rrect, [In] ref SKMatrix matrix, sk_rrect_t dest);
}
#pragma warning restore IDE1006 // Naming Styles
}

2
externals/skia поставляемый

@ -1 +1 @@
Subproject commit 72deb3e1083ab76b7fdcbdc382b3fbb61597675d
Subproject commit 08af5e7365a0decd32e337229ea0a1e91c02b983