www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - (Skia) Submit project to bindbc?

reply evilrat <evilrat666 gmail.com> writes:
Skia is 2D graphics library used by Google Chrome and Firefox, it 
is used by Android and Flutter. It provides canvas API to draw 
graphics and fonts and licensed under permissive license (BSD).


I've made bindbc-skia bindings and would like to transfer it to 
BindBC team.
Whom I need to write to have it added as part of official BindBC 
packages?

It (C API) seems stable enough, unfortunately I'm not willing to 
maintain it for a long time and I may be unavailable for quite 
some time from time to time. However I think it will be useful to 
someone.

Source
https://github.com/Superbelko/bindbc-skia
Jun 02 2021
next sibling parent Mike Parker <aldacron gmail.com> writes:
On Wednesday, 2 June 2021 at 17:48:09 UTC, evilrat wrote:

 I've made bindbc-skia bindings and would like to transfer it to 
 BindBC team.
 Whom I need to write to have it added as part of official 
 BindBC packages?

 It (C API) seems stable enough, unfortunately I'm not willing 
 to maintain it for a long time and I may be unavailable for 
 quite some time from time to time. However I think it will be 
 useful to someone.

 Source
 https://github.com/Superbelko/bindbc-skia
There is no bindbc team. Just me. I'm not particularly eager to take on new packages, as I barely have time to maintain what's already there. But skia is worth having, IMO, so in this case I'll accept. I'll email you about it shortly.
Jun 02 2021
prev sibling parent reply Sebastiaan Koppe <mail skoppe.eu> writes:
On Wednesday, 2 June 2021 at 17:48:09 UTC, evilrat wrote:
 Skia is 2D graphics library used by Google Chrome and Firefox, 
 it is used by Android and Flutter. It provides canvas API to 
 draw graphics and fonts and licensed under permissive license 
 (BSD).


 I've made bindbc-skia bindings and would like to transfer it to 
 BindBC team.
 Whom I need to write to have it added as part of official 
 BindBC packages?

 It (C API) seems stable enough, unfortunately I'm not willing 
 to maintain it for a long time and I may be unavailable for 
 quite some time from time to time. However I think it will be 
 useful to someone.

 Source
 https://github.com/Superbelko/bindbc-skia
The C API is still marked experimental though. It definitely works; I ran dpp over it a month ago and compiled a simple demo. The biggest problem for me is that the C API is missing things like text for instance. I really can't live without that. The Skia codebase is pretty clean though, and dpp seems to be able to transpile most of the C++ headers I have tried (although the resulting D code is invalid here and there.) So it might be a nice project to try C++ interop on.
Jun 03 2021
next sibling parent pilger <fake email.com> writes:
On Thursday, 3 June 2021 at 07:27:13 UTC, Sebastiaan Koppe wrote:
 I ran dpp over it a month ago and compiled a simple demo.
i tried to compile skia on windows about a month ago. not a very enjoyable experience. the non standard build system/ tool chain is painful to set up. documentation for it is all over the place. i gave up frustrated when i couldn't resolve compilation errors. it feels like the windows platform isn't very well supported- to speak diplomatically.
Jun 03 2021
prev sibling next sibling parent reply pilger <abcd dcba.com> writes:
On Thursday, 3 June 2021 at 07:27:13 UTC, Sebastiaan Koppe wrote:
 I ran dpp over it a month ago and compiled a simple demo.
i tried to compile skia on windows about a month ago. not a very enjoyable experience. the non standard build system/ tool chain is painful to set up. documentation for it is all over the place. i gave up frustrated when i couldn't resolve compilation errors. it feels like the windows platform isn't very well supported- to speak diplomatically.
Jun 03 2021
next sibling parent Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Thursday, 3 June 2021 at 08:39:07 UTC, pilger wrote:
 On Thursday, 3 June 2021 at 07:27:13 UTC, Sebastiaan Koppe 
 wrote:
 I ran dpp over it a month ago and compiled a simple demo.
