зеркало из https://github.com/mono/SkiaSharp.git
Function pointers and LibraryImport (#2917)
* Update generator to emit function pointers * Regenerate interop files * Enable USE_LIBRARY_IMPORT in HarfBuzzSharp * Enable USE_LIBRARY_IMPORT on SkiaSharp * Set DisableRuntimeMarshalling on HarfBuzzSharp * Replace remaining DllImports with LibraryImport on SkiaSharp * Set DisableRuntimeMarshalling on SkiaSharp as well * Fix missed proxy definition * Regenerate skia api with a correct submodule version * Collections literals are not supported on the CI .NET SDK * An attempt to fix Tizen build * Forgot about partial * Set UnmanagedType.LPStr on evas_gl_proc_address_get instead * Set USE_LIBRARY_IMPORT on remaining projects too * Update generator tool to generate DelegateProxy as well * Regenerate HarfBuzz and SkiaSharp with new DelegateProxy source gen * Regenerate other projects as well * Add `protected internal` to test classes too, since this project has InternalsVisibleTo configured * Disable DelegateTypesAreValid and DelegateTypesHaveAttributes tests on .NET 7+ build, see comments * Reduce warnings noise * Update binding/SkiaSharp/GRGlInterface.cs Co-authored-by: Filip Navara <filip.navara@gmail.com> * Add missing USE_LIBRARY_IMPORT defines * Update binding/SkiaSharp/GRGlInterface.cs * Also needs USE_LIBRARY_IMPORT --------- Co-authored-by: Matthew Leibowitz <mattleibow@live.com> Co-authored-by: Filip Navara <filip.navara@gmail.com>
This commit is contained in:
Родитель
6058ab0c79
Коммит
9cbf9c80b7
|
@ -25,20 +25,6 @@ namespace SkiaSharp
|
|||
{
|
||||
// normal delegates
|
||||
|
||||
[MethodImpl (MethodImplOptions.AggressiveInlining)]
|
||||
public static T Create<T> (object managedDel, T nativeDel, out GCHandle gch, out IntPtr contextPtr)
|
||||
{
|
||||
if (managedDel == null) {
|
||||
gch = default (GCHandle);
|
||||
contextPtr = IntPtr.Zero;
|
||||
return default (T);
|
||||
}
|
||||
|
||||
gch = GCHandle.Alloc (managedDel);
|
||||
contextPtr = GCHandle.ToIntPtr (gch);
|
||||
return nativeDel;
|
||||
}
|
||||
|
||||
[MethodImpl (MethodImplOptions.AggressiveInlining)]
|
||||
public static void Create (object managedDel, out GCHandle gch, out IntPtr contextPtr)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
|
||||
namespace HarfBuzzSharp
|
||||
|
@ -84,7 +83,8 @@ namespace HarfBuzzSharp
|
|||
|
||||
private static IntPtr Create (IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseProc)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (releaseProc, DelegateProxies.ReleaseDelegateProxy, out _, out var ctx);
|
||||
DelegateProxies.Create (releaseProc, out _, out var ctx);
|
||||
var proxy = releaseProc != null ? DelegateProxies.DestroyProxy : null;
|
||||
return HarfBuzzApi.hb_blob_create ((void*)data, (uint)length, mode, (void*)ctx, proxy);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
// ReSharper disable PartialMethodParameterNameMismatch
|
||||
|
||||
namespace HarfBuzzSharp
|
||||
{
|
||||
|
@ -11,15 +13,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
// references to the proxy implementations
|
||||
public static readonly DestroyProxyDelegate ReleaseDelegateProxy = ReleaseDelegateProxyImplementation;
|
||||
public static readonly DestroyProxyDelegate ReleaseDelegateProxyForMulti = ReleaseDelegateProxyImplementationForMulti;
|
||||
public static readonly ReferenceTableProxyDelegate GetTableDelegateProxy = GetTableDelegateProxyImplementation;
|
||||
|
||||
// internal proxy implementations
|
||||
|
||||
[MonoPInvokeCallback (typeof (DestroyProxyDelegate))]
|
||||
private static void ReleaseDelegateProxyImplementation (void* context)
|
||||
private static partial void DestroyProxyImplementation (void* context)
|
||||
{
|
||||
var del = Get<ReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -29,16 +23,7 @@ namespace HarfBuzzSharp
|
|||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (ReferenceTableProxyDelegate))]
|
||||
private static IntPtr GetTableDelegateProxyImplementation (IntPtr face, uint tag, void* context)
|
||||
{
|
||||
GetMultiUserData<GetTableDelegate, Face> ((IntPtr)context, out var getTable, out var userData, out _);
|
||||
var blob = getTable.Invoke (userData, tag);
|
||||
return blob?.Handle ?? IntPtr.Zero;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (DestroyProxyDelegate))]
|
||||
private static void ReleaseDelegateProxyImplementationForMulti (void* context)
|
||||
private static partial void DestroyProxyImplementationForMulti (void* context)
|
||||
{
|
||||
var del = GetMulti<ReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -47,5 +32,12 @@ namespace HarfBuzzSharp
|
|||
gch.Free ();
|
||||
}
|
||||
}
|
||||
|
||||
private static partial IntPtr ReferenceTableProxyImplementation (IntPtr face, uint tag, void* context)
|
||||
{
|
||||
GetMultiUserData<GetTableDelegate, Face> ((IntPtr)context, out var getTable, out var userData, out _);
|
||||
var blob = getTable.Invoke (userData, tag);
|
||||
return blob?.Handle ?? IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#nullable disable
|
||||
// ReSharper disable PartialMethodParameterNameMismatch
|
||||
|
||||
using System;
|
||||
|
||||
|
@ -30,24 +31,9 @@ namespace HarfBuzzSharp
|
|||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
// references to the proxy implementations
|
||||
public static readonly FontGetFontExtentsProxyDelegate FontExtentsProxy = FontExtentsProxyImplementation;
|
||||
public static readonly FontGetNominalGlyphProxyDelegate NominalGlyphProxy = NominalGlyphProxyImplementation;
|
||||
public static readonly FontGetVariationGlyphProxyDelegate VariationGlyphProxy = VariationGlyphProxyImplementation;
|
||||
public static readonly FontGetNominalGlyphsProxyDelegate NominalGlyphsProxy = NominalGlyphsProxyImplementation;
|
||||
public static readonly FontGetGlyphAdvanceProxyDelegate GlyphAdvanceProxy = GlyphAdvanceProxyImplementation;
|
||||
public static readonly FontGetGlyphAdvancesProxyDelegate GlyphAdvancesProxy = GlyphAdvancesProxyImplementation;
|
||||
public static readonly FontGetGlyphOriginProxyDelegate GlyphOriginProxy = GlyphOriginProxyImplementation;
|
||||
public static readonly FontGetGlyphKerningProxyDelegate GlyphKerningProxy = GlyphKerningProxyImplementation;
|
||||
public static readonly FontGetGlyphExtentsProxyDelegate GlyphExtentsProxy = GlyphExtentsProxyImplementation;
|
||||
public static readonly FontGetGlyphContourPointProxyDelegate GlyphContourPointProxy = GlyphContourPointProxyImplementation;
|
||||
public static readonly FontGetGlyphNameProxyDelegate GlyphNameProxy = GlyphNameProxyImplementation;
|
||||
public static readonly FontGetGlyphFromNameProxyDelegate GlyphFromNameProxy = GlyphFromNameProxyImplementation;
|
||||
|
||||
// internal proxy implementations
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetFontExtentsProxyDelegate))]
|
||||
private static bool FontExtentsProxyImplementation (IntPtr font, void* fontData, FontExtents* extents, void* context)
|
||||
private static partial bool FontGetFontExtentsProxyImplementation (IntPtr font, void* fontData, FontExtents* extents, void* context)
|
||||
{
|
||||
var del = GetMulti<FontExtentsDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -57,8 +43,7 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetNominalGlyphProxyDelegate))]
|
||||
private static bool NominalGlyphProxyImplementation (IntPtr font, void* fontData, uint unicode, uint* glyph, void* context)
|
||||
private static partial bool FontGetNominalGlyphProxyImplementation (IntPtr font, void* fontData, uint unicode, uint* glyph, void* context)
|
||||
{
|
||||
var del = GetMulti<NominalGlyphDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -68,8 +53,7 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetNominalGlyphsProxyDelegate))]
|
||||
private static uint NominalGlyphsProxyImplementation (IntPtr font, void* fontData, uint count, uint* firstUnicode, uint unicodeStride, uint* firstGlyph, uint glyphStride, void* context)
|
||||
private static partial uint FontGetNominalGlyphsProxyImplementation (IntPtr font, void* fontData, uint count, uint* firstUnicode, uint unicodeStride, uint* firstGlyph, uint glyphStride, void* context)
|
||||
{
|
||||
var del = GetMulti<NominalGlyphsDelegate> ((IntPtr)context, out _);
|
||||
var unicodes = new ReadOnlySpan<uint> (firstUnicode, (int)count);
|
||||
|
@ -78,8 +62,7 @@ namespace HarfBuzzSharp
|
|||
return del.Invoke (userData.Font, userData.FontData, count, unicodes, glyphs);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetVariationGlyphProxyDelegate))]
|
||||
private static bool VariationGlyphProxyImplementation (IntPtr font, void* fontData, uint unicode, uint variationSelector, uint* glyph, void* context)
|
||||
private static partial bool FontGetVariationGlyphProxyImplementation (IntPtr font, void* fontData, uint unicode, uint variationSelector, uint* glyph, void* context)
|
||||
{
|
||||
var del = GetMulti<VariationGlyphDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -89,16 +72,14 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphAdvanceProxyDelegate))]
|
||||
private static int GlyphAdvanceProxyImplementation (IntPtr font, void* fontData, uint glyph, void* context)
|
||||
private static partial int FontGetGlyphAdvanceProxyImplementation (IntPtr font, void* fontData, uint glyph, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphAdvanceDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
return del.Invoke (userData.Font, userData.FontData, glyph);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphAdvancesProxyDelegate))]
|
||||
private static void GlyphAdvancesProxyImplementation (IntPtr font, void* fontData, uint count, uint* firstGlyph, uint glyphStride, int* firstAdvance, uint advanceStride, void* context)
|
||||
private static partial void FontGetGlyphAdvancesProxyImplementation (IntPtr font, void* fontData, uint count, uint* firstGlyph, uint glyphStride, int* firstAdvance, uint advanceStride, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphAdvancesDelegate> ((IntPtr)context, out _);
|
||||
var glyphs = new ReadOnlySpan<uint> (firstGlyph, (int)count);
|
||||
|
@ -107,8 +88,7 @@ namespace HarfBuzzSharp
|
|||
del.Invoke (userData.Font, userData.FontData, count, glyphs, advances);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphOriginProxyDelegate))]
|
||||
private static bool GlyphOriginProxyImplementation (IntPtr font, void* fontData, uint glyph, int* x, int* y, void* context)
|
||||
private static partial bool FontGetGlyphOriginProxyImplementation (IntPtr font, void* fontData, uint glyph, int* x, int* y, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphOriginDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -120,16 +100,14 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphKerningProxyDelegate))]
|
||||
private static int GlyphKerningProxyImplementation (IntPtr font, void* fontData, uint firstGlyph, uint secondGlyph, void* context)
|
||||
private static partial int FontGetGlyphKerningProxyImplementation (IntPtr font, void* fontData, uint firstGlyph, uint secondGlyph, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphKerningDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
return del.Invoke (userData.Font, userData.FontData, firstGlyph, secondGlyph);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphExtentsProxyDelegate))]
|
||||
private static bool GlyphExtentsProxyImplementation (IntPtr font, void* fontData, uint glyph, GlyphExtents* extents, void* context)
|
||||
private static partial bool FontGetGlyphExtentsProxyImplementation (IntPtr font, void* fontData, uint glyph, GlyphExtents* extents, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphExtentsDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -139,8 +117,7 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphContourPointProxyDelegate))]
|
||||
private static bool GlyphContourPointProxyImplementation (IntPtr font, void* fontData, uint glyph, uint pointIndex, int* x, int* y, void* context)
|
||||
private static partial bool FontGetGlyphContourPointProxyImplementation (IntPtr font, void* fontData, uint glyph, uint pointIndex, int* x, int* y, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphContourPointDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -152,8 +129,7 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphNameProxyDelegate))]
|
||||
private static bool GlyphNameProxyImplementation (IntPtr font, void* fontData, uint glyph, void* nameBuffer, uint size, void* context)
|
||||
private static partial bool FontGetGlyphNameProxyImplementation (IntPtr font, void* fontData, uint glyph, void* nameBuffer, uint size, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphNameDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
@ -166,8 +142,7 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (FontGetGlyphFromNameProxyDelegate))]
|
||||
private static bool GlyphFromNameProxyImplementation (IntPtr font, void* fontData, void* name, int len, uint* glyph, void* context)
|
||||
private static partial bool FontGetGlyphFromNameProxyImplementation (IntPtr font, void* fontData, void* name, int len, uint* glyph, void* context)
|
||||
{
|
||||
var del = GetMulti<GlyphFromNameDelegate> ((IntPtr)context, out _);
|
||||
var userData = GetMultiUserData<FontUserData> ((IntPtr)fontData, out _);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#nullable disable
|
||||
// ReSharper disable PartialMethodParameterNameMismatch
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace HarfBuzzSharp
|
||||
{
|
||||
|
@ -18,43 +21,31 @@ namespace HarfBuzzSharp
|
|||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
public static readonly UnicodeCombiningClassProxyDelegate CombiningClassProxy = CombiningClassProxyImplementation;
|
||||
public static readonly UnicodeGeneralCategoryProxyDelegate GeneralCategoryProxy = GeneralCategoryProxyImplementation;
|
||||
public static readonly UnicodeMirroringProxyDelegate MirroringProxy = MirroringProxyImplementation;
|
||||
public static readonly UnicodeScriptProxyDelegate ScriptProxy = ScriptProxyImplementation;
|
||||
public static readonly UnicodeComposeProxyDelegate ComposeProxy = ComposeProxyImplementation;
|
||||
public static readonly UnicodeDecomposeProxyDelegate DecomposeProxy = DecomposeProxyImplementation;
|
||||
|
||||
[MonoPInvokeCallback (typeof (UnicodeCombiningClassProxyDelegate))]
|
||||
private static int CombiningClassProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
private static partial int UnicodeCombiningClassProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
{
|
||||
GetMultiUserData<CombiningClassDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
|
||||
return (int)del.Invoke (functions, unicode);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (UnicodeGeneralCategoryProxyDelegate))]
|
||||
private static int GeneralCategoryProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
private static partial int UnicodeGeneralCategoryProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
{
|
||||
GetMultiUserData<GeneralCategoryDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
|
||||
return (int)del.Invoke (functions, unicode);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (UnicodeMirroringProxyDelegate))]
|
||||
private static uint MirroringProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
private static partial uint UnicodeMirroringProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
{
|
||||
GetMultiUserData<MirroringDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
|
||||
return del.Invoke (functions, unicode);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (UnicodeScriptProxyDelegate))]
|
||||
private static uint ScriptProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
private static partial uint UnicodeScriptProxyImplementation (IntPtr ufuncs, uint unicode, void* context)
|
||||
{
|
||||
GetMultiUserData<ScriptDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
|
||||
return del.Invoke (functions, unicode);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (UnicodeComposeProxyDelegate))]
|
||||
private static bool ComposeProxyImplementation (IntPtr ufuncs, uint a, uint b, uint* ab, void* context)
|
||||
private static partial bool UnicodeComposeProxyImplementation (IntPtr ufuncs, uint a, uint b, uint* ab, void* context)
|
||||
{
|
||||
GetMultiUserData<ComposeDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
|
||||
var result = del.Invoke (functions, a, b, out var abManaged);
|
||||
|
@ -63,8 +54,7 @@ namespace HarfBuzzSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (UnicodeDecomposeProxyDelegate))]
|
||||
private static bool DecomposeProxyImplementation (IntPtr ufuncs, uint ab, uint* a, uint* b, void* context)
|
||||
private static partial bool UnicodeDecomposeProxyImplementation (IntPtr ufuncs, uint ab, uint* a, uint* b, void* context)
|
||||
{
|
||||
GetMultiUserData<DecomposeDelegate, UnicodeFunctions> ((IntPtr)context, out var del, out var functions, out _);
|
||||
var result = del.Invoke (functions, ab, out var aManaged, out var bManaged);
|
||||
|
|
|
@ -41,9 +41,9 @@ namespace HarfBuzzSharp
|
|||
throw new ArgumentNullException (nameof (getTable));
|
||||
|
||||
Handle = HarfBuzzApi.hb_face_create_for_tables (
|
||||
DelegateProxies.GetTableDelegateProxy,
|
||||
DelegateProxies.ReferenceTableProxy,
|
||||
(void*)DelegateProxies.CreateMultiUserData (getTable, destroy, this),
|
||||
DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
internal Face (IntPtr handle)
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var container = new FontUserData (this, fontData);
|
||||
var ctx = DelegateProxies.CreateMultiUserData (destroy, container);
|
||||
HarfBuzzApi.hb_font_set_funcs (Handle, fontFunctions.Handle, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
HarfBuzzApi.hb_font_set_funcs (Handle, fontFunctions.Handle, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void GetScale (out int xScale, out int yScale)
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_font_h_extents_func (
|
||||
Handle, DelegateProxies.FontExtentsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetFontExtentsProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetVerticalFontExtentsDelegate (FontExtentsDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -42,7 +42,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_font_v_extents_func (
|
||||
Handle, DelegateProxies.FontExtentsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetFontExtentsProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetNominalGlyphDelegate (NominalGlyphDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -52,7 +52,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_nominal_glyph_func (
|
||||
Handle, DelegateProxies.NominalGlyphProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetNominalGlyphProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetNominalGlyphsDelegate (NominalGlyphsDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -62,7 +62,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_nominal_glyphs_func (
|
||||
Handle, DelegateProxies.NominalGlyphsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetNominalGlyphsProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetVariationGlyphDelegate (VariationGlyphDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -72,7 +72,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_variation_glyph_func (
|
||||
Handle, DelegateProxies.VariationGlyphProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetVariationGlyphProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetHorizontalGlyphAdvanceDelegate (GlyphAdvanceDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -82,7 +82,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_h_advance_func (
|
||||
Handle, DelegateProxies.GlyphAdvanceProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphAdvanceProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetVerticalGlyphAdvanceDelegate (GlyphAdvanceDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -92,7 +92,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_v_advance_func (
|
||||
Handle, DelegateProxies.GlyphAdvanceProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphAdvanceProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetHorizontalGlyphAdvancesDelegate (GlyphAdvancesDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -102,7 +102,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_h_advances_func (
|
||||
Handle, DelegateProxies.GlyphAdvancesProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphAdvancesProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetVerticalGlyphAdvancesDelegate (GlyphAdvancesDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -112,7 +112,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_v_advances_func (
|
||||
Handle, DelegateProxies.GlyphAdvancesProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphAdvancesProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetHorizontalGlyphOriginDelegate (GlyphOriginDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -122,7 +122,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_h_origin_func (
|
||||
Handle, DelegateProxies.GlyphOriginProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphOriginProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetVerticalGlyphOriginDelegate (GlyphOriginDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -132,7 +132,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_v_origin_func (
|
||||
Handle, DelegateProxies.GlyphOriginProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphOriginProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetHorizontalGlyphKerningDelegate (GlyphKerningDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -142,7 +142,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_h_kerning_func (
|
||||
Handle, DelegateProxies.GlyphKerningProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphKerningProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetGlyphExtentsDelegate (GlyphExtentsDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -152,7 +152,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_extents_func (
|
||||
Handle, DelegateProxies.GlyphExtentsProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphExtentsProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
public void SetGlyphContourPointDelegate (GlyphContourPointDelegate del, ReleaseDelegate destroy = null)
|
||||
{
|
||||
|
@ -161,7 +161,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_contour_point_func (
|
||||
Handle, DelegateProxies.GlyphContourPointProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphContourPointProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetGlyphNameDelegate (GlyphNameDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -171,7 +171,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_name_func (
|
||||
Handle, DelegateProxies.GlyphNameProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphNameProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetGlyphFromNameDelegate (GlyphFromNameDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -181,7 +181,7 @@ namespace HarfBuzzSharp
|
|||
var ctx = DelegateProxies.CreateMulti (del, destroy);
|
||||
|
||||
HarfBuzzApi.hb_font_funcs_set_glyph_from_name_func (
|
||||
Handle, DelegateProxies.GlyphFromNameProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.FontGetGlyphFromNameProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing) =>
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,10 +6,15 @@
|
|||
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
|
||||
<DefineConstants>$(DefineConstants);HARFBUZZ</DefineConstants>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>$(WarningsAsErrors);CA1420;CA1421;</WarningsAsErrors>
|
||||
<NoWarn>$(NoWarn);CS8826</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
|
||||
<DefineConstants>$(DefineConstants);USE_DELEGATES</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<ProjectReference Include="..\HarfBuzzSharp.NativeAssets.Android\HarfBuzzSharp.NativeAssets.Android.csproj" Condition="$(TargetFramework.Contains('-android'))" />
|
||||
<ProjectReference Include="..\HarfBuzzSharp.NativeAssets.iOS\HarfBuzzSharp.NativeAssets.iOS.csproj" Condition="$(TargetFramework.Contains('-ios'))" />
|
||||
|
|
|
@ -62,17 +62,6 @@ namespace HarfBuzzSharp
|
|||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
internal static IntPtr StructureArrayToPtr<T> (IReadOnlyList<T> items)
|
||||
{
|
||||
var size = Marshal.SizeOf<T> ();
|
||||
var memory = Marshal.AllocCoTaskMem (size * items.Count);
|
||||
for (var i = 0; i < items.Count; i++) {
|
||||
var ptr = new IntPtr (memory.ToInt64 () + (i * size));
|
||||
Marshal.StructureToPtr (items[i], ptr, true);
|
||||
}
|
||||
return memory;
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> PtrToStringArray (IntPtr intPtr)
|
||||
{
|
||||
if (intPtr != IntPtr.Zero) {
|
||||
|
|
|
@ -27,3 +27,7 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: Foundation.LinkerSafe]
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[assembly: DisableRuntimeMarshalling]
|
||||
#endif
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
|
||||
HarfBuzzApi.hb_unicode_funcs_set_combining_class_func (
|
||||
Handle, DelegateProxies.CombiningClassProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.UnicodeCombiningClassProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetGeneralCategoryDelegate (GeneralCategoryDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -106,7 +106,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
|
||||
HarfBuzzApi.hb_unicode_funcs_set_general_category_func (
|
||||
Handle, DelegateProxies.GeneralCategoryProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.UnicodeGeneralCategoryProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetMirroringDelegate (MirroringDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -115,7 +115,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
|
||||
HarfBuzzApi.hb_unicode_funcs_set_mirroring_func (
|
||||
Handle, DelegateProxies.MirroringProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.UnicodeMirroringProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetScriptDelegate (ScriptDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -124,7 +124,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
|
||||
HarfBuzzApi.hb_unicode_funcs_set_script_func (
|
||||
Handle, DelegateProxies.ScriptProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.UnicodeScriptProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetComposeDelegate (ComposeDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -133,7 +133,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
|
||||
HarfBuzzApi.hb_unicode_funcs_set_compose_func (
|
||||
Handle, DelegateProxies.ComposeProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.UnicodeComposeProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
public void SetDecomposeDelegate (DecomposeDelegate del, ReleaseDelegate destroy = null)
|
||||
|
@ -142,7 +142,7 @@ namespace HarfBuzzSharp
|
|||
|
||||
var ctx = DelegateProxies.CreateMultiUserData (del, destroy, this);
|
||||
HarfBuzzApi.hb_unicode_funcs_set_decompose_func (
|
||||
Handle, DelegateProxies.DecomposeProxy, (void*)ctx, DelegateProxies.ReleaseDelegateProxyForMulti);
|
||||
Handle, DelegateProxies.UnicodeDecomposeProxy, (void*)ctx, DelegateProxies.DestroyProxyForMulti);
|
||||
}
|
||||
|
||||
private void VerifyParameters (Delegate del)
|
||||
|
|
|
@ -34,3 +34,7 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: Foundation.LinkerSafe]
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[assembly: DisableRuntimeMarshalling]
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#region Namespaces
|
||||
|
||||
|
@ -17,6 +18,7 @@ using gr_recording_context_t = System.IntPtr;
|
|||
using gr_vk_extensions_t = System.IntPtr;
|
||||
using gr_vk_memory_allocator_t = System.IntPtr;
|
||||
using gr_vkinterface_t = System.IntPtr;
|
||||
using sk_bbh_factory_t = System.IntPtr;
|
||||
using sk_bitmap_t = System.IntPtr;
|
||||
using sk_blender_t = System.IntPtr;
|
||||
using sk_canvas_t = System.IntPtr;
|
||||
|
@ -59,6 +61,7 @@ using sk_region_iterator_t = System.IntPtr;
|
|||
using sk_region_spanerator_t = System.IntPtr;
|
||||
using sk_region_t = System.IntPtr;
|
||||
using sk_rrect_t = System.IntPtr;
|
||||
using sk_rtree_factory_t = System.IntPtr;
|
||||
using sk_runtimeeffect_t = System.IntPtr;
|
||||
using sk_shader_t = System.IntPtr;
|
||||
using sk_stream_asset_t = System.IntPtr;
|
||||
|
@ -110,8 +113,13 @@ namespace SkiaSharp
|
|||
|
||||
// skresources_resource_provider_t* skresources_caching_resource_provider_proxy_make(skresources_resource_provider_t* rp)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skresources_resource_provider_t skresources_caching_resource_provider_proxy_make (skresources_resource_provider_t rp);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skresources_resource_provider_t skresources_caching_resource_provider_proxy_make (skresources_resource_provider_t rp);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -124,8 +132,13 @@ namespace SkiaSharp
|
|||
|
||||
// skresources_resource_provider_t* skresources_data_uri_resource_provider_proxy_make(skresources_resource_provider_t* rp, bool predecode)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skresources_resource_provider_t skresources_data_uri_resource_provider_proxy_make (skresources_resource_provider_t rp, [MarshalAs (UnmanagedType.I1)] bool predecode);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skresources_resource_provider_t skresources_data_uri_resource_provider_proxy_make (skresources_resource_provider_t rp, [MarshalAs (UnmanagedType.I1)] bool predecode);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -138,8 +151,13 @@ namespace SkiaSharp
|
|||
|
||||
// skresources_resource_provider_t* skresources_file_resource_provider_make(sk_string_t* base_dir, bool predecode)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skresources_resource_provider_t skresources_file_resource_provider_make (sk_string_t base_dir, [MarshalAs (UnmanagedType.I1)] bool predecode);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skresources_resource_provider_t skresources_file_resource_provider_make (sk_string_t base_dir, [MarshalAs (UnmanagedType.I1)] bool predecode);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -152,8 +170,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skresources_resource_provider_delete(skresources_resource_provider_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skresources_resource_provider_delete (skresources_resource_provider_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skresources_resource_provider_delete (skresources_resource_provider_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -166,8 +189,13 @@ namespace SkiaSharp
|
|||
|
||||
// sk_data_t* skresources_resource_provider_load(skresources_resource_provider_t* instance, const char* path, const char* name)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial sk_data_t skresources_resource_provider_load (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern sk_data_t skresources_resource_provider_load (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -180,8 +208,13 @@ namespace SkiaSharp
|
|||
|
||||
// skresources_external_track_asset_t* skresources_resource_provider_load_audio_asset(skresources_resource_provider_t* instance, const char* path, const char* name, const char* id)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skresources_external_track_asset_t skresources_resource_provider_load_audio_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skresources_external_track_asset_t skresources_resource_provider_load_audio_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -194,8 +227,13 @@ namespace SkiaSharp
|
|||
|
||||
// skresources_image_asset_t* skresources_resource_provider_load_image_asset(skresources_resource_provider_t* instance, const char* path, const char* name, const char* id)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skresources_image_asset_t skresources_resource_provider_load_image_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skresources_image_asset_t skresources_resource_provider_load_image_asset (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String path, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String id);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -208,8 +246,13 @@ namespace SkiaSharp
|
|||
|
||||
// sk_typeface_t* skresources_resource_provider_load_typeface(skresources_resource_provider_t* instance, const char* name, const char* url)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial sk_typeface_t skresources_resource_provider_load_typeface (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String url);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern sk_typeface_t skresources_resource_provider_load_typeface (skresources_resource_provider_t instance, [MarshalAs (UnmanagedType.LPStr)] String name, [MarshalAs (UnmanagedType.LPStr)] String url);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -222,8 +265,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skresources_resource_provider_ref(skresources_resource_provider_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skresources_resource_provider_ref (skresources_resource_provider_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skresources_resource_provider_ref (skresources_resource_provider_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -236,8 +284,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skresources_resource_provider_unref(skresources_resource_provider_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skresources_resource_provider_unref (skresources_resource_provider_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skresources_resource_provider_unref (skresources_resource_provider_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -256,7 +309,9 @@ namespace SkiaSharp
|
|||
#endregion Functions
|
||||
|
||||
#region Delegates
|
||||
#if !USE_LIBRARY_IMPORT
|
||||
|
||||
#endif // !USE_LIBRARY_IMPORT
|
||||
#endregion
|
||||
|
||||
#region Structs
|
||||
|
@ -266,3 +321,7 @@ namespace SkiaSharp
|
|||
#region Enums
|
||||
|
||||
#endregion
|
||||
|
||||
#region DelegateProxies
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
<PackageDescription>SkiaSharp Skottie provides a Lottie implementation using the SkiaSharp library.</PackageDescription>
|
||||
<PackageTags>skottie;lottie</PackageTags>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>$(WarningsAsErrors);CA1420;CA1421;</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
|
||||
<DefineConstants>$(DefineConstants);USE_DELEGATES</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SkiaSharp\SkiaSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -33,3 +33,7 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: Foundation.LinkerSafe]
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[assembly: DisableRuntimeMarshalling]
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#region Namespaces
|
||||
|
||||
|
@ -17,6 +18,7 @@ using gr_recording_context_t = System.IntPtr;
|
|||
using gr_vk_extensions_t = System.IntPtr;
|
||||
using gr_vk_memory_allocator_t = System.IntPtr;
|
||||
using gr_vkinterface_t = System.IntPtr;
|
||||
using sk_bbh_factory_t = System.IntPtr;
|
||||
using sk_bitmap_t = System.IntPtr;
|
||||
using sk_blender_t = System.IntPtr;
|
||||
using sk_canvas_t = System.IntPtr;
|
||||
|
@ -59,6 +61,7 @@ using sk_region_iterator_t = System.IntPtr;
|
|||
using sk_region_spanerator_t = System.IntPtr;
|
||||
using sk_region_t = System.IntPtr;
|
||||
using sk_rrect_t = System.IntPtr;
|
||||
using sk_rtree_factory_t = System.IntPtr;
|
||||
using sk_runtimeeffect_t = System.IntPtr;
|
||||
using sk_shader_t = System.IntPtr;
|
||||
using sk_stream_asset_t = System.IntPtr;
|
||||
|
@ -110,8 +113,13 @@ namespace SkiaSharp
|
|||
|
||||
// void sksg_invalidation_controller_begin(sksg_invalidation_controller_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void sksg_invalidation_controller_begin (sksg_invalidation_controller_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void sksg_invalidation_controller_begin (sksg_invalidation_controller_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -124,8 +132,13 @@ namespace SkiaSharp
|
|||
|
||||
// void sksg_invalidation_controller_delete(sksg_invalidation_controller_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void sksg_invalidation_controller_delete (sksg_invalidation_controller_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void sksg_invalidation_controller_delete (sksg_invalidation_controller_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -138,8 +151,13 @@ namespace SkiaSharp
|
|||
|
||||
// void sksg_invalidation_controller_end(sksg_invalidation_controller_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void sksg_invalidation_controller_end (sksg_invalidation_controller_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void sksg_invalidation_controller_end (sksg_invalidation_controller_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -152,8 +170,13 @@ namespace SkiaSharp
|
|||
|
||||
// void sksg_invalidation_controller_get_bounds(sksg_invalidation_controller_t* instance, sk_rect_t* bounds)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void sksg_invalidation_controller_get_bounds (sksg_invalidation_controller_t instance, SKRect* bounds);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void sksg_invalidation_controller_get_bounds (sksg_invalidation_controller_t instance, SKRect* bounds);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -166,8 +189,13 @@ namespace SkiaSharp
|
|||
|
||||
// void sksg_invalidation_controller_inval(sksg_invalidation_controller_t* instance, sk_rect_t* rect, sk_matrix_t* matrix)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void sksg_invalidation_controller_inval (sksg_invalidation_controller_t instance, SKRect* rect, SKMatrix* matrix);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void sksg_invalidation_controller_inval (sksg_invalidation_controller_t instance, SKRect* rect, SKMatrix* matrix);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -180,8 +208,13 @@ namespace SkiaSharp
|
|||
|
||||
// sksg_invalidation_controller_t* sksg_invalidation_controller_new()
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial sksg_invalidation_controller_t sksg_invalidation_controller_new ();
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern sksg_invalidation_controller_t sksg_invalidation_controller_new ();
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -194,8 +227,13 @@ namespace SkiaSharp
|
|||
|
||||
// void sksg_invalidation_controller_reset(sksg_invalidation_controller_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void sksg_invalidation_controller_reset (sksg_invalidation_controller_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void sksg_invalidation_controller_reset (sksg_invalidation_controller_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -214,7 +252,9 @@ namespace SkiaSharp
|
|||
#endregion Functions
|
||||
|
||||
#region Delegates
|
||||
#if !USE_LIBRARY_IMPORT
|
||||
|
||||
#endif // !USE_LIBRARY_IMPORT
|
||||
#endregion
|
||||
|
||||
#region Structs
|
||||
|
@ -224,3 +264,7 @@ namespace SkiaSharp
|
|||
#region Enums
|
||||
|
||||
#endregion
|
||||
|
||||
#region DelegateProxies
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
<PackageDescription>SkiaSharp Skottie provides a Lottie implementation using the SkiaSharp library.</PackageDescription>
|
||||
<PackageTags>skottie;lottie</PackageTags>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>$(WarningsAsErrors);CA1420;CA1421;</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
|
||||
<DefineConstants>$(DefineConstants);USE_DELEGATES</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SkiaSharp\SkiaSharp.csproj" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -34,3 +34,7 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: Foundation.LinkerSafe]
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[assembly: DisableRuntimeMarshalling]
|
||||
#endif
|
||||
|
|
|
@ -8,10 +8,14 @@
|
|||
<PackageDescription>SkiaSharp Skottie provides a Lottie implementation using the SkiaSharp library.</PackageDescription>
|
||||
<PackageTags>skottie;lottie</PackageTags>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>$(WarningsAsErrors);CA1420;CA1421;</WarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
|
||||
<DefineConstants>$(DefineConstants);USE_DELEGATES</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SkiaSharp\SkiaSharp.csproj" />
|
||||
<ProjectReference Include="..\SkiaSharp.SceneGraph\SkiaSharp.SceneGraph.csproj" />
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#region Namespaces
|
||||
|
||||
|
@ -17,6 +18,7 @@ using gr_recording_context_t = System.IntPtr;
|
|||
using gr_vk_extensions_t = System.IntPtr;
|
||||
using gr_vk_memory_allocator_t = System.IntPtr;
|
||||
using gr_vkinterface_t = System.IntPtr;
|
||||
using sk_bbh_factory_t = System.IntPtr;
|
||||
using sk_bitmap_t = System.IntPtr;
|
||||
using sk_blender_t = System.IntPtr;
|
||||
using sk_canvas_t = System.IntPtr;
|
||||
|
@ -59,6 +61,7 @@ using sk_region_iterator_t = System.IntPtr;
|
|||
using sk_region_spanerator_t = System.IntPtr;
|
||||
using sk_region_t = System.IntPtr;
|
||||
using sk_rrect_t = System.IntPtr;
|
||||
using sk_rtree_factory_t = System.IntPtr;
|
||||
using sk_runtimeeffect_t = System.IntPtr;
|
||||
using sk_shader_t = System.IntPtr;
|
||||
using sk_stream_asset_t = System.IntPtr;
|
||||
|
@ -110,8 +113,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_builder_delete(skottie_animation_builder_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_builder_delete (skottie_animation_builder_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_builder_delete (skottie_animation_builder_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -124,8 +132,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_builder_get_stats(skottie_animation_builder_t* instance, skottie_animation_builder_stats_t* stats)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_builder_get_stats (skottie_animation_builder_t instance, AnimationBuilderStats* stats);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_builder_get_stats (skottie_animation_builder_t instance, AnimationBuilderStats* stats);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -138,8 +151,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_builder_make_from_data(skottie_animation_builder_t* instance, const char* data, size_t length)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_builder_make_from_data (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_builder_make_from_data (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -152,8 +170,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_builder_make_from_file(skottie_animation_builder_t* instance, const char* path)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_builder_make_from_file (skottie_animation_builder_t instance, /* char */ void* path);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_builder_make_from_file (skottie_animation_builder_t instance, /* char */ void* path);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -166,8 +189,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_builder_make_from_stream(skottie_animation_builder_t* instance, sk_stream_t* stream)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_builder_make_from_stream (skottie_animation_builder_t instance, sk_stream_t stream);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_builder_make_from_stream (skottie_animation_builder_t instance, sk_stream_t stream);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -180,8 +208,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_builder_make_from_string(skottie_animation_builder_t* instance, const char* data, size_t length)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_builder_make_from_string (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_builder_make_from_string (skottie_animation_builder_t instance, /* char */ void* data, /* size_t */ IntPtr length);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -194,8 +227,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_builder_t* skottie_animation_builder_new(skottie_animation_builder_flags_t flags)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_builder_t skottie_animation_builder_new (AnimationBuilderFlags flags);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_builder_t skottie_animation_builder_new (AnimationBuilderFlags flags);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -208,8 +246,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_builder_set_font_manager(skottie_animation_builder_t* instance, sk_fontmgr_t* fontManager)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_builder_set_font_manager (skottie_animation_builder_t instance, sk_fontmgr_t fontManager);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_builder_set_font_manager (skottie_animation_builder_t instance, sk_fontmgr_t fontManager);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -222,8 +265,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_builder_set_resource_provider(skottie_animation_builder_t* instance, skottie_resource_provider_t* resourceProvider)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_builder_set_resource_provider (skottie_animation_builder_t instance, skottie_resource_provider_t resourceProvider);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_builder_set_resource_provider (skottie_animation_builder_t instance, skottie_resource_provider_t resourceProvider);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -236,8 +284,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_delete(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_delete (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_delete (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -250,8 +303,13 @@ namespace SkiaSharp
|
|||
|
||||
// double skottie_animation_get_duration(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial Double skottie_animation_get_duration (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Double skottie_animation_get_duration (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -264,8 +322,13 @@ namespace SkiaSharp
|
|||
|
||||
// double skottie_animation_get_fps(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial Double skottie_animation_get_fps (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Double skottie_animation_get_fps (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -278,8 +341,13 @@ namespace SkiaSharp
|
|||
|
||||
// double skottie_animation_get_in_point(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial Double skottie_animation_get_in_point (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Double skottie_animation_get_in_point (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -292,8 +360,13 @@ namespace SkiaSharp
|
|||
|
||||
// double skottie_animation_get_out_point(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial Double skottie_animation_get_out_point (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern Double skottie_animation_get_out_point (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -306,8 +379,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_get_size(skottie_animation_t* instance, sk_size_t* size)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_get_size (skottie_animation_t instance, SKSize* size);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_get_size (skottie_animation_t instance, SKSize* size);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -320,8 +398,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_get_version(skottie_animation_t* instance, sk_string_t* version)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_get_version (skottie_animation_t instance, sk_string_t version);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_get_version (skottie_animation_t instance, sk_string_t version);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -334,8 +417,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_make_from_data(const char* data, size_t length)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_make_from_data (/* char */ void* data, /* size_t */ IntPtr length);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_make_from_data (/* char */ void* data, /* size_t */ IntPtr length);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -348,8 +436,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_make_from_file(const char* path)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_make_from_file ([MarshalAs (UnmanagedType.LPStr)] String path);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_make_from_file ([MarshalAs (UnmanagedType.LPStr)] String path);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -362,8 +455,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_make_from_stream(sk_stream_t* stream)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_make_from_stream (sk_stream_t stream);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_make_from_stream (sk_stream_t stream);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -376,8 +474,13 @@ namespace SkiaSharp
|
|||
|
||||
// skottie_animation_t* skottie_animation_make_from_string(const char* data, size_t length)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial skottie_animation_t skottie_animation_make_from_string ([MarshalAs (UnmanagedType.LPStr)] String data, int length);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern skottie_animation_t skottie_animation_make_from_string ([MarshalAs (UnmanagedType.LPStr)] String data, int length);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -390,8 +493,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_ref(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_ref (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_ref (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -404,8 +512,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_render(skottie_animation_t* instance, sk_canvas_t* canvas, sk_rect_t* dst)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_render (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_render (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -418,8 +531,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_render_with_flags(skottie_animation_t* instance, sk_canvas_t* canvas, sk_rect_t* dst, skottie_animation_renderflags_t flags)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_render_with_flags (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst, AnimationRenderFlags flags);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_render_with_flags (skottie_animation_t instance, sk_canvas_t canvas, SKRect* dst, AnimationRenderFlags flags);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -432,8 +550,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_seek(skottie_animation_t* instance, float t, sksg_invalidation_controller_t* ic)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_seek (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_seek (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -446,8 +569,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_seek_frame(skottie_animation_t* instance, float t, sksg_invalidation_controller_t* ic)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_seek_frame (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_seek_frame (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -460,8 +588,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_seek_frame_time(skottie_animation_t* instance, float t, sksg_invalidation_controller_t* ic)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_seek_frame_time (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_seek_frame_time (skottie_animation_t instance, Single t, sksg_invalidation_controller_t ic);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -474,8 +607,13 @@ namespace SkiaSharp
|
|||
|
||||
// void skottie_animation_unref(skottie_animation_t* instance)
|
||||
#if !USE_DELEGATES
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport (SKIA)]
|
||||
internal static partial void skottie_animation_unref (skottie_animation_t instance);
|
||||
#else // !USE_LIBRARY_IMPORT
|
||||
[DllImport (SKIA, CallingConvention = CallingConvention.Cdecl)]
|
||||
internal static extern void skottie_animation_unref (skottie_animation_t instance);
|
||||
#endif
|
||||
#else
|
||||
private partial class Delegates {
|
||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||
|
@ -494,7 +632,9 @@ namespace SkiaSharp
|
|||
#endregion Functions
|
||||
|
||||
#region Delegates
|
||||
#if !USE_LIBRARY_IMPORT
|
||||
|
||||
#endif // !USE_LIBRARY_IMPORT
|
||||
#endregion
|
||||
|
||||
#region Structs
|
||||
|
@ -520,7 +660,9 @@ namespace SkiaSharp.Skottie {
|
|||
private readonly /* size_t */ IntPtr fAnimatorCount;
|
||||
|
||||
public readonly bool Equals (AnimationBuilderStats obj) =>
|
||||
#pragma warning disable CS8909
|
||||
fTotalLoadTimeMS == obj.fTotalLoadTimeMS && fJsonParseTimeMS == obj.fJsonParseTimeMS && fSceneParseTimeMS == obj.fSceneParseTimeMS && fJsonSize == obj.fJsonSize && fAnimatorCount == obj.fAnimatorCount;
|
||||
#pragma warning restore CS8909
|
||||
|
||||
public readonly override bool Equals (object obj) =>
|
||||
obj is AnimationBuilderStats f && Equals (f);
|
||||
|
@ -572,3 +714,7 @@ namespace SkiaSharp.Skottie {
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DelegateProxies
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#nullable disable
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable PartialMethodParameterNameMismatch
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SkiaSharp
|
||||
|
@ -24,23 +27,11 @@ namespace SkiaSharp
|
|||
|
||||
public delegate void SKGlyphPathDelegate (SKPath path, SKMatrix matrix);
|
||||
|
||||
internal unsafe static partial class DelegateProxies
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
// references to the proxy implementations
|
||||
public static readonly SKBitmapReleaseProxyDelegate SKBitmapReleaseDelegateProxy = SKBitmapReleaseDelegateProxyImplementation;
|
||||
public static readonly SKDataReleaseProxyDelegate SKDataReleaseDelegateProxy = SKDataReleaseDelegateProxyImplementation;
|
||||
public static readonly SKImageRasterReleaseProxyDelegate SKImageRasterReleaseDelegateProxy = SKImageRasterReleaseDelegateProxyImplementation;
|
||||
public static readonly SKImageRasterReleaseProxyDelegate SKImageRasterReleaseDelegateProxyForCoTaskMem = SKImageRasterReleaseDelegateProxyImplementationForCoTaskMem;
|
||||
public static readonly SKImageTextureReleaseProxyDelegate SKImageTextureReleaseDelegateProxy = SKImageTextureReleaseDelegateProxyImplementation;
|
||||
public static readonly SKSurfaceRasterReleaseProxyDelegate SKSurfaceReleaseDelegateProxy = SKSurfaceReleaseDelegateProxyImplementation;
|
||||
public static readonly GRGlGetProcProxyDelegate GRGlGetProcDelegateProxy = GRGlGetProcDelegateProxyImplementation;
|
||||
public static readonly GRVkGetProcProxyDelegate GRVkGetProcDelegateProxy = GRVkGetProcDelegateProxyImplementation;
|
||||
public static readonly SKGlyphPathProxyDelegate SKGlyphPathDelegateProxy = SKGlyphPathDelegateProxyImplementation;
|
||||
|
||||
// internal proxy implementations
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKBitmapReleaseProxyDelegate))]
|
||||
private static void SKBitmapReleaseDelegateProxyImplementation (void* address, void* context)
|
||||
private static partial void SKBitmapReleaseProxyImplementation (void* address, void* context)
|
||||
{
|
||||
var del = Get<SKBitmapReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -50,8 +41,7 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKDataReleaseProxyDelegate))]
|
||||
private static void SKDataReleaseDelegateProxyImplementation (void* address, void* context)
|
||||
private static partial void SKDataReleaseProxyImplementation (void* address, void* context)
|
||||
{
|
||||
var del = Get<SKDataReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -61,14 +51,7 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKImageRasterReleaseProxyDelegate))]
|
||||
private static void SKImageRasterReleaseDelegateProxyImplementationForCoTaskMem (void* pixels, void* context)
|
||||
{
|
||||
Marshal.FreeCoTaskMem ((IntPtr)pixels);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKImageRasterReleaseProxyDelegate))]
|
||||
private static void SKImageRasterReleaseDelegateProxyImplementation (void* pixels, void* context)
|
||||
private static partial void SKImageRasterReleaseProxyImplementation (void* pixels, void* context)
|
||||
{
|
||||
var del = Get<SKImageRasterReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -78,8 +61,7 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKImageTextureReleaseProxyDelegate))]
|
||||
private static void SKImageTextureReleaseDelegateProxyImplementation (void* context)
|
||||
private static partial void SKImageTextureReleaseProxyImplementation (void* context)
|
||||
{
|
||||
var del = Get<SKImageTextureReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -89,8 +71,7 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKSurfaceRasterReleaseProxyDelegate))]
|
||||
private static void SKSurfaceReleaseDelegateProxyImplementation (void* address, void* context)
|
||||
private static partial void SKSurfaceRasterReleaseProxyImplementation (void* address, void* context)
|
||||
{
|
||||
var del = Get<SKSurfaceReleaseDelegate> ((IntPtr)context, out var gch);
|
||||
try {
|
||||
|
@ -100,23 +81,25 @@ namespace SkiaSharp
|
|||
}
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (GRGlGetProcProxyDelegate))]
|
||||
private static IntPtr GRGlGetProcDelegateProxyImplementation (void* context, void* name)
|
||||
private static partial void SKImageRasterReleaseProxyImplementationForCoTaskMem (void* pixels, void* context)
|
||||
{
|
||||
Marshal.FreeCoTaskMem ((IntPtr)pixels);
|
||||
}
|
||||
|
||||
private static partial IntPtr GRGlGetProcProxyImplementation (void* context, void* name)
|
||||
{
|
||||
var del = Get<GRGlGetProcedureAddressDelegate> ((IntPtr)context, out _);
|
||||
return del.Invoke (Marshal.PtrToStringAnsi ((IntPtr)name));
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (GRVkGetProcProxyDelegate))]
|
||||
private static IntPtr GRVkGetProcDelegateProxyImplementation (void* context, void* name, IntPtr instance, IntPtr device)
|
||||
private static partial IntPtr GRVkGetProcProxyImplementation (void* context, void* name, IntPtr instance, IntPtr device)
|
||||
{
|
||||
var del = Get<GRVkGetProcedureAddressDelegate> ((IntPtr)context, out _);
|
||||
|
||||
return del.Invoke (Marshal.PtrToStringAnsi ((IntPtr)name), instance, device);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKGlyphPathProxyDelegate))]
|
||||
private static void SKGlyphPathDelegateProxyImplementation (IntPtr pathOrNull, SKMatrix* matrix, void* context)
|
||||
private static partial void SKGlyphPathProxyImplementation (IntPtr pathOrNull, SKMatrix* matrix, void* context)
|
||||
{
|
||||
var del = Get<SKGlyphPathDelegate> ((IntPtr)context, out _);
|
||||
var path = SKPath.GetObject (pathOrNull, false);
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace SkiaSharp;
|
||||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
private static partial /* size_t */ IntPtr SKManagedDrawableApproximateBytesUsedProxyImplementation (IntPtr d, void* context)
|
||||
{
|
||||
var drawable = GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
return (IntPtr)drawable.OnGetApproximateBytesUsed ();
|
||||
}
|
||||
|
||||
private static partial void SKManagedDrawableDestroyProxyImplementation (IntPtr d, void* context)
|
||||
{
|
||||
var drawable = GetUserData<SKDrawable> ((IntPtr)context, out var gch);
|
||||
if (drawable != null) {
|
||||
Interlocked.Exchange (ref drawable.fromNative, 1);
|
||||
drawable.Dispose ();
|
||||
}
|
||||
gch.Free ();
|
||||
}
|
||||
|
||||
private static partial void SKManagedDrawableDrawProxyImplementation (IntPtr d, void* context, IntPtr ccanvas)
|
||||
{
|
||||
var drawable = GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
drawable.OnDraw (SKCanvas.GetObject (ccanvas, false));
|
||||
}
|
||||
|
||||
private static partial void SKManagedDrawableGetBoundsProxyImplementation (IntPtr d, void* context, SKRect* rect)
|
||||
{
|
||||
var drawable = GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
var bounds = drawable.OnGetBounds ();
|
||||
*rect = bounds;
|
||||
}
|
||||
|
||||
private static partial IntPtr SKManagedDrawableMakePictureSnapshotProxyImplementation (IntPtr d, void* context)
|
||||
{
|
||||
var drawable = GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
return drawable.OnSnapshot ()?.Handle ?? IntPtr.Zero;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace SkiaSharp;
|
||||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
private static partial IntPtr SKManagedStreamDuplicateProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnDuplicate ();
|
||||
}
|
||||
|
||||
private static partial IntPtr SKManagedStreamForkProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnFork ();
|
||||
}
|
||||
|
||||
private static partial /* size_t */ IntPtr SKManagedStreamGetLengthProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnGetLength ();
|
||||
}
|
||||
|
||||
private static partial /* size_t */ IntPtr SKManagedStreamGetPositionProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnGetPosition ();
|
||||
}
|
||||
|
||||
private static partial bool SKManagedStreamHasLengthProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnHasLength ();
|
||||
}
|
||||
|
||||
private static partial void SKManagedStreamDestroyProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out var gch);
|
||||
if (stream != null) {
|
||||
Interlocked.Exchange (ref stream.fromNative, 1);
|
||||
stream.Dispose ();
|
||||
}
|
||||
gch.Free ();
|
||||
}
|
||||
|
||||
private static partial bool SKManagedStreamHasPositionProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnHasPosition ();
|
||||
}
|
||||
|
||||
private static partial bool SKManagedStreamIsAtEndProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnIsAtEnd ();
|
||||
}
|
||||
|
||||
private static partial bool SKManagedStreamMoveProxyImplementation (IntPtr s, void* context, int offset)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnMove (offset);
|
||||
}
|
||||
|
||||
private static partial /* size_t */
|
||||
IntPtr SKManagedStreamPeekProxyImplementation (IntPtr s, void* context, void* buffer, /* size_t */ IntPtr size)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnPeek ((IntPtr)buffer, size);
|
||||
}
|
||||
|
||||
private static partial /* size_t */
|
||||
IntPtr SKManagedStreamReadProxyImplementation (IntPtr s, void* context, void* buffer, /* size_t */ IntPtr size)
|
||||
{
|
||||
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnRead ((IntPtr)buffer, size);
|
||||
}
|
||||
|
||||
private static partial bool SKManagedStreamRewindProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnRewind ();
|
||||
}
|
||||
|
||||
private static partial bool SKManagedStreamSeekProxyImplementation (IntPtr s, void* context, /* size_t */
|
||||
IntPtr position)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnSeek (position);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace SkiaSharp;
|
||||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
private static partial void SKManagedTraceMemoryDumpDumpNumericValueProxyImplementation (IntPtr d,
|
||||
void* context, /* char */ void* dumpName, /* char */ void* valueName, /* char */ void* units, ulong value)
|
||||
{
|
||||
var dump = GetUserData<SKTraceMemoryDump> ((IntPtr)context, out _);
|
||||
dump.OnDumpNumericValue (
|
||||
Marshal.PtrToStringAnsi ((IntPtr)dumpName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)valueName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)units),
|
||||
value);
|
||||
}
|
||||
|
||||
private static partial void SKManagedTraceMemoryDumpDumpStringValueProxyImplementation (IntPtr d,
|
||||
void* context, /* char */ void* dumpName, /* char */ void* valueName, /* char */ void* value)
|
||||
{
|
||||
var dump = GetUserData<SKTraceMemoryDump> ((IntPtr)context, out _);
|
||||
dump.OnDumpStringValue (
|
||||
Marshal.PtrToStringAnsi ((IntPtr)dumpName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)valueName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)value));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace SkiaSharp;
|
||||
|
||||
internal static unsafe partial class DelegateProxies
|
||||
{
|
||||
private static partial /* size_t */ IntPtr SKManagedWStreamBytesWrittenProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out _);
|
||||
return stream.OnBytesWritten ();
|
||||
}
|
||||
|
||||
private static partial void SKManagedWStreamDestroyProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out var gch);
|
||||
if (stream != null) {
|
||||
Interlocked.Exchange (ref stream.fromNative, 1);
|
||||
stream.Dispose ();
|
||||
}
|
||||
gch.Free ();
|
||||
}
|
||||
|
||||
private static partial void SKManagedWStreamFlushProxyImplementation (IntPtr s, void* context)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out _);
|
||||
stream.OnFlush ();
|
||||
}
|
||||
|
||||
private static partial bool SKManagedWStreamWriteProxyImplementation (IntPtr s, void* context,
|
||||
void* buffer, /* size_t */ IntPtr size)
|
||||
{
|
||||
var stream = GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out _);
|
||||
return stream.OnWrite ((IntPtr)buffer, size);
|
||||
}
|
||||
}
|
|
@ -7,11 +7,12 @@ using SkiaSharp.Internals;
|
|||
|
||||
#if __TIZEN__
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
#endif
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
public unsafe class GRGlInterface : SKObject, ISKReferenceCounted, ISKSkipObjectRegistration
|
||||
public unsafe partial class GRGlInterface : SKObject, ISKReferenceCounted, ISKSkipObjectRegistration
|
||||
{
|
||||
internal GRGlInterface (IntPtr h, bool owns)
|
||||
: base (h, owns)
|
||||
|
@ -50,7 +51,8 @@ namespace SkiaSharp
|
|||
|
||||
public static GRGlInterface Create (GRGlGetProcedureAddressDelegate get)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (get, DelegateProxies.GRGlGetProcDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (get, out var gch, out var ctx);
|
||||
var proxy = get != null ? DelegateProxies.GRGlGetProcProxy : null;
|
||||
try {
|
||||
return GetObject (SkiaApi.gr_glinterface_assemble_interface ((void*)ctx, proxy));
|
||||
} finally {
|
||||
|
@ -63,7 +65,8 @@ namespace SkiaSharp
|
|||
|
||||
public static GRGlInterface CreateOpenGl (GRGlGetProcedureAddressDelegate get)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (get, DelegateProxies.GRGlGetProcDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (get, out var gch, out var ctx);
|
||||
var proxy = get != null ? DelegateProxies.GRGlGetProcProxy : null;
|
||||
try {
|
||||
return GetObject (SkiaApi.gr_glinterface_assemble_gl_interface ((void*)ctx, proxy));
|
||||
} finally {
|
||||
|
@ -73,7 +76,8 @@ namespace SkiaSharp
|
|||
|
||||
public static GRGlInterface CreateGles (GRGlGetProcedureAddressDelegate get)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (get, DelegateProxies.GRGlGetProcDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (get, out var gch, out var ctx);
|
||||
var proxy = get != null ? DelegateProxies.GRGlGetProcProxy : null;
|
||||
try {
|
||||
return GetObject (SkiaApi.gr_glinterface_assemble_gles_interface ((void*)ctx, proxy));
|
||||
} finally {
|
||||
|
@ -83,7 +87,8 @@ namespace SkiaSharp
|
|||
|
||||
public static GRGlInterface CreateWebGl (GRGlGetProcedureAddressDelegate get)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (get, DelegateProxies.GRGlGetProcDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (get, out var gch, out var ctx);
|
||||
var proxy = get != null ? DelegateProxies.GRGlGetProcProxy : null;
|
||||
try {
|
||||
return GetObject (SkiaApi.gr_glinterface_assemble_webgl_interface ((void*)ctx, proxy));
|
||||
} finally {
|
||||
|
@ -117,7 +122,7 @@ namespace SkiaSharp
|
|||
//
|
||||
|
||||
#if (NETSTANDARD || NET6_0_OR_GREATER || NET40_OR_GREATER) && (!NETPLATFORM || WINDOWS)
|
||||
private static class AngleLoader
|
||||
private static partial class AngleLoader
|
||||
{
|
||||
private static readonly IntPtr libEGL;
|
||||
private static readonly IntPtr libGLESv2;
|
||||
|
@ -132,6 +137,12 @@ namespace SkiaSharp
|
|||
private static extern IntPtr GetProcAddress (IntPtr hModule, [MarshalAs (UnmanagedType.LPStr)] string lpProcName);
|
||||
|
||||
private static IntPtr LoadLibrary (string lpFileName) => LoadPackagedLibrary(lpFileName, 0);
|
||||
#elif USE_LIBRARY_IMPORT
|
||||
[LibraryImport ("Kernel32.dll", SetLastError = true, EntryPoint = "LoadLibraryW", StringMarshalling = StringMarshalling.Utf16)]
|
||||
private static partial IntPtr LoadLibrary (string lpFileName);
|
||||
|
||||
[LibraryImport ("Kernel32.dll", SetLastError = true)]
|
||||
private static partial IntPtr GetProcAddress (IntPtr hModule, [MarshalAs (UnmanagedType.LPStr)] string lpProcName);
|
||||
#else
|
||||
[DllImport ("Kernel32.dll", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||
private static extern IntPtr LoadLibrary ([MarshalAs (UnmanagedType.LPStr)] string lpFileName);
|
||||
|
@ -140,8 +151,13 @@ namespace SkiaSharp
|
|||
private static extern IntPtr GetProcAddress (IntPtr hModule, [MarshalAs (UnmanagedType.LPStr)] string lpProcName);
|
||||
#endif
|
||||
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport ("libEGL.dll")]
|
||||
private static partial IntPtr eglGetProcAddress ([MarshalAs (UnmanagedType.LPStr)] string procname);
|
||||
#else
|
||||
[DllImport ("libEGL.dll")]
|
||||
private static extern IntPtr eglGetProcAddress ([MarshalAs (UnmanagedType.LPStr)] string procname);
|
||||
#endif
|
||||
|
||||
static AngleLoader()
|
||||
{
|
||||
|
@ -183,7 +199,7 @@ namespace SkiaSharp
|
|||
#endif
|
||||
|
||||
#if __TIZEN__
|
||||
private class EvasGlLoader
|
||||
private partial class EvasGlLoader
|
||||
{
|
||||
private const string libevas = "libevas.so.1";
|
||||
|
||||
|
@ -194,17 +210,17 @@ namespace SkiaSharp
|
|||
private readonly IntPtr glEvas;
|
||||
private readonly EvasGlApi api;
|
||||
|
||||
[DllImport (libevas)]
|
||||
internal static extern IntPtr evas_gl_api_get (IntPtr evas_gl);
|
||||
[LibraryImport (libevas)]
|
||||
internal static partial IntPtr evas_gl_api_get (IntPtr evas_gl);
|
||||
|
||||
[DllImport (libevas)]
|
||||
internal static extern IntPtr evas_gl_context_api_get (IntPtr evas_gl, IntPtr ctx);
|
||||
[LibraryImport (libevas)]
|
||||
internal static partial IntPtr evas_gl_context_api_get (IntPtr evas_gl, IntPtr ctx);
|
||||
|
||||
[DllImport (libevas)]
|
||||
internal static extern IntPtr evas_gl_current_context_get (IntPtr evas_gl);
|
||||
[LibraryImport (libevas)]
|
||||
internal static partial IntPtr evas_gl_current_context_get (IntPtr evas_gl);
|
||||
|
||||
[DllImport (libevas)]
|
||||
internal static extern IntPtr evas_gl_proc_address_get (IntPtr evas_gl, string name);
|
||||
[LibraryImport(libevas)]
|
||||
internal static partial IntPtr evas_gl_proc_address_get (IntPtr evas_gl, [MarshalAs (UnmanagedType.LPStr)] string name);
|
||||
|
||||
static EvasGlLoader ()
|
||||
{
|
||||
|
@ -213,7 +229,7 @@ namespace SkiaSharp
|
|||
apiFields = EvasGlApiType.GetFields (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
public EvasGlLoader (IntPtr evas)
|
||||
public unsafe EvasGlLoader (IntPtr evas)
|
||||
{
|
||||
glEvas = evas;
|
||||
var glContext = evas_gl_current_context_get (glEvas);
|
||||
|
@ -222,7 +238,7 @@ namespace SkiaSharp
|
|||
? evas_gl_context_api_get (glEvas, glContext)
|
||||
: evas_gl_api_get (glEvas);
|
||||
|
||||
api = Marshal.PtrToStructure<EvasGlApi> (apiPtr);
|
||||
api = *(EvasGlApi*)apiPtr;
|
||||
}
|
||||
|
||||
public IntPtr GetFunctionPointer (string name)
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace SkiaSharp
|
|||
public unsafe class GRVkBackendContext : IDisposable
|
||||
{
|
||||
private GRVkGetProcedureAddressDelegate getProc;
|
||||
private GRVkGetProcProxyDelegate getProcProxy;
|
||||
private GCHandle getProcHandle;
|
||||
private void* getProcContext;
|
||||
|
||||
|
@ -58,12 +57,11 @@ namespace SkiaSharp
|
|||
if (getProcHandle.IsAllocated)
|
||||
getProcHandle.Free ();
|
||||
|
||||
getProcProxy = null;
|
||||
getProcHandle = default;
|
||||
getProcContext = null;
|
||||
|
||||
if (value != null) {
|
||||
getProcProxy = DelegateProxies.Create (value, DelegateProxies.GRVkGetProcDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (value, out var gch, out var ctx);
|
||||
getProcHandle = gch;
|
||||
getProcContext = (void*)ctx;
|
||||
}
|
||||
|
@ -84,7 +82,7 @@ namespace SkiaSharp
|
|||
fDeviceFeatures = VkPhysicalDeviceFeatures,
|
||||
fDeviceFeatures2 = VkPhysicalDeviceFeatures2,
|
||||
fGetProcUserData = getProcContext,
|
||||
fGetProc = getProcProxy,
|
||||
fGetProc = getProcContext is not null ? DelegateProxies.GRVkGetProcProxy : null,
|
||||
fProtectedContext = ProtectedContext ? (byte)1 : (byte)0
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,10 +27,11 @@ namespace SkiaSharp
|
|||
|
||||
public void Initialize (GRVkGetProcedureAddressDelegate getProc, IntPtr vkInstance, IntPtr vkPhysicalDevice, string[] instanceExtensions, string[] deviceExtensions)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (getProc, DelegateProxies.GRVkGetProcDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (getProc, out var gch, out var ctx);
|
||||
try {
|
||||
var ie = instanceExtensions;
|
||||
var de = deviceExtensions;
|
||||
var proxy = getProc != null ? DelegateProxies.GRVkGetProcProxy : null;
|
||||
SkiaApi.gr_vk_extensions_init (Handle, proxy, (void*)ctx, vkInstance, vkPhysicalDevice, (uint)(ie?.Length ?? 0), ie, (uint)(de?.Length ?? 0), de);
|
||||
} finally {
|
||||
gch.Free ();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -38,7 +39,7 @@ namespace SkiaSharp.Internals
|
|||
/// Helper class to create a IPlatformLock instance, by default according to the current platform
|
||||
/// but also client toolkits can plugin their own implementation.
|
||||
/// </summary>
|
||||
public static class PlatformLock
|
||||
public static partial class PlatformLock
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a platform lock
|
||||
|
@ -92,11 +93,11 @@ namespace SkiaSharp.Internals
|
|||
/// <summary>
|
||||
/// Windows platform lock uses Win32 CRITICAL_SECTION
|
||||
/// </summary>
|
||||
class NonAlertableWin32Lock : IPlatformLock
|
||||
partial class NonAlertableWin32Lock : IPlatformLock
|
||||
{
|
||||
public NonAlertableWin32Lock ()
|
||||
{
|
||||
_cs = Marshal.AllocHGlobal (Marshal.SizeOf<CRITICAL_SECTION> ());
|
||||
_cs = Marshal.AllocHGlobal (Unsafe.SizeOf<CRITICAL_SECTION>());
|
||||
if (_cs == IntPtr.Zero)
|
||||
throw new OutOfMemoryException ("Failed to allocate memory for critical section");
|
||||
|
||||
|
@ -146,6 +147,17 @@ namespace SkiaSharp.Internals
|
|||
public UIntPtr SpinCount;
|
||||
}
|
||||
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport ("Kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs (UnmanagedType.Bool)]
|
||||
private static partial bool InitializeCriticalSectionEx (IntPtr lpCriticalSection, uint dwSpinCount, uint Flags);
|
||||
[LibraryImport ("Kernel32.dll")]
|
||||
private static partial void DeleteCriticalSection (IntPtr lpCriticalSection);
|
||||
[LibraryImport ("Kernel32.dll")]
|
||||
private static partial void EnterCriticalSection (IntPtr lpCriticalSection);
|
||||
[LibraryImport ("Kernel32.dll")]
|
||||
private static partial void LeaveCriticalSection (IntPtr lpCriticalSection);
|
||||
#else
|
||||
[DllImport ("Kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs (UnmanagedType.Bool)]
|
||||
static extern bool InitializeCriticalSectionEx (IntPtr lpCriticalSection, uint dwSpinCount, uint Flags);
|
||||
|
@ -155,6 +167,7 @@ namespace SkiaSharp.Internals
|
|||
static extern void EnterCriticalSection (IntPtr lpCriticalSection);
|
||||
[DllImport ("Kernel32.dll")]
|
||||
static extern void LeaveCriticalSection (IntPtr lpCriticalSection);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,3 +62,7 @@ using System.Runtime.CompilerServices;
|
|||
[assembly: Foundation.LinkerSafe]
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
#endif
|
||||
|
||||
#if NET7_0_OR_GREATER
|
||||
[assembly: DisableRuntimeMarshalling]
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace SkiaSharp
|
||||
|
@ -10,24 +9,24 @@ namespace SkiaSharp
|
|||
{
|
||||
private static readonly SKManagedStreamDelegates delegates;
|
||||
|
||||
private int fromNative;
|
||||
internal int fromNative;
|
||||
|
||||
static SKAbstractManagedStream ()
|
||||
{
|
||||
delegates = new SKManagedStreamDelegates {
|
||||
fRead = ReadInternal,
|
||||
fPeek = PeekInternal,
|
||||
fIsAtEnd = IsAtEndInternal,
|
||||
fHasPosition = HasPositionInternal,
|
||||
fHasLength = HasLengthInternal,
|
||||
fRewind = RewindInternal,
|
||||
fGetPosition = GetPositionInternal,
|
||||
fSeek = SeekInternal,
|
||||
fMove = MoveInternal,
|
||||
fGetLength = GetLengthInternal,
|
||||
fDuplicate = DuplicateInternal,
|
||||
fFork = ForkInternal,
|
||||
fDestroy = DestroyInternal,
|
||||
fRead = DelegateProxies.SKManagedStreamReadProxy,
|
||||
fPeek = DelegateProxies.SKManagedStreamPeekProxy,
|
||||
fIsAtEnd = DelegateProxies.SKManagedStreamIsAtEndProxy,
|
||||
fHasPosition = DelegateProxies.SKManagedStreamHasPositionProxy,
|
||||
fHasLength = DelegateProxies.SKManagedStreamHasLengthProxy,
|
||||
fRewind = DelegateProxies.SKManagedStreamRewindProxy,
|
||||
fGetPosition = DelegateProxies.SKManagedStreamGetPositionProxy,
|
||||
fSeek = DelegateProxies.SKManagedStreamSeekProxy,
|
||||
fMove = DelegateProxies.SKManagedStreamMoveProxy,
|
||||
fGetLength = DelegateProxies.SKManagedStreamGetLengthProxy,
|
||||
fDuplicate = DelegateProxies.SKManagedStreamDuplicateProxy,
|
||||
fFork = DelegateProxies.SKManagedStreamForkProxy,
|
||||
fDestroy = DelegateProxies.SKManagedStreamDestroyProxy,
|
||||
};
|
||||
SkiaApi.sk_managedstream_set_procs (delegates);
|
||||
}
|
||||
|
@ -53,130 +52,35 @@ namespace SkiaSharp
|
|||
SkiaApi.sk_managedstream_destroy (Handle);
|
||||
}
|
||||
|
||||
protected abstract IntPtr OnRead (IntPtr buffer, IntPtr size);
|
||||
protected internal abstract IntPtr OnRead (IntPtr buffer, IntPtr size);
|
||||
|
||||
protected abstract IntPtr OnPeek (IntPtr buffer, IntPtr size);
|
||||
protected internal abstract IntPtr OnPeek (IntPtr buffer, IntPtr size);
|
||||
|
||||
protected abstract bool OnIsAtEnd ();
|
||||
protected internal abstract bool OnIsAtEnd ();
|
||||
|
||||
protected abstract bool OnHasPosition ();
|
||||
protected internal abstract bool OnHasPosition ();
|
||||
|
||||
protected abstract bool OnHasLength ();
|
||||
protected internal abstract bool OnHasLength ();
|
||||
|
||||
protected abstract bool OnRewind ();
|
||||
protected internal abstract bool OnRewind ();
|
||||
|
||||
protected abstract IntPtr OnGetPosition ();
|
||||
protected internal abstract IntPtr OnGetPosition ();
|
||||
|
||||
protected abstract IntPtr OnGetLength ();
|
||||
protected internal abstract IntPtr OnGetLength ();
|
||||
|
||||
protected abstract bool OnSeek (IntPtr position);
|
||||
protected internal abstract bool OnSeek (IntPtr position);
|
||||
|
||||
protected abstract bool OnMove (int offset);
|
||||
protected internal abstract bool OnMove (int offset);
|
||||
|
||||
protected abstract IntPtr OnCreateNew ();
|
||||
protected internal abstract IntPtr OnCreateNew ();
|
||||
|
||||
protected virtual IntPtr OnFork ()
|
||||
protected internal virtual IntPtr OnFork ()
|
||||
{
|
||||
var stream = OnCreateNew ();
|
||||
SkiaApi.sk_stream_seek (stream, SkiaApi.sk_stream_get_position (Handle));
|
||||
return stream;
|
||||
}
|
||||
|
||||
protected virtual IntPtr OnDuplicate () => OnCreateNew ();
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamReadProxyDelegate))]
|
||||
private static IntPtr ReadInternal (IntPtr s, void* context, void* buffer, IntPtr size)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnRead ((IntPtr)buffer, size);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamPeekProxyDelegate))]
|
||||
private static IntPtr PeekInternal (IntPtr s, void* context, void* buffer, IntPtr size)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnPeek ((IntPtr)buffer, size);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamIsAtEndProxyDelegate))]
|
||||
private static bool IsAtEndInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnIsAtEnd ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamHasPositionProxyDelegate))]
|
||||
private static bool HasPositionInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnHasPosition ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamHasLengthProxyDelegate))]
|
||||
private static bool HasLengthInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnHasLength ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamRewindProxyDelegate))]
|
||||
private static bool RewindInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnRewind ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamGetPositionProxyDelegate))]
|
||||
private static IntPtr GetPositionInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnGetPosition ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamSeekProxyDelegate))]
|
||||
private static bool SeekInternal (IntPtr s, void* context, IntPtr position)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnSeek (position);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamMoveProxyDelegate))]
|
||||
private static bool MoveInternal (IntPtr s, void* context, int offset)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnMove (offset);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamGetLengthProxyDelegate))]
|
||||
private static IntPtr GetLengthInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnGetLength ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamDuplicateProxyDelegate))]
|
||||
private static IntPtr DuplicateInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnDuplicate ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamForkProxyDelegate))]
|
||||
private static IntPtr ForkInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
|
||||
return stream.OnFork ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedStreamDestroyProxyDelegate))]
|
||||
private static void DestroyInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out var gch);
|
||||
if (stream != null) {
|
||||
Interlocked.Exchange (ref stream.fromNative, 1);
|
||||
stream.Dispose ();
|
||||
}
|
||||
gch.Free ();
|
||||
}
|
||||
protected internal virtual IntPtr OnDuplicate () => OnCreateNew ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -10,15 +11,15 @@ namespace SkiaSharp
|
|||
{
|
||||
private static readonly SKManagedWStreamDelegates delegates;
|
||||
|
||||
private int fromNative;
|
||||
internal int fromNative;
|
||||
|
||||
static SKAbstractManagedWStream ()
|
||||
{
|
||||
delegates = new SKManagedWStreamDelegates {
|
||||
fWrite = WriteInternal,
|
||||
fFlush = FlushInternal,
|
||||
fBytesWritten = BytesWrittenInternal,
|
||||
fDestroy = DestroyInternal,
|
||||
fWrite = DelegateProxies.SKManagedWStreamWriteProxy,
|
||||
fFlush = DelegateProxies.SKManagedWStreamFlushProxy,
|
||||
fBytesWritten = DelegateProxies.SKManagedWStreamBytesWrittenProxy,
|
||||
fDestroy = DelegateProxies.SKManagedWStreamDestroyProxy
|
||||
};
|
||||
|
||||
SkiaApi.sk_managedwstream_set_procs (delegates);
|
||||
|
@ -45,42 +46,10 @@ namespace SkiaSharp
|
|||
SkiaApi.sk_managedwstream_destroy (Handle);
|
||||
}
|
||||
|
||||
protected abstract bool OnWrite (IntPtr buffer, IntPtr size);
|
||||
protected internal abstract bool OnWrite (IntPtr buffer, IntPtr size);
|
||||
|
||||
protected abstract void OnFlush ();
|
||||
protected internal abstract void OnFlush ();
|
||||
|
||||
protected abstract IntPtr OnBytesWritten ();
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedWStreamWriteProxyDelegate))]
|
||||
private static bool WriteInternal (IntPtr s, void* context, void* buffer, IntPtr size)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out _);
|
||||
return stream.OnWrite ((IntPtr)buffer, size);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedWStreamFlushProxyDelegate))]
|
||||
private static void FlushInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out _);
|
||||
stream.OnFlush ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedWStreamBytesWrittenProxyDelegate))]
|
||||
private static IntPtr BytesWrittenInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out _);
|
||||
return stream.OnBytesWritten ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedWStreamDestroyProxyDelegate))]
|
||||
private static void DestroyInternal (IntPtr s, void* context)
|
||||
{
|
||||
var stream = DelegateProxies.GetUserData<SKAbstractManagedWStream> ((IntPtr)context, out var gch);
|
||||
if (stream != null) {
|
||||
Interlocked.Exchange (ref stream.fromNative, 1);
|
||||
stream.Dispose ();
|
||||
}
|
||||
gch.Free ();
|
||||
}
|
||||
protected internal abstract IntPtr OnBytesWritten ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using SkiaSharp.Internals;
|
|||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
public class SKAutoCoInitialize : IDisposable
|
||||
public partial class SKAutoCoInitialize : IDisposable
|
||||
{
|
||||
private long hResult;
|
||||
|
||||
|
@ -41,10 +41,16 @@ namespace SkiaSharp
|
|||
private const uint COINIT_DISABLE_OLE1DDE = 0x4;
|
||||
private const uint COINIT_SPEED_OVER_MEMORY = 0x8;
|
||||
|
||||
#if USE_LIBRARY_IMPORT
|
||||
[LibraryImport("ole32.dll", SetLastError = true)]
|
||||
private static partial long CoInitializeEx(IntPtr pvReserved, uint dwCoInit);
|
||||
[LibraryImport("ole32.dll", SetLastError = true)]
|
||||
private static partial void CoUninitialize();
|
||||
#else
|
||||
[DllImport("ole32.dll", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern long CoInitializeEx([In, Optional] IntPtr pvReserved, [In] uint dwCoInit);
|
||||
|
||||
[DllImport("ole32.dll", CharSet = CharSet.Ansi, SetLastError = true, CallingConvention = CallingConvention.StdCall)]
|
||||
private static extern void CoUninitialize();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -609,7 +609,8 @@ namespace SkiaSharp
|
|||
var del = releaseProc != null && context != null
|
||||
? new SKBitmapReleaseDelegate ((addr, _) => releaseProc (addr, context))
|
||||
: releaseProc;
|
||||
var proxy = DelegateProxies.Create (del, DelegateProxies.SKBitmapReleaseDelegateProxy, out _, out var ctx);
|
||||
DelegateProxies.Create (del, out _, out var ctx);
|
||||
var proxy = del is not null ? DelegateProxies.SKBitmapReleaseProxy : null;
|
||||
return SkiaApi.sk_bitmap_install_pixels (Handle, &cinfo, (void*)pixels, (IntPtr)rowBytes, proxy, (void*)ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -207,7 +207,8 @@ namespace SkiaSharp
|
|||
var del = releaseProc != null && context != null
|
||||
? new SKDataReleaseDelegate ((addr, _) => releaseProc (addr, context))
|
||||
: releaseProc;
|
||||
var proxy = DelegateProxies.Create (del, DelegateProxies.SKDataReleaseDelegateProxy, out _, out var ctx);
|
||||
DelegateProxies.Create (del, out _, out var ctx);
|
||||
var proxy = del is not null ? DelegateProxies.SKDataReleaseProxy : null;
|
||||
return GetObject (SkiaApi.sk_data_new_with_proc ((void*)address, (IntPtr)length, proxy, (void*)ctx));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace SkiaSharp
|
||||
|
@ -10,16 +9,16 @@ namespace SkiaSharp
|
|||
{
|
||||
private static readonly SKManagedDrawableDelegates delegates;
|
||||
|
||||
private int fromNative;
|
||||
internal int fromNative;
|
||||
|
||||
static SKDrawable ()
|
||||
{
|
||||
delegates = new SKManagedDrawableDelegates {
|
||||
fDraw = DrawInternal,
|
||||
fGetBounds = GetBoundsInternal,
|
||||
fApproximateBytesUsed = ApproximateBytesUsedInternal,
|
||||
fMakePictureSnapshot = MakePictureSnapshotInternal,
|
||||
fDestroy = DestroyInternal,
|
||||
fDraw = DelegateProxies.SKManagedDrawableDrawProxy,
|
||||
fGetBounds = DelegateProxies.SKManagedDrawableGetBoundsProxy,
|
||||
fApproximateBytesUsed = DelegateProxies.SKManagedDrawableApproximateBytesUsedProxy,
|
||||
fMakePictureSnapshot = DelegateProxies.SKManagedDrawableMakePictureSnapshotProxy,
|
||||
fDestroy = DelegateProxies.SKManagedDrawableDestroyProxy
|
||||
};
|
||||
|
||||
SkiaApi.sk_manageddrawable_set_procs (delegates);
|
||||
|
@ -87,15 +86,15 @@ namespace SkiaSharp
|
|||
public void NotifyDrawingChanged () =>
|
||||
SkiaApi.sk_drawable_notify_drawing_changed (Handle);
|
||||
|
||||
protected virtual void OnDraw (SKCanvas canvas)
|
||||
protected internal virtual void OnDraw (SKCanvas canvas)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual int OnGetApproximateBytesUsed () => 0;
|
||||
protected internal virtual int OnGetApproximateBytesUsed () => 0;
|
||||
|
||||
protected virtual SKRect OnGetBounds () => SKRect.Empty;
|
||||
protected internal virtual SKRect OnGetBounds () => SKRect.Empty;
|
||||
|
||||
protected virtual SKPicture OnSnapshot ()
|
||||
protected internal virtual SKPicture OnSnapshot ()
|
||||
{
|
||||
using var recorder = new SKPictureRecorder ();
|
||||
var canvas = recorder.BeginRecording (Bounds);
|
||||
|
@ -103,46 +102,6 @@ namespace SkiaSharp
|
|||
return recorder.EndRecording ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedDrawableDrawProxyDelegate))]
|
||||
private static void DrawInternal (IntPtr d, void* context, IntPtr canvas)
|
||||
{
|
||||
var drawable = DelegateProxies.GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
drawable.OnDraw (SKCanvas.GetObject (canvas, false));
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedDrawableGetBoundsProxyDelegate))]
|
||||
private static void GetBoundsInternal (IntPtr d, void* context, SKRect* rect)
|
||||
{
|
||||
var drawable = DelegateProxies.GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
var bounds = drawable.OnGetBounds ();
|
||||
*rect = bounds;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedDrawableApproximateBytesUsedProxyDelegate))]
|
||||
private static IntPtr ApproximateBytesUsedInternal (IntPtr d, void* context)
|
||||
{
|
||||
var drawable = DelegateProxies.GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
return (IntPtr)drawable.OnGetApproximateBytesUsed ();
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedDrawableMakePictureSnapshotProxyDelegate))]
|
||||
private static IntPtr MakePictureSnapshotInternal (IntPtr d, void* context)
|
||||
{
|
||||
var drawable = DelegateProxies.GetUserData<SKDrawable> ((IntPtr)context, out _);
|
||||
return drawable.OnSnapshot ()?.Handle ?? IntPtr.Zero;
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedDrawableDestroyProxyDelegate))]
|
||||
private static void DestroyInternal (IntPtr d, void* context)
|
||||
{
|
||||
var drawable = DelegateProxies.GetUserData<SKDrawable> ((IntPtr)context, out var gch);
|
||||
if (drawable != null) {
|
||||
Interlocked.Exchange (ref drawable.fromNative, 1);
|
||||
drawable.Dispose ();
|
||||
}
|
||||
gch.Free ();
|
||||
}
|
||||
|
||||
internal static SKDrawable GetObject (IntPtr handle) =>
|
||||
GetOrAddObject (handle, (h, o) => new SKDrawable (h, o));
|
||||
}
|
||||
|
|
|
@ -793,7 +793,8 @@ namespace SkiaSharp
|
|||
|
||||
public void GetGlyphPaths (ReadOnlySpan<ushort> glyphs, SKGlyphPathDelegate glyphPathDelegate)
|
||||
{
|
||||
var proxy = DelegateProxies.Create (glyphPathDelegate, DelegateProxies.SKGlyphPathDelegateProxy, out var gch, out var ctx);
|
||||
DelegateProxies.Create (glyphPathDelegate, out var gch, out var ctx);
|
||||
var proxy = glyphPathDelegate is not null ? DelegateProxies.SKGlyphPathProxy : null;
|
||||
try {
|
||||
fixed (ushort* g = glyphs) {
|
||||
SkiaApi.sk_font_get_paths (Handle, g, glyphs.Length, proxy, (void*)ctx);
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace SkiaSharp
|
|||
base.DisposeManaged ();
|
||||
}
|
||||
|
||||
protected override IntPtr OnRead (IntPtr buffer, IntPtr size)
|
||||
protected internal override IntPtr OnRead (IntPtr buffer, IntPtr size)
|
||||
{
|
||||
var start = offset;
|
||||
|
||||
|
@ -123,7 +123,7 @@ namespace SkiaSharp
|
|||
return (IntPtr)(offset - start);
|
||||
}
|
||||
|
||||
protected override IntPtr OnPeek (IntPtr buffer, IntPtr size)
|
||||
protected internal override IntPtr OnPeek (IntPtr buffer, IntPtr size)
|
||||
{
|
||||
if (offset >= bufferLength)
|
||||
{
|
||||
|
@ -143,7 +143,7 @@ namespace SkiaSharp
|
|||
return (IntPtr)bytesRead;
|
||||
}
|
||||
|
||||
protected override bool OnIsAtEnd ()
|
||||
protected internal override bool OnIsAtEnd ()
|
||||
{
|
||||
if (offset < bufferedSoFar)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ namespace SkiaSharp
|
|||
return stream.IsAtEnd;
|
||||
}
|
||||
|
||||
protected override bool OnRewind ()
|
||||
protected internal override bool OnRewind ()
|
||||
{
|
||||
// only allow a rewind if we have not exceeded the buffer.
|
||||
if (offset <= bufferLength)
|
||||
|
@ -167,23 +167,23 @@ namespace SkiaSharp
|
|||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnHasLength () => hasLength;
|
||||
protected internal override bool OnHasLength () => hasLength;
|
||||
|
||||
protected override IntPtr OnGetLength () => (IntPtr)streamLength;
|
||||
protected internal override IntPtr OnGetLength () => (IntPtr)streamLength;
|
||||
|
||||
// seeking is not supported
|
||||
protected override bool OnHasPosition () => false;
|
||||
protected internal override bool OnHasPosition () => false;
|
||||
|
||||
// seeking is not supported
|
||||
protected override IntPtr OnGetPosition () => (IntPtr)0;
|
||||
protected internal override IntPtr OnGetPosition () => (IntPtr)0;
|
||||
|
||||
// seeking is not supported
|
||||
protected override bool OnSeek (IntPtr position) => false;
|
||||
protected internal override bool OnSeek (IntPtr position) => false;
|
||||
|
||||
// seeking is not supported
|
||||
protected override bool OnMove (int offset) => false;
|
||||
protected internal override bool OnMove (int offset) => false;
|
||||
|
||||
// duplicating or forking is not supported
|
||||
protected override IntPtr OnCreateNew () => IntPtr.Zero;
|
||||
protected internal override IntPtr OnCreateNew () => IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace SkiaSharp
|
|||
var pixels = Marshal.AllocCoTaskMem (info.BytesSize);
|
||||
using (var pixmap = new SKPixmap (info, pixels)) {
|
||||
// don't use the managed version as that is just extra overhead which isn't necessary
|
||||
return GetObject (SkiaApi.sk_image_new_raster (pixmap.Handle, DelegateProxies.SKImageRasterReleaseDelegateProxyForCoTaskMem, null));
|
||||
return GetObject (SkiaApi.sk_image_new_raster (pixmap.Handle, DelegateProxies.SKImageRasterReleaseProxyForCoTaskMem, null));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,8 @@ namespace SkiaSharp
|
|||
var del = releaseProc != null && releaseContext != null
|
||||
? new SKImageRasterReleaseDelegate ((addr, _) => releaseProc (addr, releaseContext))
|
||||
: releaseProc;
|
||||
var proxy = DelegateProxies.Create (del, DelegateProxies.SKImageRasterReleaseDelegateProxy, out _, out var ctx);
|
||||
DelegateProxies.Create (del, out _, out var ctx);
|
||||
var proxy = del is not null ? DelegateProxies.SKImageRasterReleaseProxy : null;
|
||||
return GetObject (SkiaApi.sk_image_new_raster (pixmap.Handle, proxy, (void*)ctx));
|
||||
}
|
||||
|
||||
|
@ -289,7 +290,8 @@ namespace SkiaSharp
|
|||
var del = releaseProc != null && releaseContext != null
|
||||
? new SKImageTextureReleaseDelegate ((_) => releaseProc (releaseContext))
|
||||
: releaseProc;
|
||||
var proxy = DelegateProxies.Create (del, DelegateProxies.SKImageTextureReleaseDelegateProxy, out _, out var ctx);
|
||||
DelegateProxies.Create (del, out _, out var ctx);
|
||||
var proxy = del is not null ? DelegateProxies.SKImageTextureReleaseProxy : null;
|
||||
return GetObject (SkiaApi.sk_image_new_from_texture (context.Handle, texture.Handle, origin, colorType.ToNative (), alpha, cs, proxy, (void*)ctx));
|
||||
}
|
||||
|
||||
|
|
|
@ -111,14 +111,14 @@ namespace SkiaSharp
|
|||
return (IntPtr)len;
|
||||
}
|
||||
|
||||
protected override IntPtr OnRead (IntPtr buffer, IntPtr size)
|
||||
protected internal override IntPtr OnRead (IntPtr buffer, IntPtr size)
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
return OnReadManagedStream (buffer, size);
|
||||
}
|
||||
|
||||
protected override IntPtr OnPeek (IntPtr buffer, IntPtr size)
|
||||
protected internal override IntPtr OnPeek (IntPtr buffer, IntPtr size)
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace SkiaSharp
|
|||
return result;
|
||||
}
|
||||
|
||||
protected override bool OnIsAtEnd ()
|
||||
protected internal override bool OnIsAtEnd ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -141,21 +141,21 @@ namespace SkiaSharp
|
|||
return stream.Position >= stream.Length;
|
||||
}
|
||||
|
||||
protected override bool OnHasPosition ()
|
||||
protected internal override bool OnHasPosition ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
return stream.CanSeek;
|
||||
}
|
||||
|
||||
protected override bool OnHasLength ()
|
||||
protected internal override bool OnHasLength ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
return stream.CanSeek;
|
||||
}
|
||||
|
||||
protected override bool OnRewind ()
|
||||
protected internal override bool OnRewind ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -166,7 +166,7 @@ namespace SkiaSharp
|
|||
return true;
|
||||
}
|
||||
|
||||
protected override IntPtr OnGetPosition ()
|
||||
protected internal override IntPtr OnGetPosition ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -176,7 +176,7 @@ namespace SkiaSharp
|
|||
return (IntPtr)stream.Position;
|
||||
}
|
||||
|
||||
protected override IntPtr OnGetLength ()
|
||||
protected internal override IntPtr OnGetLength ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -186,7 +186,7 @@ namespace SkiaSharp
|
|||
return (IntPtr)stream.Length;
|
||||
}
|
||||
|
||||
protected override bool OnSeek (IntPtr position)
|
||||
protected internal override bool OnSeek (IntPtr position)
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -197,7 +197,7 @@ namespace SkiaSharp
|
|||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnMove (int offset)
|
||||
protected internal override bool OnMove (int offset)
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -208,14 +208,14 @@ namespace SkiaSharp
|
|||
return true;
|
||||
}
|
||||
|
||||
protected override IntPtr OnCreateNew ()
|
||||
protected internal override IntPtr OnCreateNew ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
protected override IntPtr OnDuplicate ()
|
||||
protected internal override IntPtr OnDuplicate ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
@ -234,7 +234,7 @@ namespace SkiaSharp
|
|||
return newStream.Handle;
|
||||
}
|
||||
|
||||
protected override IntPtr OnFork ()
|
||||
protected internal override IntPtr OnFork ()
|
||||
{
|
||||
VerifyOriginal ();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace SkiaSharp
|
|||
base.DisposeManaged ();
|
||||
}
|
||||
|
||||
protected override bool OnWrite (IntPtr buffer, IntPtr size)
|
||||
protected internal override bool OnWrite (IntPtr buffer, IntPtr size)
|
||||
{
|
||||
var count = (int)size;
|
||||
using var managedBuffer = Utils.RentArray<byte> (count);
|
||||
|
@ -53,12 +53,12 @@ namespace SkiaSharp
|
|||
return true;
|
||||
}
|
||||
|
||||
protected override void OnFlush ()
|
||||
protected internal override void OnFlush ()
|
||||
{
|
||||
stream.Flush ();
|
||||
}
|
||||
|
||||
protected override IntPtr OnBytesWritten ()
|
||||
protected internal override IntPtr OnBytesWritten ()
|
||||
{
|
||||
return (IntPtr)stream.Position;
|
||||
}
|
||||
|
|
|
@ -206,24 +206,6 @@ namespace SkiaSharp
|
|||
|
||||
return owner;
|
||||
}
|
||||
|
||||
internal static T[] PtrToStructureArray<T> (IntPtr intPtr, int count)
|
||||
{
|
||||
var items = new T[count];
|
||||
var size = Marshal.SizeOf<T> ();
|
||||
for (var i = 0; i < count; i++) {
|
||||
var newPtr = new IntPtr (intPtr.ToInt64 () + (i * size));
|
||||
items[i] = Marshal.PtrToStructure<T> (newPtr);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
internal static T PtrToStructure<T> (IntPtr intPtr, int index)
|
||||
{
|
||||
var size = Marshal.SizeOf<T> ();
|
||||
var newPtr = new IntPtr (intPtr.ToInt64 () + (index * size));
|
||||
return Marshal.PtrToStructure<T> (newPtr);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SKNativeObject : IDisposable
|
||||
|
|
|
@ -68,7 +68,8 @@ namespace SkiaSharp
|
|||
var del = releaseProc != null && context != null
|
||||
? new SKSurfaceReleaseDelegate ((addr, _) => releaseProc (addr, context))
|
||||
: releaseProc;
|
||||
var proxy = DelegateProxies.Create (del, DelegateProxies.SKSurfaceReleaseDelegateProxy, out _, out var ctx);
|
||||
DelegateProxies.Create (del, out _, out var ctx);
|
||||
var proxy = del != null ? DelegateProxies.SKSurfaceRasterReleaseProxy : null;
|
||||
return GetObject (SkiaApi.sk_surface_new_raster_direct (&cinfo, (void*)pixels, (IntPtr)rowBytes, proxy, (void*)ctx, props?.Handle ?? IntPtr.Zero));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#nullable disable
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SkiaSharp
|
||||
{
|
||||
|
@ -13,8 +12,8 @@ namespace SkiaSharp
|
|||
static SKTraceMemoryDump ()
|
||||
{
|
||||
delegates = new SKManagedTraceMemoryDumpDelegates {
|
||||
fDumpNumericValue = DumpNumericValueInternal,
|
||||
fDumpStringValue = DumpStringValueInternal,
|
||||
fDumpNumericValue = DelegateProxies.SKManagedTraceMemoryDumpDumpNumericValueProxy,
|
||||
fDumpStringValue = DelegateProxies.SKManagedTraceMemoryDumpDumpStringValueProxy,
|
||||
};
|
||||
|
||||
SkiaApi.sk_managedtracememorydump_set_procs (delegates);
|
||||
|
@ -39,35 +38,12 @@ namespace SkiaSharp
|
|||
gch.Free ();
|
||||
}
|
||||
|
||||
protected virtual void OnDumpNumericValue (string dumpName, string valueName, string units, ulong value)
|
||||
protected internal virtual void OnDumpNumericValue (string dumpName, string valueName, string units, ulong value)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnDumpStringValue (string dumpName, string valueName, string value)
|
||||
protected internal virtual void OnDumpStringValue (string dumpName, string valueName, string value)
|
||||
{
|
||||
}
|
||||
|
||||
// impl
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedTraceMemoryDumpDumpNumericValueProxyDelegate))]
|
||||
private static void DumpNumericValueInternal (IntPtr d, void* context, void* dumpName, void* valueName, void* units, ulong value)
|
||||
{
|
||||
var dump = DelegateProxies.GetUserData<SKTraceMemoryDump> ((IntPtr)context, out _);
|
||||
dump.OnDumpNumericValue (
|
||||
Marshal.PtrToStringAnsi ((IntPtr)dumpName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)valueName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)units),
|
||||
value);
|
||||
}
|
||||
|
||||
[MonoPInvokeCallback (typeof (SKManagedTraceMemoryDumpDumpStringValueProxyDelegate))]
|
||||
private static void DumpStringValueInternal (IntPtr d, void* context, void* dumpName, void* valueName, void* value)
|
||||
{
|
||||
var dump = DelegateProxies.GetUserData<SKTraceMemoryDump> ((IntPtr)context, out _);
|
||||
dump.OnDumpStringValue (
|
||||
Marshal.PtrToStringAnsi ((IntPtr)dumpName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)valueName),
|
||||
Marshal.PtrToStringAnsi ((IntPtr)value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,10 +6,15 @@
|
|||
<PackagingGroup>SkiaSharp</PackagingGroup>
|
||||
<Nullable>enable</Nullable>
|
||||
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
|
||||
<WarningsAsErrors>$(WarningsAsErrors);CA1420;CA1421;</WarningsAsErrors>
|
||||
<NoWarn>$(NoWarn);CS8826</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
|
||||
<DefineConstants>$(DefineConstants);USE_DELEGATES</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
|
||||
<ProjectReference Include="..\SkiaSharp.NativeAssets.Android\SkiaSharp.NativeAssets.Android.csproj" Condition="$(TargetFramework.Contains('-android'))" />
|
||||
<ProjectReference Include="..\SkiaSharp.NativeAssets.iOS\SkiaSharp.NativeAssets.iOS.csproj" Condition="$(TargetFramework.Contains('-ios'))" />
|
||||
|
|
|
@ -231,6 +231,11 @@
|
|||
"-1": "int"
|
||||
}
|
||||
},
|
||||
"hb_unicode_combining_category_func_t": {
|
||||
"parameters": {
|
||||
"-1": "int"
|
||||
}
|
||||
},
|
||||
"hb_font_get_glyph_from_name": {
|
||||
"parameters": {
|
||||
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
|
||||
|
@ -265,6 +270,23 @@
|
|||
"parameters": {
|
||||
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
|
||||
}
|
||||
},
|
||||
"hb_destroy_func_t": {
|
||||
"proxySuffixes": [
|
||||
"", "ForMulti"
|
||||
]
|
||||
},
|
||||
"hb_unicode_decompose_compatibility_func_t": {
|
||||
"generateProxy": false
|
||||
},
|
||||
"hb_unicode_eastasian_width_func_t": {
|
||||
"generateProxy": false
|
||||
},
|
||||
"hb_buffer_message_func_t": {
|
||||
"generateProxy": false
|
||||
},
|
||||
"hb_font_get_glyph_func_t": {
|
||||
"generateProxy": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -405,6 +405,9 @@
|
|||
},
|
||||
"functions": {
|
||||
// delegates
|
||||
"gr_gl_func_ptr": {
|
||||
"generateProxy": false
|
||||
},
|
||||
"gr_gl_get_proc": {
|
||||
"cs": "GRGlGetProcProxyDelegate",
|
||||
"parameters": {
|
||||
|
@ -412,7 +415,8 @@
|
|||
}
|
||||
},
|
||||
"gr_vk_func_ptr": {
|
||||
"convention": "stdcall"
|
||||
"convention": "stdcall",
|
||||
"generateProxy": false
|
||||
},
|
||||
"gr_vk_get_proc": {
|
||||
"cs": "GRVkGetProcProxyDelegate",
|
||||
|
@ -479,6 +483,11 @@
|
|||
"parameters": {
|
||||
"1": "[MarshalAs (UnmanagedType.LPStr)] String"
|
||||
}
|
||||
},
|
||||
"sk_image_raster_release_proc": {
|
||||
"proxySuffixes": [
|
||||
"", "ForCoTaskMem"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
<Platforms>AnyCPU;x64;x86</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.2" />
|
||||
<PackageReference Include="xunit" Version="2.4.2" />
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<SignAssembly>false</SignAssembly>
|
||||
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>
|
||||
<SkipMDocGenerateDocs>true</SkipMDocGenerateDocs>
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<AssemblyName>SkiaSharp.Tests</AssemblyName>
|
||||
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>
|
||||
<SkipMDocGenerateDocs>true</SkipMDocGenerateDocs>
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_IMPORT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(TFMCurrent)</TargetFrameworks>
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_LOADER</DefineConstants>
|
||||
<DefineConstants>$(DefineConstants);USE_LIBRARY_LOADER;USE_LIBRARY_IMPORT</DefineConstants>
|
||||
<RootNamespace>SkiaSharp.Tests</RootNamespace>
|
||||
<AssemblyName>SkiaSharp.Tests</AssemblyName>
|
||||
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>
|
||||
|
|
|
@ -61,9 +61,15 @@ namespace SkiaSharp.Tests
|
|||
public void DelegateTypesAreValid()
|
||||
{
|
||||
var del = InteropDelegatesData;
|
||||
#if USE_LIBRARY_IMPORT
|
||||
// Targets using USE_LIBRARY_IMPORT don't have delegates generated as they are not used.
|
||||
Assert.Empty(del);
|
||||
#else
|
||||
Assert.NotEmpty(del);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !USE_LIBRARY_IMPORT
|
||||
[Trait(Traits.Category.Key, Traits.Category.Values.Api)]
|
||||
[SkippableTheory]
|
||||
[MemberData(nameof(InteropDelegatesData))]
|
||||
|
@ -71,6 +77,7 @@ namespace SkiaSharp.Tests
|
|||
{
|
||||
Assert.NotNull(delegateType.GetCustomAttribute<UnmanagedFunctionPointerAttribute>());
|
||||
}
|
||||
#endif
|
||||
|
||||
[Trait(Traits.Category.Key, Traits.Category.Values.Api)]
|
||||
[SkippableTheory]
|
||||
|
|
|
@ -4,26 +4,26 @@ namespace SkiaSharp.Tests
|
|||
{
|
||||
public class ManagedStream : SKAbstractManagedStream
|
||||
{
|
||||
protected override IntPtr OnRead (IntPtr buffer, IntPtr size) => (IntPtr)0;
|
||||
protected internal override IntPtr OnRead (IntPtr buffer, IntPtr size) => (IntPtr)0;
|
||||
|
||||
protected override IntPtr OnPeek (IntPtr buffer, IntPtr size) => (IntPtr)0;
|
||||
protected internal override IntPtr OnPeek (IntPtr buffer, IntPtr size) => (IntPtr)0;
|
||||
|
||||
protected override bool OnIsAtEnd () => false;
|
||||
protected internal override bool OnIsAtEnd () => false;
|
||||
|
||||
protected override bool OnHasPosition () => false;
|
||||
protected internal override bool OnHasPosition () => false;
|
||||
|
||||
protected override bool OnHasLength () => false;
|
||||
protected internal override bool OnHasLength () => false;
|
||||
|
||||
protected override bool OnRewind () => false;
|
||||
protected internal override bool OnRewind () => false;
|
||||
|
||||
protected override IntPtr OnGetPosition () => (IntPtr)0;
|
||||
protected internal override IntPtr OnGetPosition () => (IntPtr)0;
|
||||
|
||||
protected override IntPtr OnGetLength () => (IntPtr)0;
|
||||
protected internal override IntPtr OnGetLength () => (IntPtr)0;
|
||||
|
||||
protected override bool OnSeek (IntPtr position) => false;
|
||||
protected internal override bool OnSeek (IntPtr position) => false;
|
||||
|
||||
protected override bool OnMove (int offset) => false;
|
||||
protected internal override bool OnMove (int offset) => false;
|
||||
|
||||
protected override IntPtr OnCreateNew () => IntPtr.Zero;
|
||||
protected internal override IntPtr OnCreateNew () => IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,28 +107,28 @@ namespace SkiaSharp.Tests
|
|||
public int SnapshotFireCount;
|
||||
public int ApproxBytesCount;
|
||||
|
||||
protected override void OnDraw(SKCanvas canvas)
|
||||
protected internal override void OnDraw(SKCanvas canvas)
|
||||
{
|
||||
DrawFireCount++;
|
||||
|
||||
canvas.DrawColor(SKColors.Blue);
|
||||
}
|
||||
|
||||
protected override SKRect OnGetBounds()
|
||||
protected internal override SKRect OnGetBounds()
|
||||
{
|
||||
BoundsFireCount++;
|
||||
|
||||
return SKRect.Create(100, 100);
|
||||
}
|
||||
|
||||
protected override SKPicture OnSnapshot()
|
||||
protected internal override SKPicture OnSnapshot()
|
||||
{
|
||||
SnapshotFireCount++;
|
||||
|
||||
return base.OnSnapshot();
|
||||
}
|
||||
|
||||
protected override int OnGetApproximateBytesUsed ()
|
||||
protected internal override int OnGetApproximateBytesUsed ()
|
||||
{
|
||||
ApproxBytesCount++;
|
||||
|
||||
|
|
|
@ -182,9 +182,9 @@ namespace SkiaSharp.Tests
|
|||
fHasPosition = hasPosition;
|
||||
}
|
||||
|
||||
protected override bool OnHasLength () => fHasLength;
|
||||
protected internal override bool OnHasLength () => fHasLength;
|
||||
|
||||
protected override bool OnHasPosition () => fHasPosition;
|
||||
protected internal override bool OnHasPosition () => fHasPosition;
|
||||
}
|
||||
|
||||
[SkippableTheory]
|
||||
|
@ -222,9 +222,9 @@ namespace SkiaSharp.Tests
|
|||
{
|
||||
private bool fAtEnd;
|
||||
|
||||
protected override bool OnIsAtEnd () => fAtEnd;
|
||||
protected internal override bool OnIsAtEnd () => fAtEnd;
|
||||
|
||||
protected override IntPtr OnRead (IntPtr buffer, IntPtr size)
|
||||
protected internal override IntPtr OnRead (IntPtr buffer, IntPtr size)
|
||||
{
|
||||
Assert.False (fAtEnd);
|
||||
fAtEnd = true;
|
||||
|
|
|
@ -140,10 +140,10 @@ namespace SkiaSharp.Tests
|
|||
|
||||
public List<string> Lines { get; } = new List<string>();
|
||||
|
||||
protected override void OnDumpNumericValue(string dumpName, string valueName, string units, ulong value) =>
|
||||
protected internal override void OnDumpNumericValue(string dumpName, string valueName, string units, ulong value) =>
|
||||
Lines.Add($"{dumpName}.{valueName} = {value} {units}");
|
||||
|
||||
protected override void OnDumpStringValue(string dumpName, string valueName, string value) =>
|
||||
protected internal override void OnDumpStringValue(string dumpName, string valueName, string value) =>
|
||||
Lines.Add($"{dumpName}.{valueName} = '{value}'");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,6 +191,67 @@ namespace SkiaSharpGenerator
|
|||
return config ?? throw new InvalidOperationException("Unable to parse json config file.");
|
||||
}
|
||||
|
||||
protected (List<string> args, string returnType) GetManagedFunctionArguments(CppFunctionType function, FunctionMapping? map)
|
||||
{
|
||||
var paramsList = new List<string>();
|
||||
for (var i = 0; i < function.Parameters.Count; i++)
|
||||
{
|
||||
var p = function.Parameters[i];
|
||||
var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name;
|
||||
var t = GetType(p.Type);
|
||||
var cppT = GetCppType(p.Type);
|
||||
if (t == "Boolean" || cppT == "bool")
|
||||
t = "[MarshalAs (UnmanagedType.I1)] bool";
|
||||
if (map != null && map.Parameters.TryGetValue(i.ToString(), out var newT))
|
||||
t = newT;
|
||||
paramsList.Add($"{t} {n}");
|
||||
}
|
||||
|
||||
var returnType = GetType(function.ReturnType);
|
||||
if (map != null && map.Parameters.TryGetValue("-1", out var newR))
|
||||
{
|
||||
returnType = newR;
|
||||
}
|
||||
else if (returnType == "Boolean" || GetCppType(function.ReturnType) == "bool")
|
||||
{
|
||||
returnType = "bool";
|
||||
}
|
||||
return (paramsList, returnType);
|
||||
}
|
||||
|
||||
protected string? GetFunctionPointerType(CppType type, FunctionMapping? map = null)
|
||||
{
|
||||
if (map is null)
|
||||
{
|
||||
functionMappings.TryGetValue(type.GetDisplayName(), out map);
|
||||
}
|
||||
|
||||
type = (type as CppQualifiedType)?.ElementType as CppTypedef ?? type;
|
||||
type = (type as CppTypedef)?.ElementType as CppTypedef ?? type;
|
||||
type = (type as CppTypedef)?.ElementType as CppPointerType ?? type;
|
||||
type = (type as CppPointerType)?.ElementType as CppFunctionType ?? type;
|
||||
if (type is CppFunctionType { CallingConvention: CppCallingConvention.C } function)
|
||||
{
|
||||
var parameters = string.Join(", ", function.Parameters
|
||||
.Select((p, i) => (p.Type, i))
|
||||
.Concat(new[] { (function.ReturnType, -1) })
|
||||
.Select(tuple =>
|
||||
{
|
||||
var (cppType, i) = tuple;
|
||||
var t = GetType(cppType);
|
||||
var cppT = GetCppType(cppType);
|
||||
if (t == "Boolean" || cppT == "bool")
|
||||
t = "bool";
|
||||
if (map != null && map.Parameters.TryGetValue(i.ToString(), out var newT))
|
||||
t = newT;
|
||||
return t;
|
||||
}));
|
||||
return $"delegate* unmanaged[Cdecl] <{parameters}>";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected string GetType(CppType type)
|
||||
{
|
||||
var typeName = GetCppType(type);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace SkiaSharpGenerator
|
||||
|
@ -10,5 +11,11 @@ namespace SkiaSharpGenerator
|
|||
|
||||
[JsonPropertyName("parameters")]
|
||||
public Dictionary<string, string> Parameters { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
[JsonPropertyName("generateProxy")]
|
||||
public bool? GenerateProxy { get; set; }
|
||||
|
||||
[JsonPropertyName("proxySuffixes")]
|
||||
public List<string>? ProxySuffixes { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ namespace SkiaSharpGenerator
|
|||
|
||||
writer.WriteLine("using System;");
|
||||
writer.WriteLine("using System.Runtime.InteropServices;");
|
||||
writer.WriteLine("using System.Runtime.CompilerServices;");
|
||||
writer.WriteLine();
|
||||
WriteNamespaces(writer);
|
||||
writer.WriteLine();
|
||||
|
@ -62,6 +63,8 @@ namespace SkiaSharpGenerator
|
|||
WriteStructs(writer);
|
||||
writer.WriteLine();
|
||||
WriteEnums(writer);
|
||||
writer.WriteLine();
|
||||
WriteDelegateProxies(writer);
|
||||
}
|
||||
|
||||
private void WriteDelegates(TextWriter writer)
|
||||
|
@ -69,6 +72,7 @@ namespace SkiaSharpGenerator
|
|||
Log?.LogVerbose(" Writing delegates...");
|
||||
|
||||
writer.WriteLine($"#region Delegates");
|
||||
writer.WriteLine($"#if !USE_LIBRARY_IMPORT");
|
||||
|
||||
var delegates = compilation.Typedefs
|
||||
.Where(t => t.ElementType.TypeKind == CppTypeKind.Pointer)
|
||||
|
@ -90,6 +94,7 @@ namespace SkiaSharpGenerator
|
|||
}
|
||||
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"#endif // !USE_LIBRARY_IMPORT");
|
||||
writer.WriteLine($"#endregion");
|
||||
}
|
||||
|
||||
|
@ -113,28 +118,9 @@ namespace SkiaSharpGenerator
|
|||
writer.WriteLine($"\t// {del}");
|
||||
writer.WriteLine($"\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
|
||||
|
||||
var paramsList = new List<string>();
|
||||
for (var i = 0; i < function.Parameters.Count; i++)
|
||||
var (paramsList, returnType) = GetManagedFunctionArguments(function, map);
|
||||
if (returnType == "bool")
|
||||
{
|
||||
var p = function.Parameters[i];
|
||||
var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name;
|
||||
var t = GetType(p.Type);
|
||||
var cppT = GetCppType(p.Type);
|
||||
if (t == "Boolean" || cppT == "bool")
|
||||
t = $"[MarshalAs (UnmanagedType.I1)] bool";
|
||||
if (map != null && map.Parameters.TryGetValue(i.ToString(), out var newT))
|
||||
t = newT;
|
||||
paramsList.Add($"{t} {n}");
|
||||
}
|
||||
|
||||
var returnType = GetType(function.ReturnType);
|
||||
if (map != null && map.Parameters.TryGetValue("-1", out var newR))
|
||||
{
|
||||
returnType = newR;
|
||||
}
|
||||
else if (returnType == "Boolean" || GetCppType(function.ReturnType) == "bool")
|
||||
{
|
||||
returnType = "bool";
|
||||
writer.WriteLine($"\t[return: MarshalAs (UnmanagedType.I1)]");
|
||||
}
|
||||
|
||||
|
@ -198,6 +184,7 @@ namespace SkiaSharpGenerator
|
|||
foreach (var field in klass.Fields)
|
||||
{
|
||||
var type = GetType(field.Type);
|
||||
var funcPointerType = GetFunctionPointerType(field.Type);
|
||||
var cppT = GetCppType(field.Type);
|
||||
|
||||
writer.WriteLine($"\t\t// {field}");
|
||||
|
@ -212,7 +199,18 @@ namespace SkiaSharpGenerator
|
|||
|
||||
var vis = map?.IsInternal == true ? "public" : "private";
|
||||
var ro = map?.IsReadOnly == true ? " readonly" : "";
|
||||
writer.WriteLine($"\t\t{vis}{ro} {type} {fieldName};");
|
||||
if (funcPointerType is null)
|
||||
{
|
||||
writer.WriteLine($"\t\t{vis}{ro} {type} {fieldName};");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($"#if USE_LIBRARY_IMPORT");
|
||||
writer.WriteLine($"\t\t{vis}{ro} {funcPointerType} {fieldName};");
|
||||
writer.WriteLine($"#else");
|
||||
writer.WriteLine($"\t\t{vis}{ro} {type} {fieldName};");
|
||||
writer.WriteLine($"#endif");
|
||||
}
|
||||
|
||||
if (!isPrivate && (map == null || (map.GenerateProperties && !map.IsInternal)))
|
||||
{
|
||||
|
@ -251,7 +249,18 @@ namespace SkiaSharpGenerator
|
|||
{
|
||||
if (map?.IsReadOnly == true)
|
||||
{
|
||||
writer.WriteLine($"\t\tpublic readonly {type} {propertyName} => {fieldName};");
|
||||
if (funcPointerType is null)
|
||||
{
|
||||
writer.WriteLine($"\t\tpublic readonly {type} {propertyName} => {fieldName};");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine($"#if USE_LIBRARY_IMPORT");
|
||||
writer.WriteLine($"\t\tpublic readonly {funcPointerType} {propertyName} => {fieldName};");
|
||||
writer.WriteLine($"#else");
|
||||
writer.WriteLine($"\t\tpublic readonly {type} {propertyName} => {fieldName};");
|
||||
writer.WriteLine($"#endif");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -276,7 +285,9 @@ namespace SkiaSharpGenerator
|
|||
equalityFields.Add($"{f} == obj.{f}");
|
||||
}
|
||||
writer.WriteLine($"\t\tpublic readonly bool Equals ({name} obj) =>");
|
||||
writer.WriteLine($"#pragma warning disable CS8909");
|
||||
writer.WriteLine($"\t\t\t{string.Join(" && ", equalityFields)};");
|
||||
writer.WriteLine($"#pragma warning restore CS8909");
|
||||
writer.WriteLine();
|
||||
|
||||
// Equals
|
||||
|
@ -464,13 +475,22 @@ namespace SkiaSharpGenerator
|
|||
var skipFunction = false;
|
||||
|
||||
var paramsList = new List<string>();
|
||||
var paramsListWithFuncPointers = new List<string>();
|
||||
var paramNamesList = new List<string>();
|
||||
for (var i = 0; i < function.Parameters.Count; i++)
|
||||
{
|
||||
var p = function.Parameters[i];
|
||||
var n = string.IsNullOrEmpty(p.Name) ? $"param{i}" : p.Name;
|
||||
n = SafeName(n);
|
||||
var t = GetType(p.Type);
|
||||
var t1 = GetType(p.Type);
|
||||
var t2 = GetFunctionPointerType(p.Type);
|
||||
|
||||
// Mono WASM didn't support function pointers in DllImport definitions until .NET 8.
|
||||
// While it should, it still didn't work for me even on .NET 9 previews, so keeping `void*` instead of function pointers.
|
||||
// It makes higher chance of accident mistakes, but old managed delegates build should catch the errors compile time too.
|
||||
if (t2 is not null) t2 = "void*";
|
||||
t2 ??= t1;
|
||||
|
||||
var cppT = GetCppType(p.Type);
|
||||
if (excludedTypes.Contains(cppT) == true)
|
||||
{
|
||||
|
@ -478,11 +498,12 @@ namespace SkiaSharpGenerator
|
|||
skipFunction = true;
|
||||
break;
|
||||
}
|
||||
if (t == "Boolean" || cppT == "bool")
|
||||
t = $"[MarshalAs (UnmanagedType.I1)] bool";
|
||||
if (t1 == "Boolean" || cppT == "bool")
|
||||
t1 = t2 = "[MarshalAs (UnmanagedType.I1)] bool";
|
||||
if (funcMap != null && funcMap.Parameters.TryGetValue(i.ToString(), out var newT))
|
||||
t = newT;
|
||||
paramsList.Add($"{t} {n}");
|
||||
t1 = t2 = newT;
|
||||
paramsList.Add($"{t1} {n}");
|
||||
paramsListWithFuncPointers.Add($"{t2} {n}");
|
||||
paramNamesList.Add(n);
|
||||
}
|
||||
|
||||
|
@ -504,10 +525,19 @@ namespace SkiaSharpGenerator
|
|||
writer.WriteLine();
|
||||
writer.WriteLine($"\t\t// {function}");
|
||||
writer.WriteLine($"\t\t#if !USE_DELEGATES");
|
||||
writer.WriteLine($"\t\t#if USE_LIBRARY_IMPORT");
|
||||
writer.WriteLine($"\t\t[LibraryImport ({config.DllName})]");
|
||||
if (!string.IsNullOrEmpty(retAttr))
|
||||
writer.WriteLine($"\t\t{retAttr}");
|
||||
writer.WriteLine($"\t\tinternal static partial {returnType} {name} ({string.Join(", ", paramsListWithFuncPointers)});");
|
||||
|
||||
writer.WriteLine($"\t\t#else // !USE_LIBRARY_IMPORT");
|
||||
writer.WriteLine($"\t\t[DllImport ({config.DllName}, CallingConvention = CallingConvention.Cdecl)]");
|
||||
if (!string.IsNullOrEmpty(retAttr))
|
||||
writer.WriteLine($"\t\t{retAttr}");
|
||||
writer.WriteLine($"\t\tinternal static extern {returnType} {name} ({string.Join(", ", paramsList)});");
|
||||
writer.WriteLine($"\t\t#endif");
|
||||
|
||||
writer.WriteLine($"\t\t#else");
|
||||
writer.WriteLine($"\t\tprivate partial class Delegates {{");
|
||||
writer.WriteLine($"\t\t\t[UnmanagedFunctionPointer (CallingConvention.Cdecl)]");
|
||||
|
@ -525,5 +555,86 @@ namespace SkiaSharpGenerator
|
|||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteDelegateProxies(TextWriter writer)
|
||||
{
|
||||
Log?.LogVerbose(" Writing delegate proxies...");
|
||||
|
||||
writer.WriteLine($"#region DelegateProxies");
|
||||
|
||||
var delegates = compilation.Typedefs
|
||||
.Where(t => t.ElementType.TypeKind == CppTypeKind.Pointer)
|
||||
.Where(t => IncludeNamespace(t.GetDisplayName()))
|
||||
.OrderBy(t => t.GetDisplayName())
|
||||
.GroupBy(t => GetNamespace(t.GetDisplayName()));
|
||||
|
||||
foreach (var group in delegates)
|
||||
{
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"namespace {group.Key} {{");
|
||||
writer.WriteLine($"internal static unsafe partial class DelegateProxies {{ ");
|
||||
|
||||
foreach (var del in group)
|
||||
{
|
||||
WriteDelegateProxy(writer, del);
|
||||
}
|
||||
|
||||
writer.WriteLine($"}}");
|
||||
writer.WriteLine($"}}");
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
writer.WriteLine($"#endregion");
|
||||
}
|
||||
|
||||
private void WriteDelegateProxy(TextWriter writer, CppTypedef del)
|
||||
{
|
||||
if (!(((CppPointerType)del.ElementType).ElementType is CppFunctionType function))
|
||||
{
|
||||
Log?.LogWarning($"Unknown delegate type {del}");
|
||||
|
||||
writer.WriteLine($"// TODO: {del}");
|
||||
return;
|
||||
}
|
||||
|
||||
var nativeName = del.GetDisplayName();
|
||||
|
||||
Log?.LogVerbose($" {nativeName}");
|
||||
|
||||
functionMappings.TryGetValue(nativeName, out var map);
|
||||
var name = map?.CsType ?? CleanName(nativeName);
|
||||
|
||||
if (map?.GenerateProxy == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var functionPointerType = GetFunctionPointerType(del, map);
|
||||
|
||||
var (paramsList, returnType) = GetManagedFunctionArguments(function, map);
|
||||
|
||||
var proxies = map?.ProxySuffixes ?? new List<string> { "" };
|
||||
|
||||
foreach (var proxyPrefix in proxies)
|
||||
{
|
||||
var proxyName = name.EndsWith("ProxyDelegate") ? name.Replace("ProxyDelegate", "Proxy") : name;
|
||||
var implName = name.EndsWith("ProxyDelegate") ? name.Replace("ProxyDelegate", "ProxyImplementation") : name + "Implementation";
|
||||
|
||||
proxyName += proxyPrefix;
|
||||
implName += proxyPrefix;
|
||||
|
||||
writer.WriteLine($"\t/// Proxy for {nativeName} native function.");
|
||||
writer.WriteLine($"#if USE_LIBRARY_IMPORT");
|
||||
writer.WriteLine($"\tpublic static readonly {functionPointerType} {proxyName} = &{implName};");
|
||||
writer.WriteLine($"\t[UnmanagedCallersOnly(CallConvs = new [] {{typeof(CallConvCdecl)}})]");
|
||||
writer.WriteLine($"#else");
|
||||
writer.WriteLine($"\tpublic static readonly {name} {proxyName} = {implName};");
|
||||
writer.WriteLine($"\t[MonoPInvokeCallback (typeof ({name}))]");
|
||||
writer.WriteLine($"#endif");
|
||||
if (returnType == "bool") writer.WriteLine($"\t[return: MarshalAs (UnmanagedType.I1)]");
|
||||
writer.WriteLine($"\tprivate static partial {returnType} {implName}({string.Join(",", paramsList)});");
|
||||
writer.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче