MCPcopy Create free account
hub / github.com/MyGUI/mygui / findErrors

Method findErrors

MyGUIEngine/src/msdfgen/core/MSDFErrorCorrection.cpp:384–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

382
383template <int N>
384void MSDFErrorCorrection::findErrors(const BitmapConstSection<float, N> &sdf) {
385 stencil.reorient(sdf.yOrientation);
386 // Compute the expected deltas between values of horizontally, vertically, and diagonally adjacent texels.
387 double hSpan = minDeviationRatio*transformation.unprojectVector(Vector2(transformation.distanceMapping(DistanceMapping::Delta(1)), 0)).length();
388 double vSpan = minDeviationRatio*transformation.unprojectVector(Vector2(0, transformation.distanceMapping(DistanceMapping::Delta(1)))).length();
389 double dSpan = minDeviationRatio*transformation.unprojectVector(Vector2(transformation.distanceMapping(DistanceMapping::Delta(1)))).length();
390 // Inspect all texels.
391 for (int y = 0; y < sdf.height; ++y) {
392 for (int x = 0; x < sdf.width; ++x) {
393 const float *c = sdf(x, y);
394 float cm = median(c[0], c[1], c[2]);
395 bool protectedFlag = (*stencil(x, y)&PROTECTED) != 0;
396 const float *l = NULL, *b = NULL, *r = NULL, *t = NULL;
397 // Mark current texel c with the error flag if an artifact occurs when it's interpolated with any of its 8 neighbors.
398 *stencil(x, y) |= (byte) (ERROR*(
399 (x > 0 && ((l = sdf(x-1, y)), hasLinearArtifact(BaseArtifactClassifier(hSpan, protectedFlag), cm, c, l))) ||
400 (y > 0 && ((b = sdf(x, y-1)), hasLinearArtifact(BaseArtifactClassifier(vSpan, protectedFlag), cm, c, b))) ||
401 (x < sdf.width-1 && ((r = sdf(x+1, y)), hasLinearArtifact(BaseArtifactClassifier(hSpan, protectedFlag), cm, c, r))) ||
402 (y < sdf.height-1 && ((t = sdf(x, y+1)), hasLinearArtifact(BaseArtifactClassifier(vSpan, protectedFlag), cm, c, t))) ||
403 (x > 0 && y > 0 && hasDiagonalArtifact(BaseArtifactClassifier(dSpan, protectedFlag), cm, c, l, b, sdf(x-1, y-1))) ||
404 (x < sdf.width-1 && y > 0 && hasDiagonalArtifact(BaseArtifactClassifier(dSpan, protectedFlag), cm, c, r, b, sdf(x+1, y-1))) ||
405 (x > 0 && y < sdf.height-1 && hasDiagonalArtifact(BaseArtifactClassifier(dSpan, protectedFlag), cm, c, l, t, sdf(x-1, y+1))) ||
406 (x < sdf.width-1 && y < sdf.height-1 && hasDiagonalArtifact(BaseArtifactClassifier(dSpan, protectedFlag), cm, c, r, t, sdf(x+1, y+1)))
407 ));
408 }
409 }
410}
411
412template <template <typename> class ContourCombiner, int N>
413void MSDFErrorCorrection::findErrors(BitmapConstSection<float, N> sdf, const Shape &shape) {

Callers

nothing calls this directly

Calls 12

Vector2Class · 0.85
DeltaClass · 0.85
hasLinearArtifactFunction · 0.85
hasDiagonalArtifactFunction · 0.85
unprojectVectorMethod · 0.80
getYAxisOrientationMethod · 0.80
unprojectMethod · 0.80
classifierMethod · 0.80
medianFunction · 0.70
reorientMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected