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

[Skia][Wasm] Missing methods in current Skia implementation #1131

Closed
11 of 23 tasks
jeromelaban opened this issue Jun 25, 2019 · 3 comments
Closed
11 of 23 tasks

[Skia][Wasm] Missing methods in current Skia implementation #1131

jeromelaban opened this issue Jun 25, 2019 · 3 comments
Labels
kind/enhancement New feature or request platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform project/third-party 3️⃣ Categorizes an issue or PR as relevant to 3rd party libraries

Comments

@jeromelaban
Copy link
Member

jeromelaban commented Jun 25, 2019

Description

Mono provides two ways for interoperating with native WebAssembly: Dynamic Linking for interpreter-only builds and Static Linking for AOT enabled builds.

Static linking is currently not working, and is being tracked by this issue [link].

Dynamic linking relies on a generated table of method invocations, to give the ability to invoke wasm methods, which the signatures must be known in advance.

Problem

The list of methods used by SkiaSharp to interop with the C++ Skia API contains signatures that are not provided by this mono file. Modifiying this file to add missing signatures is currently not an option because of this emscripten issue: emscripten-core/emscripten#8770, which breaks the compilation of the release-dynamic runtime configuration in mono,

Workaround

The workaround consist in adjusting the signatures of the Skia API to match known signatures of the m2n wrapper, and transform parameters into structures if no signature adjustment is possible.

Methods to adjust

Signatures to transform into structures

  • FIIII :
    System.Single SkiaSharp.SkiaApi::sk_paint_measure_text(System.IntPtr,System.IntPtr,System.IntPtr,SkiaSharp.SKRect&)
  • FIIII :
    System.Single SkiaSharp.SkiaApi::sk_paint_measure_text(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr)
  • FIIF :
    System.Single SkiaSharp.SkiaApi::sk_paint_get_fontmetrics(System.IntPtr,SkiaSharp.SKFontMetrics&,System.Single)
  • FIIF :
    System.Single SkiaSharp.SkiaApi::sk_paint_get_fontmetrics(System.IntPtr,System.IntPtr,System.Single)
  • VIFFFIIFF :
    System.Void SkiaSharp.SkiaApi::sk_path_arc_to(System.IntPtr,System.Single,System.Single,System.Single,SkiaSharp.SKPathArcSize,SkiaSharp.SKPathDirection,System.Single,System.Single)
  • VIFFFIIFF :
    System.Void SkiaSharp.SkiaApi::sk_path_rarc_to(System.IntPtr,System.Single,System.Single,System.Single,SkiaSharp.SKPathArcSize,SkiaSharp.SKPathDirection,System.Single,System.Single)
  • IFFFFIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_imagefilter_new_drop_shadow(System.Single,System.Single,System.Single,System.Single,System.UInt32,SkiaSharp.SKDropShadowImageFilterShadowMode,System.IntPtr,System.IntPtr)
  • IFFFFIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_imagefilter_new_arithmetic(System.Single,System.Single,System.Single,System.Single,System.Boolean,System.IntPtr,System.IntPtr,System.IntPtr)
  • IIFIFIIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_shader_new_two_point_conical_gradient(SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKColor[],System.Single[],System.Int32,SkiaSharp.SKShaderTileMode,SkiaSharp.SKMatrix&)
  • IIFIFIIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_shader_new_two_point_conical_gradient(SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKColor[],System.Single[],System.Int32,SkiaSharp.SKShaderTileMode,System.IntPtr)
  • IIFIFIIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_shader_new_two_point_conical_gradient(SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKColor[],System.IntPtr,System.Int32,SkiaSharp.SKShaderTileMode,SkiaSharp.SKMatrix&)
  • IIFIFIIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_shader_new_two_point_conical_gradient(SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKPoint&,System.Single,SkiaSharp.SKColor[],System.IntPtr,System.Int32,SkiaSharp.SKShaderTileMode,System.IntPtr)
  • IIIFFFII :
    System.IntPtr SkiaSharp.SkiaApi::sk_imagefilter_new_distant_lit_specular(SkiaSharp.SKPoint3&,System.UInt32,System.Single,System.Single,System.Single,System.IntPtr,System.IntPtr)
  • IIIFFFII :
    System.IntPtr SkiaSharp.SkiaApi::sk_imagefilter_new_point_lit_specular(SkiaSharp.SKPoint3&,System.UInt32,System.Single,System.Single,System.Single,System.IntPtr,System.IntPtr)
  • FIII :
    System.Single SkiaSharp.SkiaApi::sk_matrix44_get(System.IntPtr,System.Int32,System.Int32)
  • IIIFFIFFFII :
    System.IntPtr SkiaSharp.SkiaApi::sk_imagefilter_new_spot_lit_specular(SkiaSharp.SKPoint3&,SkiaSharp.SKPoint3&,System.Single,System.Single,System.UInt32,System.Single,System.Single,System.Single,System.IntPtr,System.IntPtr)
  • IIIFFIIIII :
    System.IntPtr SkiaSharp.SkiaApi::sk_imagefilter_new_matrix_convolution(SkiaSharp.SKSizeI&,System.Single[],System.Single,System.Single,SkiaSharp.SKPointI&,SkiaSharp.SKMatrixConvolutionTileMode,System.Boolean,System.IntPtr,System.IntPtr)
  • FIFFF :
    System.Single SkiaSharp.SkiaApi::sk_3dview_dot_with_normal(System.IntPtr,System.Single,System.Single,System.Single)
  • VIIIFFIIII :
    System.Void SkiaSharp.SkiaApi::sk_textblob_builder_alloc_run_text(System.IntPtr,System.IntPtr,System.Int32,System.Single,System.Single,System.Int32,System.IntPtr,SkiaSharp.SKRect*,SkiaSharp.SKTextBlobBuilderRunBuffer&)
  • VIIIFIIII :
    System.Void SkiaSharp.SkiaApi::sk_textblob_builder_alloc_run_text_pos_h(System.IntPtr,System.IntPtr,System.Int32,System.Single,System.Int32,System.IntPtr,SkiaSharp.SKRect*,SkiaSharp.SKTextBlobBuilderRunBuffer&)

Object based signatures

  • IIIO :
    System.Boolean SkiaSharp.SkiaApi::sk_webpencoder_encode(System.IntPtr,System.IntPtr,SkiaSharp.SKWebpEncoderOptions)
  • IIIO :
    System.Boolean SkiaSharp.SkiaApi::sk_jpegencoder_encode(System.IntPtr,System.IntPtr,SkiaSharp.SKJpegEncoderOptions)
  • IIIO :
    System.Boolean SkiaSharp.SkiaApi::sk_pngencoder_encode(System.IntPtr,System.IntPtr,SkiaSharp.SKPngEncoderOptions)
@jeromelaban jeromelaban added kind/enhancement New feature or request platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform labels Jun 25, 2019
@gritsenko
Copy link

sk_paint_measure_text and sk_pngencoder_encode are pretty important also...

@jeromelaban
Copy link
Member Author

sk_paint_measure_text is now in the latest nuget package.

pngencoder has a particularity with the way parameters are passed in, it'll have to be handled differently.

@jeromelaban
Copy link
Member Author

This issue can now be closed as the support for mono has improved for those scenarios.

@agneszitte agneszitte added the project/third-party 3️⃣ Categorizes an issue or PR as relevant to 3rd party libraries label Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform project/third-party 3️⃣ Categorizes an issue or PR as relevant to 3rd party libraries
Projects
None yet
Development

No branches or pull requests

3 participants