i tried to compile skia on windows about a month ago. not a very enjoyable experience. the non standard build system/ tool chain is painful to set up. documentation for it is all over the place. i gave up frustrated when i couldn't resolve compilation errors. it feels like the windows platform isn't very well supported- to speak diplomatically.
I don't have windows, but did you set is_official_build=true, if that is set to false (the default) it apparently builds all third party libraries from scratch.
Jun 03 2021
prev sibling parent reply evilrat <evilrat666 gmail.com> writes:
On Thursday, 3 June 2021 at 08:39:07 UTC, pilger wrote:
 On Thursday, 3 June 2021 at 07:27:13 UTC, Sebastiaan Koppe 
 wrote:
 I ran dpp over it a month ago and compiled a simple demo.
i tried to compile skia on windows about a month ago. not a very enjoyable experience. the non standard build system/ tool chain is painful to set up. documentation for it is all over the place. i gave up frustrated when i couldn't resolve compilation errors. it feels like the windows platform isn't very well supported- to speak diplomatically.
The build process requires python 2(python 3 works too), git, ninja, and Visual Studio/Clang compiler. it is then as simple as 1) clone depot_tools and skia 2) run their sync utility (python script) 3) run their gn tool(step 1) to generate ninja build files 4) build with ninja Step 3 is most error-prone as there is literally zero documentation on what it does and how to decide what to choose. Here is my cmd for build for steps 3 and 4 ```sh bin/gn gen out/Shared --args='is_official_build=true is_component_build=true skia_enable_tools=false skia_use_icu=false skia_use_sfntly=false skia_use_piex=true skia_use_dng_sdk=false skia_use_system_expat=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false' ninja -C out/Shared ``` found and tweaked from https://stackoverflow.com/questions/50228652/how-to-compile-skia-on-windows and specifically (turn off dng_sdk) https://github.com/mono/SkiaSharp/blob/605946352e543ee39345bb4969db28ddf2ae4977/cake/BuildExternals.cake#L95-L101 The build process took just about one minute. No idea how feature complete this configuration, but it seems everything works for my needs.
Jun 03 2021
parent reply pilger <abcd dcba.com> writes:
On Thursday, 3 June 2021 at 11:04:10 UTC, evilrat wrote:
 https://stackoverflow.com/questions/50228652/how-to-compile-skia-on-windows
iirc this describes the roadblock i hit. i even tried a similar solution/ workaround first but it lead me nowhere, too. thanx for the detailed instructions. i'm going to try this again.
Jun 03 2021
parent reply russhy <russhy gmail.com> writes:
This is where ImportC should shine, we'd no longer have to 
maintain bindings manually (hopefully)
Jun 03 2021
parent reply rikki cattermole <rikki cattermole.co.nz> writes:
On 04/06/2021 10:18 AM, russhy wrote:
 This is where ImportC should shine, we'd no longer have to maintain 
 bindings manually (hopefully)
That only includes static linking (both objects and shared libraries). Dynamic linking of shared libraries which BindBC has as one of its key features isn't covered as of right now (not expected to).
Jun 03 2021
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Friday, 4 June 2021 at 00:52:21 UTC, rikki cattermole wrote:
 That only includes static linking (both objects and shared 
 libraries).
Well, if importc works as well as claimed, it would be trivial to do a dynamic load off it using the same pattern I did in simpledisplay's dynamic loader: reflect over the static stuff and mix in dynamic stuff from it.
Jun 03 2021
parent =?UTF-8?Q?S=c3=b6nke_Ludwig?= <sludwig outerproduct.org> writes:
Am 04.06.2021 um 03:11 schrieb Adam D. Ruppe:
 On Friday, 4 June 2021 at 00:52:21 UTC, rikki cattermole wrote:
 That only includes static linking (both objects and shared libraries).
Well, if importc works as well as claimed, it would be trivial to do a dynamic load off it using the same pattern I did in simpledisplay's dynamic loader: reflect over the static stuff and mix in dynamic stuff from it.
FWIW, I've also made a little library a while ago that does this. It probably doesn't handle all attributes correctly, but otherwise works for any static binding: https://code.dlang.org/packages/dynamic
Jun 07 2021
prev sibling parent reply evilrat <evilrat666 gmail.com> writes:
On Thursday, 3 June 2021 at 07:27:13 UTC, Sebastiaan Koppe wrote:
 The C API is still marked experimental though. It definitely 
 works; I ran dpp over it a month ago and compiled a simple demo.

 The biggest problem for me is that the C API is missing things 
 like text for instance. I really can't live without that.
