| 1 |
|
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include "SDFTransformation.h" |
| 5 |
#include "Shape.h" |
| 6 |
#include "BitmapRef.hpp" |
| 7 |
|
| 8 |
namespace msdfgen { |
| 9 |
|
| 10 |
|
| 11 |
class MSDFErrorCorrection { |
| 12 |
|
| 13 |
public: |
| 14 |
|
| 15 |
enum Flags { |
| 16 |
|
| 17 |
ERROR = 1, |
| 18 |
|
| 19 |
PROTECTED = 2 |
| 20 |
}; |
| 21 |
|
| 22 |
MSDFErrorCorrection(); |
| 23 |
explicit MSDFErrorCorrection(const BitmapSection<byte, 1> &stencil, const SDFTransformation &transformation); |
| 24 |
|
| 25 |
void setMinDeviationRatio(double minDeviationRatio); |
| 26 |
|
| 27 |
void setMinImproveRatio(double minImproveRatio); |
| 28 |
|
| 29 |
void protectCorners(const Shape &shape); |
| 30 |
|
| 31 |
template <int N> |
| 32 |
void protectEdges(const BitmapConstSection<float, N> &sdf); |
| 33 |
|
| 34 |
void protectAll(); |
| 35 |
|
| 36 |
template <int N> |
| 37 |
void findErrors(const BitmapConstSection<float, N> &sdf); |
| 38 |
|
| 39 |
template <template <typename> class ContourCombiner, int N> |
| 40 |
void findErrors(BitmapConstSection<float, N> sdf, const Shape &shape); |
| 41 |
|
| 42 |
template <int N> |
| 43 |
void apply(BitmapSection<float, N> sdf) const; |
| 44 |
|
| 45 |
BitmapConstSection<byte, 1> getStencil() const; |
| 46 |
|
| 47 |
private: |
| 48 |
BitmapSection<byte, 1> stencil; |
| 49 |
SDFTransformation transformation; |
| 50 |
double minDeviationRatio; |
| 51 |
double minImproveRatio; |
| 52 |
|
| 53 |
}; |
| 54 |
|
| 55 |
} |