-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Building using Alpine 3.9. Tested on Alpine 3.7. This is both the full libSkiaSharp and the "no dependencies" build.
- Loading branch information
1 parent
17d21be
commit c23eab0
Showing
12 changed files
with
165 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM amd64/alpine:3.9 | ||
|
||
RUN apk add --no-cache bash curl ca-certificates python git build-base ninja fontconfig-dev | ||
RUN apk add --no-cache samurai --repository http://dl-cdn.alpinelinux.org/alpine/edge/main | ||
RUN apk add --no-cache mono clang gn --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing | ||
RUN cert-sync /etc/ssl/certs/ca-certificates.crt | ||
|
||
WORKDIR /work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
|
||
using sk_bitmap_t = System.IntPtr; | ||
using sk_colorspace_t = System.IntPtr; | ||
using sk_pixmap_t = System.IntPtr; | ||
using sk_wstream_t = System.IntPtr; | ||
using sk_wstream_filestream_t = System.IntPtr; | ||
|
||
namespace NativeLibraryMiniTest { | ||
unsafe class Program { | ||
const string SKIA = "libSkiaSharp.so"; | ||
|
||
static int Main(string[] args) { | ||
Console.WriteLine("Starting test..."); | ||
|
||
Console.WriteLine("Color type test..."); | ||
Console.WriteLine($"sk_colortype_get_default_8888() = {sk_colortype_get_default_8888()}"); | ||
|
||
Console.WriteLine("Bitmap create and save test..."); | ||
var bmp = sk_bitmap_new(); | ||
var info = new sk_imageinfo_t { | ||
width = 100, | ||
height = 100, | ||
colorType = sk_colortype_get_default_8888(), | ||
alphaType = sk_alphatype_t.Premul, | ||
}; | ||
sk_bitmap_try_alloc_pixels_with_flags(bmp, &info, 0); | ||
sk_bitmap_erase(bmp, 0xFFFF0000); | ||
var pix = sk_pixmap_new(); | ||
sk_bitmap_peek_pixels(bmp, pix); | ||
var stream = sk_filewstream_new("output.png"); | ||
var opt = new sk_pngencoder_options_t { | ||
fFilterFlags = 248, | ||
fZLibLevel = 6, | ||
}; | ||
sk_pngencoder_encode(stream, pix, &opt); | ||
sk_filewstream_destroy(stream); | ||
sk_pixmap_destructor(pix); | ||
sk_bitmap_destructor(bmp); | ||
|
||
Console.WriteLine("Test complete."); | ||
return 0; | ||
} | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern sk_colortype_t sk_colortype_get_default_8888(); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern sk_bitmap_t sk_bitmap_new(); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
[return: MarshalAs(UnmanagedType.I1)] | ||
static extern bool sk_bitmap_try_alloc_pixels_with_flags(sk_bitmap_t cbitmap, sk_imageinfo_t* requestedInfo, uint flags); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern void sk_bitmap_erase(sk_bitmap_t cbitmap, uint color); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
[return: MarshalAs(UnmanagedType.I1)] | ||
static extern bool sk_bitmap_peek_pixels(sk_bitmap_t cbitmap, sk_pixmap_t cpixmap); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
[return: MarshalAs(UnmanagedType.I1)] | ||
static extern bool sk_pngencoder_encode(sk_wstream_t dst, sk_pixmap_t src, void* options); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern void sk_bitmap_destructor(sk_bitmap_t cbitmap); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern sk_pixmap_t sk_pixmap_new(); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern void sk_pixmap_destructor(sk_pixmap_t cpixmap); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern sk_wstream_filestream_t sk_filewstream_new([MarshalAs(UnmanagedType.LPStr)] string path); | ||
|
||
[DllImport(SKIA, CallingConvention = CallingConvention.Cdecl)] | ||
static extern void sk_filewstream_destroy(sk_wstream_filestream_t cstream); | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
unsafe partial struct sk_imageinfo_t { | ||
public sk_colorspace_t colorspace; | ||
public int width; | ||
public int height; | ||
public sk_colortype_t colorType; | ||
public sk_alphatype_t alphaType; | ||
} | ||
|
||
enum sk_colortype_t { | ||
Unknown = 0, | ||
Rgba8888 = 4, | ||
Bgra8888 = 6, | ||
} | ||
|
||
enum sk_alphatype_t { | ||
Unknown = 0, | ||
Opaque = 1, | ||
Premul = 2, | ||
Unpremul = 3, | ||
} | ||
|
||
[StructLayout (LayoutKind.Sequential)] | ||
struct sk_pngencoder_options_t { | ||
public int fFilterFlags; | ||
public int fZLibLevel; | ||
public void* fComments; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
mkdir -p utils/NativeLibraryMiniTest/bin | ||
csc /out:utils/NativeLibraryMiniTest/bin/Program.exe /unsafe utils/NativeLibraryMiniTest/Program.cs | ||
cp output/native/linux/x64/libSkiaSharp.so utils/NativeLibraryMiniTest/bin/ | ||
|
||
(cd utils/NativeLibraryMiniTest/bin && mono Program.exe) |