digitalmars.D - (Skia) Submit project to bindbc?
- evilrat (13/13) Jun 02 2021 Skia is 2D graphics library used by Google Chrome and Firefox, it
- Mike Parker (5/15) Jun 02 2021 There is no bindbc team. Just me. I'm not particularly eager to
- Sebastiaan Koppe (9/23) Jun 03 2021 The C API is still marked experimental though. It definitely
- pilger (7/8) Jun 03 2021 i tried to compile skia on windows about a month ago. not a very
- pilger (7/8) Jun 03 2021 i tried to compile skia on windows about a month ago. not a very
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (4/13) Jun 03 2021 I don't have windows, but did you set is_official_build=true, if
- evilrat (27/36) Jun 03 2021 The build process requires python 2(python 3 works too), git,
- pilger (4/5) Jun 03 2021 iirc this describes the roadblock i hit. i even tried a similar
- russhy (2/2) Jun 03 2021 This is where ImportC should shine, we'd no longer have to
- rikki cattermole (4/6) Jun 03 2021 That only includes static linking (both objects and shared libraries).
- Adam D. Ruppe (5/7) Jun 03 2021 Well, if importc works as well as claimed, it would be trivial to
- =?UTF-8?Q?S=c3=b6nke_Ludwig?= (4/11) Jun 07 2021 FWIW, I've also made a little library a while ago that does this. It
- evilrat (8/16) Jun 03 2021 Yup, that sucks. But since C API looks like just a thin wrapper I
- Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= (4/9) Jun 03 2021 So maybe it is better to write an abstraction layer in C++ that
- evilrat (70/79) Jun 04 2021 Actually I tried this as quick hack and it writes text on top of
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
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-skiaThere 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
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-skiaThe 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
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
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
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 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.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
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: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.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
On Thursday, 3 June 2021 at 11:04:10 UTC, evilrat wrote:https://stackoverflow.com/questions/50228652/how-to-compile-skia-on-windowsiirc 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
This is where ImportC should shine, we'd no longer have to maintain bindings manually (hopefully)
Jun 03 2021
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
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
Am 04.06.2021 um 03:11 schrieb Adam D. Ruppe:On Friday, 4 June 2021 at 00:52:21 UTC, rikki cattermole wrote: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/dynamicThat 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 07 2021
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
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
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: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 } ```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 04 2021