Skip to content

Commit

Permalink
Merge pull request #77959 from akien-mga/msdfgen-1.10
Browse files Browse the repository at this point in the history
msdfgen: Sync with upstream 1.10
  • Loading branch information
akien-mga committed Jun 7, 2023
2 parents 803ad98 + 3c25dfe commit 285fbcc
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 103 deletions.
2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ License: BSD-2-clause

Files: ./thirdparty/msdfgen/
Comment: Multi-channel signed distance field generator
Copyright: 2016, Viktor Chlumsky
Copyright: 2016-2022, Viktor Chlumsky
License: MIT

Files: ./thirdparty/oidn/
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,14 +529,14 @@ Collection of single-file libraries used in Godot components.
## msdfgen

- Upstream: https://github.com/Chlumsky/msdfgen
- Version: 1.9.2 (64a91eec3ca3787e6f78b4c99fcd3052ad3e37c0, 2021)
- Version: 1.10 (64a91eec3ca3787e6f78b4c99fcd3052ad3e37c0, 2021)
- License: MIT

Files extracted from the upstream source:

- `msdfgen.h`
- Files in `core/` folder.
- `LICENSE.txt` and `CHANGELOG.md`
- `LICENSE.txt`


## oidn
Expand Down
82 changes: 0 additions & 82 deletions thirdparty/msdfgen/CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion thirdparty/msdfgen/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Viktor Chlumsky
Copyright (c) 2016 - 2022 Viktor Chlumsky

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 2 additions & 3 deletions thirdparty/msdfgen/core/SignedDistance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
#include "SignedDistance.h"

#include <cmath>
#include <cfloat>

namespace msdfgen {

const SignedDistance SignedDistance::INFINITE(-1e240, 1);

SignedDistance::SignedDistance() : distance(-1e240), dot(1) { }
SignedDistance::SignedDistance() : distance(-DBL_MAX), dot(1) { }

SignedDistance::SignedDistance(double dist, double d) : distance(dist), dot(d) { }

Expand Down
2 changes: 0 additions & 2 deletions thirdparty/msdfgen/core/SignedDistance.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ namespace msdfgen {
class SignedDistance {

public:
static const SignedDistance INFINITE;

double distance;
double dot;

Expand Down
9 changes: 5 additions & 4 deletions thirdparty/msdfgen/core/contour-combiners.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@

#include "contour-combiners.h"

#include <cfloat>
#include "arithmetics.hpp"

namespace msdfgen {

static void initDistance(double &distance) {
distance = SignedDistance::INFINITE.distance;
distance = -DBL_MAX;
}

static void initDistance(MultiDistance &distance) {
distance.r = SignedDistance::INFINITE.distance;
distance.g = SignedDistance::INFINITE.distance;
distance.b = SignedDistance::INFINITE.distance;
distance.r = -DBL_MAX;
distance.g = -DBL_MAX;
distance.b = -DBL_MAX;
}

static double resolveDistance(double distance) {
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/msdfgen/core/edge-coloring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cfloat>
#include <queue>
#include "arithmetics.hpp"

Expand Down Expand Up @@ -244,7 +245,7 @@ static double edgeToEdgeDistance(const EdgeSegment &a, const EdgeSegment &b, int
}

static double splineToSplineDistance(EdgeSegment * const *edgeSegments, int aStart, int aEnd, int bStart, int bEnd, int precision) {
double minDistance = fabs(SignedDistance::INFINITE.distance);
double minDistance = DBL_MAX;
for (int ai = aStart; ai < aEnd; ++ai)
for (int bi = bStart; bi < bEnd && minDistance; ++bi) {
double d = edgeToEdgeDistance(*edgeSegments[ai], *edgeSegments[bi], precision);
Expand Down
8 changes: 6 additions & 2 deletions thirdparty/msdfgen/core/generator-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
#include <cstdlib>
#include "BitmapRef.hpp"

#ifndef MSDFGEN_PUBLIC
#define MSDFGEN_PUBLIC // for DLL import/export
#endif

namespace msdfgen {

/// The configuration of the MSDF error correction pass.
struct ErrorCorrectionConfig {
/// The default value of minDeviationRatio.
static const double defaultMinDeviationRatio;
static MSDFGEN_PUBLIC const double defaultMinDeviationRatio;
/// The default value of minImproveRatio.
static const double defaultMinImproveRatio;
static MSDFGEN_PUBLIC const double defaultMinImproveRatio;

/// Mode of operation.
enum Mode {
Expand Down
8 changes: 3 additions & 5 deletions thirdparty/msdfgen/msdfgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#pragma once

/*
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR v1.9 (2021-05-28)
* ---------------------------------------------------------------
* A utility by Viktor Chlumsky, (c) 2014 - 2021
* MULTI-CHANNEL SIGNED DISTANCE FIELD GENERATOR
* ---------------------------------------------
* A utility by Viktor Chlumsky, (c) 2014 - 2022
*
* 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,
Expand Down Expand Up @@ -34,8 +34,6 @@
#include "core/save-tiff.h"
#include "core/shape-description.h"

#define MSDFGEN_VERSION "1.9"

namespace msdfgen {

/// Generates a conventional single-channel signed distance field.
Expand Down

0 comments on commit 285fbcc

Please sign in to comment.