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

Function generateMTSDF_legacy

MyGUIEngine/src/msdfgen/core/msdfgen.cpp:276–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void generateMTSDF_legacy(BitmapSection<float, 4> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, ErrorCorrectionConfig errorCorrectionConfig) {
277 DistanceMapping distanceMapping(range);
278 output.reorient(shape.getYAxisOrientation());
279#ifdef MSDFGEN_USE_OPENMP
280 #pragma omp parallel for
281#endif
282 for (int y = 0; y < output.height; ++y) {
283 for (int x = 0; x < output.width; ++x) {
284 Point2 p = Vector2(x+.5, y+.5)/scale-translate;
285
286 SignedDistance minDistance;
287 struct {
288 SignedDistance minDistance;
289 const EdgeHolder *nearEdge;
290 double nearParam;
291 } r, g, b;
292 r.nearEdge = g.nearEdge = b.nearEdge = NULL;
293 r.nearParam = g.nearParam = b.nearParam = 0;
294
295 for (std::vector<Contour>::const_iterator contour = shape.contours.begin(); contour != shape.contours.end(); ++contour)
296 for (std::vector<EdgeHolder>::const_iterator edge = contour->edges.begin(); edge != contour->edges.end(); ++edge) {
297 double param;
298 SignedDistance distance = (*edge)->signedDistance(p, param);
299 if (distance < minDistance)
300 minDistance = distance;
301 if ((*edge)->color&RED && distance < r.minDistance) {
302 r.minDistance = distance;
303 r.nearEdge = &*edge;
304 r.nearParam = param;
305 }
306 if ((*edge)->color&GREEN && distance < g.minDistance) {
307 g.minDistance = distance;
308 g.nearEdge = &*edge;
309 g.nearParam = param;
310 }
311 if ((*edge)->color&BLUE && distance < b.minDistance) {
312 b.minDistance = distance;
313 b.nearEdge = &*edge;
314 b.nearParam = param;
315 }
316 }
317
318 if (r.nearEdge)
319 (*r.nearEdge)->distanceToPerpendicularDistance(r.minDistance, p, r.nearParam);
320 if (g.nearEdge)
321 (*g.nearEdge)->distanceToPerpendicularDistance(g.minDistance, p, g.nearParam);
322 if (b.nearEdge)
323 (*b.nearEdge)->distanceToPerpendicularDistance(b.minDistance, p, b.nearParam);
324 output(x, y)[0] = float(distanceMapping(r.minDistance.distance));
325 output(x, y)[1] = float(distanceMapping(g.minDistance.distance));
326 output(x, y)[2] = float(distanceMapping(b.minDistance.distance));
327 output(x, y)[3] = float(distanceMapping(minDistance.distance));
328 }
329 }
330
331 errorCorrectionConfig.distanceCheckMode = ErrorCorrectionConfig::DO_NOT_CHECK_DISTANCE;
332 msdfErrorCorrection(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(false, errorCorrectionConfig));
333}

Callers 1

mainFunction · 0.85

Calls 10

Vector2Class · 0.85
msdfErrorCorrectionFunction · 0.85
ProjectionClass · 0.85
MSDFGeneratorConfigClass · 0.85
getYAxisOrientationMethod · 0.80
signedDistanceMethod · 0.80
reorientMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected