Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WASM Support for Uno Platform #1333

Merged
merged 218 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 134 commits
Commits
Show all changes
218 commits
Select commit Hold shift + click to select a range
a93983d
Add support for uno-wasm
jeromelaban Apr 11, 2019
c5b4090
Adjust dependencies
jeromelaban Apr 11, 2019
53ebd43
Add CI support
jeromelaban Apr 11, 2019
fc5687d
Directory.Build.props
jeromelaban Apr 11, 2019
c9a0de2
Adjust for unsupported samples
jeromelaban Apr 11, 2019
8bb0366
Adjust string interop
jeromelaban Apr 11, 2019
09f4249
Update logging, disable some more samples
jeromelaban Apr 11, 2019
2f1b803
Add banner
jeromelaban Apr 12, 2019
374dd86
Enable AOT
jeromelaban Apr 12, 2019
d426988
Update description
jeromelaban Apr 12, 2019
170385a
Update readme
jeromelaban Apr 12, 2019
99d564d
Add listview workaround
jeromelaban Apr 12, 2019
2479746
Enable mixed mode, exclude skia from AOT
jeromelaban Apr 12, 2019
6bbc361
Disable AOT
jeromelaban Apr 12, 2019
e912eaf
Adjust for unsafe blocks
jeromelaban Apr 12, 2019
6734056
Adjust the splash color
jeromelaban Apr 12, 2019
71dfe5e
Remove color table filter sample, custom fonts samples.
jeromelaban Apr 12, 2019
17050e9
Add analytics, disable gif sample
jeromelaban Apr 12, 2019
98dceed
Add mono issue link
jeromelaban Apr 12, 2019
0e514f7
Adjust text color
jeromelaban Apr 12, 2019
f1e184c
Software rendering explanation
jeromelaban Apr 12, 2019
ba8e161
Move to static linking
jeromelaban Jun 19, 2019
b2b8f89
Update build
jeromelaban Jun 19, 2019
525271c
Adjust CI
jeromelaban Jun 20, 2019
0ece3b4
Adjust ci
jeromelaban Jun 20, 2019
f24bd0b
Adjust for content file
jeromelaban Jun 20, 2019
bfd7201
Generate packages
jeromelaban Jun 20, 2019
0660fba
Disable AOT until libSkiaSharp.bc can be linked
jeromelaban Jun 20, 2019
9ea4faf
Generate packages
jeromelaban Jun 20, 2019
276b36c
Add SKXamlCanvas for iOS/Android
jeromelaban Jun 20, 2019
2fde321
Build view.uno explicitly
jeromelaban Jun 20, 2019
6edd4de
Cleanup, wasm+bc inclusion
jeromelaban Jun 21, 2019
81dc170
Align SKXamlCanvas namespace, adjust nuget
jeromelaban Jun 21, 2019
a672def
Adjust libSkia path
jeromelaban Jun 21, 2019
9744b25
Workaround structure parameter marshaling issue for mono-wasm.
jeromelaban Jun 21, 2019
9f26631
Align UWP namespace
jeromelaban Jun 21, 2019
3acd268
Fix visibility
jeromelaban Jun 21, 2019
a89acab
Update bitcode output
jeromelaban Jun 21, 2019
8ea94ee
Adjust iOS and Android support
jeromelaban Jun 21, 2019
1be8a81
Update readme
jeromelaban Jun 21, 2019
aafd760
Merge pull request #1 from nventive/dev/jela/wasm-linking
jeromelaban Jun 21, 2019
ea782aa
Add more supported methods
jeromelaban Jun 25, 2019
46956e0
Merge pull request #2 from nventive/dev/jela/wasm-linking
jeromelaban Jun 25, 2019
4b7aa4f
Add AOT support for libSkia
jeromelaban Jun 27, 2019
b292551
Merge pull request #3 from nventive/dev/jela/wasm-linking
jeromelaban Jun 27, 2019
503c994
Update uno, banner
jeromelaban Jun 27, 2019
be5bae5
Merge pull request #4 from nventive/dev/jela/wasm-linking
jeromelaban Jun 27, 2019
de20c82
Add support for sk_shader_new_two_point_conical_gradient
jeromelaban Jun 30, 2019
1022645
Merge pull request #5 from unoplatform/dev/jela/wasm-linking
jeromelaban Jun 30, 2019
d1b6b92
Remove listview workaround
jeromelaban Jul 3, 2019
de50678
Update to fix splashscreen flicker
jeromelaban Jul 3, 2019
5bcbeaf
Merge branch 'uno' into dev/jela/updates
jeromelaban Jul 3, 2019
56e2b72
Merge pull request #6 from unoplatform/dev/jela/updates
jeromelaban Jul 3, 2019
ef27dac
Hide the command bar
jeromelaban Jul 3, 2019
7792f37
Merge pull request #7 from unoplatform/dev/jela/updates
jeromelaban Jul 3, 2019
8cc45a6
Add support for SKXamlCanvas.CanvasSize property
jeromelaban Jul 4, 2019
c3864f3
Add support for multiple native methods.
jeromelaban Jul 4, 2019
971da61
Restore working samples
jeromelaban Jul 4, 2019
07109f5
Merge pull request #8 from unoplatform/dev/jela/misc
jeromelaban Jul 4, 2019
c3b56ae
Adjust DPI support
jeromelaban Jul 8, 2019
1f9c4d9
Update to uno latest for DPI fixes
jeromelaban Jul 9, 2019
9903725
Update to uno latest for DPI fixes (#9)
ghuntley Jul 10, 2019
898353b
[Wasm] Fix support for sk_path_arc_to and sk_path_rarc_to
jeromelaban Aug 28, 2019
8290854
Merge pull request #10 from unoplatform/dev/jela/misc
jeromelaban Aug 28, 2019
21c712d
Fix sk_path_add_circle signature
jeromelaban Aug 29, 2019
e2f684e
Merge pull request #11 from unoplatform/dev/jela/misc
jeromelaban Aug 29, 2019
123d033
Merge from SkiaSharp master
jeromelaban Sep 30, 2019
bdf3fba
Wasm adjustments resulting of merge from master
jeromelaban Oct 1, 2019
2e159b7
Enable UI Tests
jeromelaban Oct 1, 2019
be541d2
Update screenshot method
jeromelaban Oct 2, 2019
b5aa860
Add gitpod support
jeromelaban Oct 2, 2019
1e948a0
Update for gitpod
jeromelaban Oct 2, 2019
4fdeebb
Adjust filename
jeromelaban Oct 2, 2019
e783983
Merge pull request #13 from unoplatform/dev/jela/merge-master
jeromelaban Oct 2, 2019
5fc2e86
BREAKING CHANGE: Update Uno.Wasm.Bootstrap to 1.1 for static linking
jeromelaban Feb 6, 2020
da314ee
Adjust emscripten version, fail linux fast
jeromelaban Feb 6, 2020
e9233ab
Merge pull request #15 from unoplatform/dev/jela/static-linking
jeromelaban Feb 6, 2020
e50ba66
Fix draw_line, draw_point, draw_circle
jeromelaban Feb 17, 2020
585e56c
Merge pull request #16 from unoplatform/dev/jela/misc-fixes
jeromelaban Feb 17, 2020
bb67570
fix: Dangling pointer in SKXamlCanvas after Unload
jeromelaban Mar 13, 2020
8d6e77b
Update gitversion
jeromelaban Mar 13, 2020
04c7658
Merge pull request #17 from unoplatform/dev/jela/misc-fixes
jeromelaban Mar 13, 2020
dd3e2a8
Merge from mono/skiasharp/develop
jeromelaban Apr 29, 2020
b721460
adjust wasm samples location
jeromelaban Apr 29, 2020
3c712eb
adjust sample
jeromelaban Apr 29, 2020
6f256c2
Update skia to latest xamarin-develop
jeromelaban Apr 29, 2020
f3ed814
ci: Build skia from submodule
jeromelaban Apr 29, 2020
f4550c6
fix: Adjust SKAbstractManagedStream to use IntPtr instead of void*
jeromelaban Apr 29, 2020
655e600
feat: Use libSkiaSharp.a
jeromelaban Apr 29, 2020
2f1ace1
Update skia module to latest
jeromelaban Apr 29, 2020
31ee0c0
Merge from origin/uno
jeromelaban Apr 30, 2020
6430ce4
chore: Adjust versions
jeromelaban Apr 30, 2020
52bf37d
Merge pull request #18 from unoplatform/dev/jela/m80
jeromelaban Apr 30, 2020
7130ed4
fix: Update the Was.Bootstrapper to fix a memory corruption issue
jeromelaban May 6, 2020
574119f
Merge pull request #20 from unoplatform/dev/jela/bootstrap-update
jeromelaban May 6, 2020
1d90dd1
fix: Restore disabled CPU shaders
jeromelaban May 12, 2020
7248979
Merge pull request #21 from unoplatform/dev/jela/cpu-shaders
jeromelaban May 12, 2020
653bcd4
Update versions for m84
mattleibow Jun 5, 2020
5274851
Revert "Update versions for m84"
mattleibow Jun 5, 2020
f20b6d8
feat(macOS): Add initial support for macOS
MartinZikmund Jun 5, 2020
405ca2a
chore: macOS only
MartinZikmund Jun 5, 2020
4b755b1
Merge pull request #22 from MartinZikmund/dev/mazi/macos-support
jeromelaban Jun 6, 2020
26ed7a7
Merge remote-tracking branch 'origin/master' into develop
mattleibow Jun 6, 2020
d04b610
Merge remote-tracking branch 'origin/master' into develop
mattleibow Jun 6, 2020
c05fc06
merge from mono/develop
jeromelaban Jun 8, 2020
ef65d2f
chore: Adjust wasm sample to use C# 8.0
jeromelaban Jun 9, 2020
46cda62
Merge pull request #23 from unoplatform/dev/jela/merge-mono
jeromelaban Jun 9, 2020
b0226b0
Merge branch 'master' into develop
mattleibow Jun 10, 2020
5da9671
Merge remote-tracking branch 'origin/master' into develop
mattleibow Jun 10, 2020
1f71333
Merge branch 'master' into develop
mattleibow Jun 10, 2020
0a13eba
Merge branch 'master' into dev/update
mattleibow Jun 11, 2020
b29c822
reduce diff
mattleibow Jun 11, 2020
4009e5c
Start merge
mattleibow Jun 12, 2020
03c3275
split project
mattleibow Jun 12, 2020
37aba42
More things
mattleibow Jun 12, 2020
8e2b785
native
mattleibow Jun 13, 2020
b0f4edf
remove old scipts
mattleibow Jun 13, 2020
5571fb9
more things
mattleibow Jun 13, 2020
a1e8dc5
basic sample
mattleibow Jun 13, 2020
dab2786
remove more things
mattleibow Jun 13, 2020
04135f6
Try building WASM on CI
mattleibow Jun 13, 2020
4b204a3
Better startup script
mattleibow Jun 13, 2020
ccf6501
don't install if we aren't going to use it
mattleibow Jun 13, 2020
5d7529b
More things
mattleibow Jun 14, 2020
143277c
More changes
mattleibow Jun 14, 2020
fe66112
Use a plain string
mattleibow Jun 14, 2020
506bf1f
Work
mattleibow Jun 14, 2020
ef386fd
Test other platforms
mattleibow Jun 14, 2020
dd620b2
Remove unused things
mattleibow Jun 14, 2020
eafa0ea
Wasm -> Uno
mattleibow Jun 14, 2020
8402e0d
Build WASM everywhere
mattleibow Jun 14, 2020
4707b7e
Skip the copy
mattleibow Jun 14, 2020
3f7cfe2
SkiaSharp.Views.Uno NuGet
mattleibow Jun 14, 2020
0bdc9e3
build everything
mattleibow Jun 14, 2020
143f3ff
Update azure-pipelines.yml
mattleibow Jun 15, 2020
c2354b7
Not needed anymore
mattleibow Jun 15, 2020
49fdca2
stuff
mattleibow Jun 15, 2020
004114b
Use the Uno.UI assemblies
mattleibow Jun 15, 2020
663d612
Fix the links
mattleibow Jun 15, 2020
f9343d0
Fix the gallery sample
mattleibow Jun 15, 2020
356af0e
revert samples
mattleibow Jun 15, 2020
e30f913
things
mattleibow Jun 15, 2020
1c7ca4d
Fix path samples
mattleibow Jun 15, 2020
d8c6635
VS is not showing those files...
mattleibow Jun 15, 2020
b55811d
New assets
mattleibow Jun 15, 2020
60bbd91
reduce code diff
mattleibow Jun 15, 2020
e0d24c1
duplicate for better changes
mattleibow Jun 15, 2020
b549ab0
Better linker
mattleibow Jun 15, 2020
5dd0227
Closer
mattleibow Jun 15, 2020
52a7e13
Merge branch 'master' into develop
mattleibow Jun 18, 2020
9baa9a3
Merge branch 'master' into dev/wasm
mattleibow Jun 18, 2020
d3260c2
No more skippies
mattleibow Jun 18, 2020
0496e0a
Merge remote-tracking branch 'origin/master' into develop
mattleibow Jun 24, 2020
ad9da80
Merge branch 'master' into dev/wasm
mattleibow Jun 24, 2020
a4579a8
Merge branch 'develop' into dev/wasm
mattleibow Jun 24, 2020
c475fef
Merge branch 'master' into develop
mattleibow Jun 27, 2020
f8cc880
Merge branch 'develop' into dev/wasm
mattleibow Jun 27, 2020
74a2137
Merge branch 'master' into dev/wasm
mattleibow Jun 28, 2020
73ab060
Merge branch 'master' into develop
mattleibow Jul 1, 2020
d9e7d28
Merge branch 'master' into develop
mattleibow Jul 9, 2020
4479d9c
Merge branch 'master' into dev/wasm
mattleibow Jul 9, 2020
7313e99
Merge branch 'develop' into dev/wasm
mattleibow Jul 9, 2020
38d1d05
Add a quick build script
mattleibow Jul 9, 2020
105cc85
Merge branch 'master' into develop
mattleibow Jul 14, 2020
61e3cb7
Merge branch 'develop' into dev/wasm
mattleibow Jul 14, 2020
05dd329
Make it build
mattleibow Jul 14, 2020
e3f1be7
Things
mattleibow Jul 14, 2020
a2d590f
More things
mattleibow Jul 14, 2020
d2e9f15
remove gallery for now
mattleibow Jul 14, 2020
fdae93e
From WSL
mattleibow Jul 14, 2020
f5ca1e0
Make it all work
mattleibow Jul 14, 2020
3caf79f
Don't build native now...
mattleibow Jul 14, 2020
f8bd479
Clean up a few lines
mattleibow Jul 14, 2020
439fb83
Mapped all the callback delegates
mattleibow Jul 15, 2020
99a7aa8
The big sample with everything
mattleibow Jul 15, 2020
a099cb8
Adding the gallery back
mattleibow Jul 15, 2020
8095b58
Merge branch 'master' into develop
mattleibow Jul 15, 2020
36eba74
Merge branch 'develop' into dev/wasm
mattleibow Jul 15, 2020
6a7bfce
Using JS const strings
mattleibow Jul 15, 2020
e0a5581
Everything still works
mattleibow Jul 15, 2020
5fa0213
Merge branch 'master' into develop
mattleibow Jul 16, 2020
bbe652b
No more hacks!
mattleibow Jul 16, 2020
7d27068
Merge remote-tracking branch 'origin/develop' into dev/wasm
mattleibow Jul 16, 2020
ae66e43
Gallery
mattleibow Jul 16, 2020
d64963d
things
mattleibow Jul 16, 2020
8c49a05
good night
mattleibow Jul 16, 2020
6e17770
use the interpreter for speedier builds
mattleibow Jul 16, 2020
0393773
remove old delegates
mattleibow Jul 16, 2020
7188d48
samples
mattleibow Jul 16, 2020
10e3386
more
mattleibow Jul 16, 2020
e3146c9
sample
mattleibow Jul 16, 2020
cf55735
add dng and pdf support
mattleibow Jul 16, 2020
43cf6f8
drop DNG for now
mattleibow Jul 16, 2020
f75fce7
Things
mattleibow Jul 16, 2020
a9974f0
Merge branch 'dev/wasm' of github.com:mono/SkiaSharp into dev/wasm
mattleibow Jul 16, 2020
9fad12c
warnings
mattleibow Jul 16, 2020
816e6b7
Fixing the build
mattleibow Jul 16, 2020
806dc91
Merge branch 'master' into develop
mattleibow Jul 16, 2020
e7429fe
Merge branch 'develop' into dev/wasm
mattleibow Jul 16, 2020
b5fad57
Oops
mattleibow Jul 16, 2020
73f8755
Things
mattleibow Jul 17, 2020
e969c49
updates
mattleibow Jul 17, 2020
ea99055
Logs
mattleibow Jul 17, 2020
965a284
Changes
mattleibow Jul 18, 2020
d4ba94d
Fix things
mattleibow Jul 18, 2020
d21bafa
dsafasdasfdsdaffd
mattleibow Jul 18, 2020
0ec9626
vmImage
mattleibow Jul 18, 2020
ec64a6b
yaml
mattleibow Jul 18, 2020
0934adc
Add GPU views just in case
mattleibow Jul 18, 2020
e313773
Merge branch 'master' into dev/wasm
mattleibow Jul 19, 2020
635a826
Merge remote-tracking branch 'origin/master' into dev/wasm
mattleibow Jul 20, 2020
4ebe1c1
No more SkiaSharp.Wasm! Use netstandard!
mattleibow Jul 20, 2020
7c66c13
the nugets
mattleibow Jul 20, 2020
ec94f36
fixes
mattleibow Jul 20, 2020
692c54a
remove this for now
mattleibow Jul 20, 2020
bc0a6a7
No fancy things needed
mattleibow Jul 20, 2020
6ae7946
final things
mattleibow Jul 20, 2020
ac7a1c6
deps
mattleibow Jul 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)

# Code files
[*.{cs,csx,vb,vbx}]
[*.{cs,csx,vb,vbx,ts}]
indent_style = tab
indent_size = 4
insert_final_newline = true
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ SkiaSharp provides cross-platform bindings for:
- Xamarin.Mac
- Windows Classic Desktop (Windows.Forms / WPF)
- Windows UWP (Desktop / Mobile / Xbox / HoloLens)
- Web Assembly (WASM)

The [API Documentation](https://docs.microsoft.com/en-us/dotnet/api/SkiaSharp/) is
available on the web to browse.
Expand Down
3 changes: 3 additions & 0 deletions VERSIONS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ AtkSharp release 3.22.24.37
System.Memory release 4.5.3
System.IO.UnmanagedMemoryStream release 4.3.0
SharpVk release 0.4.2
Uno.UI release 2.0.532

# additional references used by the tooling
OpenTK.GLControl reference 1.1.2349.61993
Expand Down Expand Up @@ -50,8 +51,10 @@ SkiaSharp.Views.WPF nuget 2.80.0
SkiaSharp.Views.Forms nuget 2.80.0
SkiaSharp.Views.Forms.WPF nuget 2.80.0
SkiaSharp.Views.Forms.GTK nuget 2.80.0
SkiaSharp.Views.Uno nuget 2.80.0
SkiaSharp.HarfBuzz nuget 2.80.0
SkiaSharp.Vulkan.SharpVk nuget 2.80.0
SkiaSharp.WebAssembly nuget 2.80.0
HarfBuzzSharp nuget 2.6.1.5
HarfBuzzSharp.NativeAssets.Linux nuget 2.6.1.5

Expand Down
100 changes: 100 additions & 0 deletions binding/Binding/SKAbstractManagedStream.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
#if __WASM__
using System.Globalization;
using System.Linq;
#else
using System.Runtime.InteropServices;
#endif
using System.Threading;

namespace SkiaSharp
Expand All @@ -12,6 +17,49 @@ public unsafe abstract class SKAbstractManagedStream : SKStreamAsset

static SKAbstractManagedStream ()
{
#if __WASM__
const string js =
"SkiaSharp.SkiaApi.bindMembers('[SkiaSharp] SkiaSharp.SKAbstractManagedStream', {" +
" 'ReadInternal': 'iiiii'," +
" 'PeekInternal': 'iiiii'," +
" 'IsAtEndInternal': 'iii'," +
" 'HasPositionInternal': 'iii'," +
" 'HasLengthInternal': 'iii'," +
" 'RewindInternal': 'iii'," +
" 'GetPositionInternal': 'iii'," +
" 'SeekInternal': 'iiii'," +
" 'MoveInternal': 'iiii'," +
" 'GetLengthInternal': 'iii'," +
" 'DuplicateInternal': 'iii'," +
" 'ForkInternal': 'iii'," +
" 'DestroyInternal': 'vii'," +
"});";
const int expected = 13;

var ret = WebAssembly.Runtime.InvokeJS (js);
var funcs = ret.Split (new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
.Select (f => (IntPtr)int.Parse (f, CultureInfo.InvariantCulture))
.ToArray ();

if (funcs.Length != expected)
throw new InvalidOperationException ($"Mismatch when binding 'SkiaSharp.SKAbstractManagedStream' members. Returned {funcs.Length}, expected {expected}.");

// we can do magic with variables
var ReadInternal = funcs[0];
var PeekInternal = funcs[1];
var IsAtEndInternal = funcs[2];
var HasPositionInternal = funcs[3];
var HasLengthInternal = funcs[4];
var RewindInternal = funcs[5];
var GetPositionInternal = funcs[6];
var SeekInternal = funcs[7];
var MoveInternal = funcs[8];
var GetLengthInternal = funcs[9];
var DuplicateInternal = funcs[10];
var ForkInternal = funcs[11];
var DestroyInternal = funcs[12];
#endif

delegates = new SKManagedStreamDelegates {
fRead = ReadInternal,
fPeek = PeekInternal,
Expand Down Expand Up @@ -83,91 +131,143 @@ protected virtual IntPtr OnFork ()
protected virtual IntPtr OnDuplicate () => OnCreateNew ();

[MonoPInvokeCallback (typeof (SKManagedStreamReadProxyDelegate))]
#if __WASM__
private static IntPtr ReadInternal (IntPtr s, IntPtr context, IntPtr buffer, IntPtr size)
#else
private static IntPtr ReadInternal (IntPtr s, void* context, void* buffer, IntPtr size)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnRead ((IntPtr)buffer, size);
}

[MonoPInvokeCallback (typeof (SKManagedStreamPeekProxyDelegate))]
#if __WASM__
private static IntPtr PeekInternal (IntPtr s, IntPtr context, IntPtr buffer, IntPtr size)
#else
private static IntPtr PeekInternal (IntPtr s, void* context, void* buffer, IntPtr size)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnPeek ((IntPtr)buffer, size);
}

[MonoPInvokeCallback (typeof (SKManagedStreamIsAtEndProxyDelegate))]
#if __WASM__
private static bool IsAtEndInternal (IntPtr s, IntPtr context)
#else
private static bool IsAtEndInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnIsAtEnd ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamHasPositionProxyDelegate))]
#if __WASM__
private static bool HasPositionInternal (IntPtr s, IntPtr context)
#else
private static bool HasPositionInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnHasPosition ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamHasLengthProxyDelegate))]
#if __WASM__
private static bool HasLengthInternal (IntPtr s, IntPtr context)
#else
private static bool HasLengthInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnHasLength ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamRewindProxyDelegate))]
#if __WASM__
private static bool RewindInternal (IntPtr s, IntPtr context)
#else
private static bool RewindInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnRewind ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamGetPositionProxyDelegate))]
#if __WASM__
private static IntPtr GetPositionInternal (IntPtr s, IntPtr context)
#else
private static IntPtr GetPositionInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnGetPosition ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamSeekProxyDelegate))]
#if __WASM__
private static bool SeekInternal (IntPtr s, IntPtr context, IntPtr position)
#else
private static bool SeekInternal (IntPtr s, void* context, IntPtr position)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnSeek (position);
}

[MonoPInvokeCallback (typeof (SKManagedStreamMoveProxyDelegate))]
#if __WASM__
private static bool MoveInternal (IntPtr s, IntPtr context, int offset)
#else
private static bool MoveInternal (IntPtr s, void* context, int offset)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnMove (offset);
}

[MonoPInvokeCallback (typeof (SKManagedStreamGetLengthProxyDelegate))]
#if __WASM__
private static IntPtr GetLengthInternal (IntPtr s, IntPtr context)
#else
private static IntPtr GetLengthInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnGetLength ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamDuplicateProxyDelegate))]
#if __WASM__
private static IntPtr DuplicateInternal (IntPtr s, IntPtr context)
#else
private static IntPtr DuplicateInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnDuplicate ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamForkProxyDelegate))]
#if __WASM__
private static IntPtr ForkInternal (IntPtr s, IntPtr context)
#else
private static IntPtr ForkInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out _);
return stream.OnFork ();
}

[MonoPInvokeCallback (typeof (SKManagedStreamDestroyProxyDelegate))]
#if __WASM__
private static void DestroyInternal (IntPtr s, IntPtr context)
#else
private static void DestroyInternal (IntPtr s, void* context)
#endif
{
var stream = DelegateProxies.GetUserData<SKAbstractManagedStream> ((IntPtr)context, out var gch);
if (stream != null) {
Expand Down
2 changes: 2 additions & 0 deletions binding/Binding/SkiaApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ internal partial class SkiaApi
private const string SKIA = "libSkiaSharp.dll";
#elif NET_STANDARD
private const string SKIA = "libSkiaSharp";
#elif __WASM__
private const string SKIA = "libSkiaSharp";
#else
private const string SKIA = "libSkiaSharp";
#endif
Expand Down
52 changes: 52 additions & 0 deletions binding/Binding/SkiaApi.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5262,43 +5262,95 @@ public readonly override int GetHashCode ()
[StructLayout (LayoutKind.Sequential)]
internal unsafe partial struct SKManagedStreamDelegates : IEquatable<SKManagedStreamDelegates> {
// public sk_managedstream_read_proc fRead
#if __WASM__
public IntPtr fRead;
#else
public SKManagedStreamReadProxyDelegate fRead;
#endif

// public sk_managedstream_peek_proc fPeek
#if __WASM__
public IntPtr fPeek;
#else
public SKManagedStreamPeekProxyDelegate fPeek;
#endif

// public sk_managedstream_isAtEnd_proc fIsAtEnd
#if __WASM__
public IntPtr fIsAtEnd;
#else
public SKManagedStreamIsAtEndProxyDelegate fIsAtEnd;
#endif

// public sk_managedstream_hasPosition_proc fHasPosition
#if __WASM__
public IntPtr fHasPosition;
#else
public SKManagedStreamHasPositionProxyDelegate fHasPosition;
#endif

// public sk_managedstream_hasLength_proc fHasLength
#if __WASM__
public IntPtr fHasLength;
#else
public SKManagedStreamHasLengthProxyDelegate fHasLength;
#endif

// public sk_managedstream_rewind_proc fRewind
#if __WASM__
public IntPtr fRewind;
#else
public SKManagedStreamRewindProxyDelegate fRewind;
#endif

// public sk_managedstream_getPosition_proc fGetPosition
#if __WASM__
public IntPtr fGetPosition;
#else
public SKManagedStreamGetPositionProxyDelegate fGetPosition;
#endif

// public sk_managedstream_seek_proc fSeek
#if __WASM__
public IntPtr fSeek;
#else
public SKManagedStreamSeekProxyDelegate fSeek;
#endif

// public sk_managedstream_move_proc fMove
#if __WASM__
public IntPtr fMove;
#else
public SKManagedStreamMoveProxyDelegate fMove;
#endif

// public sk_managedstream_getLength_proc fGetLength
#if __WASM__
public IntPtr fGetLength;
#else
public SKManagedStreamGetLengthProxyDelegate fGetLength;
#endif

// public sk_managedstream_duplicate_proc fDuplicate
#if __WASM__
public IntPtr fDuplicate;
#else
public SKManagedStreamDuplicateProxyDelegate fDuplicate;
#endif

// public sk_managedstream_fork_proc fFork
#if __WASM__
public IntPtr fFork;
#else
public SKManagedStreamForkProxyDelegate fFork;
#endif

// public sk_managedstream_destroy_proc fDestroy
#if __WASM__
public IntPtr fDestroy;
#else
public SKManagedStreamDestroyProxyDelegate fDestroy;
#endif

public readonly bool Equals (SKManagedStreamDelegates obj) =>
fRead == obj.fRead && fPeek == obj.fPeek && fIsAtEnd == obj.fIsAtEnd && fHasPosition == obj.fHasPosition && fHasLength == obj.fHasLength && fRewind == obj.fRewind && fGetPosition == obj.fGetPosition && fSeek == obj.fSeek && fMove == obj.fMove && fGetLength == obj.fGetLength && fDuplicate == obj.fDuplicate && fFork == obj.fFork && fDestroy == obj.fDestroy;
Expand Down
3 changes: 3 additions & 0 deletions binding/SkiaSharp.Wasm/LinkerDefinition.Wasm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<linker>
<assembly fullname="SkiaSharp" />
</linker>
36 changes: 36 additions & 0 deletions binding/SkiaSharp.Wasm/SkiaSharp.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>SkiaSharp</RootNamespace>
<AssemblyName>SkiaSharp</AssemblyName>
<PackagingGroup>SkiaSharp.WebAssembly</PackagingGroup>
<DefineConstants>$(DefineConstants);__WASM__</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="Microsoft.TypeScript.Compiler" Version="3.1.5" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.9.5" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\output\native\wasm\libSkiaSharp.a" Link="nuget\build\$(PackagingPlatform)\libSkiaSharp.a" />
<None Include="nuget\build\wasm\SkiaSharp.props" Link="nuget\build\$(PackagingPlatform)\SkiaSharp.WebAssembly.props" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Binding.Shared\**\*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Include="..\Binding\**\*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Include="WebAssembly.Runtime.cs" />
</ItemGroup>
<ItemGroup>
<None Remove="LinkerDefinition.Wasm.xml" />
<EmbeddedResource Include="LinkerDefinition.Wasm.xml" LogicalName="$(AssemblyName).xml" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Remove="WasmScripts\**\*" />
<TypeScriptCompile Include="ts\tsconfig.json" />
<TypeScriptCompile Include="..\..\externals\typescript\**\*.ts" Link="ts\%(RecursiveDir)%(Filename)%(Extension)" />
<TypeScriptCompile Include="ts\**\*.ts" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmScripts\*.js" />
</ItemGroup>
</Project>
Loading