mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Squashed 'external/lunasvg/' changes from 585d61eef..f924651b8
f924651b8 Merge pull request #129 from lemirep/master db27b7c0e Add missing cstdint include b66e22402 Merge pull request #126 from m-carrasco/fix-null-ptr-arithmetic a1edbff60 Merge pull request #125 from m-carrasco/fix-ub-memcpy f595f7be3 Fix UB caused by null pointer arithmetic. a854444e5 Fix UB caused by wrong call to memcpy. b7e72fb37 Merge pull request #84 from seanharmer/master 4c16abf41 Merge pull request #123 from m-carrasco/fix-gradient-ub 4d51541c2 Fix undefined behavior caused by a domain error on an sqrt call. d4a7080cf Merge pull request #1 from seanharmer/cmake_modernization b08d7d03a Relax the cmake version and other improvements 33a458302 Modernize the cmake usage 4b2609c14 Add initial .gitignore git-subtree-dir: external/lunasvg git-subtree-split: f924651b85cac47dbe15f51a4aa320461fc1d07b
This commit is contained in:
parent
8436127894
commit
2c16a78282
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.vscode
|
||||||
|
build/*
|
8
3rdparty/plutovg/plutovg-blend.c
vendored
8
3rdparty/plutovg/plutovg-blend.c
vendored
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
#define COLOR_TABLE_SIZE 1024
|
#define COLOR_TABLE_SIZE 1024
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -243,6 +244,7 @@ static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values
|
||||||
while(buffer < end)
|
while(buffer < end)
|
||||||
{
|
{
|
||||||
uint32_t result = 0;
|
uint32_t result = 0;
|
||||||
|
det = fabs(det) < DBL_EPSILON ? 0.0 : det;
|
||||||
if(det >= 0)
|
if(det >= 0)
|
||||||
{
|
{
|
||||||
double w = sqrt(det) - b;
|
double w = sqrt(det) - b;
|
||||||
|
@ -261,7 +263,11 @@ static void fetch_radial_gradient(uint32_t* buffer, const radial_gradient_values
|
||||||
{
|
{
|
||||||
while(buffer < end)
|
while(buffer < end)
|
||||||
{
|
{
|
||||||
*buffer++ = gradient_pixel(gradient, sqrt(det) - b);
|
det = fabs(det) < DBL_EPSILON ? 0.0 : det;
|
||||||
|
uint32_t result = 0;
|
||||||
|
if (det >= 0)
|
||||||
|
result = gradient_pixel(gradient, sqrt(det) - b);
|
||||||
|
*buffer++ = result;
|
||||||
det += delta_det;
|
det += delta_det;
|
||||||
delta_det += delta_delta_det;
|
delta_det += delta_delta_det;
|
||||||
b += delta_b;
|
b += delta_b;
|
||||||
|
|
3
3rdparty/plutovg/plutovg-ft-stroker.c
vendored
3
3rdparty/plutovg/plutovg-ft-stroker.c
vendored
|
@ -629,10 +629,12 @@ static void ft_stroke_border_export(PVG_FT_StrokeBorder border,
|
||||||
PVG_FT_Outline* outline)
|
PVG_FT_Outline* outline)
|
||||||
{
|
{
|
||||||
/* copy point locations */
|
/* copy point locations */
|
||||||
|
if (outline->points != NULL && border->points != NULL)
|
||||||
memcpy(outline->points + outline->n_points, border->points,
|
memcpy(outline->points + outline->n_points, border->points,
|
||||||
border->num_points * sizeof(PVG_FT_Vector));
|
border->num_points * sizeof(PVG_FT_Vector));
|
||||||
|
|
||||||
/* copy tags */
|
/* copy tags */
|
||||||
|
if (outline->tags)
|
||||||
{
|
{
|
||||||
PVG_FT_UInt count = border->num_points;
|
PVG_FT_UInt count = border->num_points;
|
||||||
PVG_FT_Byte* read = border->tags;
|
PVG_FT_Byte* read = border->tags;
|
||||||
|
@ -649,6 +651,7 @@ static void ft_stroke_border_export(PVG_FT_StrokeBorder border,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy contours */
|
/* copy contours */
|
||||||
|
if (outline->contours)
|
||||||
{
|
{
|
||||||
PVG_FT_UInt count = border->num_points;
|
PVG_FT_UInt count = border->num_points;
|
||||||
PVG_FT_Byte* tags = border->tags;
|
PVG_FT_Byte* tags = border->tags;
|
||||||
|
|
4
3rdparty/plutovg/plutovg-rle.c
vendored
4
3rdparty/plutovg/plutovg-rle.c
vendored
|
@ -21,9 +21,13 @@ static void ft_outline_init(PVG_FT_Outline* outline, plutovg_t* pluto, int point
|
||||||
|
|
||||||
PVG_FT_Byte* data = pluto->outline_data;
|
PVG_FT_Byte* data = pluto->outline_data;
|
||||||
outline->points = (PVG_FT_Vector*)(data);
|
outline->points = (PVG_FT_Vector*)(data);
|
||||||
|
outline->tags = outline->contours_flag = NULL;
|
||||||
|
outline->contours = NULL;
|
||||||
|
if(data){
|
||||||
outline->tags = (char*)(data + size_a);
|
outline->tags = (char*)(data + size_a);
|
||||||
outline->contours = (int*)(data + size_a + size_b);
|
outline->contours = (int*)(data + size_a + size_b);
|
||||||
outline->contours_flag = (char*)(data + size_a + size_b + size_c);
|
outline->contours_flag = (char*)(data + size_a + size_b + size_c);
|
||||||
|
}
|
||||||
outline->n_points = 0;
|
outline->n_points = 0;
|
||||||
outline->n_contours = 0;
|
outline->n_contours = 0;
|
||||||
outline->flags = 0x0;
|
outline->flags = 0x0;
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
cmake_minimum_required(VERSION 3.3)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
project(lunasvg VERSION 2.3.5 LANGUAGES CXX C)
|
project(lunasvg VERSION 2.3.5 LANGUAGES CXX C)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
|
||||||
|
# Default to hidden visibility for symbols
|
||||||
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||||
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||||
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||||
|
|
||||||
option(BUILD_SHARED_LIBS "Builds as shared library" OFF)
|
option(BUILD_SHARED_LIBS "Builds as shared library" OFF)
|
||||||
option(LUNASVG_BUILD_EXAMPLES "Builds examples" OFF)
|
option(LUNASVG_BUILD_EXAMPLES "Builds examples" OFF)
|
||||||
|
|
||||||
|
@ -14,25 +19,61 @@ add_subdirectory(include)
|
||||||
add_subdirectory(source)
|
add_subdirectory(source)
|
||||||
add_subdirectory(3rdparty/plutovg)
|
add_subdirectory(3rdparty/plutovg)
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
set_target_properties(lunasvg
|
||||||
target_compile_definitions(lunasvg PUBLIC LUNASVG_SHARED)
|
PROPERTIES
|
||||||
target_compile_definitions(lunasvg PRIVATE LUNASVG_EXPORT)
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(lunasvg::lunasvg ALIAS lunasvg)
|
||||||
|
|
||||||
|
if(NOT BUILD_SHARED_LIBS)
|
||||||
|
target_compile_definitions(lunasvg PUBLIC LUNASVG_STATIC_DEFINE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LUNASVG_BUILD_EXAMPLES)
|
if(LUNASVG_BUILD_EXAMPLES)
|
||||||
add_subdirectory(example)
|
add_subdirectory(example)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LUNASVG_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib)
|
#
|
||||||
set(LUNASVG_INCDIR ${CMAKE_INSTALL_PREFIX}/include)
|
# Installation
|
||||||
|
#
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/include/lunasvg.h
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/include/lunasvg_export.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lunasvg
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
TARGETS lunasvg
|
||||||
|
EXPORT lunasvg-targets
|
||||||
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
install(
|
||||||
|
EXPORT lunasvg-targets
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg NAMESPACE lunasvg:: FILE lunasvgTargets.cmake
|
||||||
|
)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake/lunasvgConfig.cmake.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfig.cmake
|
||||||
|
INSTALL_DESTINATION
|
||||||
|
${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg
|
||||||
|
)
|
||||||
|
|
||||||
|
write_basic_package_version_file(lunasvgConfigVersion.cmake
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
install(FILES
|
install(FILES
|
||||||
include/lunasvg.h
|
${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfig.cmake
|
||||||
DESTINATION ${LUNASVG_INCDIR}
|
${CMAKE_CURRENT_BINARY_DIR}/lunasvgConfigVersion.cmake
|
||||||
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/lunasvg
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS lunasvg
|
export(EXPORT lunasvg-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/lunasvgTargets.cmake NAMESPACE lunasvg::)
|
||||||
LIBRARY DESTINATION ${LUNASVG_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${LUNASVG_LIBDIR}
|
|
||||||
INCLUDES DESTINATION ${LUNASVG_INCDIR}
|
|
||||||
)
|
|
||||||
|
|
3
cmake/lunasvgConfig.cmake.in
Normal file
3
cmake/lunasvgConfig.cmake.in
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/lunasvgTargets.cmake")
|
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.3)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
|
# Generate a standard header with export macros
|
||||||
|
include(GenerateExportHeader)
|
||||||
|
generate_export_header(lunasvg)
|
||||||
|
|
||||||
target_include_directories(lunasvg
|
target_include_directories(lunasvg
|
||||||
|
# When building a project that uses the lunasvg library,
|
||||||
|
# we need to look in the installed include directory
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
$<INSTALL_INTERFACE:include>
|
||||||
|
|
||||||
|
# When building the lunasvg library we need to look in the
|
||||||
|
# build dir for the lunasvg_export.h header and in the source
|
||||||
|
# dir for other headers
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||||
)
|
)
|
||||||
|
|
|
@ -25,16 +25,10 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#if defined(_MSC_VER) && defined(LUNASVG_SHARED)
|
#include <lunasvg_export.h>
|
||||||
#ifdef LUNASVG_EXPORT
|
#define LUNASVG_API LUNASVG_EXPORT
|
||||||
#define LUNASVG_API __declspec(dllexport)
|
|
||||||
#else
|
|
||||||
#define LUNASVG_API __declspec(dllimport)
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define LUNASVG_API
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace lunasvg {
|
namespace lunasvg {
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace lunasvg {
|
namespace lunasvg {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue