Merge branch 'main' into dev/mt-main

This commit is contained in:
Matthew Leibowitz 2024-09-19 03:20:56 +08:00 коммит произвёл GitHub
Родитель 1268755d82 60b07b722e
Коммит 4f0bd198f0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
433 изменённых файлов: 14359 добавлений и 5608 удалений

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

@ -3,28 +3,39 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.3.0",
"version": "4.0.0",
"commands": [
"dotnet-cake"
]
],
"rollForward": false
},
"nano-api-scan": {
"version": "1.0.1",
"commands": [
"nano-api-scan"
]
],
"rollForward": false
},
"dotnet-reportgenerator-globaltool": {
"version": "5.1.19",
"commands": [
"reportgenerator"
]
],
"rollForward": false
},
"microsoft.dotnet.xharness.cli": {
"version": "8.0.0-prerelease.23407.2",
"version": "9.0.0-prerelease.24317.3",
"commands": [
"xharness"
]
],
"rollForward": false
},
"api-tools": {
"version": "1.4.0",
"commands": [
"api-tools"
],
"rollForward": false
}
}
}

27
.github/workflows/rebase.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,27 @@
name: Automatic Rebase
on:
issue_comment:
types: [created]
permissions:
pull-requests: write
contents: write
jobs:
rebase:
name: Rebase
runs-on: ubuntu-latest
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase')
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.7
with:
autosquash: ${{ startsWith(github.event.comment.body, '/rebase-squash') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

38
.github/workflows/similarissues.yml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,38 @@
name: Find Similar Issues
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
getSimilarIssues:
runs-on: ubuntu-latest
if: >-
(github.event_name == 'issues' && github.event.action == 'opened') ||
(github.event_name == 'issue_comment' && github.event.action == 'created' && startsWith(github.event.comment.body, '/similarissues'))
outputs:
message: ${{ steps.getBody.outputs.message }}
steps:
- id: getBody
uses: craigloewen-msft/GitGudSimilarIssues@main
with:
issueTitle: ${{ github.event.issue.title }}
issueBody: ${{ github.event.issue.body }}
repo: ${{ github.repository }}
similaritytolerance: "0.70"
add-comment:
needs: getSimilarIssues
runs-on: ubuntu-latest
permissions:
issues: write
if: needs.getSimilarIssues.outputs.message != ''
steps:
- name: Add comment
run: gh issue comment "$NUMBER" --repo "$REPO" --body "$BODY"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUMBER: ${{ github.event.issue.number }}
REPO: ${{ github.repository }}
BODY: ${{ needs.getSimilarIssues.outputs.message }}

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

@ -67,6 +67,6 @@ However, these are easy to install as they are found on the various websites. If
Here are some links to show the differences in our code as compared to Google's code.
What version are we on? [**m115**](https://github.com/google/skia/tree/chrome/m115)
Are we up-to-date with Google? [Compare](https://github.com/mono/skia/compare/skiasharp...google:chrome/m115)
What have we added? [Compare](https://github.com/google/skia/compare/chrome/m115...mono:skiasharp)
What version are we on? [**m116**](https://github.com/google/skia/tree/chrome/m116)
Are we up-to-date with Google? [Compare](https://github.com/mono/skia/compare/skiasharp...google:chrome/m116)
What have we added? [Compare](https://github.com/google/skia/compare/chrome/m116...mono:skiasharp)

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

@ -12,6 +12,7 @@ namespace SkiaSharp.Benchmarks;
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net472)]
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net80)]
public class TheBenchmark
{
[GlobalSetup]

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

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>$(TFMCurrent)</TargetFramework>
<RootNamespace>SkiaSharp.Benchmarks</RootNamespace>
<AssemblyName>SkiaSharp.Benchmarks</AssemblyName>
<SkipGenerateAssemblyVersionInfo>true</SkipGenerateAssemblyVersionInfo>

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

@ -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,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-android</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-android</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-android$(TPVAndroidCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-android$(TPVAndroidNext)</TargetFrameworks>
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Android</Title>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-maccatalyst</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-maccatalyst$(TPVMacCatalystCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-maccatalyst$(TPVMacCatalystNext)</TargetFrameworks>
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Mac Catalyst</Title>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-tizen</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tizen</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-tizen$(TPVTizenCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tizen$(TPVTizenNext)</TargetFrameworks>
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Tizen</Title>
</PropertyGroup>

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

@ -27,6 +27,8 @@
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)\3.1.12\$(_HarfBuzzSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0'))" />
<!-- net8.0 -->
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)\3.1.34\$(_HarfBuzzSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" />
<!-- net9.0+ -->
<NativeFileReference Include="$(HarfBuzzSharpStaticLibraryPath)\3.1.34\$(_HarfBuzzSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionGreaterThan($(TargetFrameworkVersion), '8.0'))" />
</ItemGroup>
</Project>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-ios</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-ios$(TPViOSCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-ios$(TPViOSNext)</TargetFrameworks>
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for iOS</Title>
</PropertyGroup>

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

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(BasicTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux)">$(TargetFrameworks);$(TFMCurrent)-macos</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux) and '$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-macos</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux)">$(TargetFrameworks);$(TFMCurrent)-macos$(TPVmacOSCurrent)</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux) and '$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-macos$(TPVmacOSNext)</TargetFrameworks>
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for macOS</Title>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-tvos</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tvos</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-tvos$(TPVtvOSCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tvos$(TPVtvOSNext)</TargetFrameworks>
<PackagingGroup>HarfBuzzSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for tvOS</Title>
</PropertyGroup>

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

@ -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)

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

@ -2,7 +2,7 @@
<!-- This file is exactly the same as IncludeNativeAssets.SkiaSharp.targets, but with a find-replace 'SkiaSharp' to 'HarfBuzzSharp' -->
<ItemGroup Condition="!$(TargetFramework.Contains('-'))">
<ItemGroup Condition="!$(TargetFramework.Contains('-')) or $(TargetFramework.Contains('-desktop'))">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\windows\x64\libHarfBuzzSharp.*" Condition="'$(Platform)' == '' or '$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU'" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\windows\$(Platform)\libHarfBuzzSharp.*" Condition="'$(Platform)' != '' and '$(Platform)' != 'AnyCPU' and '$(Platform)' != 'Any CPU'" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\osx\libHarfBuzzSharp.*" Visible="False" CopyToOutputDirectory="PreserveNewest" />
@ -69,6 +69,7 @@
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libHarfBuzzSharp.a\2.0.23\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0'))" />
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libHarfBuzzSharp.a\3.1.12\st\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0'))" />
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libHarfBuzzSharp.a\3.1.34\st\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" />
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libHarfBuzzSharp.a\3.1.34\st\*.a" Condition="$([MSBuild]::VersionGreaterThan($(TargetFrameworkVersion), '8.0'))" />
</ItemGroup>
</Project>

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

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ItemGroup Condition="'$(IsUnoHead)' != 'True'">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\winui\any\*.dll" Visible="False" />
</ItemGroup>

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

@ -2,7 +2,7 @@
<!-- This file is exactly the same as IncludeNativeAssets.HarfBuzzSharp.targets, but with a find-replace 'HarfBuzzSharp' to 'SkiaSharp' -->
<ItemGroup Condition="!$(TargetFramework.Contains('-'))">
<ItemGroup Condition="!$(TargetFramework.Contains('-')) or $(TargetFramework.Contains('-desktop'))">
<Content Include="$(MSBuildThisFileDirectory)..\output\native\windows\x64\libSkiaSharp.*" Condition="'$(Platform)' == '' or '$(Platform)' == 'AnyCPU' or '$(Platform)' == 'Any CPU'" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\windows\$(Platform)\libSkiaSharp.*" Condition="'$(Platform)' != '' and '$(Platform)' != 'AnyCPU' and '$(Platform)' != 'Any CPU'" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(MSBuildThisFileDirectory)..\output\native\osx\libSkiaSharp.*" Visible="False" CopyToOutputDirectory="PreserveNewest" />
@ -62,7 +62,7 @@
<Content Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libSkiaSharp.a\**\*.a" Visible="false" />
</ItemGroup>
<ItemGroup Condition="'$(IsUnoHead)' == 'True' and '$(UnoRuntimeIdentifier)' == 'WebAssembly'">
<WasmShellEmccExportedRuntimeMethod Include="GL" />
<WasmShellExtraEmccFlags Include="-s USE_WEBGL2=1"/>
<WasmShellExtraEmccFlags Condition="'$(WasmShellEnableThreads)'=='True'" Include="-s OFFSCREEN_FRAMEBUFFER=1" />
</ItemGroup>
@ -74,6 +74,7 @@
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libSkiaSharp.a\2.0.23\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '6.0'))" />
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libSkiaSharp.a\3.1.12\st\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0'))" />
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libSkiaSharp.a\3.1.34\st\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" />
<NativeFileReference Include="$(MSBuildThisFileDirectory)..\output\native\wasm\libSkiaSharp.a\3.1.34\st\*.a" Condition="$([MSBuild]::VersionGreaterThan($(TargetFrameworkVersion), '8.0'))" />
</ItemGroup>
</Project>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-android</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-android</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-android$(TPVAndroidCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-android$(TPVAndroidNext)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Android</Title>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-maccatalyst</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-maccatalyst$(TPVMacCatalystCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-maccatalyst$(TPVMacCatalystNext)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Mac Catalyst</Title>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-tizen</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tizen</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-tizen$(TPVTizenCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tizen$(TPVTizenNext)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for Tizen</Title>
</PropertyGroup>

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

@ -12,6 +12,8 @@
<ItemGroup Condition="'$(IsUnoHead)' == 'True' and '$(UnoRuntimeIdentifier)' == 'WebAssembly' and '$(ShouldIncludeNativeSkiaSharp)' == 'True'">
<!-- Include the GL symbol when running under net7 (https://github.com/dotnet/runtime/issues/76077) -->
<WasmShellEmccExportedRuntimeMethod Include="GL" />
<!-- Include the emscripten_gl* symbols in net8 -->
<WasmShellExtraEmccFlags Include="-s USE_WEBGL2=1"/>
<!-- Enable GLCtx when threading is available -->
<WasmShellExtraEmccFlags Condition="'$(WasmShellEnableThreads)'=='True'" Include="-s OFFSCREEN_FRAMEBUFFER=1" />
</ItemGroup>
@ -34,6 +36,8 @@
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.12\$(_SkiaSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '7.0'))" />
<!-- net8.0 -->
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.34\$(_SkiaSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionEquals($(TargetFrameworkVersion), '8.0'))" />
<!-- net9.0+ -->
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\3.1.34\$(_SkiaSharpNativeBinaryType)\*.a" Condition="$([MSBuild]::VersionGreaterThan($(TargetFrameworkVersion), '8.0'))" />
</ItemGroup>
</Project>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-ios</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-ios</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-ios$(TPViOSCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-ios$(TPViOSNext)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for iOS</Title>
</PropertyGroup>

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

@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(BasicTargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux)">$(TargetFrameworks);$(TFMCurrent)-macos</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux) and '$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-macos</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux)">$(TargetFrameworks);$(TFMCurrent)-macos$(TPVmacOSCurrent)</TargetFrameworks>
<TargetFrameworks Condition="!$(IsLinux) and '$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-macos$(TPVmacOSNext)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for macOS</Title>
</PropertyGroup>

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

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(TFMCurrent)-tvos</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tvos</TargetFrameworks>
<TargetFrameworks>$(TFMCurrent)-tvos$(TPVtvOSCurrent)</TargetFrameworks>
<TargetFrameworks Condition="'$(TFMNext)' != ''">$(TargetFrameworks);$(TFMNext)-tvos$(TPVtvOSNext)</TargetFrameworks>
<PackagingGroup>SkiaSharp</PackagingGroup>
<Title>$(PackagingGroup) - Native Assets for tvOS</Title>
</PropertyGroup>

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

@ -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,7 +18,9 @@ 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;
using sk_codec_t = System.IntPtr;
using sk_colorfilter_t = System.IntPtr;
@ -58,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;
@ -109,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)]
@ -123,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)]
@ -137,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)]
@ -151,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)]
@ -165,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)]
@ -179,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)]
@ -193,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)]
@ -207,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)]
@ -221,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)]
@ -235,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)]
@ -255,7 +309,9 @@ namespace SkiaSharp
#endregion Functions
#region Delegates
#if !USE_LIBRARY_IMPORT
#endif // !USE_LIBRARY_IMPORT
#endregion
#region Structs
@ -265,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,7 +18,9 @@ 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;
using sk_codec_t = System.IntPtr;
using sk_colorfilter_t = System.IntPtr;
@ -58,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;
@ -109,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)]
@ -123,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)]
@ -137,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)]
@ -151,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)]
@ -165,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)]
@ -179,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)]
@ -193,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)]
@ -213,7 +252,9 @@ namespace SkiaSharp
#endregion Functions
#region Delegates
#if !USE_LIBRARY_IMPORT
#endif // !USE_LIBRARY_IMPORT
#endregion
#region Structs
@ -223,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,7 +18,9 @@ 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;
using sk_codec_t = System.IntPtr;
using sk_colorfilter_t = System.IntPtr;
@ -58,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;
@ -109,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)]
@ -123,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)]
@ -137,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)]
@ -151,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)]
@ -165,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)]
@ -179,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)]
@ -193,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)]
@ -207,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)]
@ -221,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)]
@ -235,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)]
@ -249,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)]
@ -263,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)]
@ -277,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)]
@ -291,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)]
@ -305,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)]
@ -319,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)]
@ -333,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)]
@ -347,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)]
@ -361,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)]
@ -375,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)]
@ -389,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)]
@ -403,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)]
@ -417,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)]
@ -431,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)]
@ -445,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)]
@ -459,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)]
@ -473,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)]
@ -493,7 +632,9 @@ namespace SkiaSharp
#endregion Functions
#region Delegates
#if !USE_LIBRARY_IMPORT
#endif // !USE_LIBRARY_IMPORT
#endregion
#region Structs
@ -519,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);
@ -571,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);
}
}

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

@ -25,8 +25,6 @@ namespace SkiaSharp
CreateVulkan (width, height, vkInfo);
}
#if __IOS__ || __MACOS__
public GRBackendTexture (int width, int height, bool mipmapped, GRMtlTextureInfo mtlInfo)
: this (IntPtr.Zero, true)
{
@ -38,8 +36,6 @@ namespace SkiaSharp
}
}
#endif
private void CreateGl (int width, int height, bool mipmapped, GRGlTextureInfo glInfo)
{
Handle = SkiaApi.gr_backendtexture_new_gl (width, height, mipmapped, &glInfo);

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

@ -63,8 +63,6 @@ namespace SkiaSharp
}
}
#if __IOS__ || __MACOS__
// CreateMetal
public static GRContext CreateMetal (GRMtlBackendContext backendContext) =>
@ -75,19 +73,17 @@ namespace SkiaSharp
if (backendContext == null)
throw new ArgumentNullException (nameof (backendContext));
var device = backendContext.Device;
var queue = backendContext.Queue;
var device = backendContext.DeviceHandle;
var queue = backendContext.QueueHandle;
if (options == null) {
return GetObject (SkiaApi.gr_direct_context_make_metal ((void*)(IntPtr)device.Handle, (void*)(IntPtr)queue.Handle));
return GetObject (SkiaApi.gr_direct_context_make_metal ((void*)device, (void*)queue));
} else {
var opts = options.ToNative ();
return GetObject (SkiaApi.gr_direct_context_make_metal_with_options ((void*)(IntPtr)device.Handle, (void*)(IntPtr)queue.Handle, &opts));
return GetObject (SkiaApi.gr_direct_context_make_metal_with_options ((void*)device, (void*)queue, &opts));
}
}
#endif
//
public override GRBackend Backend => base.Backend;

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

@ -74,24 +74,48 @@ namespace SkiaSharp
}
}
#if __IOS__ || __MACOS__
public unsafe partial struct GRMtlTextureInfo
{
private IntPtr _textureHandle;
public GRMtlTextureInfo (IntPtr textureHandle)
{
TextureHandle = textureHandle;
}
public IntPtr TextureHandle {
readonly get => _textureHandle;
set {
_textureHandle = value;
#if __IOS__ || __MACOS__
_texture = null;
#endif
}
}
#if __IOS__ || __MACOS__
private Metal.IMTLTexture _texture;
public GRMtlTextureInfo (Metal.IMTLTexture texture)
{
Texture = texture;
}
public Metal.IMTLTexture Texture { get; set; }
public Metal.IMTLTexture Texture {
readonly get => _texture;
set {
_texture = value;
_textureHandle = _texture.Handle;
}
}
#endif
internal GRMtlTextureInfoNative ToNative () =>
new GRMtlTextureInfoNative {
fTexture = (void*)(IntPtr)Texture.Handle
fTexture = (void*)TextureHandle
};
public readonly bool Equals (GRMtlTextureInfo obj) =>
Texture == obj.Texture;
TextureHandle == obj.TextureHandle;
public readonly override bool Equals (object obj) =>
obj is GRMtlTextureInfo f && Equals (f);
@ -105,13 +129,11 @@ namespace SkiaSharp
public readonly override int GetHashCode ()
{
var hash = new HashCode ();
hash.Add (Texture);
hash.Add (TextureHandle);
return hash.ToHashCode ();
}
}
#endif
public static partial class SkiaExtensions
{
public static uint ToGlSizedFormat (this SKColorType colorType) =>

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

@ -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)
@ -34,19 +35,24 @@ namespace SkiaSharp
public static GRGlInterface CreateAngle ()
{
#if (NETSTANDARD || NET6_0_OR_GREATER || NET40_OR_GREATER) && (!NETPLATFORM || WINDOWS) // a cross-platform TFM or windows-only
if (PlatformConfiguration.IsWindows) {
return CreateAngle (AngleLoader.GetProc);
} else {
// return null on non-DirectX platforms: everything except Windows
return null;
}
#else
return null;
#endif
}
// Create* (assemble)
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 {
@ -59,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 {
@ -69,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 {
@ -79,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 {
@ -112,7 +121,8 @@ namespace SkiaSharp
//
private static class AngleLoader
#if (NETSTANDARD || NET6_0_OR_GREATER || NET40_OR_GREATER) && (!NETPLATFORM || WINDOWS)
private static partial class AngleLoader
{
private static readonly IntPtr libEGL;
private static readonly IntPtr libGLESv2;
@ -127,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);
@ -135,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()
{
@ -175,9 +196,10 @@ namespace SkiaSharp
return proc;
}
}
#endif
#if __TIZEN__
private class EvasGlLoader
private partial class EvasGlLoader
{
private const string libevas = "libevas.so.1";
@ -188,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 ()
{
@ -207,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);
@ -216,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)

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

@ -1,16 +1,56 @@
#nullable disable
#if __IOS__ || __MACOS__
using System;
#if __IOS__ || __MACOS__
using Metal;
#endif
namespace SkiaSharp
{
public class GRMtlBackendContext : IDisposable
{
public IMTLDevice Device { get; set; }
private IntPtr _deviceHandle, _queueHandle;
public IMTLCommandQueue Queue { get; set; }
public IntPtr DeviceHandle {
get => _deviceHandle;
set {
_deviceHandle = value;
#if __IOS__ || __MACOS__
_device = null;
#endif
}
}
public IntPtr QueueHandle {
get => _queueHandle;
set {
_queueHandle = value;
#if __IOS__ || __MACOS__
_queue = null;
#endif
}
}
#if __IOS__ || __MACOS__
private IMTLDevice _device;
private IMTLCommandQueue _queue;
public IMTLDevice Device {
get => _device;
set {
_device = value;
_deviceHandle = _device.Handle;
}
}
public IMTLCommandQueue Queue {
get => _queue;
set {
_queue = value;
_queueHandle = _queue.Handle;
}
}
#endif
protected virtual void Dispose (bool disposing)
{
@ -23,4 +63,3 @@ namespace SkiaSharp
}
}
}
#endif

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

@ -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);
}
@ -766,12 +767,20 @@ namespace SkiaSharp
public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) =>
ToShader (tmx, tmy, sampling, null);
[Obsolete ("Use ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.")]
public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality) =>
ToShader (tmx, tmy, quality.ToSamplingOptions(), null);
public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) =>
ToShader (tmx, tmy, SKSamplingOptions.Default, &localMatrix);
public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) =>
ToShader (tmx, tmy, sampling, &localMatrix);
[Obsolete ("Use ToShader(SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")]
public SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality, SKMatrix localMatrix) =>
ToShader (tmx, tmy, quality.ToSamplingOptions(), &localMatrix);
private SKShader ToShader (SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix* localMatrix) =>
SKShader.GetObject (SkiaApi.sk_bitmap_make_shader (Handle, tmx, tmy, &sampling, localMatrix));
}

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

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
namespace SkiaSharp;
public unsafe class SKBlender : SKObject, ISKReferenceCounted
{
private static readonly Dictionary<SKBlendMode, SKBlender> blendModeBlenders;
static SKBlender ()
{
// TODO: This is not the best way to do this as it will create a lot of objects that
// might not be needed, but it is the only way to ensure that the static
// instances are created before any access is made to them.
// See more info: SKObject.EnsureStaticInstanceAreInitialized()
var modes = Enum.GetValues (typeof (SKBlendMode));
blendModeBlenders = new Dictionary<SKBlendMode, SKBlender> (modes.Length);
foreach (SKBlendMode mode in modes)
{
blendModeBlenders [mode] = new SKBlenderStatic (SkiaApi.sk_blender_new_mode (mode));
}
}
internal static void EnsureStaticInstanceAreInitialized ()
{
// IMPORTANT: do not remove to ensure that the static instances
// are initialized before any access is made to them
}
internal SKBlender(IntPtr handle, bool owns)
: base (handle, owns)
{
}
protected override void Dispose (bool disposing) =>
base.Dispose (disposing);
public static SKBlender CreateBlendMode (SKBlendMode mode)
{
if (!blendModeBlenders.TryGetValue (mode, out var value))
throw new ArgumentOutOfRangeException (nameof (mode));
return value;
}
public static SKBlender CreateArithmetic (float k1, float k2, float k3, float k4, bool enforcePMColor) =>
GetObject (SkiaApi.sk_blender_new_arithmetic (k1, k2, k3, k4, enforcePMColor));
internal static SKBlender GetObject (IntPtr handle) =>
GetOrAddObject (handle, (h, o) => new SKBlender (h, o));
//
private sealed class SKBlenderStatic : SKBlender
{
internal SKBlenderStatic (IntPtr x)
: base (x, false)
{
}
protected override void Dispose (bool disposing) { }
}
}

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

@ -450,7 +450,9 @@ namespace SkiaSharp
public void DrawImage (SKImage image, SKPoint p, SKPaint paint = null)
{
DrawImage (image, p.X, p.Y, SKSamplingOptions.Default, paint);
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawImage (image, p.X, p.Y, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
}
public void DrawImage (SKImage image, SKPoint p, SKSamplingOptions sampling, SKPaint paint = null)
@ -460,7 +462,9 @@ namespace SkiaSharp
public void DrawImage (SKImage image, float x, float y, SKPaint paint = null)
{
DrawImage (image, x, y, SKSamplingOptions.Default, paint);
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawImage (image, x, y, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
}
public void DrawImage (SKImage image, float x, float y, SKSamplingOptions sampling, SKPaint paint = null)
@ -472,7 +476,9 @@ namespace SkiaSharp
public void DrawImage (SKImage image, SKRect dest, SKPaint paint = null)
{
DrawImage (image, null, &dest, SKSamplingOptions.Default, paint);
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawImage (image, null, &dest, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
}
public void DrawImage (SKImage image, SKRect dest, SKSamplingOptions sampling, SKPaint paint = null)
@ -482,7 +488,9 @@ namespace SkiaSharp
public void DrawImage (SKImage image, SKRect source, SKRect dest, SKPaint paint = null)
{
DrawImage (image, &source, &dest, SKSamplingOptions.Default, paint);
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawImage (image, &source, &dest, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
}
public void DrawImage (SKImage image, SKRect source, SKRect dest, SKSamplingOptions sampling, SKPaint paint = null)
@ -856,6 +864,10 @@ namespace SkiaSharp
public void SetMatrix (in SKMatrix matrix) =>
SetMatrix ((SKMatrix44)matrix);
[Obsolete("Use SetMatrix(in SKMatrix) instead.", true)]
public void SetMatrix (SKMatrix matrix) =>
SetMatrix (in matrix);
public void SetMatrix (in SKMatrix44 matrix)
{
fixed (SKMatrix44* ptr = &matrix) {
@ -937,25 +949,31 @@ namespace SkiaSharp
// DrawAtlas
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKPaint paint) =>
DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, SKSamplingOptions.Default, null, paint);
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKPaint paint = null) =>
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, null, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKSamplingOptions sampling, SKPaint paint) =>
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKSamplingOptions sampling, SKPaint paint = null) =>
DrawAtlas (atlas, sprites, transforms, null, SKBlendMode.Dst, sampling, null, paint);
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKPaint paint) =>
DrawAtlas (atlas, sprites, transforms, colors, mode, SKSamplingOptions.Default, null, paint);
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKPaint paint = null) =>
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, null, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKPaint paint) =>
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKPaint paint = null) =>
DrawAtlas (atlas, sprites, transforms, colors, mode, sampling, null, paint);
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKRect cullRect, SKPaint paint) =>
DrawAtlas (atlas, sprites, transforms, colors, mode, SKSamplingOptions.Default, &cullRect, paint);
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKRect cullRect, SKPaint paint = null) =>
#pragma warning disable CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
DrawAtlas (atlas, sprites, transforms, colors, mode, paint?.FilterQuality.ToSamplingOptions() ?? SKSamplingOptions.Default, &cullRect, paint);
#pragma warning restore CS0618 // 'SKPaint.FilterQuality' is obsolete: 'Use SKSamplingOptions instead.'
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect cullRect, SKPaint paint) =>
public void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect cullRect, SKPaint paint = null) =>
DrawAtlas (atlas, sprites, transforms, colors, mode, sampling, &cullRect, paint);
private void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect* cullRect, SKPaint paint)
private void DrawAtlas (SKImage atlas, SKRect[] sprites, SKRotationScaleMatrix[] transforms, SKColor[] colors, SKBlendMode mode, SKSamplingOptions sampling, SKRect* cullRect, SKPaint paint = null)
{
if (atlas == null)
throw new ArgumentNullException (nameof (atlas));
@ -972,7 +990,7 @@ namespace SkiaSharp
fixed (SKRect* s = sprites)
fixed (SKRotationScaleMatrix* t = transforms)
fixed (SKColor* c = colors) {
SkiaApi.sk_canvas_draw_atlas (Handle, atlas.Handle, t, s, (uint*)c, transforms.Length, mode, &sampling, cullRect, paint.Handle);
SkiaApi.sk_canvas_draw_atlas (Handle, atlas.Handle, t, s, (uint*)c, transforms.Length, mode, &sampling, cullRect, paint?.Handle ?? IntPtr.Zero);
}
}

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

@ -4,8 +4,6 @@ using System;
namespace SkiaSharp
{
// TODO: `FilterColor` may be useful
public unsafe class SKColorFilter : SKObject, ISKReferenceCounted
{
public const int ColorMatrixSize = 20;
@ -42,6 +40,11 @@ namespace SkiaSharp
{
if (matrix == null)
throw new ArgumentNullException(nameof(matrix));
return CreateColorMatrix(matrix.AsSpan());
}
public static SKColorFilter CreateColorMatrix(ReadOnlySpan<float> matrix)
{
if (matrix.Length != 20)
throw new ArgumentException("Matrix must have a length of 20.", nameof(matrix));
fixed (float* m = matrix) {
@ -58,6 +61,11 @@ namespace SkiaSharp
{
if (table == null)
throw new ArgumentNullException(nameof(table));
return CreateTable(table.AsSpan());
}
public static SKColorFilter CreateTable(ReadOnlySpan<byte> table)
{
if (table.Length != TableMaxLength)
throw new ArgumentException($"Table must have a length of {TableMaxLength}.", nameof(table));
fixed (byte* t = table) {
@ -67,13 +75,26 @@ namespace SkiaSharp
public static SKColorFilter CreateTable(byte[] tableA, byte[] tableR, byte[] tableG, byte[] tableB)
{
if (tableA != null && tableA.Length != TableMaxLength)
if (tableA == null)
throw new ArgumentNullException(nameof(tableA));
if (tableR == null)
throw new ArgumentNullException(nameof(tableR));
if (tableG == null)
throw new ArgumentNullException(nameof(tableG));
if (tableB == null)
throw new ArgumentNullException(nameof(tableB));
return CreateTable(tableA.AsSpan(), tableR.AsSpan(), tableG.AsSpan(), tableB.AsSpan());
}
public static SKColorFilter CreateTable(ReadOnlySpan<byte> tableA, ReadOnlySpan<byte> tableR, ReadOnlySpan<byte> tableG, ReadOnlySpan<byte> tableB)
{
if (tableA.Length != TableMaxLength)
throw new ArgumentException($"Table A must have a length of {TableMaxLength}.", nameof(tableA));
if (tableR != null && tableR.Length != TableMaxLength)
if (tableR.Length != TableMaxLength)
throw new ArgumentException($"Table R must have a length of {TableMaxLength}.", nameof(tableR));
if (tableG != null && tableG.Length != TableMaxLength)
if (tableG.Length != TableMaxLength)
throw new ArgumentException($"Table G must have a length of {TableMaxLength}.", nameof(tableG));
if (tableB != null && tableB.Length != TableMaxLength)
if (tableB.Length != TableMaxLength)
throw new ArgumentException($"Table B must have a length of {TableMaxLength}.", nameof(tableB));
fixed (byte* a = tableA)

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

@ -12,6 +12,11 @@ namespace SkiaSharp
static SKColorSpace ()
{
// TODO: This is not the best way to do this as it will create a lot of objects that
// might not be needed, but it is the only way to ensure that the static
// instances are created before any access is made to them.
// See more info: SKObject.EnsureStaticInstanceAreInitialized()
srgb = new SKColorSpaceStatic (SkiaApi.sk_colorspace_new_srgb ());
srgbLinear = new SKColorSpaceStatic (SkiaApi.sk_colorspace_new_srgb_linear ());
}

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

@ -19,6 +19,11 @@ namespace SkiaSharp
static SKData ()
{
// TODO: This is not the best way to do this as it will create a lot of objects that
// might not be needed, but it is the only way to ensure that the static
// instances are created before any access is made to them.
// See more info: SKObject.EnsureStaticInstanceAreInitialized()
empty = new SKDataStatic (SkiaApi.sk_data_new_empty ());
}
@ -181,7 +186,7 @@ namespace SkiaSharp
throw new ArgumentNullException (nameof (stream));
try {
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
return GetObject (SkiaApi.sk_data_new_from_stream (stream.Handle, (IntPtr)length));
} finally {
GC.KeepAlive(stream);
}
@ -202,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);
@ -65,6 +64,9 @@ namespace SkiaSharp
}
}
public int ApproximateBytesUsed =>
(int)SkiaApi.sk_drawable_approximate_bytes_used (Handle);
public void Draw (SKCanvas canvas, in SKMatrix matrix)
{
fixed (SKMatrix* m = &matrix)
@ -84,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);
@ -100,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);

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

@ -14,6 +14,11 @@ namespace SkiaSharp
static SKFontManager ()
{
// TODO: This is not the best way to do this as it will create a lot of objects that
// might not be needed, but it is the only way to ensure that the static
// instances are created before any access is made to them.
// See more info: SKObject.EnsureStaticInstanceAreInitialized()
defaultManager = new SKFontManagerStatic (SkiaApi.sk_fontmgr_ref_default ());
}

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

@ -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));
}
@ -409,9 +411,17 @@ namespace SkiaSharp
public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling) =>
ToShader (tileX, tileY, sampling, null);
[Obsolete ("Use ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling) instead.")]
public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKFilterQuality quality) =>
ToShader (tileX, tileY, quality.ToSamplingOptions(), null);
public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling, SKMatrix localMatrix) =>
ToShader (tileX, tileY, sampling, &localMatrix);
[Obsolete ("Use ToShader(SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")]
public SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKFilterQuality quality, SKMatrix localMatrix) =>
ToShader (tileX, tileY, quality.ToSamplingOptions(), &localMatrix);
private SKShader ToShader (SKShaderTileMode tileX, SKShaderTileMode tileY, SKSamplingOptions sampling, SKMatrix* localMatrix) =>
SKShader.GetObject (SkiaApi.sk_image_make_shader (Handle, tileX, tileY, &sampling, localMatrix));

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

@ -14,6 +14,14 @@ namespace SkiaSharp
// CreateMatrix
[Obsolete("Use SetMatrix(in SKMatrix) instead.", true)]
public static SKImageFilter CreateMatrix (SKMatrix matrix) =>
CreateMatrix (in matrix);
[Obsolete("Use SetMatrix(in SKMatrix, SKSamplingOptions, SKImageFilter) instead.", true)]
public static SKImageFilter CreateMatrix (SKMatrix matrix, SKFilterQuality quality, SKImageFilter? input) =>
CreateMatrix (in matrix, quality.ToSamplingOptions (), input);
public static SKImageFilter CreateMatrix (in SKMatrix matrix) =>
CreateMatrix (matrix, SKSamplingOptions.Default, null);
@ -26,18 +34,6 @@ namespace SkiaSharp
return GetObject (SkiaApi.sk_imagefilter_new_matrix_transform (m, &sampling, input?.Handle ?? IntPtr.Zero));
}
// CreateAlphaThreshold
public static SKImageFilter CreateAlphaThreshold (SKRegion region, float innerThreshold, float outerThreshold) =>
CreateAlphaThreshold (region, innerThreshold, outerThreshold, null);
public static SKImageFilter CreateAlphaThreshold (SKRegion region, float innerThreshold, float outerThreshold, SKImageFilter? input)
{
_ = region ?? throw new ArgumentNullException (nameof (region));
return GetObject (SkiaApi.sk_imagefilter_new_alpha_threshold (region.Handle, innerThreshold, outerThreshold, input?.Handle ?? IntPtr.Zero));
}
// CreateBlur
public static SKImageFilter CreateBlur (float sigmaX, float sigmaY) =>
@ -345,6 +341,23 @@ namespace SkiaSharp
private static SKImageFilter CreateBlendMode (SKBlendMode mode, SKImageFilter? background, SKImageFilter? foreground, SKRect* cropRect) =>
GetObject (SkiaApi.sk_imagefilter_new_blend (mode, background?.Handle ?? IntPtr.Zero, foreground?.Handle ?? IntPtr.Zero, cropRect));
// CreateBlendMode (Blender)
public static SKImageFilter CreateBlendMode (SKBlender blender, SKImageFilter? background) =>
CreateBlendMode (blender, background, null, null);
public static SKImageFilter CreateBlendMode (SKBlender blender, SKImageFilter? background, SKImageFilter? foreground) =>
CreateBlendMode (blender, background, foreground, null);
public static SKImageFilter CreateBlendMode (SKBlender blender, SKImageFilter? background, SKImageFilter? foreground, SKRect cropRect) =>
CreateBlendMode (blender, background, foreground, &cropRect);
private static SKImageFilter CreateBlendMode (SKBlender blender, SKImageFilter? background, SKImageFilter? foreground, SKRect* cropRect)
{
_ = blender ?? throw new ArgumentNullException (nameof (blender));
return GetObject (SkiaApi.sk_imagefilter_new_blender (blender.Handle, background?.Handle ?? IntPtr.Zero, foreground?.Handle ?? IntPtr.Zero, cropRect));
}
// CreateArithmetic
public static SKImageFilter CreateArithmetic (float k1, float k2, float k3, float k4, bool enforcePMColor, SKImageFilter? background) =>
@ -376,6 +389,10 @@ namespace SkiaSharp
return GetObject (SkiaApi.sk_imagefilter_new_image (image.Handle, &src, &dst, &sampling));
}
[Obsolete("Use CreateImage(SKImage, SKRect, SKRect, SKSamplingOptions) instead.", true)]
public static SKImageFilter CreateImage (SKImage image, SKRect src, SKRect dst, SKFilterQuality filterQuality) =>
CreateImage (image, src, dst, filterQuality.ToSamplingOptions ());
// CreateMagnifier
public static SKImageFilter CreateMagnifier (SKRect lensBounds, float zoomAmount, float inset, SKSamplingOptions sampling) =>
@ -390,6 +407,22 @@ namespace SkiaSharp
private static SKImageFilter CreateMagnifier (SKRect lensBounds, float zoomAmount, float inset, SKSamplingOptions sampling, SKImageFilter? input, SKRect* cropRect) =>
GetObject (SkiaApi.sk_imagefilter_new_magnifier (&lensBounds, zoomAmount, inset, &sampling, input?.Handle ?? IntPtr.Zero, cropRect));
// CreatePaint
[Obsolete("Use CreateShader(SKShader) instead.", true)]
public static SKImageFilter CreatePaint (SKPaint paint)
{
_ = paint ?? throw new ArgumentNullException (nameof (paint));
return CreateShader(paint.Shader, paint.IsDither, null);
}
[Obsolete("Use CreateShader(SKShader, bool, SKRect) instead.", true)]
public static SKImageFilter CreatePaint (SKPaint paint, SKRect cropRect)
{
_ = paint ?? throw new ArgumentNullException (nameof (paint));
return CreateShader(paint.Shader, paint.IsDither, &cropRect);
}
// CreateShader
public static SKImageFilter CreateShader (SKShader? shader) =>

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

@ -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;
}

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

@ -44,6 +44,7 @@ namespace SkiaSharp
SKData.EnsureStaticInstanceAreInitialized ();
SKFontManager.EnsureStaticInstanceAreInitialized ();
SKTypeface.EnsureStaticInstanceAreInitialized ();
SKBlender.EnsureStaticInstanceAreInitialized ();
}
internal SKObject (IntPtr handle, bool owns)
@ -205,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

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

@ -203,6 +203,11 @@ namespace SkiaSharp
set => SkiaApi.sk_paint_set_blendmode (Handle, value);
}
public SKBlender Blender {
get => SKBlender.GetObject (SkiaApi.sk_paint_get_blender (Handle));
set => SkiaApi.sk_paint_set_blender (Handle, value == null ? IntPtr.Zero : value.Handle);
}
[Obsolete ($"Use {nameof (SKSamplingOptions)} instead.")]
public SKFilterQuality FilterQuality {
get => (SKFilterQuality)SkiaApi.sk_compatpaint_get_filter_quality (Handle);
@ -272,7 +277,7 @@ namespace SkiaSharp
// Clone
public SKPaint Clone () =>
GetObject (SkiaApi.sk_paint_clone (Handle))!;
GetObject (SkiaApi.sk_compatpaint_clone (Handle))!;
// MeasureText

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

@ -181,8 +181,11 @@ namespace SkiaSharp
public void Offset (SKPoint offset) =>
Offset (offset.X, offset.Y);
public void Offset (float dx, float dy) =>
Transform (SKMatrix.CreateTranslation (dx, dy));
public void Offset (float dx, float dy)
{
var matrix = SKMatrix.CreateTranslation (dx, dy);
Transform (in matrix);
}
public void MoveTo (SKPoint point) =>
SkiaApi.sk_path_move_to (Handle, point.X, point.Y);
@ -340,6 +343,14 @@ namespace SkiaSharp
SkiaApi.sk_path_transform_to_dest (Handle, m, destination.Handle);
}
[Obsolete("Use Transform(in SKMatrix) instead.", true)]
public void Transform (SKMatrix matrix) =>
Transform (in matrix);
[Obsolete("Use Transform(in SKMatrix matrix, SKPath destination) instead.", true)]
public void Transform (SKMatrix matrix, SKPath destination) =>
Transform (in matrix, destination);
public void AddPath (SKPath other, float dx, float dy, SKPathAddMode mode = SKPathAddMode.Append)
{
if (other == null)

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

@ -26,6 +26,15 @@ namespace SkiaSharp
}
}
public int ApproximateBytesUsed =>
(int)SkiaApi.sk_picture_approximate_bytes_used (Handle);
public int ApproximateOperationCount =>
GetApproximateOperationCount (false);
public int GetApproximateOperationCount(bool includeNested) =>
SkiaApi.sk_picture_approximate_op_count (Handle, includeNested);
// Serialize
public SKData Serialize () =>
@ -48,6 +57,16 @@ namespace SkiaSharp
SkiaApi.sk_picture_serialize_to_stream (Handle, stream.Handle);
}
// Playback
public void Playback (SKCanvas canvas)
{
if (canvas is null)
throw new ArgumentNullException (nameof (canvas));
SkiaApi.sk_picture_playback (Handle, canvas.Handle);
}
// ToShader
public SKShader ToShader () =>

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

@ -30,6 +30,25 @@ namespace SkiaSharp
return OwnedBy (SKCanvas.GetObject (SkiaApi.sk_picture_recorder_begin_recording (Handle, &cullRect), false), this);
}
public SKCanvas BeginRecording (SKRect cullRect, bool useRTree)
{
// no R-Tree is being used, so use the default path
if (!useRTree) {
return BeginRecording (cullRect);
}
// an R-Tree was requested, so create the R-Tree BBH factory
var rtreeHandle = IntPtr.Zero;
try {
rtreeHandle = SkiaApi.sk_rtree_factory_new ();
return OwnedBy (SKCanvas.GetObject (SkiaApi.sk_picture_recorder_begin_recording_with_bbh_factory (Handle, &cullRect, rtreeHandle), false), this);
} finally {
if (rtreeHandle != IntPtr.Zero) {
SkiaApi.sk_rtree_factory_delete (rtreeHandle);
}
}
}
public SKPicture EndRecording ()
{
return SKPicture.GetObject (SkiaApi.sk_picture_recorder_end_recording (Handle));

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

@ -122,6 +122,12 @@ namespace SkiaSharp
{
if (radii == null)
throw new ArgumentNullException (nameof (radii));
SetRectRadii(rect, radii.AsSpan());
}
public void SetRectRadii (SKRect rect, ReadOnlySpan<SKPoint> radii)
{
if (radii.Length != 4)
throw new ArgumentException ("Radii must have a length of 4.", nameof (radii));

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

@ -1,10 +1,11 @@
#nullable disable
using System;
using System.ComponentModel;
namespace SkiaSharp
{
// Base
public unsafe class SKRunBuffer
{
internal readonly SKRunBufferInternal internalBuffer;
@ -17,103 +18,142 @@ namespace SkiaSharp
public int Size { get; }
public Span<ushort> GetGlyphSpan () =>
new Span<ushort> (internalBuffer.glyphs, internalBuffer.glyphs == null ? 0 : Size);
public Span<ushort> Glyphs => new (internalBuffer.glyphs, Size);
public void SetGlyphs (ReadOnlySpan<ushort> glyphs) =>
glyphs.CopyTo (GetGlyphSpan ());
public void SetGlyphs (ReadOnlySpan<ushort> glyphs) => glyphs.CopyTo (Glyphs);
[Obsolete ("Use Glyphs instead.")]
public Span<ushort> GetGlyphSpan () => Glyphs;
}
public sealed unsafe class SKHorizontalRunBuffer : SKRunBuffer
{
internal SKHorizontalRunBuffer (SKRunBufferInternal buffer, int count)
: base (buffer, count)
internal SKHorizontalRunBuffer (SKRunBufferInternal buffer, int size)
: base (buffer, size)
{
}
public Span<float> GetPositionSpan () =>
new Span<float> (internalBuffer.pos, internalBuffer.pos == null ? 0 : Size);
public Span<float> Positions => new (internalBuffer.pos, Size);
public void SetPositions (ReadOnlySpan<float> positions) =>
positions.CopyTo (GetPositionSpan ());
public void SetPositions (ReadOnlySpan<float> positions) => positions.CopyTo (Positions);
[Obsolete ("Use Positions instead.")]
public Span<float> GetPositionSpan () => Positions;
}
public sealed unsafe class SKPositionedRunBuffer : SKRunBuffer
{
internal SKPositionedRunBuffer (SKRunBufferInternal buffer, int count)
: base (buffer, count)
internal SKPositionedRunBuffer (SKRunBufferInternal buffer, int size)
: base (buffer, size)
{
}
public Span<SKPoint> GetPositionSpan () =>
new Span<SKPoint> (internalBuffer.pos, internalBuffer.pos == null ? 0 : Size);
public Span<SKPoint> Positions => new (internalBuffer.pos, Size);
public void SetPositions (ReadOnlySpan<SKPoint> positions) =>
positions.CopyTo (GetPositionSpan ());
public void SetPositions (ReadOnlySpan<SKPoint> positions) => positions.CopyTo (Positions);
[Obsolete ("Use Positions instead.")]
public Span<SKPoint> GetPositionSpan () => Positions;
}
public sealed unsafe class SKRotationScaleRunBuffer : SKRunBuffer
{
internal SKRotationScaleRunBuffer (SKRunBufferInternal buffer, int count)
: base (buffer, count)
internal SKRotationScaleRunBuffer (SKRunBufferInternal buffer, int size)
: base (buffer, size)
{
}
public Span<SKRotationScaleMatrix> GetRotationScaleSpan () =>
new Span<SKRotationScaleMatrix> (internalBuffer.pos, Size);
public Span<SKRotationScaleMatrix> Positions => new (internalBuffer.pos, Size);
public void SetRotationScale (ReadOnlySpan<SKRotationScaleMatrix> positions) =>
positions.CopyTo (GetRotationScaleSpan ());
public void SetPositions (ReadOnlySpan<SKRotationScaleMatrix> positions) => positions.CopyTo (Positions);
[Obsolete ("Use Positions instead.")]
public Span<SKRotationScaleMatrix> GetRotationScaleSpan () => Positions;
[Obsolete ("Use SetPositions instead.")]
public void SetRotationScale (ReadOnlySpan<SKRotationScaleMatrix> positions) => SetPositions (positions);
}
// Text
public unsafe class SKTextRunBuffer : SKRunBuffer
{
internal SKTextRunBuffer (SKRunBufferInternal buffer, int count, int textSize)
: base (buffer, count)
internal SKTextRunBuffer (SKRunBufferInternal buffer, int size, int textSize)
: base (buffer, size)
{
TextSize = textSize;
}
public int TextSize { get; }
public Span<byte> GetTextSpan () =>
new Span<byte> (internalBuffer.utf8text, internalBuffer.utf8text == null ? 0 : TextSize);
public Span<byte> Text => new (internalBuffer.utf8text, TextSize);
public Span<uint> GetClusterSpan () =>
new Span<uint> (internalBuffer.clusters, internalBuffer.clusters == null ? 0 : Size);
public Span<uint> Clusters => new (internalBuffer.clusters, Size);
public void SetText (ReadOnlySpan<byte> text) =>
text.CopyTo (GetTextSpan ());
public void SetText (ReadOnlySpan<byte> text) => text.CopyTo (Text);
public void SetClusters (ReadOnlySpan<uint> clusters) =>
clusters.CopyTo (GetClusterSpan ());
public void SetClusters (ReadOnlySpan<uint> clusters) => clusters.CopyTo (Clusters);
}
public sealed unsafe class SKHorizontalTextRunBuffer : SKTextRunBuffer
{
internal SKHorizontalTextRunBuffer (SKRunBufferInternal buffer, int count, int textSize)
: base (buffer, count, textSize)
internal SKHorizontalTextRunBuffer (SKRunBufferInternal buffer, int size, int textSize)
: base (buffer, size, textSize)
{
}
public Span<float> GetPositionSpan () =>
new Span<float> (internalBuffer.pos, internalBuffer.pos == null ? 0 : Size);
public Span<float> Positions => new (internalBuffer.pos, Size);
public void SetPositions (ReadOnlySpan<float> positions) =>
positions.CopyTo (GetPositionSpan ());
public void SetPositions (ReadOnlySpan<float> positions) => positions.CopyTo (Positions);
}
public sealed unsafe class SKPositionedTextRunBuffer : SKTextRunBuffer
{
internal SKPositionedTextRunBuffer (SKRunBufferInternal buffer, int count, int textSize)
: base (buffer, count, textSize)
internal SKPositionedTextRunBuffer (SKRunBufferInternal buffer, int size, int textSize)
: base (buffer, size, textSize)
{
}
public Span<SKPoint> GetPositionSpan () =>
new Span<SKPoint> (internalBuffer.pos, internalBuffer.pos == null ? 0 : Size);
public Span<SKPoint> Positions => new (internalBuffer.pos, Size);
public void SetPositions (ReadOnlySpan<SKPoint> positions) =>
positions.CopyTo (GetPositionSpan ());
public void SetPositions (ReadOnlySpan<SKPoint> positions) => positions.CopyTo (Positions);
}
public sealed unsafe class SKRotationScaleTextRunBuffer : SKTextRunBuffer
{
internal SKRotationScaleTextRunBuffer (SKRunBufferInternal buffer, int size, int textSize)
: base (buffer, size, textSize)
{
}
public Span<SKRotationScaleMatrix> Positions => new (internalBuffer.pos, Size);
public void SetPositions (ReadOnlySpan<SKRotationScaleMatrix> positions) => positions.CopyTo (Positions);
}
// Raw / Struct
public unsafe readonly struct SKRawRunBuffer<T>
{
internal readonly SKRunBufferInternal buffer;
private readonly int size;
private readonly int posSize;
private readonly int textSize;
internal SKRawRunBuffer (SKRunBufferInternal buffer, int size, int posSize, int textSize)
{
this.buffer = buffer;
this.size = size;
this.posSize = posSize;
this.textSize = textSize;
}
public Span<ushort> Glyphs => new (buffer.glyphs, size);
public Span<T> Positions => new (buffer.pos, posSize);
public Span<byte> Text => new (buffer.utf8text, textSize);
public Span<uint> Clusters => new (buffer.clusters, size);
}
}

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

@ -41,6 +41,17 @@ namespace SkiaSharp
return effect;
}
public static SKRuntimeEffect CreateBlender (string sksl, out string errors)
{
using var s = new SKString (sksl);
using var errorString = new SKString ();
var effect = GetObject (SkiaApi.sk_runtimeeffect_make_for_blender (s.Handle, errorString.Handle));
errors = errorString?.ToString ();
if (errors?.Length == 0)
errors = null;
return effect;
}
// Build*
public static SKRuntimeShaderBuilder BuildShader (string sksl)
@ -57,6 +68,13 @@ namespace SkiaSharp
return new SKRuntimeColorFilterBuilder (effect);
}
public static SKRuntimeBlenderBuilder BuildBlender (string sksl)
{
var effect = CreateBlender (sksl, out var errors);
ValidateResult (effect, errors);
return new SKRuntimeBlenderBuilder (effect);
}
private static void ValidateResult (SKRuntimeEffect effect, string errors)
{
if (effect is null) {
@ -148,6 +166,30 @@ namespace SkiaSharp
}
}
// ToBlender
public SKBlender ToBlender () =>
ToBlender ((SKData)null, null);
public SKBlender ToBlender (SKRuntimeEffectUniforms uniforms) =>
ToBlender (uniforms.ToData (), null);
private SKBlender ToBlender (SKData uniforms) =>
ToBlender (uniforms, null);
public SKBlender ToBlender (SKRuntimeEffectUniforms uniforms, SKRuntimeEffectChildren children) =>
ToBlender (uniforms.ToData (), children.ToArray ());
private SKBlender ToBlender (SKData uniforms, SKObject[] children)
{
var uniformsHandle = uniforms?.Handle ?? IntPtr.Zero;
using var childrenHandles = Utils.RentHandlesArray (children, true);
fixed (IntPtr* ch = childrenHandles) {
return SKBlender.GetObject (SkiaApi.sk_runtimeeffect_make_blender (Handle, uniformsHandle, ch, (IntPtr)childrenHandles.Length));
}
}
//
internal static SKRuntimeEffect GetObject (IntPtr handle) =>
@ -560,15 +602,24 @@ namespace SkiaSharp
value = colorFilter;
}
public SKRuntimeEffectChild (SKBlender blender)
{
value = blender;
}
public SKObject Value => value;
public SKShader Shader => value as SKShader;
public SKColorFilter ColorFilter => value as SKColorFilter;
public SKBlender Blender => value as SKBlender;
public static implicit operator SKRuntimeEffectChild (SKShader shader) => new (shader);
public static implicit operator SKRuntimeEffectChild (SKColorFilter colorFilter) => new (colorFilter);
public static implicit operator SKRuntimeEffectChild (SKBlender blender) => new (blender);
}
public class SKRuntimeEffectBuilderException : ApplicationException
@ -627,4 +678,15 @@ namespace SkiaSharp
public SKColorFilter Build () =>
Effect.ToColorFilter (Uniforms, Children);
}
public class SKRuntimeBlenderBuilder : SKRuntimeEffectBuilder
{
public SKRuntimeBlenderBuilder (SKRuntimeEffect effect)
: base (effect)
{
}
public SKBlender Build () =>
Effect.ToBlender (Uniforms, Children);
}
}

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

@ -80,12 +80,20 @@ namespace SkiaSharp
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) =>
src?.ToShader (tmx, tmy, sampling) ?? throw new ArgumentNullException (nameof (src));
[Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling) instead.")]
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality) =>
src?.ToShader (tmx, tmy, quality.ToSamplingOptions()) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKMatrix localMatrix) =>
src?.ToShader (tmx, tmy, localMatrix) ?? throw new ArgumentNullException (nameof (src));
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) =>
src?.ToShader (tmx, tmy, sampling, localMatrix) ?? throw new ArgumentNullException (nameof (src));
[Obsolete ("Use CreateImage(SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKSamplingOptions sampling, SKMatrix localMatrix) instead.")]
public static SKShader CreateImage (SKImage src, SKShaderTileMode tmx, SKShaderTileMode tmy, SKFilterQuality quality, SKMatrix localMatrix) =>
src?.ToShader (tmx, tmy, quality.ToSamplingOptions(), localMatrix) ?? throw new ArgumentNullException (nameof (src));
// CreatePicture
public static SKShader CreatePicture (SKPicture src) =>
@ -408,6 +416,23 @@ namespace SkiaSharp
return GetObject (SkiaApi.sk_shader_new_blend (mode, shaderA.Handle, shaderB.Handle));
}
// CreateBlend
public static SKShader CreateBlend (SKBlendMode mode, SKShader shaderA, SKShader shaderB)
{
_ = shaderA ?? throw new ArgumentNullException (nameof (shaderA));
_ = shaderB ?? throw new ArgumentNullException (nameof (shaderB));
return GetObject (SkiaApi.sk_shader_new_blend (mode, shaderA.Handle, shaderB.Handle));
}
public static SKShader CreateBlend (SKBlender blender, SKShader shaderA, SKShader shaderB)
{
_ = shaderA ?? throw new ArgumentNullException (nameof (shaderA));
_ = shaderB ?? throw new ArgumentNullException (nameof (shaderB));
_ = blender ?? throw new ArgumentNullException (nameof (blender));
return GetObject (SkiaApi.sk_shader_new_blender (blender.Handle, shaderA.Handle, shaderB.Handle));
}
// CreateColorFilter
public static SKShader CreateColorFilter (SKShader shader, SKColorFilter filter)

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

@ -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,4 @@
#nullable disable
using System;
using System.ComponentModel;
using System;
namespace SkiaSharp
{
@ -31,27 +28,27 @@ namespace SkiaSharp
// Create
public static SKTextBlob Create (string text, SKFont font, SKPoint origin = default) =>
public static SKTextBlob? Create (string text, SKFont font, SKPoint origin = default) =>
Create (text.AsSpan (), font, origin);
public static SKTextBlob Create (ReadOnlySpan<char> text, SKFont font, SKPoint origin = default)
public static SKTextBlob? Create (ReadOnlySpan<char> text, SKFont font, SKPoint origin = default)
{
fixed (void* t = text) {
return Create (t, text.Length * 2, SKTextEncoding.Utf16, font, origin);
}
}
public static SKTextBlob Create (IntPtr text, int length, SKTextEncoding encoding, SKFont font, SKPoint origin = default) =>
public static SKTextBlob? Create (IntPtr text, int length, SKTextEncoding encoding, SKFont font, SKPoint origin = default) =>
Create (text.AsReadOnlySpan (length), encoding, font, origin);
public static SKTextBlob Create (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, SKPoint origin = default)
public static SKTextBlob? Create (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, SKPoint origin = default)
{
fixed (void* t = text) {
return Create (t, text.Length, encoding, font, origin);
}
}
internal static SKTextBlob Create (void* text, int length, SKTextEncoding encoding, SKFont font, SKPoint origin)
internal static SKTextBlob? Create (void* text, int length, SKTextEncoding encoding, SKFont font, SKPoint origin)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -61,35 +58,35 @@ namespace SkiaSharp
return null;
using var builder = new SKTextBlobBuilder ();
var buffer = builder.AllocatePositionedRun (font, count);
font.GetGlyphs (text, length, encoding, buffer.GetGlyphSpan ());
font.GetGlyphPositions (buffer.GetGlyphSpan (), buffer.GetPositionSpan (), origin);
var buffer = builder.AllocateRawPositionedRun (font, count);
font.GetGlyphs (text, length, encoding, buffer.Glyphs);
font.GetGlyphPositions (buffer.Glyphs, buffer.Positions, origin);
return builder.Build ();
}
// CreateHorizontal
public static SKTextBlob CreateHorizontal (string text, SKFont font, ReadOnlySpan<float> positions, float y) =>
public static SKTextBlob? CreateHorizontal (string text, SKFont font, ReadOnlySpan<float> positions, float y) =>
CreateHorizontal (text.AsSpan (), font, positions, y);
public static SKTextBlob CreateHorizontal (ReadOnlySpan<char> text, SKFont font, ReadOnlySpan<float> positions, float y)
public static SKTextBlob? CreateHorizontal (ReadOnlySpan<char> text, SKFont font, ReadOnlySpan<float> positions, float y)
{
fixed (void* t = text) {
return CreateHorizontal (t, text.Length * 2, SKTextEncoding.Utf16, font, positions, y);
}
}
public static SKTextBlob CreateHorizontal (IntPtr text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<float> positions, float y) =>
public static SKTextBlob? CreateHorizontal (IntPtr text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<float> positions, float y) =>
CreateHorizontal (text.AsReadOnlySpan (length), encoding, font, positions, y);
public static SKTextBlob CreateHorizontal (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, ReadOnlySpan<float> positions, float y)
public static SKTextBlob? CreateHorizontal (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, ReadOnlySpan<float> positions, float y)
{
fixed (void* t = text) {
return CreateHorizontal (t, text.Length, encoding, font, positions, y);
}
}
internal static SKTextBlob CreateHorizontal (void* text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<float> positions, float y)
internal static SKTextBlob? CreateHorizontal (void* text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<float> positions, float y)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -99,35 +96,35 @@ namespace SkiaSharp
return null;
using var builder = new SKTextBlobBuilder ();
var buffer = builder.AllocateHorizontalRun (font, count, y);
font.GetGlyphs (text, length, encoding, buffer.GetGlyphSpan ());
positions.CopyTo (buffer.GetPositionSpan ());
var buffer = builder.AllocateRawHorizontalRun (font, count, y);
font.GetGlyphs (text, length, encoding, buffer.Glyphs);
positions.CopyTo (buffer.Positions);
return builder.Build ();
}
// CreatePositioned
public static SKTextBlob CreatePositioned (string text, SKFont font, ReadOnlySpan<SKPoint> positions) =>
public static SKTextBlob? CreatePositioned (string text, SKFont font, ReadOnlySpan<SKPoint> positions) =>
CreatePositioned (text.AsSpan (), font, positions);
public static SKTextBlob CreatePositioned (ReadOnlySpan<char> text, SKFont font, ReadOnlySpan<SKPoint> positions)
public static SKTextBlob? CreatePositioned (ReadOnlySpan<char> text, SKFont font, ReadOnlySpan<SKPoint> positions)
{
fixed (void* t = text) {
return CreatePositioned (t, text.Length * 2, SKTextEncoding.Utf16, font, positions);
}
}
public static SKTextBlob CreatePositioned (IntPtr text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKPoint> positions) =>
public static SKTextBlob? CreatePositioned (IntPtr text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKPoint> positions) =>
CreatePositioned (text.AsReadOnlySpan (length), encoding, font, positions);
public static SKTextBlob CreatePositioned (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKPoint> positions)
public static SKTextBlob? CreatePositioned (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKPoint> positions)
{
fixed (void* t = text) {
return CreatePositioned (t, text.Length, encoding, font, positions);
}
}
internal static SKTextBlob CreatePositioned (void* text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKPoint> positions)
internal static SKTextBlob? CreatePositioned (void* text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKPoint> positions)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -137,35 +134,35 @@ namespace SkiaSharp
return null;
using var builder = new SKTextBlobBuilder ();
var buffer = builder.AllocatePositionedRun (font, count);
font.GetGlyphs (text, length, encoding, buffer.GetGlyphSpan ());
positions.CopyTo (buffer.GetPositionSpan ());
var buffer = builder.AllocateRawPositionedRun (font, count);
font.GetGlyphs (text, length, encoding, buffer.Glyphs);
positions.CopyTo (buffer.Positions);
return builder.Build ();
}
// CreateRotationScale
public static SKTextBlob CreateRotationScale (string text, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions) =>
public static SKTextBlob? CreateRotationScale (string text, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions) =>
CreateRotationScale (text.AsSpan (), font, positions);
public static SKTextBlob CreateRotationScale (ReadOnlySpan<char> text, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
public static SKTextBlob? CreateRotationScale (ReadOnlySpan<char> text, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
{
fixed (void* t = text) {
return CreateRotationScale (t, text.Length * 2, SKTextEncoding.Utf16, font, positions);
}
}
public static SKTextBlob CreateRotationScale (IntPtr text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions) =>
public static SKTextBlob? CreateRotationScale (IntPtr text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions) =>
CreateRotationScale (text.AsReadOnlySpan (length), encoding, font, positions);
public static SKTextBlob CreateRotationScale (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
public static SKTextBlob? CreateRotationScale (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
{
fixed (void* t = text) {
return CreateRotationScale (t, text.Length, encoding, font, positions);
}
}
internal static SKTextBlob CreateRotationScale (void* text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
internal static SKTextBlob? CreateRotationScale (void* text, int length, SKTextEncoding encoding, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -176,34 +173,34 @@ namespace SkiaSharp
using var builder = new SKTextBlobBuilder ();
var buffer = builder.AllocateRotationScaleRun (font, count);
font.GetGlyphs (text, length, encoding, buffer.GetGlyphSpan ());
positions.CopyTo (buffer.GetRotationScaleSpan ());
font.GetGlyphs (text, length, encoding, buffer.Glyphs);
positions.CopyTo (buffer.Positions);
return builder.Build ();
}
// CreatePathPositioned
public static SKTextBlob CreatePathPositioned (string text, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default) =>
public static SKTextBlob? CreatePathPositioned (string text, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default) =>
CreatePathPositioned (text.AsSpan (), font, path, textAlign, origin);
public static SKTextBlob CreatePathPositioned (ReadOnlySpan<char> text, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default)
public static SKTextBlob? CreatePathPositioned (ReadOnlySpan<char> text, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default)
{
fixed (void* t = text) {
return CreatePathPositioned (t, text.Length * 2, SKTextEncoding.Utf16, font, path, textAlign, origin);
}
}
public static SKTextBlob CreatePathPositioned (IntPtr text, int length, SKTextEncoding encoding, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default) =>
public static SKTextBlob? CreatePathPositioned (IntPtr text, int length, SKTextEncoding encoding, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default) =>
CreatePathPositioned (text.AsReadOnlySpan (length), encoding, font, path, textAlign, origin);
public static SKTextBlob CreatePathPositioned (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default)
public static SKTextBlob? CreatePathPositioned (ReadOnlySpan<byte> text, SKTextEncoding encoding, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default)
{
fixed (void* t = text) {
return CreatePathPositioned (t, text.Length, encoding, font, path, textAlign, origin);
}
}
internal static SKTextBlob CreatePathPositioned (void* text, int length, SKTextEncoding encoding, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default)
internal static SKTextBlob? CreatePathPositioned (void* text, int length, SKTextEncoding encoding, SKFont font, SKPath path, SKTextAlign textAlign = SKTextAlign.Left, SKPoint origin = default)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -228,7 +225,7 @@ namespace SkiaSharp
// GetIntercepts
public float[] GetIntercepts (float upperBounds, float lowerBounds, SKPaint paint = null)
public float[] GetIntercepts (float upperBounds, float lowerBounds, SKPaint? paint = null)
{
var n = CountIntercepts (upperBounds, lowerBounds, paint);
var intervals = new float[n];
@ -236,7 +233,7 @@ namespace SkiaSharp
return intervals;
}
public void GetIntercepts (float upperBounds, float lowerBounds, Span<float> intervals, SKPaint paint = null)
public void GetIntercepts (float upperBounds, float lowerBounds, Span<float> intervals, SKPaint? paint = null)
{
var bounds = stackalloc float[2];
bounds[0] = upperBounds;
@ -248,7 +245,7 @@ namespace SkiaSharp
// CountIntercepts
public int CountIntercepts (float upperBounds, float lowerBounds, SKPaint paint = null)
public int CountIntercepts (float upperBounds, float lowerBounds, SKPaint? paint = null)
{
var bounds = stackalloc float[2];
bounds[0] = upperBounds;
@ -258,7 +255,7 @@ namespace SkiaSharp
//
internal static SKTextBlob GetObject (IntPtr handle) =>
internal static SKTextBlob? GetObject (IntPtr handle) =>
handle == IntPtr.Zero ? null : new SKTextBlob (handle, true);
}
@ -282,7 +279,7 @@ namespace SkiaSharp
// Build
public SKTextBlob Build ()
public SKTextBlob? Build ()
{
var blob = SKTextBlob.GetObject (SkiaApi.sk_textblob_builder_make (Handle));
GC.KeepAlive (this);
@ -293,48 +290,36 @@ namespace SkiaSharp
public void AddRun (ReadOnlySpan<ushort> glyphs, SKFont font, SKPoint origin = default)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
var buffer = AllocatePositionedRun (font, glyphs.Length);
glyphs.CopyTo (buffer.GetGlyphSpan ());
font.GetGlyphPositions (buffer.GetGlyphSpan (), buffer.GetPositionSpan (), origin);
var buffer = AllocateRawPositionedRun (font, glyphs.Length);
glyphs.CopyTo (buffer.Glyphs);
font.GetGlyphPositions (buffer.Glyphs, buffer.Positions, origin);
}
// AddHorizontalRun
public void AddHorizontalRun (ReadOnlySpan<ushort> glyphs, SKFont font, ReadOnlySpan<float> positions, float y)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
var buffer = AllocateHorizontalRun (font, glyphs.Length, y);
glyphs.CopyTo (buffer.GetGlyphSpan ());
positions.CopyTo (buffer.GetPositionSpan ());
var buffer = AllocateRawHorizontalRun (font, glyphs.Length, y);
glyphs.CopyTo (buffer.Glyphs);
positions.CopyTo (buffer.Positions);
}
// AddPositionedRun
public void AddPositionedRun (ReadOnlySpan<ushort> glyphs, SKFont font, ReadOnlySpan<SKPoint> positions)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
var buffer = AllocatePositionedRun (font, glyphs.Length);
glyphs.CopyTo (buffer.GetGlyphSpan ());
positions.CopyTo (buffer.GetPositionSpan ());
var buffer = AllocateRawPositionedRun (font, glyphs.Length);
glyphs.CopyTo (buffer.Glyphs);
positions.CopyTo (buffer.Positions);
}
// AddRotationScaleRun
public void AddRotationScaleRun (ReadOnlySpan<ushort> glyphs, SKFont font, ReadOnlySpan<SKRotationScaleMatrix> positions)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
var buffer = AllocateRotationScaleRun (font, glyphs.Length);
glyphs.CopyTo (buffer.GetGlyphSpan ());
positions.CopyTo (buffer.GetRotationScaleSpan ());
var buffer = AllocateRawRotationScaleRun (font, glyphs.Length);
glyphs.CopyTo (buffer.Glyphs);
positions.CopyTo (buffer.Positions);
}
// AddPathPositionedRun
@ -390,9 +375,17 @@ namespace SkiaSharp
AddRotationScaleRun (glyphSubset, font, positions);
}
// AllocateRun
// Allocate*
// Allocate*Run
public SKRunBuffer AllocateRun (SKFont font, int count, float x, float y, SKRect? bounds = null)
{
var buffer = AllocateRawRun (font, count, x, y, bounds);
return new SKRunBuffer (buffer.buffer, count);
}
public SKRawRunBuffer<float> AllocateRawRun (SKFont font, int count, float x, float y, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -403,10 +396,16 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run (Handle, font.Handle, count, x, y, null, &runbuffer);
return new SKRunBuffer (runbuffer, count);
return new SKRawRunBuffer<float> (runbuffer, count, 0, 0);
}
public SKTextRunBuffer AllocateTextRun (SKFont font, int count, float x, float y, int textByteCount, SKRect? bounds = null)
{
var buffer = AllocateRawTextRun (font, count, x, y, textByteCount, bounds);
return new SKTextRunBuffer (buffer.buffer, count, textByteCount);
}
public SKRawRunBuffer<float> AllocateRawTextRun (SKFont font, int count, float x, float y, int textByteCount, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -417,12 +416,18 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_text (Handle, font.Handle, count, x, y, textByteCount, null, &runbuffer);
return new SKTextRunBuffer (runbuffer, count, textByteCount);
return new SKRawRunBuffer<float> (runbuffer, count, 0, textByteCount);
}
// AllocateHorizontalRun
// Allocate*HorizontalRun
public SKHorizontalRunBuffer AllocateHorizontalRun (SKFont font, int count, float y, SKRect? bounds = null)
{
var buffer = AllocateRawHorizontalRun (font, count, y, bounds);
return new SKHorizontalRunBuffer (buffer.buffer, count);
}
public SKRawRunBuffer<float> AllocateRawHorizontalRun (SKFont font, int count, float y, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -433,10 +438,16 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_pos_h (Handle, font.Handle, count, y, null, &runbuffer);
return new SKHorizontalRunBuffer (runbuffer, count);
return new SKRawRunBuffer<float> (runbuffer, count, count, 0);
}
public SKHorizontalTextRunBuffer AllocateHorizontalTextRun (SKFont font, int count, float y, int textByteCount, SKRect? bounds = null)
{
var buffer = AllocateRawHorizontalTextRun (font, count, y, textByteCount, bounds);
return new SKHorizontalTextRunBuffer (buffer.buffer, count, textByteCount);
}
public SKRawRunBuffer<float> AllocateRawHorizontalTextRun (SKFont font, int count, float y, int textByteCount, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -447,12 +458,19 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_text_pos_h (Handle, font.Handle, count, y, textByteCount, null, &runbuffer);
return new SKHorizontalTextRunBuffer (runbuffer, count, textByteCount);
return new SKRawRunBuffer<float> (runbuffer, count, count, textByteCount);
}
// AllocatePositionedRun
public SKPositionedRunBuffer AllocatePositionedRun (SKFont font, int count, SKRect? bounds = null)
{
var buffer = AllocateRawPositionedRun (font, count, bounds);
return new SKPositionedRunBuffer (buffer.buffer, count);
}
public SKRawRunBuffer<SKPoint> AllocateRawPositionedRun (SKFont font, int count, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -463,10 +481,16 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_pos (Handle, font.Handle, count, null, &runbuffer);
return new SKPositionedRunBuffer (runbuffer, count);
return new SKRawRunBuffer<SKPoint> (runbuffer, count, count, 0);
}
public SKPositionedTextRunBuffer AllocatePositionedTextRun (SKFont font, int count, int textByteCount, SKRect? bounds = null)
{
var buffer = AllocateRawPositionedTextRun (font, count, textByteCount, bounds);
return new SKPositionedTextRunBuffer (buffer.buffer, count, textByteCount);
}
public SKRawRunBuffer<SKPoint> AllocateRawPositionedTextRun (SKFont font, int count, int textByteCount, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -477,12 +501,18 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_text_pos (Handle, font.Handle, count, textByteCount, null, &runbuffer);
return new SKPositionedTextRunBuffer (runbuffer, count, textByteCount);
return new SKRawRunBuffer<SKPoint> (runbuffer, count, count, textByteCount);
}
// AllocateRotationScaleRun
public SKRotationScaleRunBuffer AllocateRotationScaleRun (SKFont font, int count, SKRect? bounds = null)
{
var buffer = AllocateRawRotationScaleRun (font, count, bounds);
return new SKRotationScaleRunBuffer (buffer.buffer, count);
}
public SKRawRunBuffer<SKRotationScaleMatrix> AllocateRawRotationScaleRun (SKFont font, int count, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -493,10 +523,16 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_rsxform (Handle, font.Handle, count, null, &runbuffer);
return new SKRotationScaleRunBuffer (runbuffer, count);
return new SKRawRunBuffer<SKRotationScaleMatrix> (runbuffer, count, count, 0);
}
public SKRotationScaleRunBuffer AllocateRotationScaleTextRun (SKFont font, int count, int textByteCount, SKRect? bounds = null)
public SKRotationScaleTextRunBuffer AllocateRotationScaleTextRun (SKFont font, int count, int textByteCount, SKRect? bounds = null)
{
var buffer = AllocateRawRotationScaleTextRun (font, count, textByteCount, bounds);
return new SKRotationScaleTextRunBuffer (buffer.buffer, count, textByteCount);
}
public SKRawRunBuffer<SKRotationScaleMatrix> AllocateRawRotationScaleTextRun (SKFont font, int count, int textByteCount, SKRect? bounds = null)
{
if (font == null)
throw new ArgumentNullException (nameof (font));
@ -507,7 +543,7 @@ namespace SkiaSharp
else
SkiaApi.sk_textblob_builder_alloc_run_text_rsxform (Handle, font.Handle, count, textByteCount, null, &runbuffer);
return new SKRotationScaleRunBuffer (runbuffer, count);
return new SKRawRunBuffer<SKRotationScaleMatrix> (runbuffer, count, count, textByteCount);
}
}
}

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

@ -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));
}
}
}

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

@ -14,6 +14,11 @@ namespace SkiaSharp
static SKTypeface ()
{
// TODO: This is not the best way to do this as it will create a lot of objects that
// might not be needed, but it is the only way to ensure that the static
// instances are created before any access is made to them.
// See more info: SKObject.EnsureStaticInstanceAreInitialized()
defaultTypeface = new SKTypefaceStatic (SkiaApi.sk_typeface_ref_default ());
}
@ -294,14 +299,65 @@ namespace SkiaSharp
// GetKerningPairAdjustments
/// <summary>
/// If false, then <see cref="GetKerningPairAdjustments"/> will never return nonzero
/// adjustments for any possible pair of glyphs.
/// </summary>
public bool HasGetKerningPairAdjustments =>
SkiaApi.sk_typeface_get_kerning_pair_adjustments (Handle, null, 0, null);
/// <summary>
/// Gets a kerning adjustment for each sequential pair of glyph indices in <paramref name="glyphs"/>.
/// </summary>
/// <param name="glyphs">The sequence of glyph indices to get kerning adjustments for.</param>
/// <returns>
/// Adjustments are returned in design units, relative to <see cref="UnitsPerEm"/>.
/// </returns>
/// <remarks>
/// For backwards-compatibility reasons, an additional zero entry is present at the end of the array.
/// </remarks>
public int[] GetKerningPairAdjustments (ReadOnlySpan<ushort> glyphs)
{
var adjustments = new int[glyphs.Length];
GetKerningPairAdjustments (glyphs, adjustments);
return adjustments;
}
/// <summary>
/// Gets a kerning adjustment for each sequential pair of glyph indices in <paramref name="glyphs"/>.
/// </summary>
/// <param name="glyphs">The sequence of glyph indices to get kerning adjustments for.</param>
/// <param name="adjustments">
/// The span that will hold the output adjustments, one per adjacent pari of <paramref name="glyphs"/>.
/// Adjustments are returned in design units, relative to <see cref="UnitsPerEm"/>.
/// This must contain a minimum of glyphs.Length - 1 elements.
/// </param>
/// <returns>
/// True if any kerning pair adjustments were written to <paramref name="adjustments"/>.
/// False if the typeface does not contain adjustments for any of the given pairs of glyphs.
/// </returns>
/// <remarks>
/// If this function returns false, then the first <paramref name="glyphs"/>.Length - 1 elements of <paramref name="adjustments"/> will be zero.
/// Elements of <paramref name="adjustments"/> beyond <paramref name="glyphs"/>.Length - 1 will not be modified.
/// </remarks>
public bool GetKerningPairAdjustments (ReadOnlySpan<ushort> glyphs, Span<int> adjustments)
{
if (adjustments.Length < glyphs.Length - 1)
throw new ArgumentException ("Length of adjustments must be large enough to hold one adjustment per pair of glyphs (or, glyphs.Length - 1).");
bool res;
fixed (ushort* gp = glyphs)
fixed (int* ap = adjustments) {
SkiaApi.sk_typeface_get_kerning_pair_adjustments (Handle, gp, glyphs.Length, ap);
res = SkiaApi.sk_typeface_get_kerning_pair_adjustments (Handle, gp, glyphs.Length, ap);
}
return adjustments;
if (!res && glyphs.Length > 1)
//Per SkTypeface::GetKerningPairAdjustments documentation, the method may have written
//nonsense into the array before bailing. Don't return it to the caller, the doc says
//such values must be ignored.
adjustments.Slice(0, glyphs.Length - 1).Clear ();
return res;
}
//

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -5,10 +5,16 @@
<AssemblyName>SkiaSharp</AssemblyName>
<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"
]
}
}
}

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

