|
@@ -15,7 +15,7 @@ template <>
|
|
class DistancePixelConversion<double> {
|
|
class DistancePixelConversion<double> {
|
|
DistanceMapping mapping;
|
|
DistanceMapping mapping;
|
|
public:
|
|
public:
|
|
- typedef BitmapRef<float, 1> BitmapRefType;
|
|
|
|
|
|
+ typedef BitmapSection<float, 1> BitmapSectionType;
|
|
inline explicit DistancePixelConversion(DistanceMapping mapping) : mapping(mapping) { }
|
|
inline explicit DistancePixelConversion(DistanceMapping mapping) : mapping(mapping) { }
|
|
inline void operator()(float *pixels, double distance) const {
|
|
inline void operator()(float *pixels, double distance) const {
|
|
*pixels = float(mapping(distance));
|
|
*pixels = float(mapping(distance));
|
|
@@ -26,7 +26,7 @@ template <>
|
|
class DistancePixelConversion<MultiDistance> {
|
|
class DistancePixelConversion<MultiDistance> {
|
|
DistanceMapping mapping;
|
|
DistanceMapping mapping;
|
|
public:
|
|
public:
|
|
- typedef BitmapRef<float, 3> BitmapRefType;
|
|
|
|
|
|
+ typedef BitmapSection<float, 3> BitmapSectionType;
|
|
inline explicit DistancePixelConversion(DistanceMapping mapping) : mapping(mapping) { }
|
|
inline explicit DistancePixelConversion(DistanceMapping mapping) : mapping(mapping) { }
|
|
inline void operator()(float *pixels, const MultiDistance &distance) const {
|
|
inline void operator()(float *pixels, const MultiDistance &distance) const {
|
|
pixels[0] = float(mapping(distance.r));
|
|
pixels[0] = float(mapping(distance.r));
|
|
@@ -39,7 +39,7 @@ template <>
|
|
class DistancePixelConversion<MultiAndTrueDistance> {
|
|
class DistancePixelConversion<MultiAndTrueDistance> {
|
|
DistanceMapping mapping;
|
|
DistanceMapping mapping;
|
|
public:
|
|
public:
|
|
- typedef BitmapRef<float, 4> BitmapRefType;
|
|
|
|
|
|
+ typedef BitmapSection<float, 4> BitmapSectionType;
|
|
inline explicit DistancePixelConversion(DistanceMapping mapping) : mapping(mapping) { }
|
|
inline explicit DistancePixelConversion(DistanceMapping mapping) : mapping(mapping) { }
|
|
inline void operator()(float *pixels, const MultiAndTrueDistance &distance) const {
|
|
inline void operator()(float *pixels, const MultiAndTrueDistance &distance) const {
|
|
pixels[0] = float(mapping(distance.r));
|
|
pixels[0] = float(mapping(distance.r));
|
|
@@ -50,45 +50,46 @@ public:
|
|
};
|
|
};
|
|
|
|
|
|
template <class ContourCombiner>
|
|
template <class ContourCombiner>
|
|
-void generateDistanceField(const typename DistancePixelConversion<typename ContourCombiner::DistanceType>::BitmapRefType &output, const Shape &shape, const SDFTransformation &transformation) {
|
|
|
|
|
|
+void generateDistanceField(typename DistancePixelConversion<typename ContourCombiner::DistanceType>::BitmapSectionType output, const Shape &shape, const SDFTransformation &transformation) {
|
|
DistancePixelConversion<typename ContourCombiner::DistanceType> distancePixelConversion(transformation.distanceMapping);
|
|
DistancePixelConversion<typename ContourCombiner::DistanceType> distancePixelConversion(transformation.distanceMapping);
|
|
|
|
+ output.reorient(shape.getYAxisOrientation());
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#pragma omp parallel
|
|
#pragma omp parallel
|
|
#endif
|
|
#endif
|
|
{
|
|
{
|
|
ShapeDistanceFinder<ContourCombiner> distanceFinder(shape);
|
|
ShapeDistanceFinder<ContourCombiner> distanceFinder(shape);
|
|
- bool rightToLeft = false;
|
|
|
|
|
|
+ int xDirection = 1;
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#pragma omp for
|
|
#pragma omp for
|
|
#endif
|
|
#endif
|
|
for (int y = 0; y < output.height; ++y) {
|
|
for (int y = 0; y < output.height; ++y) {
|
|
- int row = shape.inverseYAxis ? output.height-y-1 : y;
|
|
|
|
|
|
+ int x = xDirection < 0 ? output.width-1 : 0;
|
|
for (int col = 0; col < output.width; ++col) {
|
|
for (int col = 0; col < output.width; ++col) {
|
|
- int x = rightToLeft ? output.width-col-1 : col;
|
|
|
|
Point2 p = transformation.unproject(Point2(x+.5, y+.5));
|
|
Point2 p = transformation.unproject(Point2(x+.5, y+.5));
|
|
typename ContourCombiner::DistanceType distance = distanceFinder.distance(p);
|
|
typename ContourCombiner::DistanceType distance = distanceFinder.distance(p);
|
|
- distancePixelConversion(output(x, row), distance);
|
|
|
|
|
|
+ distancePixelConversion(output(x, y), distance);
|
|
|
|
+ x += xDirection;
|
|
}
|
|
}
|
|
- rightToLeft = !rightToLeft;
|
|
|
|
|
|
+ xDirection = -xDirection;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void generateSDF(const BitmapRef<float, 1> &output, const Shape &shape, const SDFTransformation &transformation, const GeneratorConfig &config) {
|
|
|
|
|
|
+void generateSDF(const BitmapSection<float, 1> &output, const Shape &shape, const SDFTransformation &transformation, const GeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<TrueDistanceSelector> >(output, shape, transformation);
|
|
generateDistanceField<OverlappingContourCombiner<TrueDistanceSelector> >(output, shape, transformation);
|
|
else
|
|
else
|
|
generateDistanceField<SimpleContourCombiner<TrueDistanceSelector> >(output, shape, transformation);
|
|
generateDistanceField<SimpleContourCombiner<TrueDistanceSelector> >(output, shape, transformation);
|
|
}
|
|
}
|
|
|
|
|
|
-void generatePSDF(const BitmapRef<float, 1> &output, const Shape &shape, const SDFTransformation &transformation, const GeneratorConfig &config) {
|
|
|
|
|
|
+void generatePSDF(const BitmapSection<float, 1> &output, const Shape &shape, const SDFTransformation &transformation, const GeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<PerpendicularDistanceSelector> >(output, shape, transformation);
|
|
generateDistanceField<OverlappingContourCombiner<PerpendicularDistanceSelector> >(output, shape, transformation);
|
|
else
|
|
else
|
|
generateDistanceField<SimpleContourCombiner<PerpendicularDistanceSelector> >(output, shape, transformation);
|
|
generateDistanceField<SimpleContourCombiner<PerpendicularDistanceSelector> >(output, shape, transformation);
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMSDF(const BitmapRef<float, 3> &output, const Shape &shape, const SDFTransformation &transformation, const MSDFGeneratorConfig &config) {
|
|
|
|
|
|
+void generateMSDF(const BitmapSection<float, 3> &output, const Shape &shape, const SDFTransformation &transformation, const MSDFGeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<MultiDistanceSelector> >(output, shape, transformation);
|
|
generateDistanceField<OverlappingContourCombiner<MultiDistanceSelector> >(output, shape, transformation);
|
|
else
|
|
else
|
|
@@ -96,7 +97,7 @@ void generateMSDF(const BitmapRef<float, 3> &output, const Shape &shape, const S
|
|
msdfErrorCorrection(output, shape, transformation, config);
|
|
msdfErrorCorrection(output, shape, transformation, config);
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMTSDF(const BitmapRef<float, 4> &output, const Shape &shape, const SDFTransformation &transformation, const MSDFGeneratorConfig &config) {
|
|
|
|
|
|
+void generateMTSDF(const BitmapSection<float, 4> &output, const Shape &shape, const SDFTransformation &transformation, const MSDFGeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<MultiAndTrueDistanceSelector> >(output, shape, transformation);
|
|
generateDistanceField<OverlappingContourCombiner<MultiAndTrueDistanceSelector> >(output, shape, transformation);
|
|
else
|
|
else
|
|
@@ -104,21 +105,21 @@ void generateMTSDF(const BitmapRef<float, 4> &output, const Shape &shape, const
|
|
msdfErrorCorrection(output, shape, transformation, config);
|
|
msdfErrorCorrection(output, shape, transformation, config);
|
|
}
|
|
}
|
|
|
|
|
|
-void generateSDF(const BitmapRef<float, 1> &output, const Shape &shape, const Projection &projection, Range range, const GeneratorConfig &config) {
|
|
|
|
|
|
+void generateSDF(const BitmapSection<float, 1> &output, const Shape &shape, const Projection &projection, Range range, const GeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<TrueDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
generateDistanceField<OverlappingContourCombiner<TrueDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
else
|
|
else
|
|
generateDistanceField<SimpleContourCombiner<TrueDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
generateDistanceField<SimpleContourCombiner<TrueDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
}
|
|
}
|
|
|
|
|
|
-void generatePSDF(const BitmapRef<float, 1> &output, const Shape &shape, const Projection &projection, Range range, const GeneratorConfig &config) {
|
|
|
|
|
|
+void generatePSDF(const BitmapSection<float, 1> &output, const Shape &shape, const Projection &projection, Range range, const GeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<PerpendicularDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
generateDistanceField<OverlappingContourCombiner<PerpendicularDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
else
|
|
else
|
|
generateDistanceField<SimpleContourCombiner<PerpendicularDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
generateDistanceField<SimpleContourCombiner<PerpendicularDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMSDF(const BitmapRef<float, 3> &output, const Shape &shape, const Projection &projection, Range range, const MSDFGeneratorConfig &config) {
|
|
|
|
|
|
+void generateMSDF(const BitmapSection<float, 3> &output, const Shape &shape, const Projection &projection, Range range, const MSDFGeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<MultiDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
generateDistanceField<OverlappingContourCombiner<MultiDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
else
|
|
else
|
|
@@ -126,7 +127,7 @@ void generateMSDF(const BitmapRef<float, 3> &output, const Shape &shape, const P
|
|
msdfErrorCorrection(output, shape, SDFTransformation(projection, range), config);
|
|
msdfErrorCorrection(output, shape, SDFTransformation(projection, range), config);
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMTSDF(const BitmapRef<float, 4> &output, const Shape &shape, const Projection &projection, Range range, const MSDFGeneratorConfig &config) {
|
|
|
|
|
|
+void generateMTSDF(const BitmapSection<float, 4> &output, const Shape &shape, const Projection &projection, Range range, const MSDFGeneratorConfig &config) {
|
|
if (config.overlapSupport)
|
|
if (config.overlapSupport)
|
|
generateDistanceField<OverlappingContourCombiner<MultiAndTrueDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
generateDistanceField<OverlappingContourCombiner<MultiAndTrueDistanceSelector> >(output, shape, SDFTransformation(projection, range));
|
|
else
|
|
else
|
|
@@ -136,39 +137,39 @@ void generateMTSDF(const BitmapRef<float, 4> &output, const Shape &shape, const
|
|
|
|
|
|
// Legacy API
|
|
// Legacy API
|
|
|
|
|
|
-void generatePseudoSDF(const BitmapRef<float, 1> &output, const Shape &shape, const Projection &projection, Range range, const GeneratorConfig &config) {
|
|
|
|
|
|
+void generatePseudoSDF(const BitmapSection<float, 1> &output, const Shape &shape, const Projection &projection, Range range, const GeneratorConfig &config) {
|
|
generatePSDF(output, shape, SDFTransformation(projection, range), config);
|
|
generatePSDF(output, shape, SDFTransformation(projection, range), config);
|
|
}
|
|
}
|
|
|
|
|
|
-void generateSDF(const BitmapRef<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, bool overlapSupport) {
|
|
|
|
|
|
+void generateSDF(const BitmapSection<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, bool overlapSupport) {
|
|
generateSDF(output, shape, Projection(scale, translate), range, GeneratorConfig(overlapSupport));
|
|
generateSDF(output, shape, Projection(scale, translate), range, GeneratorConfig(overlapSupport));
|
|
}
|
|
}
|
|
|
|
|
|
-void generatePSDF(const BitmapRef<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, bool overlapSupport) {
|
|
|
|
|
|
+void generatePSDF(const BitmapSection<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, bool overlapSupport) {
|
|
generatePSDF(output, shape, Projection(scale, translate), range, GeneratorConfig(overlapSupport));
|
|
generatePSDF(output, shape, Projection(scale, translate), range, GeneratorConfig(overlapSupport));
|
|
}
|
|
}
|
|
|
|
|
|
-void generatePseudoSDF(const BitmapRef<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, bool overlapSupport) {
|
|
|
|
|
|
+void generatePseudoSDF(const BitmapSection<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, bool overlapSupport) {
|
|
generatePSDF(output, shape, Projection(scale, translate), range, GeneratorConfig(overlapSupport));
|
|
generatePSDF(output, shape, Projection(scale, translate), range, GeneratorConfig(overlapSupport));
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMSDF(const BitmapRef<float, 3> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, const ErrorCorrectionConfig &errorCorrectionConfig, bool overlapSupport) {
|
|
|
|
|
|
+void generateMSDF(const BitmapSection<float, 3> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, const ErrorCorrectionConfig &errorCorrectionConfig, bool overlapSupport) {
|
|
generateMSDF(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(overlapSupport, errorCorrectionConfig));
|
|
generateMSDF(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(overlapSupport, errorCorrectionConfig));
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMTSDF(const BitmapRef<float, 4> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, const ErrorCorrectionConfig &errorCorrectionConfig, bool overlapSupport) {
|
|
|
|
|
|
+void generateMTSDF(const BitmapSection<float, 4> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, const ErrorCorrectionConfig &errorCorrectionConfig, bool overlapSupport) {
|
|
generateMTSDF(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(overlapSupport, errorCorrectionConfig));
|
|
generateMTSDF(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(overlapSupport, errorCorrectionConfig));
|
|
}
|
|
}
|
|
|
|
|
|
// Legacy version
|
|
// Legacy version
|
|
|
|
|
|
-void generateSDF_legacy(const BitmapRef<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate) {
|
|
|
|
|
|
+void generateSDF_legacy(BitmapSection<float, 1> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate) {
|
|
DistanceMapping distanceMapping(range);
|
|
DistanceMapping distanceMapping(range);
|
|
|
|
+ output.reorient(shape.getYAxisOrientation());
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
#endif
|
|
#endif
|
|
for (int y = 0; y < output.height; ++y) {
|
|
for (int y = 0; y < output.height; ++y) {
|
|
- int row = shape.inverseYAxis ? output.height-y-1 : y;
|
|
|
|
for (int x = 0; x < output.width; ++x) {
|
|
for (int x = 0; x < output.width; ++x) {
|
|
double dummy;
|
|
double dummy;
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
@@ -179,18 +180,18 @@ void generateSDF_legacy(const BitmapRef<float, 1> &output, const Shape &shape, R
|
|
if (distance < minDistance)
|
|
if (distance < minDistance)
|
|
minDistance = distance;
|
|
minDistance = distance;
|
|
}
|
|
}
|
|
- *output(x, row) = float(distanceMapping(minDistance.distance));
|
|
|
|
|
|
+ *output(x, y) = float(distanceMapping(minDistance.distance));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void generatePSDF_legacy(const BitmapRef<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate) {
|
|
|
|
|
|
+void generatePSDF_legacy(BitmapSection<float, 1> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate) {
|
|
DistanceMapping distanceMapping(range);
|
|
DistanceMapping distanceMapping(range);
|
|
|
|
+ output.reorient(shape.getYAxisOrientation());
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
#endif
|
|
#endif
|
|
for (int y = 0; y < output.height; ++y) {
|
|
for (int y = 0; y < output.height; ++y) {
|
|
- int row = shape.inverseYAxis ? output.height-y-1 : y;
|
|
|
|
for (int x = 0; x < output.width; ++x) {
|
|
for (int x = 0; x < output.width; ++x) {
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
SignedDistance minDistance;
|
|
SignedDistance minDistance;
|
|
@@ -208,22 +209,22 @@ void generatePSDF_legacy(const BitmapRef<float, 1> &output, const Shape &shape,
|
|
}
|
|
}
|
|
if (nearEdge)
|
|
if (nearEdge)
|
|
(*nearEdge)->distanceToPerpendicularDistance(minDistance, p, nearParam);
|
|
(*nearEdge)->distanceToPerpendicularDistance(minDistance, p, nearParam);
|
|
- *output(x, row) = float(distanceMapping(minDistance.distance));
|
|
|
|
|
|
+ *output(x, y) = float(distanceMapping(minDistance.distance));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void generatePseudoSDF_legacy(const BitmapRef<float, 1> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate) {
|
|
|
|
|
|
+void generatePseudoSDF_legacy(BitmapSection<float, 1> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate) {
|
|
generatePSDF_legacy(output, shape, range, scale, translate);
|
|
generatePSDF_legacy(output, shape, range, scale, translate);
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMSDF_legacy(const BitmapRef<float, 3> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, ErrorCorrectionConfig errorCorrectionConfig) {
|
|
|
|
|
|
+void generateMSDF_legacy(BitmapSection<float, 3> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, ErrorCorrectionConfig errorCorrectionConfig) {
|
|
DistanceMapping distanceMapping(range);
|
|
DistanceMapping distanceMapping(range);
|
|
|
|
+ output.reorient(shape.getYAxisOrientation());
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
#endif
|
|
#endif
|
|
for (int y = 0; y < output.height; ++y) {
|
|
for (int y = 0; y < output.height; ++y) {
|
|
- int row = shape.inverseYAxis ? output.height-y-1 : y;
|
|
|
|
for (int x = 0; x < output.width; ++x) {
|
|
for (int x = 0; x < output.width; ++x) {
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
|
|
|
|
@@ -262,9 +263,9 @@ void generateMSDF_legacy(const BitmapRef<float, 3> &output, const Shape &shape,
|
|
(*g.nearEdge)->distanceToPerpendicularDistance(g.minDistance, p, g.nearParam);
|
|
(*g.nearEdge)->distanceToPerpendicularDistance(g.minDistance, p, g.nearParam);
|
|
if (b.nearEdge)
|
|
if (b.nearEdge)
|
|
(*b.nearEdge)->distanceToPerpendicularDistance(b.minDistance, p, b.nearParam);
|
|
(*b.nearEdge)->distanceToPerpendicularDistance(b.minDistance, p, b.nearParam);
|
|
- output(x, row)[0] = float(distanceMapping(r.minDistance.distance));
|
|
|
|
- output(x, row)[1] = float(distanceMapping(g.minDistance.distance));
|
|
|
|
- output(x, row)[2] = float(distanceMapping(b.minDistance.distance));
|
|
|
|
|
|
+ output(x, y)[0] = float(distanceMapping(r.minDistance.distance));
|
|
|
|
+ output(x, y)[1] = float(distanceMapping(g.minDistance.distance));
|
|
|
|
+ output(x, y)[2] = float(distanceMapping(b.minDistance.distance));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -272,13 +273,13 @@ void generateMSDF_legacy(const BitmapRef<float, 3> &output, const Shape &shape,
|
|
msdfErrorCorrection(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(false, errorCorrectionConfig));
|
|
msdfErrorCorrection(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(false, errorCorrectionConfig));
|
|
}
|
|
}
|
|
|
|
|
|
-void generateMTSDF_legacy(const BitmapRef<float, 4> &output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, ErrorCorrectionConfig errorCorrectionConfig) {
|
|
|
|
|
|
+void generateMTSDF_legacy(BitmapSection<float, 4> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, ErrorCorrectionConfig errorCorrectionConfig) {
|
|
DistanceMapping distanceMapping(range);
|
|
DistanceMapping distanceMapping(range);
|
|
|
|
+ output.reorient(shape.getYAxisOrientation());
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#ifdef MSDFGEN_USE_OPENMP
|
|
#pragma omp parallel for
|
|
#pragma omp parallel for
|
|
#endif
|
|
#endif
|
|
for (int y = 0; y < output.height; ++y) {
|
|
for (int y = 0; y < output.height; ++y) {
|
|
- int row = shape.inverseYAxis ? output.height-y-1 : y;
|
|
|
|
for (int x = 0; x < output.width; ++x) {
|
|
for (int x = 0; x < output.width; ++x) {
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
Point2 p = Vector2(x+.5, y+.5)/scale-translate;
|
|
|
|
|
|
@@ -320,10 +321,10 @@ void generateMTSDF_legacy(const BitmapRef<float, 4> &output, const Shape &shape,
|
|
(*g.nearEdge)->distanceToPerpendicularDistance(g.minDistance, p, g.nearParam);
|
|
(*g.nearEdge)->distanceToPerpendicularDistance(g.minDistance, p, g.nearParam);
|
|
if (b.nearEdge)
|
|
if (b.nearEdge)
|
|
(*b.nearEdge)->distanceToPerpendicularDistance(b.minDistance, p, b.nearParam);
|
|
(*b.nearEdge)->distanceToPerpendicularDistance(b.minDistance, p, b.nearParam);
|
|
- output(x, row)[0] = float(distanceMapping(r.minDistance.distance));
|
|
|
|
- output(x, row)[1] = float(distanceMapping(g.minDistance.distance));
|
|
|
|
- output(x, row)[2] = float(distanceMapping(b.minDistance.distance));
|
|
|
|
- output(x, row)[3] = float(distanceMapping(minDistance.distance));
|
|
|
|
|
|
+ output(x, y)[0] = float(distanceMapping(r.minDistance.distance));
|
|
|
|
+ output(x, y)[1] = float(distanceMapping(g.minDistance.distance));
|
|
|
|
+ output(x, y)[2] = float(distanceMapping(b.minDistance.distance));
|
|
|
|
+ output(x, y)[3] = float(distanceMapping(minDistance.distance));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|