#pragma once #include "Projection.h" #include "Shape.h" #include "BitmapRef.hpp" namespace msdfgen { /// Performs error correction on a computed MSDF to eliminate interpolation artifacts. This is a low-level class, you may want to use the API in msdf-error-correction.h instead. class MSDFErrorCorrection { public: /// Stencil flags. enum Flags { /// Texel marked as potentially causing interpolation errors. ERROR = 1, /// Texel marked as protected. Protected texels are only given the error flag if they cause inversion artifacts. PROTECTED = 2 }; MSDFErrorCorrection(); explicit MSDFErrorCorrection(const BitmapRef &stencil, const Projection &projection, double range); /// Sets the minimum ratio between the actual and maximum expected distance delta to be considered an error. void setMinDeviationRatio(double minDeviationRatio); /// Sets the minimum ratio between the pre-correction distance error and the post-correction distance error. void setMinImproveRatio(double minImproveRatio); /// Flags all texels that are interpolated at corners as protected. void protectCorners(const Shape &shape); /// Flags all texels that contribute to edges as protected. template void protectEdges(const BitmapConstRef &sdf); /// Flags all texels as protected. void protectAll(); /// Flags texels that are expected to cause interpolation artifacts based on analysis of the SDF only. template void findErrors(const BitmapConstRef &sdf); /// Flags texels that are expected to cause interpolation artifacts based on analysis of the SDF and comparison with the exact shape distance. template