Skip to content

Commit

Permalink
Merge pull request #1526 from KeyWorksRW/lunasvg
Browse files Browse the repository at this point in the history
Add lunasvg 3 as a subrepo and switch to it for wxBitmapBundleImplSVG rendering
  • Loading branch information
Randalphwa authored Nov 4, 2024
2 parents 94b2a99 + 7ba97ab commit 8ab47fe
Show file tree
Hide file tree
Showing 122 changed files with 54,063 additions and 40 deletions.
20 changes: 20 additions & 0 deletions lib_sources/lunasvg/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 5,
"patch": 0
},
"configurePresets": [
{
"name": "ninja-multi",
"displayName": "Ninja Multi-Config",
"description": "Default build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "YES"
}
}
]
}
123 changes: 123 additions & 0 deletions lib_sources/lunasvg/UPDATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# General Information

The `lunasvg_2/` folder is a static copy of the lunasvg 2.4.1 source code modified to work with wxWidgets. It can be compiled with C++11.

The `lunasvg_3/` folder contains subrepo copies of the lunasvg 3.x and plutovg repositories. These copies are modified so that they can be built into wxWidgets. C++17 is required to compile these sources.

If you are just building wxUiEditor, you don't need to do anything -- unlike submodules, subrepos don't require any updating before you can build the current sources.

# Maintainers

The following sections are for maintainers who need to merge changes from the lunasvg and plutovg repositories into the wxUiEditor code base.

To update, you need to have subrepo, which is currently an external program that calls git to perform it's functionality. To use subrepo, you should first clone https://github.com/ingydotnet/git-subrepo -- you will be running subrepo from this clone. See the instructions on the URL for Unix/Max systems (it's much easier to do then on Windows)

For Windows, follow these instructions:

- set GIT_SUBREPO_ROOT=%clone location%
- add to PATH: %clone location%;%clone location%/lib

Start a new cmd prompt with the above environment changes and run `git subrepo` -- if subrepo is working, it will list all the command line options. Note that you need to use '/' for paths on Windows.

## Updating lunasvg and plutovg

Ensure that there are no pending changes -- stash them if there are.

From the root of the wxUiEditor repository, run the following two commands:

git subrepo pull lib_sources/lunasvg/lunasvg_3
git subrepo pull lib_sources/lunasvg/lunasvg_3/plutovg

These two commands will merge changes in the upstream repository into the current subfolders -- each pull will create a single commit in history.

The `CMakeLists.txt` in lib_sources/lunasvg can be used to verify that wxlunasvg 3 can be built. Note that it includes it's list of source files -- you may need to modify this to pickup files added to either lunasvg or plutovg (see CMakeLists.txt in `lunasvg_3/` and `lunasvg_3/plutovg`.

## After updating

Updates are a merge, so it's likely that everything will just work. However, if something goes wrong, the following changes are what were initially made and can be used as a guideline.



In lunasvg_3/source/graphics.h add the following:

```C++
// Disable warnings about possible loss of data when converting int to float
// Disable warnings about possible loss of data when converting size_t to int
#ifdef _MSC_VER
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
```

In lunasvg_3/plutovg/plutovg-private.h add:

```C
// Disable warnings about possible loss of data when converting int to float
// Disable warnings about possible loss of data when converting size_t to int
#ifdef _MSC_VER
#pragma warning(disable: 4244)
#pragma warning(disable: 4267)
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
```

In lunasvg_3/plutovg/plutovg-ft-raster.c add:

```C
// Disable warnings about possible loss of data when converting size_t to long
#ifdef _MSC_VER
#pragma warning(disable: 4267)
#else
#pragma GCC diagnostic ignored "-Wsign-conversion"
#endif
```

In lunasvg_3/plutovg/plutovg-ft-stroker.c add:

```C
// Disable warnings about signed/unsigned mismatch
#ifdef _MSC_VER
#pragma warning(disable: 4018)
#else
#pragma GCC diagnostic ignored "-Wsign-compare"
#endif
```

In lunasvg_3/plutovg/plutovg.h replace

```C
#ifdef PLUTOVG_BUILD
#define PLUTOVG_API PLUTOVG_EXPORT
#else
#define PLUTOVG_API PLUTOVG_IMPORT
#endif
```

with

```C
#define PLUTOVG_API
```

In lunasvg_3/include/lunasvg.h insert the following code immediately after the #include statements:

```C++
#ifndef WXMAKINGDLL
#define LUNASVG_BUILD_STATIC
#endif

#ifdef WXBUILDING
#define LUNASVG_BUILD
#endif
```

Replace all occurences of `namespace lunasvg` with `namespace wxlunasvg`.

In lunasvg_3/source/lunasvg.cpp replace all occurences of `lunasvg::` with `wxlunasvg:`.

At this point you should be able to build the library using C++17.
55 changes: 55 additions & 0 deletions lib_sources/lunasvg/luna3_cleanup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@echo off

REM This batch file is designed to remove directories and files that are part of the upstream
REM repository, but are not used in wxUiEditor. It's not necessary to run this batch file,
REM though it does make the directory structure cleaner.

REM ------------------- lunasvg_3 -------------------

cd lunasvg_3

REM Remove the examples directory
if exist examples (
rd /s /q examples
)

REM Remove the cmake directory
if exist cmake (
rd /s /q cmake
)

REM Remove the .github directory
if exist .github (
rd /s /q .github
)

REM Remove the subprojects directory
if exist subprojects (
rd /s /q subprojects
)

REM ------------------- plutovg -------------------

cd plutovg

REM Remove the examples directory
if exist examples (
rd /s /q examples
)

REM Remove the cmake directory
if exist cmake (
rd /s /q cmake
)

REM Remove the .github directory
if exist .github (
rd /s /q .github
)

REM Remove the smiley.png file if it exists
if exist smiley.png (
del /q smiley.png
)

cd ../..
21 changes: 21 additions & 0 deletions lib_sources/lunasvg/lunasvg_2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Nwutobo Samuel Ugochukwu <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions lib_sources/lunasvg/lunasvg_2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This code is from lunasvg version 2.4.1, with plutovg code converted to C++ and the `lunasvg` namespace converted to `wxlunasvg`. Unlike lunasvg version 3, this version only requires C++11 to compile (version 3 requires C++17).
Loading

0 comments on commit 8ab47fe

Please sign in to comment.