Skip to content

Commit

Permalink
Remove lunasvg from thirdparty libs
Browse files Browse the repository at this point in the history
Since we're only using wx's SVG loading now, there isn't much point in keeping it around. This technically removes SVG support from SImage, but it wasn't being used anyway
  • Loading branch information
sirjuddington committed Jun 2, 2024
1 parent 28e1ec4 commit 93cab74
Show file tree
Hide file tree
Showing 75 changed files with 3 additions and 17,973 deletions.
1 change: 0 additions & 1 deletion src/Graphics/SImage/SImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ class SImage
bool loadJediFONT(const uint8_t* gfx_data, int size);
bool loadJaguarSprite(const uint8_t* header, int hdr_size, const uint8_t* gfx_data, int size);
bool loadJaguarTexture(const uint8_t* gfx_data, int size, int i_width, int i_height);
bool loadSVG(const string& svg_text, int width, int height);

// Conversion stuff
bool convertRGBA(const Palette* pal = nullptr);
Expand Down
18 changes: 0 additions & 18 deletions src/Graphics/SImage/SImageFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#undef BOOL
#include "Graphics/Palette/Palette.h"
#include "SIFormat.h"
#include "thirdparty/lunasvg/include/lunasvg.h"

using namespace slade;

Expand Down Expand Up @@ -960,20 +959,3 @@ bool SImage::loadJaguarTexture(const uint8_t* gfx_data, int size, int i_width, i
signals_.image_changed();
return true;
}

// -----------------------------------------------------------------------------
// Loads an SVG image, sized to [width x height].
// Returns false if the SVG data was invalid, true otherwise
// -----------------------------------------------------------------------------
bool SImage::loadSVG(const string& svg_text, int width, int height)
{
// Load SVG
const auto svg = lunasvg::Document::loadFromData(svg_text);
if (!svg)
return false;

// Render SVG
const auto bmp = svg->renderToBitmap(width, height);

return setImageData(bmp.data(), bmp.width() * bmp.height() * 4, bmp.width(), bmp.height(), Type::RGBA);
}
31 changes: 2 additions & 29 deletions src/Graphics/WxGfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "OpenGL/View.h"
#include "SImage/SImage.h"
#include "UI/Canvas/GfxCanvasBase.h"
#include "lunasvg.h"

using namespace slade;
using namespace wxgfx;
Expand Down Expand Up @@ -70,34 +69,8 @@ EXTERN_CVAR(Bool, hud_bob)
// -----------------------------------------------------------------------------
wxImage wxgfx::createImageFromSVG(const string& svg_text, int width, int height)
{
// Load SVG
const auto svg = lunasvg::Document::loadFromData(svg_text);
if (!svg)
return {};

// Render SVG
const auto bmp = svg->renderToBitmap(width, height);
if (!bmp.valid())
return {};

// Split image data to separate rgb + alpha channels
const auto bmp_data = bmp.data();
const auto n_pixels = width * height;
const auto rgb_data = new uint8_t[n_pixels * 3]; // wxImage below will take ownership
const auto alpha_data = new uint8_t[n_pixels]; // ^
auto data_index = 0;
auto rgb_index = 0;
auto alpha_index = 0;
for (auto p = 0; p < n_pixels; ++p)
{
rgb_data[rgb_index++] = bmp_data[data_index++];
rgb_data[rgb_index++] = bmp_data[data_index++];
rgb_data[rgb_index++] = bmp_data[data_index++];
alpha_data[alpha_index++] = bmp_data[data_index++];
}

// Create wxImage
return { width, height, rgb_data, alpha_data, false };
auto bundle = wxBitmapBundle::FromSVG(svg_text.c_str(), { width, height });
return bundle.GetBitmap({ width, height }).ConvertToImage();
}

// -----------------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion src/UI/WxUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "Graphics/Icons.h"
#include "UI/UI.h"
#include "Utility/Colour.h"
#include "thirdparty/lunasvg/include/lunasvg.h"

using namespace slade;

Expand Down
9 changes: 1 addition & 8 deletions thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,13 @@ else()
#target_include_directories(fmt INTERFACE ${CMAKE_CURRENT_LIST_DIR}/fmt/include)
endif()

# Add lunasvg
add_library(lunasvg STATIC)
add_subdirectory(lunasvg/include)
add_subdirectory(lunasvg/source)
add_subdirectory(lunasvg/3rdparty/software)
add_subdirectory(lunasvg/3rdparty/plutovg)

# Required for libdrawtext or we get multiple definition linker errors
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")
endif ()

add_library(external STATIC ${EXTERNAL_SOURCES})
target_link_libraries(external ${ZLIB_LIBRARY} lunasvg fmt::fmt ${CMAKE_DL_LIBS})
target_link_libraries(external ${ZLIB_LIBRARY} fmt::fmt ${CMAKE_DL_LIBS})
set(EXTERNAL_LIBRARIES external PARENT_SCOPE)

if(USE_SYSTEM_DUMB)
Expand Down
4 changes: 0 additions & 4 deletions thirdparty/lunasvg/.github/FUNDING.yml

This file was deleted.

31 changes: 0 additions & 31 deletions thirdparty/lunasvg/.github/workflows/ci.yml

This file was deleted.

14 changes: 0 additions & 14 deletions thirdparty/lunasvg/3rdparty/plutovg/CMakeLists.txt

This file was deleted.

Loading

0 comments on commit 93cab74

Please sign in to comment.