Yup, that sucks. But since C API looks like just a thin wrapper I think text could be added on top of it using C++ function loading.
 The Skia codebase is pretty clean though, and dpp seems to be 
 able to transpile most of the C++ headers I have tried 
 (although the resulting D code is invalid here and there.) So 
 it might be a nice project to try C++ interop on.
Or generate bindings using my tool O_- Unfortunately it is still sucks because it uses STL, and there is tons of junk in it. Maybe if I could just strip produced garbage and take only what is used (atomics, unique_ptr, strings, etc..., but not all those extra functions) it will work.
Jun 03 2021
parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Thursday, 3 June 2021 at 11:35:32 UTC, evilrat wrote:
 Unfortunately it is still sucks because it uses STL, and there 
 is tons of junk in it.  Maybe if I could just strip produced 
 garbage and take only what is used (atomics, unique_ptr, 
 strings, etc..., but not all those extra functions) it will 
 work.
So maybe it is better to write an abstraction layer in C++ that can be used directly from D. Other than that, Skia is a good test case for D's C++ support.
Jun 03 2021
parent evilrat <evilrat666 gmail.com> writes:
On Thursday, 3 June 2021 at 11:42:05 UTC, Ola Fosheim Grøstad 
wrote:
 On Thursday, 3 June 2021 at 11:35:32 UTC, evilrat wrote:
 Unfortunately it is still sucks because it uses STL, and there 
 is tons of junk in it.  Maybe if I could just strip produced 
 garbage and take only what is used (atomics, unique_ptr, 
 strings, etc..., but not all those extra functions) it will 
 work.
So maybe it is better to write an abstraction layer in C++ that can be used directly from D. Other than that, Skia is a good test case for D's C++ support.
Actually I tried this as quick hack and it writes text on top of C API demo. So it is indeed just thin wrapper, and it makes possible to extend bindings to load text functions on top of it. __main.d__ (add on top) ```d extern(C++) { class SkPaint; alias SkScalar = float; enum SkTextEncoding { kUTF8, //!< uses bytes to represent UTF-8 or ASCII kUTF16, //!< uses two byte words to represent most of Unicode kUTF32, //!< uses four byte words to represent all of Unicode kGlyphID, //!< uses two byte words to represent glyph indices } final class SkCanvas { void drawSimpleText(const(void)* text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, ref const SkFont font, ref const SkPaint paint); alias drawSimpleTextFn = void function(SkCanvas this_, const(void)* text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, ref const SkFont font, ref const SkPaint paint); } extern(C++, class) struct SkFont { byte[256] instanceData_; // hack, reserve enough space to fit all data, since I don't know actual size // disable this(); //pragma(msg, SkFont.__ctor.mangleof); alias ctorFn = void function(SkFont* this_); } } ``` __main.d__ (insert at the end of draw function before delete block) ```d void draw(sk_canvas_t* canvas) { // ... sk_paint_t* strokeText = sk_paint_new(); sk_paint_set_stroke(strokeText, true); sk_paint_set_stroke_width(strokeText, 1.0f); import core.sys.windows.windows; auto lib = LoadLibrary("skia.dll"); SkCanvas.drawSimpleTextFn drawTextFnPtr = cast(SkCanvas.drawSimpleTextFn) GetProcAddress(lib, "?drawSimpleText SkCanvas QEAAXPEBX_KW4SkTextEncoding MMAEBVSkFont AEBVSkPaint Z"); SkFont fnt; SkFont.ctorFn skFontCtorPtr = cast(SkFont.ctorFn) GetProcAddress(lib, "??0SkFont QEAA XZ"); skFontCtorPtr(&fnt); enum text = "test dynamic text"; drawTextFnPtr(cast(SkCanvas)canvas, text.ptr, text.length, SkTextEncoding.kUTF8, 150, 150, fnt, *cast(SkPaint*) strokeText); sk_paint_delete(strokeText); // deleters } ```
Jun 04 2021