mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Update ICU and msdfgen.
This commit is contained in:
parent
22c20cea6e
commit
0d02568ff8
53 changed files with 421 additions and 396 deletions
|
|
@ -20,8 +20,6 @@ if env["builtin_msdfgen"]:
|
||||||
"core/Projection.cpp",
|
"core/Projection.cpp",
|
||||||
"core/Scanline.cpp",
|
"core/Scanline.cpp",
|
||||||
"core/Shape.cpp",
|
"core/Shape.cpp",
|
||||||
"core/SignedDistance.cpp",
|
|
||||||
"core/Vector2.cpp",
|
|
||||||
"core/contour-combiners.cpp",
|
"core/contour-combiners.cpp",
|
||||||
"core/edge-coloring.cpp",
|
"core/edge-coloring.cpp",
|
||||||
"core/edge-segments.cpp",
|
"core/edge-segments.cpp",
|
||||||
|
|
@ -36,6 +34,7 @@ if env["builtin_msdfgen"]:
|
||||||
]
|
]
|
||||||
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
|
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
|
||||||
|
|
||||||
|
env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
env_msdfgen.Prepend(CPPPATH=["#thirdparty/freetype/include", "#thirdparty/msdfgen", "#thirdparty/nanosvg"])
|
env_msdfgen.Prepend(CPPPATH=["#thirdparty/freetype/include", "#thirdparty/msdfgen", "#thirdparty/nanosvg"])
|
||||||
|
|
||||||
lib = env_msdfgen.add_library("msdfgen_builtin", thirdparty_sources)
|
lib = env_msdfgen.add_library("msdfgen_builtin", thirdparty_sources)
|
||||||
|
|
|
||||||
|
|
@ -531,6 +531,7 @@ module_obj = []
|
||||||
|
|
||||||
if env["builtin_msdfgen"] and msdfgen_enabled:
|
if env["builtin_msdfgen"] and msdfgen_enabled:
|
||||||
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
|
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
|
||||||
|
env_text_server_adv.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
if not env.msvc:
|
if not env.msvc:
|
||||||
env_text_server_adv.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
|
env_text_server_adv.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -133,8 +133,6 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
|
||||||
"core/Projection.cpp",
|
"core/Projection.cpp",
|
||||||
"core/Scanline.cpp",
|
"core/Scanline.cpp",
|
||||||
"core/Shape.cpp",
|
"core/Shape.cpp",
|
||||||
"core/SignedDistance.cpp",
|
|
||||||
"core/Vector2.cpp",
|
|
||||||
"core/contour-combiners.cpp",
|
"core/contour-combiners.cpp",
|
||||||
"core/edge-coloring.cpp",
|
"core/edge-coloring.cpp",
|
||||||
"core/edge-segments.cpp",
|
"core/edge-segments.cpp",
|
||||||
|
|
@ -149,8 +147,10 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
|
||||||
]
|
]
|
||||||
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
|
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
|
||||||
|
|
||||||
|
env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
|
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
|
||||||
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
|
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
|
||||||
|
env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
|
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
|
||||||
|
|
||||||
lib = env_msdfgen.Library(
|
lib = env_msdfgen.Library(
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,16 @@ using namespace godot;
|
||||||
// Thirdparty headers.
|
// Thirdparty headers.
|
||||||
|
|
||||||
#ifdef MODULE_MSDFGEN_ENABLED
|
#ifdef MODULE_MSDFGEN_ENABLED
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4458)
|
||||||
|
#endif
|
||||||
#include <core/ShapeDistanceFinder.h>
|
#include <core/ShapeDistanceFinder.h>
|
||||||
#include <core/contour-combiners.h>
|
#include <core/contour-combiners.h>
|
||||||
#include <core/edge-selectors.h>
|
#include <core/edge-selectors.h>
|
||||||
#include <msdfgen.h>
|
#include <msdfgen.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(default : 4458)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_SVG_ENABLED
|
#ifdef MODULE_SVG_ENABLED
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ if "svg" in env.module_list:
|
||||||
|
|
||||||
if env["builtin_msdfgen"] and msdfgen_enabled:
|
if env["builtin_msdfgen"] and msdfgen_enabled:
|
||||||
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
|
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
|
||||||
|
env_text_server_fb.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
if not env.msvc:
|
if not env.msvc:
|
||||||
env_text_server_fb.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
|
env_text_server_fb.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -144,8 +144,10 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
|
||||||
]
|
]
|
||||||
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
|
thirdparty_msdfgen_sources = [thirdparty_msdfgen_dir + file for file in thirdparty_msdfgen_sources]
|
||||||
|
|
||||||
|
env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
|
env_msdfgen.Append(CPPPATH=["../../../thirdparty/freetype/include", "../../../thirdparty/msdfgen"])
|
||||||
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
|
env.Append(CPPPATH=["../../../thirdparty/msdfgen"])
|
||||||
|
env.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||||
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
|
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
|
||||||
|
|
||||||
lib = env_msdfgen.Library(
|
lib = env_msdfgen.Library(
|
||||||
|
|
|
||||||
|
|
@ -59,10 +59,16 @@ using namespace godot;
|
||||||
// Thirdparty headers.
|
// Thirdparty headers.
|
||||||
|
|
||||||
#ifdef MODULE_MSDFGEN_ENABLED
|
#ifdef MODULE_MSDFGEN_ENABLED
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable : 4458)
|
||||||
|
#endif
|
||||||
#include <core/ShapeDistanceFinder.h>
|
#include <core/ShapeDistanceFinder.h>
|
||||||
#include <core/contour-combiners.h>
|
#include <core/contour-combiners.h>
|
||||||
#include <core/edge-selectors.h>
|
#include <core/edge-selectors.h>
|
||||||
#include <msdfgen.h>
|
#include <msdfgen.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(default : 4458)
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_SVG_ENABLED
|
#ifdef MODULE_SVG_ENABLED
|
||||||
|
|
|
||||||
4
thirdparty/README.md
vendored
4
thirdparty/README.md
vendored
|
|
@ -390,7 +390,7 @@ Files extracted from upstream source:
|
||||||
## icu4c
|
## icu4c
|
||||||
|
|
||||||
- Upstream: https://github.com/unicode-org/icu
|
- Upstream: https://github.com/unicode-org/icu
|
||||||
- Version: 74.1 (9edac7b78327a1cb58db29e2714b15f9fa14e4d7, 2023)
|
- Version: 74.2 (2d029329c82c7792b985024b2bdab5fc7278fbc8, 2023)
|
||||||
- License: Unicode
|
- License: Unicode
|
||||||
|
|
||||||
Files extracted from upstream source:
|
Files extracted from upstream source:
|
||||||
|
|
@ -690,7 +690,7 @@ Collection of single-file libraries used in Godot components.
|
||||||
## msdfgen
|
## msdfgen
|
||||||
|
|
||||||
- Upstream: https://github.com/Chlumsky/msdfgen
|
- Upstream: https://github.com/Chlumsky/msdfgen
|
||||||
- Version: 1.10 (64a91eec3ca3787e6f78b4c99fcd3052ad3e37c0, 2021)
|
- Version: 1.11 (f12d7ca00091a632a289865b85c3f2e0bfc6542d, 2023)
|
||||||
- License: MIT
|
- License: MIT
|
||||||
|
|
||||||
Files extracted from the upstream source:
|
Files extracted from the upstream source:
|
||||||
|
|
|
||||||
6
thirdparty/icu4c/common/unicode/uvernum.h
vendored
6
thirdparty/icu4c/common/unicode/uvernum.h
vendored
|
|
@ -59,7 +59,7 @@
|
||||||
* This value will change in the subsequent releases of ICU
|
* This value will change in the subsequent releases of ICU
|
||||||
* @stable ICU 2.6
|
* @stable ICU 2.6
|
||||||
*/
|
*/
|
||||||
#define U_ICU_VERSION_MINOR_NUM 1
|
#define U_ICU_VERSION_MINOR_NUM 2
|
||||||
|
|
||||||
/** The current ICU patchlevel version as an integer.
|
/** The current ICU patchlevel version as an integer.
|
||||||
* This value will change in the subsequent releases of ICU
|
* This value will change in the subsequent releases of ICU
|
||||||
|
|
@ -132,7 +132,7 @@
|
||||||
* This value will change in the subsequent releases of ICU
|
* This value will change in the subsequent releases of ICU
|
||||||
* @stable ICU 2.4
|
* @stable ICU 2.4
|
||||||
*/
|
*/
|
||||||
#define U_ICU_VERSION "74.1"
|
#define U_ICU_VERSION "74.2"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current ICU library major version number as a string, for library name suffixes.
|
* The current ICU library major version number as a string, for library name suffixes.
|
||||||
|
|
@ -151,7 +151,7 @@
|
||||||
/** Data version in ICU4C.
|
/** Data version in ICU4C.
|
||||||
* @internal ICU 4.4 Internal Use Only
|
* @internal ICU 4.4 Internal Use Only
|
||||||
**/
|
**/
|
||||||
#define U_ICU_DATA_VERSION "74.1"
|
#define U_ICU_DATA_VERSION "74.2"
|
||||||
#endif /* U_HIDE_INTERNAL_API */
|
#endif /* U_HIDE_INTERNAL_API */
|
||||||
|
|
||||||
/*===========================================================================
|
/*===========================================================================
|
||||||
|
|
|
||||||
BIN
thirdparty/icu4c/icudt74l.dat
vendored
BIN
thirdparty/icu4c/icudt74l.dat
vendored
Binary file not shown.
2
thirdparty/msdfgen/LICENSE.txt
vendored
2
thirdparty/msdfgen/LICENSE.txt
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2016 - 2022 Viktor Chlumsky
|
Copyright (c) 2016 - 2023 Viktor Chlumsky
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|
|
||||||
4
thirdparty/msdfgen/core/BitmapRef.hpp
vendored
4
thirdparty/msdfgen/core/BitmapRef.hpp
vendored
|
|
@ -1,12 +1,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdlib>
|
#include "base.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
|
|
||||||
/// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
|
/// Reference to a 2D image bitmap or a buffer acting as one. Pixel storage not owned or managed by the object.
|
||||||
template <typename T, int N = 1>
|
template <typename T, int N = 1>
|
||||||
struct BitmapRef {
|
struct BitmapRef {
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/EdgeColor.h
vendored
2
thirdparty/msdfgen/core/EdgeColor.h
vendored
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
/// Edge color specifies which color channels an edge belongs to.
|
/// Edge color specifies which color channels an edge belongs to.
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ namespace msdfgen {
|
||||||
#define CLASSIFIER_FLAG_CANDIDATE 0x01
|
#define CLASSIFIER_FLAG_CANDIDATE 0x01
|
||||||
#define CLASSIFIER_FLAG_ARTIFACT 0x02
|
#define CLASSIFIER_FLAG_ARTIFACT 0x02
|
||||||
|
|
||||||
const double ErrorCorrectionConfig::defaultMinDeviationRatio = 1.11111111111111111;
|
MSDFGEN_PUBLIC const double ErrorCorrectionConfig::defaultMinDeviationRatio = 1.11111111111111111;
|
||||||
const double ErrorCorrectionConfig::defaultMinImproveRatio = 1.11111111111111111;
|
MSDFGEN_PUBLIC const double ErrorCorrectionConfig::defaultMinImproveRatio = 1.11111111111111111;
|
||||||
|
|
||||||
/// The base artifact classifier recognizes artifacts based on the contents of the SDF alone.
|
/// The base artifact classifier recognizes artifacts based on the contents of the SDF alone.
|
||||||
class BaseArtifactClassifier {
|
class BaseArtifactClassifier {
|
||||||
|
|
@ -317,7 +317,7 @@ static bool hasDiagonalArtifactInner(const ArtifactClassifier &artifactClassifie
|
||||||
em[0] = am, em[1] = dm;
|
em[0] = am, em[1] = dm;
|
||||||
tEnd[tEx0 > t[i]] = tEx0;
|
tEnd[tEx0 > t[i]] = tEx0;
|
||||||
em[tEx0 > t[i]] = interpolatedMedian(a, l, q, tEx0);
|
em[tEx0 > t[i]] = interpolatedMedian(a, l, q, tEx0);
|
||||||
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], am, dm, xm);
|
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], em[0], em[1], xm);
|
||||||
}
|
}
|
||||||
// tEx1
|
// tEx1
|
||||||
if (tEx1 > 0 && tEx1 < 1) {
|
if (tEx1 > 0 && tEx1 < 1) {
|
||||||
|
|
@ -325,7 +325,7 @@ static bool hasDiagonalArtifactInner(const ArtifactClassifier &artifactClassifie
|
||||||
em[0] = am, em[1] = dm;
|
em[0] = am, em[1] = dm;
|
||||||
tEnd[tEx1 > t[i]] = tEx1;
|
tEnd[tEx1 > t[i]] = tEx1;
|
||||||
em[tEx1 > t[i]] = interpolatedMedian(a, l, q, tEx1);
|
em[tEx1 > t[i]] = interpolatedMedian(a, l, q, tEx1);
|
||||||
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], am, dm, xm);
|
rangeFlags |= artifactClassifier.rangeTest(tEnd[0], tEnd[1], t[i], em[0], em[1], xm);
|
||||||
}
|
}
|
||||||
if (artifactClassifier.evaluate(t[i], xm, rangeFlags))
|
if (artifactClassifier.evaluate(t[i], xm, rangeFlags))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/Projection.h
vendored
2
thirdparty/msdfgen/core/Projection.h
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/Scanline.cpp
vendored
2
thirdparty/msdfgen/core/Scanline.cpp
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#include "Scanline.h"
|
#include "Scanline.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <cstdlib>
|
||||||
#include "arithmetics.hpp"
|
#include "arithmetics.hpp"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
|
||||||
1
thirdparty/msdfgen/core/Scanline.h
vendored
1
thirdparty/msdfgen/core/Scanline.h
vendored
|
|
@ -2,6 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
|
|
|
||||||
19
thirdparty/msdfgen/core/Shape.cpp
vendored
19
thirdparty/msdfgen/core/Shape.cpp
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <cstdlib>
|
||||||
#include "arithmetics.hpp"
|
#include "arithmetics.hpp"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
@ -40,15 +40,12 @@ bool Shape::validate() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deconvergeEdge(EdgeHolder &edgeHolder, int param) {
|
static void deconvergeEdge(EdgeHolder &edgeHolder, int param) {
|
||||||
{
|
switch (edgeHolder->type()) {
|
||||||
const QuadraticSegment *quadraticSegment = dynamic_cast<const QuadraticSegment *>(&*edgeHolder);
|
case (int) QuadraticSegment::EDGE_TYPE:
|
||||||
if (quadraticSegment)
|
edgeHolder = static_cast<const QuadraticSegment *>(&*edgeHolder)->convertToCubic();
|
||||||
edgeHolder = quadraticSegment->convertToCubic();
|
// fallthrough
|
||||||
}
|
case (int) CubicSegment::EDGE_TYPE:
|
||||||
{
|
static_cast<CubicSegment *>(&*edgeHolder)->deconverge(param, MSDFGEN_DECONVERGENCE_FACTOR);
|
||||||
CubicSegment *cubicSegment = dynamic_cast<CubicSegment *>(&*edgeHolder);
|
|
||||||
if (cubicSegment)
|
|
||||||
cubicSegment->deconverge(param, MSDFGEN_DECONVERGENCE_FACTOR);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,6 +159,7 @@ void Shape::orientContours() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!intersections.empty()) {
|
||||||
qsort(&intersections[0], intersections.size(), sizeof(Intersection), &Intersection::compare);
|
qsort(&intersections[0], intersections.size(), sizeof(Intersection), &Intersection::compare);
|
||||||
// Disqualify multiple intersections
|
// Disqualify multiple intersections
|
||||||
for (int j = 1; j < (int) intersections.size(); ++j)
|
for (int j = 1; j < (int) intersections.size(); ++j)
|
||||||
|
|
@ -174,6 +172,7 @@ void Shape::orientContours() {
|
||||||
intersections.clear();
|
intersections.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Reverse contours that have the opposite orientation
|
// Reverse contours that have the opposite orientation
|
||||||
for (int i = 0; i < (int) contours.size(); ++i)
|
for (int i = 0; i < (int) contours.size(); ++i)
|
||||||
if (orientations[i] < 0)
|
if (orientations[i] < 0)
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "edge-selectors.h"
|
#include "edge-selectors.h"
|
||||||
#include "contour-combiners.h"
|
#include "contour-combiners.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,11 @@ ShapeDistanceFinder<ContourCombiner>::ShapeDistanceFinder(const Shape &shape) :
|
||||||
template <class ContourCombiner>
|
template <class ContourCombiner>
|
||||||
typename ShapeDistanceFinder<ContourCombiner>::DistanceType ShapeDistanceFinder<ContourCombiner>::distance(const Point2 &origin) {
|
typename ShapeDistanceFinder<ContourCombiner>::DistanceType ShapeDistanceFinder<ContourCombiner>::distance(const Point2 &origin) {
|
||||||
contourCombiner.reset(origin);
|
contourCombiner.reset(origin);
|
||||||
typename ContourCombiner::EdgeSelectorType::EdgeCache *edgeCache = &shapeEdgeCache[0];
|
#ifdef MSDFGEN_USE_CPP11
|
||||||
|
typename ContourCombiner::EdgeSelectorType::EdgeCache *edgeCache = shapeEdgeCache.data();
|
||||||
|
#else
|
||||||
|
typename ContourCombiner::EdgeSelectorType::EdgeCache *edgeCache = shapeEdgeCache.empty() ? NULL : &shapeEdgeCache[0];
|
||||||
|
#endif
|
||||||
|
|
||||||
for (std::vector<Contour>::const_iterator contour = shape.contours.begin(); contour != shape.contours.end(); ++contour) {
|
for (std::vector<Contour>::const_iterator contour = shape.contours.begin(); contour != shape.contours.end(); ++contour) {
|
||||||
if (!contour->edges.empty()) {
|
if (!contour->edges.empty()) {
|
||||||
|
|
|
||||||
29
thirdparty/msdfgen/core/SignedDistance.cpp
vendored
29
thirdparty/msdfgen/core/SignedDistance.cpp
vendored
|
|
@ -1,29 +0,0 @@
|
||||||
|
|
||||||
#include "SignedDistance.h"
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <cfloat>
|
|
||||||
|
|
||||||
namespace msdfgen {
|
|
||||||
|
|
||||||
SignedDistance::SignedDistance() : distance(-DBL_MAX), dot(1) { }
|
|
||||||
|
|
||||||
SignedDistance::SignedDistance(double dist, double d) : distance(dist), dot(d) { }
|
|
||||||
|
|
||||||
bool operator<(SignedDistance a, SignedDistance b) {
|
|
||||||
return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>(SignedDistance a, SignedDistance b) {
|
|
||||||
return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<=(SignedDistance a, SignedDistance b) {
|
|
||||||
return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>=(SignedDistance a, SignedDistance b) {
|
|
||||||
return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
23
thirdparty/msdfgen/core/SignedDistance.h
vendored
23
thirdparty/msdfgen/core/SignedDistance.h
vendored
|
|
@ -1,23 +0,0 @@
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace msdfgen {
|
|
||||||
|
|
||||||
/// Represents a signed distance and alignment, which together can be compared to uniquely determine the closest edge segment.
|
|
||||||
class SignedDistance {
|
|
||||||
|
|
||||||
public:
|
|
||||||
double distance;
|
|
||||||
double dot;
|
|
||||||
|
|
||||||
SignedDistance();
|
|
||||||
SignedDistance(double dist, double d);
|
|
||||||
|
|
||||||
friend bool operator<(SignedDistance a, SignedDistance b);
|
|
||||||
friend bool operator>(SignedDistance a, SignedDistance b);
|
|
||||||
friend bool operator<=(SignedDistance a, SignedDistance b);
|
|
||||||
friend bool operator>=(SignedDistance a, SignedDistance b);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
38
thirdparty/msdfgen/core/SignedDistance.hpp
vendored
Normal file
38
thirdparty/msdfgen/core/SignedDistance.hpp
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <cfloat>
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
|
namespace msdfgen {
|
||||||
|
|
||||||
|
/// Represents a signed distance and alignment, which together can be compared to uniquely determine the closest edge segment.
|
||||||
|
class SignedDistance {
|
||||||
|
|
||||||
|
public:
|
||||||
|
double distance;
|
||||||
|
double dot;
|
||||||
|
|
||||||
|
inline SignedDistance() : distance(-DBL_MAX), dot(0) { }
|
||||||
|
inline SignedDistance(double dist, double d) : distance(dist), dot(d) { }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator<(const SignedDistance a, const SignedDistance b) {
|
||||||
|
return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot < b.dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>(const SignedDistance a, const SignedDistance b) {
|
||||||
|
return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot > b.dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator<=(const SignedDistance a, const SignedDistance b) {
|
||||||
|
return fabs(a.distance) < fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot <= b.dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator>=(const SignedDistance a, const SignedDistance b) {
|
||||||
|
return fabs(a.distance) > fabs(b.distance) || (fabs(a.distance) == fabs(b.distance) && a.dot >= b.dot);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
146
thirdparty/msdfgen/core/Vector2.cpp
vendored
146
thirdparty/msdfgen/core/Vector2.cpp
vendored
|
|
@ -1,146 +0,0 @@
|
||||||
|
|
||||||
#include "Vector2.h"
|
|
||||||
|
|
||||||
namespace msdfgen {
|
|
||||||
|
|
||||||
Vector2::Vector2(double val) : x(val), y(val) { }
|
|
||||||
|
|
||||||
Vector2::Vector2(double x, double y) : x(x), y(y) { }
|
|
||||||
|
|
||||||
void Vector2::reset() {
|
|
||||||
x = 0, y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Vector2::set(double x, double y) {
|
|
||||||
Vector2::x = x, Vector2::y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vector2::length() const {
|
|
||||||
return sqrt(x*x+y*y);
|
|
||||||
}
|
|
||||||
|
|
||||||
double Vector2::direction() const {
|
|
||||||
return atan2(y, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::normalize(bool allowZero) const {
|
|
||||||
double len = length();
|
|
||||||
if (len == 0)
|
|
||||||
return Vector2(0, !allowZero);
|
|
||||||
return Vector2(x/len, y/len);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::getOrthogonal(bool polarity) const {
|
|
||||||
return polarity ? Vector2(-y, x) : Vector2(y, -x);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::getOrthonormal(bool polarity, bool allowZero) const {
|
|
||||||
double len = length();
|
|
||||||
if (len == 0)
|
|
||||||
return polarity ? Vector2(0, !allowZero) : Vector2(0, -!allowZero);
|
|
||||||
return polarity ? Vector2(-y/len, x/len) : Vector2(y/len, -x/len);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::project(const Vector2 &vector, bool positive) const {
|
|
||||||
Vector2 n = normalize(true);
|
|
||||||
double t = dotProduct(vector, n);
|
|
||||||
if (positive && t <= 0)
|
|
||||||
return Vector2();
|
|
||||||
return t*n;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2::operator const void*() const {
|
|
||||||
return x || y ? this : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Vector2::operator!() const {
|
|
||||||
return !x && !y;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Vector2::operator==(const Vector2 &other) const {
|
|
||||||
return x == other.x && y == other.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Vector2::operator!=(const Vector2 &other) const {
|
|
||||||
return x != other.x || y != other.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator+() const {
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator-() const {
|
|
||||||
return Vector2(-x, -y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator+(const Vector2 &other) const {
|
|
||||||
return Vector2(x+other.x, y+other.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator-(const Vector2 &other) const {
|
|
||||||
return Vector2(x-other.x, y-other.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator*(const Vector2 &other) const {
|
|
||||||
return Vector2(x*other.x, y*other.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator/(const Vector2 &other) const {
|
|
||||||
return Vector2(x/other.x, y/other.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator*(double value) const {
|
|
||||||
return Vector2(x*value, y*value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 Vector2::operator/(double value) const {
|
|
||||||
return Vector2(x/value, y/value);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 & Vector2::operator+=(const Vector2 &other) {
|
|
||||||
x += other.x, y += other.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 & Vector2::operator-=(const Vector2 &other) {
|
|
||||||
x -= other.x, y -= other.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 & Vector2::operator*=(const Vector2 &other) {
|
|
||||||
x *= other.x, y *= other.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 & Vector2::operator/=(const Vector2 &other) {
|
|
||||||
x /= other.x, y /= other.y;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 & Vector2::operator*=(double value) {
|
|
||||||
x *= value, y *= value;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 & Vector2::operator/=(double value) {
|
|
||||||
x /= value, y /= value;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
double dotProduct(const Vector2 &a, const Vector2 &b) {
|
|
||||||
return a.x*b.x+a.y*b.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
double crossProduct(const Vector2 &a, const Vector2 &b) {
|
|
||||||
return a.x*b.y-a.y*b.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 operator*(double value, const Vector2 &vector) {
|
|
||||||
return Vector2(value*vector.x, value*vector.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector2 operator/(double value, const Vector2 &vector) {
|
|
||||||
return Vector2(value/vector.x, value/vector.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
66
thirdparty/msdfgen/core/Vector2.h
vendored
66
thirdparty/msdfgen/core/Vector2.h
vendored
|
|
@ -1,66 +0,0 @@
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
namespace msdfgen {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A 2-dimensional euclidean vector with double precision.
|
|
||||||
* Implementation based on the Vector2 template from Artery Engine.
|
|
||||||
* @author Viktor Chlumsky
|
|
||||||
*/
|
|
||||||
struct Vector2 {
|
|
||||||
|
|
||||||
double x, y;
|
|
||||||
|
|
||||||
Vector2(double val = 0);
|
|
||||||
Vector2(double x, double y);
|
|
||||||
/// Sets the vector to zero.
|
|
||||||
void reset();
|
|
||||||
/// Sets individual elements of the vector.
|
|
||||||
void set(double x, double y);
|
|
||||||
/// Returns the vector's length.
|
|
||||||
double length() const;
|
|
||||||
/// Returns the angle of the vector in radians (atan2).
|
|
||||||
double direction() const;
|
|
||||||
/// Returns the normalized vector - one that has the same direction but unit length.
|
|
||||||
Vector2 normalize(bool allowZero = false) const;
|
|
||||||
/// Returns a vector with the same length that is orthogonal to this one.
|
|
||||||
Vector2 getOrthogonal(bool polarity = true) const;
|
|
||||||
/// Returns a vector with unit length that is orthogonal to this one.
|
|
||||||
Vector2 getOrthonormal(bool polarity = true, bool allowZero = false) const;
|
|
||||||
/// Returns a vector projected along this one.
|
|
||||||
Vector2 project(const Vector2 &vector, bool positive = false) const;
|
|
||||||
operator const void *() const;
|
|
||||||
bool operator!() const;
|
|
||||||
bool operator==(const Vector2 &other) const;
|
|
||||||
bool operator!=(const Vector2 &other) const;
|
|
||||||
Vector2 operator+() const;
|
|
||||||
Vector2 operator-() const;
|
|
||||||
Vector2 operator+(const Vector2 &other) const;
|
|
||||||
Vector2 operator-(const Vector2 &other) const;
|
|
||||||
Vector2 operator*(const Vector2 &other) const;
|
|
||||||
Vector2 operator/(const Vector2 &other) const;
|
|
||||||
Vector2 operator*(double value) const;
|
|
||||||
Vector2 operator/(double value) const;
|
|
||||||
Vector2 & operator+=(const Vector2 &other);
|
|
||||||
Vector2 & operator-=(const Vector2 &other);
|
|
||||||
Vector2 & operator*=(const Vector2 &other);
|
|
||||||
Vector2 & operator/=(const Vector2 &other);
|
|
||||||
Vector2 & operator*=(double value);
|
|
||||||
Vector2 & operator/=(double value);
|
|
||||||
/// Dot product of two vectors.
|
|
||||||
friend double dotProduct(const Vector2 &a, const Vector2 &b);
|
|
||||||
/// A special version of the cross product for 2D vectors (returns scalar value).
|
|
||||||
friend double crossProduct(const Vector2 &a, const Vector2 &b);
|
|
||||||
friend Vector2 operator*(double value, const Vector2 &vector);
|
|
||||||
friend Vector2 operator/(double value, const Vector2 &vector);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A vector may also represent a point, which shall be differentiated semantically using the alias Point2.
|
|
||||||
typedef Vector2 Point2;
|
|
||||||
|
|
||||||
}
|
|
||||||
167
thirdparty/msdfgen/core/Vector2.hpp
vendored
Normal file
167
thirdparty/msdfgen/core/Vector2.hpp
vendored
Normal file
|
|
@ -0,0 +1,167 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
|
namespace msdfgen {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 2-dimensional euclidean floating-point vector.
|
||||||
|
* @author Viktor Chlumsky
|
||||||
|
*/
|
||||||
|
struct Vector2 {
|
||||||
|
|
||||||
|
double x, y;
|
||||||
|
|
||||||
|
inline Vector2(double val = 0) : x(val), y(val) { }
|
||||||
|
|
||||||
|
inline Vector2(double x, double y) : x(x), y(y) { }
|
||||||
|
|
||||||
|
/// Sets the vector to zero.
|
||||||
|
inline void reset() {
|
||||||
|
x = 0, y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets individual elements of the vector.
|
||||||
|
inline void set(double x, double y) {
|
||||||
|
this->x = x, this->y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the vector's squared length.
|
||||||
|
inline double squaredLength() const {
|
||||||
|
return x*x+y*y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the vector's length.
|
||||||
|
inline double length() const {
|
||||||
|
return sqrt(x*x+y*y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the normalized vector - one that has the same direction but unit length.
|
||||||
|
inline Vector2 normalize(bool allowZero = false) const {
|
||||||
|
if (double len = length())
|
||||||
|
return Vector2(x/len, y/len);
|
||||||
|
return Vector2(0, !allowZero);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a vector with the same length that is orthogonal to this one.
|
||||||
|
inline Vector2 getOrthogonal(bool polarity = true) const {
|
||||||
|
return polarity ? Vector2(-y, x) : Vector2(y, -x);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a vector with unit length that is orthogonal to this one.
|
||||||
|
inline Vector2 getOrthonormal(bool polarity = true, bool allowZero = false) const {
|
||||||
|
if (double len = length())
|
||||||
|
return polarity ? Vector2(-y/len, x/len) : Vector2(y/len, -x/len);
|
||||||
|
return polarity ? Vector2(0, !allowZero) : Vector2(0, -!allowZero);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef MSDFGEN_USE_CPP11
|
||||||
|
inline explicit operator bool() const {
|
||||||
|
return x || y;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
inline operator const void *() const {
|
||||||
|
return x || y ? this : NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline Vector2 &operator+=(const Vector2 other) {
|
||||||
|
x += other.x, y += other.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 &operator-=(const Vector2 other) {
|
||||||
|
x -= other.x, y -= other.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 &operator*=(const Vector2 other) {
|
||||||
|
x *= other.x, y *= other.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 &operator/=(const Vector2 other) {
|
||||||
|
x /= other.x, y /= other.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 &operator*=(double value) {
|
||||||
|
x *= value, y *= value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 &operator/=(double value) {
|
||||||
|
x /= value, y /= value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/// A vector may also represent a point, which shall be differentiated semantically using the alias Point2.
|
||||||
|
typedef Vector2 Point2;
|
||||||
|
|
||||||
|
/// Dot product of two vectors.
|
||||||
|
inline double dotProduct(const Vector2 a, const Vector2 b) {
|
||||||
|
return a.x*b.x+a.y*b.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A special version of the cross product for 2D vectors (returns scalar value).
|
||||||
|
inline double crossProduct(const Vector2 a, const Vector2 b) {
|
||||||
|
return a.x*b.y-a.y*b.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator==(const Vector2 a, const Vector2 b) {
|
||||||
|
return a.x == b.x && a.y == b.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const Vector2 a, const Vector2 b) {
|
||||||
|
return a.x != b.x || a.y != b.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator+(const Vector2 v) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator-(const Vector2 v) {
|
||||||
|
return Vector2(-v.x, -v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!(const Vector2 v) {
|
||||||
|
return !v.x && !v.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator+(const Vector2 a, const Vector2 b) {
|
||||||
|
return Vector2(a.x+b.x, a.y+b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator-(const Vector2 a, const Vector2 b) {
|
||||||
|
return Vector2(a.x-b.x, a.y-b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator*(const Vector2 a, const Vector2 b) {
|
||||||
|
return Vector2(a.x*b.x, a.y*b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator/(const Vector2 a, const Vector2 b) {
|
||||||
|
return Vector2(a.x/b.x, a.y/b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator*(double a, const Vector2 b) {
|
||||||
|
return Vector2(a*b.x, a*b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator/(double a, const Vector2 b) {
|
||||||
|
return Vector2(a/b.x, a/b.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator*(const Vector2 a, double b) {
|
||||||
|
return Vector2(a.x*b, a.y*b);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Vector2 operator/(const Vector2 a, double b) {
|
||||||
|
return Vector2(a.x/b, a.y/b);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
2
thirdparty/msdfgen/core/arithmetics.hpp
vendored
2
thirdparty/msdfgen/core/arithmetics.hpp
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
|
|
|
||||||
16
thirdparty/msdfgen/core/base.h
vendored
Normal file
16
thirdparty/msdfgen/core/base.h
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// This file needs to be included first for all MSDFgen sources
|
||||||
|
|
||||||
|
#ifndef MSDFGEN_PUBLIC
|
||||||
|
#include <msdfgen/msdfgen-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace msdfgen {
|
||||||
|
|
||||||
|
typedef unsigned char byte;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "arithmetics.hpp"
|
#include "arithmetics.hpp"
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "BitmapRef.hpp"
|
#include "BitmapRef.hpp"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
|
||||||
1
thirdparty/msdfgen/core/edge-coloring.cpp
vendored
1
thirdparty/msdfgen/core/edge-coloring.cpp
vendored
|
|
@ -5,6 +5,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include "arithmetics.hpp"
|
#include "arithmetics.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
24
thirdparty/msdfgen/core/edge-segments.cpp
vendored
24
thirdparty/msdfgen/core/edge-segments.cpp
vendored
|
|
@ -68,6 +68,30 @@ CubicSegment * CubicSegment::clone() const {
|
||||||
return new CubicSegment(p[0], p[1], p[2], p[3], color);
|
return new CubicSegment(p[0], p[1], p[2], p[3], color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LinearSegment::type() const {
|
||||||
|
return (int) EDGE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int QuadraticSegment::type() const {
|
||||||
|
return (int) EDGE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CubicSegment::type() const {
|
||||||
|
return (int) EDGE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Point2 *LinearSegment::controlPoints() const {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Point2 *QuadraticSegment::controlPoints() const {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Point2 *CubicSegment::controlPoints() const {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
Point2 LinearSegment::point(double param) const {
|
Point2 LinearSegment::point(double param) const {
|
||||||
return mix(p[0], p[1], param);
|
return mix(p[0], p[1], param);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
thirdparty/msdfgen/core/edge-segments.h
vendored
26
thirdparty/msdfgen/core/edge-segments.h
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "SignedDistance.h"
|
#include "SignedDistance.hpp"
|
||||||
#include "EdgeColor.h"
|
#include "EdgeColor.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
@ -21,6 +21,10 @@ public:
|
||||||
virtual ~EdgeSegment() { }
|
virtual ~EdgeSegment() { }
|
||||||
/// Creates a copy of the edge segment.
|
/// Creates a copy of the edge segment.
|
||||||
virtual EdgeSegment *clone() const = 0;
|
virtual EdgeSegment *clone() const = 0;
|
||||||
|
/// Returns the numeric code of the edge segment's type.
|
||||||
|
virtual int type() const = 0;
|
||||||
|
/// Returns the array of control points.
|
||||||
|
virtual const Point2 *controlPoints() const = 0;
|
||||||
/// Returns the point on the edge specified by the parameter (between 0 and 1).
|
/// Returns the point on the edge specified by the parameter (between 0 and 1).
|
||||||
virtual Point2 point(double param) const = 0;
|
virtual Point2 point(double param) const = 0;
|
||||||
/// Returns the direction the edge has at the point specified by the parameter.
|
/// Returns the direction the edge has at the point specified by the parameter.
|
||||||
|
|
@ -51,10 +55,16 @@ public:
|
||||||
class LinearSegment : public EdgeSegment {
|
class LinearSegment : public EdgeSegment {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum EdgeType {
|
||||||
|
EDGE_TYPE = 1
|
||||||
|
};
|
||||||
|
|
||||||
Point2 p[2];
|
Point2 p[2];
|
||||||
|
|
||||||
LinearSegment(Point2 p0, Point2 p1, EdgeColor edgeColor = WHITE);
|
LinearSegment(Point2 p0, Point2 p1, EdgeColor edgeColor = WHITE);
|
||||||
LinearSegment *clone() const;
|
LinearSegment *clone() const;
|
||||||
|
int type() const;
|
||||||
|
const Point2 *controlPoints() const;
|
||||||
Point2 point(double param) const;
|
Point2 point(double param) const;
|
||||||
Vector2 direction(double param) const;
|
Vector2 direction(double param) const;
|
||||||
Vector2 directionChange(double param) const;
|
Vector2 directionChange(double param) const;
|
||||||
|
|
@ -74,10 +84,16 @@ public:
|
||||||
class QuadraticSegment : public EdgeSegment {
|
class QuadraticSegment : public EdgeSegment {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum EdgeType {
|
||||||
|
EDGE_TYPE = 2
|
||||||
|
};
|
||||||
|
|
||||||
Point2 p[3];
|
Point2 p[3];
|
||||||
|
|
||||||
QuadraticSegment(Point2 p0, Point2 p1, Point2 p2, EdgeColor edgeColor = WHITE);
|
QuadraticSegment(Point2 p0, Point2 p1, Point2 p2, EdgeColor edgeColor = WHITE);
|
||||||
QuadraticSegment *clone() const;
|
QuadraticSegment *clone() const;
|
||||||
|
int type() const;
|
||||||
|
const Point2 *controlPoints() const;
|
||||||
Point2 point(double param) const;
|
Point2 point(double param) const;
|
||||||
Vector2 direction(double param) const;
|
Vector2 direction(double param) const;
|
||||||
Vector2 directionChange(double param) const;
|
Vector2 directionChange(double param) const;
|
||||||
|
|
@ -99,10 +115,16 @@ public:
|
||||||
class CubicSegment : public EdgeSegment {
|
class CubicSegment : public EdgeSegment {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum EdgeType {
|
||||||
|
EDGE_TYPE = 3
|
||||||
|
};
|
||||||
|
|
||||||
Point2 p[4];
|
Point2 p[4];
|
||||||
|
|
||||||
CubicSegment(Point2 p0, Point2 p1, Point2 p2, Point2 p3, EdgeColor edgeColor = WHITE);
|
CubicSegment(Point2 p0, Point2 p1, Point2 p2, Point2 p3, EdgeColor edgeColor = WHITE);
|
||||||
CubicSegment *clone() const;
|
CubicSegment *clone() const;
|
||||||
|
int type() const;
|
||||||
|
const Point2 *controlPoints() const;
|
||||||
Point2 point(double param) const;
|
Point2 point(double param) const;
|
||||||
Vector2 direction(double param) const;
|
Vector2 direction(double param) const;
|
||||||
Vector2 directionChange(double param) const;
|
Vector2 directionChange(double param) const;
|
||||||
|
|
|
||||||
4
thirdparty/msdfgen/core/edge-selectors.h
vendored
4
thirdparty/msdfgen/core/edge-selectors.h
vendored
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "SignedDistance.h"
|
#include "SignedDistance.hpp"
|
||||||
#include "edge-segments.h"
|
#include "edge-segments.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/equation-solver.h
vendored
2
thirdparty/msdfgen/core/equation-solver.h
vendored
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "base.h"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
// ax^2 + bx + c = 0
|
// ax^2 + bx + c = 0
|
||||||
|
|
|
||||||
1
thirdparty/msdfgen/core/generator-config.h
vendored
1
thirdparty/msdfgen/core/generator-config.h
vendored
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include "BitmapRef.hpp"
|
#include "BitmapRef.hpp"
|
||||||
|
|
||||||
#ifndef MSDFGEN_PUBLIC
|
#ifndef MSDFGEN_PUBLIC
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "Projection.h"
|
#include "Projection.h"
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
#include "BitmapRef.hpp"
|
#include "BitmapRef.hpp"
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/pixel-conversion.hpp
vendored
2
thirdparty/msdfgen/core/pixel-conversion.hpp
vendored
|
|
@ -5,8 +5,6 @@
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
||||||
typedef unsigned char byte;
|
|
||||||
|
|
||||||
inline byte pixelFloatToByte(float x) {
|
inline byte pixelFloatToByte(float x) {
|
||||||
return byte(clamp(256.f*x, 255.f));
|
return byte(clamp(256.f*x, 255.f));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/rasterization.h
vendored
2
thirdparty/msdfgen/core/rasterization.h
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
#include "Projection.h"
|
#include "Projection.h"
|
||||||
#include "Scanline.h"
|
#include "Scanline.h"
|
||||||
|
|
|
||||||
2
thirdparty/msdfgen/core/render-sdf.h
vendored
2
thirdparty/msdfgen/core/render-sdf.h
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "BitmapRef.hpp"
|
#include "BitmapRef.hpp"
|
||||||
|
|
||||||
namespace msdfgen {
|
namespace msdfgen {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Vector2.h"
|
#include "Vector2.hpp"
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
#include "Projection.h"
|
#include "Projection.h"
|
||||||
#include "Scanline.h"
|
#include "Scanline.h"
|
||||||
|
|
|
||||||
25
thirdparty/msdfgen/core/shape-description.cpp
vendored
25
thirdparty/msdfgen/core/shape-description.cpp
vendored
|
|
@ -244,34 +244,37 @@ bool writeShapeDescription(FILE *output, const Shape &shape) {
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (const LinearSegment *e = dynamic_cast<const LinearSegment *>(&**edge)) {
|
const Point2 *p = (*edge)->controlPoints();
|
||||||
|
switch ((*edge)->type()) {
|
||||||
|
case (int) LinearSegment::EDGE_TYPE:
|
||||||
fprintf(output, "\t");
|
fprintf(output, "\t");
|
||||||
writeCoord(output, e->p[0]);
|
writeCoord(output, p[0]);
|
||||||
fprintf(output, ";\n");
|
fprintf(output, ";\n");
|
||||||
if (colorCode)
|
if (colorCode)
|
||||||
fprintf(output, "\t\t%c;\n", colorCode);
|
fprintf(output, "\t\t%c;\n", colorCode);
|
||||||
}
|
break;
|
||||||
if (const QuadraticSegment *e = dynamic_cast<const QuadraticSegment *>(&**edge)) {
|
case (int) QuadraticSegment::EDGE_TYPE:
|
||||||
fprintf(output, "\t");
|
fprintf(output, "\t");
|
||||||
writeCoord(output, e->p[0]);
|
writeCoord(output, p[0]);
|
||||||
fprintf(output, ";\n\t\t");
|
fprintf(output, ";\n\t\t");
|
||||||
if (colorCode)
|
if (colorCode)
|
||||||
fprintf(output, "%c", colorCode);
|
fprintf(output, "%c", colorCode);
|
||||||
fprintf(output, "(");
|
fprintf(output, "(");
|
||||||
writeCoord(output, e->p[1]);
|
writeCoord(output, p[1]);
|
||||||
fprintf(output, ");\n");
|
fprintf(output, ");\n");
|
||||||
}
|
break;
|
||||||
if (const CubicSegment *e = dynamic_cast<const CubicSegment *>(&**edge)) {
|
case (int) CubicSegment::EDGE_TYPE:
|
||||||
fprintf(output, "\t");
|
fprintf(output, "\t");
|
||||||
writeCoord(output, e->p[0]);
|
writeCoord(output, p[0]);
|
||||||
fprintf(output, ";\n\t\t");
|
fprintf(output, ";\n\t\t");
|
||||||
if (colorCode)
|
if (colorCode)
|
||||||
fprintf(output, "%c", colorCode);
|
fprintf(output, "%c", colorCode);
|
||||||
fprintf(output, "(");
|
fprintf(output, "(");
|
||||||
writeCoord(output, e->p[1]);
|
writeCoord(output, p[1]);
|
||||||
fprintf(output, "; ");
|
fprintf(output, "; ");
|
||||||
writeCoord(output, e->p[2]);
|
writeCoord(output, p[2]);
|
||||||
fprintf(output, ");\n");
|
fprintf(output, ");\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(output, "\t#\n");
|
fprintf(output, "\t#\n");
|
||||||
|
|
|
||||||
1
thirdparty/msdfgen/core/shape-description.h
vendored
1
thirdparty/msdfgen/core/shape-description.h
vendored
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
|
|
||||||
|
|
|
||||||
5
thirdparty/msdfgen/msdfgen.h
vendored
5
thirdparty/msdfgen/msdfgen.h
vendored
|
|
@ -4,7 +4,7 @@
|
||||||
/*
|
/*
|
||||||
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
|
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
|
||||||
* ---------------------------------------------
|
* ---------------------------------------------
|
||||||
* A utility by Viktor Chlumsky, (c) 2014 - 2022
|
* A utility by Viktor Chlumsky, (c) 2014 - 2023
|
||||||
*
|
*
|
||||||
* The technique used to generate multi-channel distance fields in this code
|
* The technique used to generate multi-channel distance fields in this code
|
||||||
* has been developed by Viktor Chlumsky in 2014 for his master's thesis,
|
* has been developed by Viktor Chlumsky in 2014 for his master's thesis,
|
||||||
|
|
@ -15,8 +15,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "core/base.h"
|
||||||
#include "core/arithmetics.hpp"
|
#include "core/arithmetics.hpp"
|
||||||
#include "core/Vector2.h"
|
#include "core/Vector2.hpp"
|
||||||
#include "core/Projection.h"
|
#include "core/Projection.h"
|
||||||
#include "core/Scanline.h"
|
#include "core/Scanline.h"
|
||||||
#include "core/Shape.h"
|
#include "core/Shape.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue