Browse Source

Added explicit CallingConvention.Cdecl to fix stack imbalance on Windows

Marcin Ziąbek 1 year ago
parent
commit
3487b1caef

+ 5 - 5
Source/QuestPDF/Skia/SkBitmap.cs

@@ -47,19 +47,19 @@ internal sealed class SkBitmap : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr bitmap_create(int width, int height);
         public static extern IntPtr bitmap_create(int width, int height);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void bitmap_delete(IntPtr image);
         public static extern void bitmap_delete(IntPtr image);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr bitmap_encode_as_jpg(IntPtr image, int quality);
         public static extern IntPtr bitmap_encode_as_jpg(IntPtr image, int quality);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr bitmap_encode_as_png(IntPtr image);
         public static extern IntPtr bitmap_encode_as_png(IntPtr image);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr bitmap_encode_as_webp(IntPtr image, int quality);
         public static extern IntPtr bitmap_encode_as_webp(IntPtr image, int quality);
     }
     }
 }
 }

+ 21 - 21
Source/QuestPDF/Skia/SkCanvas.cs

@@ -148,67 +148,67 @@ internal sealed class SkCanvas : IDisposable
 
 
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr canvas_create_from_bitmap(IntPtr bitmap);
         public static extern IntPtr canvas_create_from_bitmap(IntPtr bitmap);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_delete(IntPtr canvas);
         public static extern void canvas_delete(IntPtr canvas);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_save(IntPtr canvas);
         public static extern void canvas_save(IntPtr canvas);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_restore(IntPtr canvas);
         public static extern void canvas_restore(IntPtr canvas);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_translate(IntPtr canvas, float x, float y);
         public static extern void canvas_translate(IntPtr canvas, float x, float y);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_rotate(IntPtr canvas, float angle);
         public static extern void canvas_rotate(IntPtr canvas, float angle);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_scale(IntPtr canvas, float factorX, float factorY);
         public static extern void canvas_scale(IntPtr canvas, float factorX, float factorY);
 
 
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_image(IntPtr canvas, IntPtr image, float width, float height);
         public static extern void canvas_draw_image(IntPtr canvas, IntPtr image, float width, float height);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_picture(IntPtr canvas, IntPtr picture);
         public static extern void canvas_draw_picture(IntPtr canvas, IntPtr picture);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_filled_rectangle(IntPtr canvas, SkRect position, uint color);
         public static extern void canvas_draw_filled_rectangle(IntPtr canvas, SkRect position, uint color);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_stroke_rectangle(IntPtr canvas, SkRect position, float strokeWidth, uint color);
         public static extern void canvas_draw_stroke_rectangle(IntPtr canvas, SkRect position, float strokeWidth, uint color);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_paragraph(IntPtr canvas, IntPtr paragraph);
         public static extern void canvas_draw_paragraph(IntPtr canvas, IntPtr paragraph);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_svg_path(IntPtr canvas, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string svg, uint color);
         public static extern void canvas_draw_svg_path(IntPtr canvas, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string svg, uint color);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_svg(IntPtr canvas, IntPtr svg, float width, float height);
         public static extern void canvas_draw_svg(IntPtr canvas, IntPtr svg, float width, float height);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_draw_overflow_area(IntPtr canvas, SkRect position);
         public static extern void canvas_draw_overflow_area(IntPtr canvas, SkRect position);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_clip_overflow_area(IntPtr canvas, SkRect availableSpace, SkRect requiredSpace);
         public static extern void canvas_clip_overflow_area(IntPtr canvas, SkRect availableSpace, SkRect requiredSpace);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_clip_rectangle(IntPtr canvas, SkRect clipArea);
         public static extern void canvas_clip_rectangle(IntPtr canvas, SkRect clipArea);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_annotate_url(IntPtr canvas, float width, float height, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string url);
         public static extern void canvas_annotate_url(IntPtr canvas, float width, float height, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string url);
 
 
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_annotate_destination(IntPtr canvas, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string destinationName);
         public static extern void canvas_annotate_destination(IntPtr canvas, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string destinationName);
 
 
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void canvas_annotate_destination_link(IntPtr canvas, float width, float height, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string destinationName);
         public static extern void canvas_annotate_destination_link(IntPtr canvas, float width, float height, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string destinationName);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern CanvasMatrix canvas_get_matrix(IntPtr canvas);
         public static extern CanvasMatrix canvas_get_matrix(IntPtr canvas);
     }
     }
 }
 }

+ 4 - 4
Source/QuestPDF/Skia/SkData.cs

@@ -72,10 +72,10 @@ internal sealed class SkData : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr data_create_from_file([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string path);
         public static extern IntPtr data_create_from_file([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string path);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern unsafe IntPtr data_create_from_binary(byte* arrayPointer, int arrayLength);
         public static extern unsafe IntPtr data_create_from_binary(byte* arrayPointer, int arrayLength);
     
     
         [StructLayout(LayoutKind.Sequential)]
         [StructLayout(LayoutKind.Sequential)]
@@ -85,10 +85,10 @@ internal sealed class SkData : IDisposable
             public IntPtr bytes;
             public IntPtr bytes;
         }
         }
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern GetBytesFromDataResult data_get_bytes(IntPtr data);
         public static extern GetBytesFromDataResult data_get_bytes(IntPtr data);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void data_unref(IntPtr data);
         public static extern void data_unref(IntPtr data);
     }
     }
 }
 }

+ 4 - 4
Source/QuestPDF/Skia/SkDocument.cs

@@ -45,16 +45,16 @@ internal sealed class SkDocument : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr document_begin_page(IntPtr document, float width, float height);
         public static extern IntPtr document_begin_page(IntPtr document, float width, float height);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void document_end_page(IntPtr document);
         public static extern void document_end_page(IntPtr document);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void document_close(IntPtr document);
         public static extern void document_close(IntPtr document);
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void document_unref(IntPtr document);
         public static extern void document_unref(IntPtr document);
     }
     }
 }
 }

+ 6 - 6
Source/QuestPDF/Skia/SkImage.cs

@@ -73,13 +73,13 @@ internal sealed class SkImage : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr image_create_from_data(IntPtr data);
         public static extern IntPtr image_create_from_data(IntPtr data);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void image_unref(IntPtr image);
         public static extern void image_unref(IntPtr image);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr image_resize_and_compress(IntPtr image, int targetImageWidth, int targetImageHeight, int compressionQuality);
         public static extern IntPtr image_resize_and_compress(IntPtr image, int targetImageWidth, int targetImageHeight, int compressionQuality);
 
 
         [StructLayout(LayoutKind.Sequential)]
         [StructLayout(LayoutKind.Sequential)]
@@ -90,13 +90,13 @@ internal sealed class SkImage : IDisposable
             public int EncodedDataSize;
             public int EncodedDataSize;
         }
         }
 
 
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern SkImageDetails image_get_details(IntPtr image);
         public static extern SkImageDetails image_get_details(IntPtr image);
 
 
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr image_get_encoded_data(IntPtr image);
         public static extern IntPtr image_get_encoded_data(IntPtr image);
  
  
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr image_generate_placeholder(int imageWidth, int imageHeight, UInt32 firstColor, UInt32 secondColor);
         public static extern IntPtr image_generate_placeholder(int imageWidth, int imageHeight, UInt32 firstColor, UInt32 secondColor);
     }
     }
 }
 }

+ 1 - 1
Source/QuestPDF/Skia/SkNativeDependencyCompatibilityChecker.cs

@@ -84,7 +84,7 @@ internal static class SkNativeDependencyCompatibilityChecker
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern int check_compatibility_by_calculating_sum(int a, int b);
         public static extern int check_compatibility_by_calculating_sum(int a, int b);
     }
     }
 }
 }

+ 1 - 1
Source/QuestPDF/Skia/SkPdfDocument.cs

@@ -33,7 +33,7 @@ internal static class SkPdfDocument
 
 
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr pdf_document_create(IntPtr stream, SkPdfDocumentMetadata metadata);
         public static extern IntPtr pdf_document_create(IntPtr stream, SkPdfDocumentMetadata metadata);
     }
     }
 }
 }

+ 3 - 3
Source/QuestPDF/Skia/SkPicture.cs

@@ -41,13 +41,13 @@ internal sealed class SkPicture : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void picture_unref(IntPtr picture);
         public static extern void picture_unref(IntPtr picture);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr picture_serialize(IntPtr picture);
         public static extern IntPtr picture_serialize(IntPtr picture);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr picture_deserialize(IntPtr data);
         public static extern IntPtr picture_deserialize(IntPtr data);
     }
     }
 }
 }

+ 4 - 4
Source/QuestPDF/Skia/SkPictureRecorder.cs

@@ -41,16 +41,16 @@ internal sealed class SkPictureRecorder : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr picture_recorder_create();
         public static extern IntPtr picture_recorder_create();
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr picture_recorder_begin_recording(IntPtr pictureRecorder, float width, float height);
         public static extern IntPtr picture_recorder_begin_recording(IntPtr pictureRecorder, float width, float height);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr picture_recorder_end_recording(IntPtr pictureRecorder);
         public static extern IntPtr picture_recorder_end_recording(IntPtr pictureRecorder);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void picture_recorder_delete(IntPtr pictureRecorder);
         public static extern void picture_recorder_delete(IntPtr pictureRecorder);
     }
     }
 }
 }

+ 1 - 1
Source/QuestPDF/Skia/SkSvgCanvas.cs

@@ -14,7 +14,7 @@ internal sealed class SkSvgCanvas
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr svg_create_canvas(SkRect bounds, IntPtr writeStream);
         public static extern IntPtr svg_create_canvas(SkRect bounds, IntPtr writeStream);
     }
     }
 }
 }

+ 3 - 3
Source/QuestPDF/Skia/SkSvgImage.cs

@@ -72,13 +72,13 @@ internal sealed class SkSvgImage : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr svg_create(IntPtr data, IntPtr fontManager);
         public static extern IntPtr svg_create(IntPtr data, IntPtr fontManager);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void svg_unref(IntPtr svg);
         public static extern void svg_unref(IntPtr svg);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void svg_get_size(IntPtr svg, out SkSvgImageSize size, out SkRect viewBox);
         public static extern void svg_get_size(IntPtr svg, out SkSvgImageSize size, out SkRect viewBox);
     }
     }
 }
 }

+ 3 - 3
Source/QuestPDF/Skia/SkWriteStream.cs

@@ -35,13 +35,13 @@ internal sealed class SkWriteStream : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr write_stream_create();
         public static extern IntPtr write_stream_create();
     
     
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void write_stream_delete(IntPtr stream);
         public static extern void write_stream_delete(IntPtr stream);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr write_stream_detach_data(IntPtr stream);    
         public static extern IntPtr write_stream_detach_data(IntPtr stream);    
     }
     }
 }
 }

+ 1 - 1
Source/QuestPDF/Skia/SkXpsDocument.cs

@@ -13,7 +13,7 @@ internal static class SkXpsDocument
 
 
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr xps_document_create(IntPtr stream, float dpi);
         public static extern IntPtr xps_document_create(IntPtr stream, float dpi);
     }
     }
 }
 }

+ 2 - 2
Source/QuestPDF/Skia/Text/SkFontCollection.cs

@@ -35,10 +35,10 @@ internal sealed class SkFontCollection : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr font_collection_create(IntPtr fontManager, IntPtr typefaceProvider);
         public static extern IntPtr font_collection_create(IntPtr fontManager, IntPtr typefaceProvider);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void font_collection_unref(IntPtr fontCollection);
         public static extern void font_collection_unref(IntPtr fontCollection);
     }
     }
 }
 }

+ 3 - 3
Source/QuestPDF/Skia/Text/SkFontManager.cs

@@ -28,13 +28,13 @@ internal sealed class SkFontManager
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr font_manager_create_local(string path);
         public static extern IntPtr font_manager_create_local(string path);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr font_manager_create_global();
         public static extern IntPtr font_manager_create_global();
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr font_manager_create_typeface(IntPtr fontManager, IntPtr fontData);
         public static extern IntPtr font_manager_create_typeface(IntPtr fontManager, IntPtr fontData);
     }
     }
 }
 }

+ 6 - 6
Source/QuestPDF/Skia/Text/SkParagraph.cs

@@ -99,22 +99,22 @@ internal sealed class SkParagraph : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_plan_layout(IntPtr paragraph, float availableWidth);
         public static extern void paragraph_plan_layout(IntPtr paragraph, float availableWidth);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_get_line_metrics(IntPtr paragraph, out IntPtr array, out int arrayLength);
         public static extern void paragraph_get_line_metrics(IntPtr paragraph, out IntPtr array, out int arrayLength);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_get_unresolved_codepoints(IntPtr paragraph, out IntPtr array, out int arrayLength);
         public static extern void paragraph_get_unresolved_codepoints(IntPtr paragraph, out IntPtr array, out int arrayLength);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_get_placeholder_positions(IntPtr paragraph, out IntPtr array, out int arrayLength);
         public static extern void paragraph_get_placeholder_positions(IntPtr paragraph, out IntPtr array, out int arrayLength);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_get_text_range_positions(IntPtr paragraph, int rangeStart, int rangeEnd, out IntPtr array, out int arrayLength);
         public static extern void paragraph_get_text_range_positions(IntPtr paragraph, int rangeStart, int rangeEnd, out IntPtr array, out int arrayLength);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_delete(IntPtr paragraph);
         public static extern void paragraph_delete(IntPtr paragraph);
     }
     }
 }
 }

+ 6 - 6
Source/QuestPDF/Skia/Text/SkParagraphBuilder.cs

@@ -137,22 +137,22 @@ internal sealed class SkParagraphBuilder : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr paragraph_builder_create(ParagraphStyleConfiguration paragraphStyleConfiguration, IntPtr fontCollection);
         public static extern IntPtr paragraph_builder_create(ParagraphStyleConfiguration paragraphStyleConfiguration, IntPtr fontCollection);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_builder_add_text(IntPtr paragraphBuilder, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string text, IntPtr textStyle);
         public static extern void paragraph_builder_add_text(IntPtr paragraphBuilder, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string text, IntPtr textStyle);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_builder_add_placeholder(IntPtr paragraphBuilder, SkPlaceholderStyle placeholderStyle);
         public static extern void paragraph_builder_add_placeholder(IntPtr paragraphBuilder, SkPlaceholderStyle placeholderStyle);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr paragraph_builder_create_paragraph(IntPtr paragraphBuilder);
         public static extern IntPtr paragraph_builder_create_paragraph(IntPtr paragraphBuilder);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_builder_reset(IntPtr paragraphBuilder);
         public static extern void paragraph_builder_reset(IntPtr paragraphBuilder);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void paragraph_builder_delete(IntPtr paragraphBuilder);
         public static extern void paragraph_builder_delete(IntPtr paragraphBuilder);
     }
     }
 }
 }

+ 2 - 2
Source/QuestPDF/Skia/Text/SkTextStyle.cs

@@ -93,10 +93,10 @@ internal sealed class SkTextStyle : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr text_style_create(TextStyleConfiguration textStyleConfiguration);
         public static extern IntPtr text_style_create(TextStyleConfiguration textStyleConfiguration);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void text_style_delete(IntPtr textStyle);
         public static extern void text_style_delete(IntPtr textStyle);
     }
     }
 }
 }

+ 1 - 1
Source/QuestPDF/Skia/Text/SkTypeface.cs

@@ -29,7 +29,7 @@ public sealed class SkTypeface : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void typeface_unref(IntPtr typeface);
         public static extern void typeface_unref(IntPtr typeface);
     }
     }
 }
 }

+ 4 - 4
Source/QuestPDF/Skia/Text/SkTypefaceProvider.cs

@@ -39,16 +39,16 @@ internal sealed class SkTypefaceProvider : IDisposable
     
     
     private static class API
     private static class API
     {
     {
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern IntPtr typeface_font_provider_create();
         public static extern IntPtr typeface_font_provider_create();
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void typeface_font_provider_add_typeface(IntPtr typefaceProvider, IntPtr typeface);
         public static extern void typeface_font_provider_add_typeface(IntPtr typefaceProvider, IntPtr typeface);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void typeface_font_provider_add_typeface_with_custom_alias(IntPtr typefaceProvider, IntPtr typeface, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string alias);
         public static extern void typeface_font_provider_add_typeface_with_custom_alias(IntPtr typefaceProvider, IntPtr typeface, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(Utf8StringMarshaller))] string alias);
         
         
-        [DllImport(SkiaAPI.LibraryName)]
+        [DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
         public static extern void typeface_font_provider_unref(IntPtr typefaceProvider);
         public static extern void typeface_font_provider_unref(IntPtr typefaceProvider);
     }
     }
 }
 }