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

Function generateMSDF_legacy

MyGUIEngine/src/msdfgen/core/msdfgen.cpp:221–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void generateMSDF_legacy(BitmapSection<float, 3> output, const Shape &shape, Range range, const Vector2 &scale, const Vector2 &translate, ErrorCorrectionConfig errorCorrectionConfig) {
222 DistanceMapping distanceMapping(range);
223 output.reorient(shape.getYAxisOrientation());
224#ifdef MSDFGEN_USE_OPENMP
225 #pragma omp parallel for
226#endif
227 for (int y = 0; y < output.height; ++y) {
228 for (int x = 0; x < output.width; ++x) {
229 Point2 p = Vector2(x+.5, y+.5)/scale-translate;
230
231 struct {
232 SignedDistance minDistance;
233 const EdgeHolder *nearEdge;
234 double nearParam;
235 } r, g, b;
236 r.nearEdge = g.nearEdge = b.nearEdge = NULL;
237 r.nearParam = g.nearParam = b.nearParam = 0;
238
239 for (std::vector<Contour>::const_iterator contour = shape.contours.begin(); contour != shape.contours.end(); ++contour)
240 for (std::vector<EdgeHolder>::const_iterator edge = contour->edges.begin(); edge != contour->edges.end(); ++edge) {
241 double param;
242 SignedDistance distance = (*edge)->signedDistance(p, param);
243 if ((*edge)->color&RED && distance < r.minDistance) {
244 r.minDistance = distance;
245 r.nearEdge = &*edge;
246 r.nearParam = param;
247 }
248 if ((*edge)->color&GREEN && distance < g.minDistance) {
249 g.minDistance = distance;
250 g.nearEdge = &*edge;
251 g.nearParam = param;
252 }
253 if ((*edge)->color&BLUE && distance < b.minDistance) {
254 b.minDistance = distance;
255 b.nearEdge = &*edge;
256 b.nearParam = param;
257 }
258 }
259
260 if (r.nearEdge)
261 (*r.nearEdge)->distanceToPerpendicularDistance(r.minDistance, p, r.nearParam);
262 if (g.nearEdge)
263 (*g.nearEdge)->distanceToPerpendicularDistance(g.minDistance, p, g.nearParam);
264 if (b.nearEdge)
265 (*b.nearEdge)->distanceToPerpendicularDistance(b.minDistance, p, b.nearParam);
266 output(x, y)[0] = float(distanceMapping(r.minDistance.distance));
267 output(x, y)[1] = float(distanceMapping(g.minDistance.distance));
268 output(x, y)[2] = float(distanceMapping(b.minDistance.distance));
269 }
270 }
271
272 errorCorrectionConfig.distanceCheckMode = ErrorCorrectionConfig::DO_NOT_CHECK_DISTANCE;
273 msdfErrorCorrection(output, shape, Projection(scale, translate), range, MSDFGeneratorConfig(false, errorCorrectionConfig));
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);

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