@ -2,11 +2,13 @@
#addin nuget:?package=Cake.XCode&version=5.0.0
#addin nuget:?package=Cake.FileHelpers&version=4.0.1
#addin nuget:?package=Cake.Json&version=6.0.1
#addin nuget:?package=NuGet.Packaging.Core&version=5.11.0
#addin nuget:?package=NuGet.Packaging&version=6.9.1
#addin nuget:?package=SharpCompress&version=0.32.2
#addin nuget:?package=Mono.Cecil&version=0.10.0
#addin nuget:?package=Mono.ApiTools&version=5.14.0.2
#addin nuget:?package=Mono.ApiTools.NuGetDiff&version=1.3.5
#addin nuget:?package=Mono.Cecil&version=0.11.5
#addin nuget:?package=Mono.ApiTools.ApiInfo&version=1.4.1
#addin nuget:?package=Mono.ApiTools.ApiDiff&version=1.4.1
#addin nuget:?package=Mono.ApiTools.ApiDiffFormatted&version=1.4.1
#addin nuget:?package=Mono.ApiTools.NuGetDiff&version=1.4.1
#tool nuget:?package=mdoc&version=5.8.9
#tool nuget:?package=xunit.runner.console&version=2.4.2
@ -251,7 +253,7 @@ Task ("tests-netcore")
var failedTests = 0;
var tfm = "net7.0";
var tfm = "net8.0";
var testAssemblies = new List<string> { "SkiaSharp.Tests.Console" };
if (SUPPORT_VULKAN)
testAssemblies.Add ("SkiaSharp.Vulkan.Tests.Console");
@ -297,7 +299,7 @@ Task ("tests-android")
FilePath csproj = "./tests/SkiaSharp.Tests.Devices/SkiaSharp.Tests.Devices.csproj";
var configuration = "Release";
var tfm = "net7.0-android";
var tfm = "net8.0-android";
var rid = "android-" + RuntimeInformation.ProcessArchitecture.ToString ().ToLower ();
FilePath app = $"./tests/SkiaSharp.Tests.Devices/bin/{configuration}/{tfm}/{rid}/com.companyname.SkiaSharpTests-Signed.apk";
@ -329,7 +331,7 @@ Task ("tests-ios")
FilePath csproj = "./tests/SkiaSharp.Tests.Devices/SkiaSharp.Tests.Devices.csproj";
var configuration = "Debug";
var tfm = "net7.0-ios";
var tfm = "net8.0-ios";
var rid = "iossimulator-" + RuntimeInformation.ProcessArchitecture.ToString ().ToLower ();
FilePath app = $"./tests/SkiaSharp.Tests.Devices/bin/{configuration}/{tfm}/{rid}/SkiaSharp.Tests.Devices.app";
@ -361,7 +363,7 @@ Task ("tests-maccatalyst")
FilePath csproj = "./tests/SkiaSharp.Tests.Devices/SkiaSharp.Tests.Devices.csproj";
var configuration = "Debug";
var tfm = "net7.0-maccatalyst";
var tfm = "net8.0-maccatalyst";
var rid = "maccatalyst-" + RuntimeInformation.ProcessArchitecture.ToString ().ToLower ();
FilePath app = $"./tests/SkiaSharp.Tests.Devices/bin/{configuration}/{tfm}/{rid}/SkiaSharp.Tests.Devices.app";
@ -395,10 +397,8 @@ Task ("tests-wasm")
IProcess serverProc = null;
try {
serverProc = RunAndReturnProcess (PYTHON_EXE, new ProcessSettings {
Arguments = MakeAbsolute (File ("./tests/SkiaSharp.Tests.Wasm/server.py")).FullPath,
WorkingDirectory = "./tests/SkiaSharp.Tests.Wasm/bin/Release/net7.0/dist",
});
var wasmProj = MakeAbsolute (File ("./tests/SkiaSharp.Tests.Wasm/SkiaSharp.Tests.Wasm.csproj")).FullPath;
serverProc = RunAndReturnProcess ("dotnet", $"run --project {wasmProj} --no-build -c {CONFIGURATION}");
DotNetRun ("./utils/WasmTestRunner/WasmTestRunner.csproj",
$"--output=\"./output/logs/testlogs/SkiaSharp.Tests.Wasm/{DATE_TIME_STR}/\" " +
(string.IsNullOrEmpty (CHROMEWEBDRIVER) ? "" : $"--driver=\"{CHROMEWEBDRIVER}\" ") +

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

@ -0,0 +1,46 @@
# API diff: SkiaSharp.Resources.dll
## SkiaSharp.Resources.dll
> Assembly Version Changed: 3.0.0.0 vs 0.0.0.0
### New Namespace SkiaSharp.Resources
#### New Type: SkiaSharp.Resources.CachingResourceProvider
```csharp
public sealed class CachingResourceProvider : SkiaSharp.Resources.ResourceProvider, SkiaSharp.ISKReferenceCounted, SkiaSharp.ISKSkipObjectRegistration {
// constructors
public CachingResourceProvider (ResourceProvider resourceProvider);
}
```
#### New Type: SkiaSharp.Resources.DataUriResourceProvider
```csharp
public sealed class DataUriResourceProvider : SkiaSharp.Resources.ResourceProvider, SkiaSharp.ISKReferenceCounted, SkiaSharp.ISKSkipObjectRegistration {
// constructors
public DataUriResourceProvider (bool preDecode);
public DataUriResourceProvider (ResourceProvider fallbackProvider, bool preDecode);
}
```
#### New Type: SkiaSharp.Resources.FileResourceProvider
```csharp
public sealed class FileResourceProvider : SkiaSharp.Resources.ResourceProvider, SkiaSharp.ISKReferenceCounted, SkiaSharp.ISKSkipObjectRegistration {
// constructors
public FileResourceProvider (string baseDirectory, bool preDecode);
}
```
#### New Type: SkiaSharp.Resources.ResourceProvider
```csharp
public abstract class ResourceProvider : SkiaSharp.SKObject, SkiaSharp.ISKReferenceCounted, SkiaSharp.ISKSkipObjectRegistration {
// methods
public SkiaSharp.SKData Load (string resourceName);
public SkiaSharp.SKData Load (string resourcePath, string resourceName);
}
```

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

@ -4,3 +4,62 @@
> Assembly Version Changed: 3.0.0.0 vs 2.88.0.0
### Namespace SkiaSharp.Skottie
#### Type Changed: SkiaSharp.Skottie.Animation
Added method:
```csharp
public static AnimationBuilder CreateBuilder (AnimationBuilderFlags flags);
```
#### New Type: SkiaSharp.Skottie.AnimationBuilder
```csharp
public sealed class AnimationBuilder : SkiaSharp.SKObject, SkiaSharp.ISKSkipObjectRegistration {
// properties
public AnimationBuilderStats Stats { get; }
// methods
public Animation Build (SkiaSharp.SKData data);
public Animation Build (SkiaSharp.SKStream stream);
public Animation Build (System.IO.Stream stream);
public Animation Build (string path);
protected override void DisposeNative ();
public AnimationBuilder SetFontManager (SkiaSharp.SKFontManager fontManager);
public AnimationBuilder SetResourceProvider (SkiaSharp.Resources.ResourceProvider resourceProvider);
}
```
#### New Type: SkiaSharp.Skottie.AnimationBuilderFlags
```csharp
[Serializable]
public enum AnimationBuilderFlags {
DeferImageLoading = 1,
None = 0,
PreferEmbeddedFonts = 2,
}
```
#### New Type: SkiaSharp.Skottie.AnimationBuilderStats
```csharp
public struct AnimationBuilderStats, System.IEquatable<AnimationBuilderStats> {
// properties
public int AnimatorCount { get; }
public System.TimeSpan JsonParseTime { get; }
public int JsonSize { get; }
public System.TimeSpan SceneParseTime { get; }
public System.TimeSpan TotalLoadTime { get; }
// methods
public virtual bool Equals (AnimationBuilderStats obj);
public override bool Equals (object obj);
public override int GetHashCode ();
public static bool op_Equality (AnimationBuilderStats left, AnimationBuilderStats right);
public static bool op_Inequality (AnimationBuilderStats left, AnimationBuilderStats right);
}
```

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

@ -4,3 +4,24 @@
> Assembly Version Changed: 3.0.0.0 vs 2.88.0.0
### Namespace SkiaSharp.Views.Blazor
#### Type Changed: SkiaSharp.Views.Blazor.SKCanvasView
Added property:
```csharp
public double Dpi { get; }
```
#### Type Changed: SkiaSharp.Views.Blazor.SKGLView
Added property:
```csharp
public double Dpi { get; }
```

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

@ -4,3 +4,26 @@
> Assembly Version Changed: 3.0.0.0 vs 2.88.0.0
### Namespace SkiaSharp.Views.WPF
#### New Type: SkiaSharp.Views.WPF.SKGLElement
```csharp
public class SKGLElement : OpenTK.Wpf.GLWpfControl, System.IDisposable {
// constructors
public SKGLElement ();
// properties
public SkiaSharp.SKSize CanvasSize { get; }
public SkiaSharp.GRContext GRContext { get; }
// events
public event System.EventHandler<SkiaSharp.Views.Desktop.SKPaintGLSurfaceEventArgs> PaintSurface;
// methods
public virtual void Dispose ();
protected virtual void Dispose (bool disposing);
protected virtual void OnPaint (System.TimeSpan e);
protected virtual void OnPaintSurface (SkiaSharp.Views.Desktop.SKPaintGLSurfaceEventArgs e);
protected override void OnRender (System.Windows.Media.DrawingContext drawingContext);
}
```

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

@ -80,5 +80,22 @@ public SkiaSharp.GRBackendRenderTargetDesc RenderTarget { get; }
```
#### Type Changed: SkiaSharp.Views.Mac.SKPaintMetalSurfaceEventArgs
Added constructors:
```csharp
public SKPaintMetalSurfaceEventArgs (SkiaSharp.SKSurface surface, SkiaSharp.GRBackendRenderTarget renderTarget, SkiaSharp.GRSurfaceOrigin origin, SkiaSharp.SKImageInfo info);
public SKPaintMetalSurfaceEventArgs (SkiaSharp.SKSurface surface, SkiaSharp.GRBackendRenderTarget renderTarget, SkiaSharp.GRSurfaceOrigin origin, SkiaSharp.SKImageInfo info, SkiaSharp.SKImageInfo rawInfo);
```
Added properties:
```csharp
public SkiaSharp.SKImageInfo Info { get; }
public SkiaSharp.SKImageInfo RawInfo { get; }
```
#### Removed Type SkiaSharp.Views.Mac.Extensions

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

@ -43,15 +43,51 @@ public static SkiaSharp.SKSizeI ToSKSizeI (this Tizen.NUI.Size2D size);
#### Removed Type SkiaSharp.Views.Tizen.Extensions
### Namespace SkiaSharp.Views.Tizen.NUI
### New Namespace SkiaSharp.Views.Tizen.NUI
#### Type Changed: SkiaSharp.Views.Tizen.NUI.CustomRenderingView
Added property:
#### New Type: SkiaSharp.Views.Tizen.NUI.CustomRenderingView
```csharp
public SkiaSharp.SKSize CanvasSize { get; }
public abstract class CustomRenderingView : Tizen.NUI.BaseComponents.ImageView, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, Tizen.NUI.Binding.IResourcesProvider, Tizen.NUI.Binding.Internals.IDynamicResourceHandler, Tizen.NUI.Binding.Internals.INameScope {
// constructors
protected CustomRenderingView ();
// properties
public SkiaSharp.SKSize CanvasSize { get; }
protected System.Threading.SynchronizationContext MainloopContext { get; }
// events
public event System.EventHandler<SkiaSharp.Views.Tizen.SKPaintSurfaceEventArgs> PaintSurface;
// methods
public void Invalidate ();
protected virtual void OnDrawFrame ();
protected virtual void OnResized ();
protected void SendPaintSurface (SkiaSharp.Views.Tizen.SKPaintSurfaceEventArgs e);
}
```
#### New Type: SkiaSharp.Views.Tizen.NUI.SKCanvasView
```csharp
public class SKCanvasView : SkiaSharp.Views.Tizen.NUI.CustomRenderingView, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, Tizen.NUI.Binding.IResourcesProvider, Tizen.NUI.Binding.Internals.IDynamicResourceHandler, Tizen.NUI.Binding.Internals.INameScope {
// constructors
public SKCanvasView ();
// properties
public bool IgnorePixelScaling { get; set; }
// methods
protected override void OnDrawFrame ();
protected override void OnResized ();
}
```
#### New Type: SkiaSharp.Views.Tizen.NUI.SKGLSurfaceView
```csharp
public class SKGLSurfaceView : SkiaSharp.Views.Tizen.NUI.CustomRenderingView, System.ComponentModel.INotifyPropertyChanged, System.IDisposable, Tizen.NUI.Binding.IResourcesProvider, Tizen.NUI.Binding.Internals.IDynamicResourceHandler, Tizen.NUI.Binding.Internals.INameScope {
// constructors
public SKGLSurfaceView ();
// methods
protected override void Dispose (bool disposing);
protected override void OnDrawFrame ();
protected override void OnResized ();
}
```

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше