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

Method protectCorners

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

Source from the content-addressed store, hash-verified

119}
120
121void MSDFErrorCorrection::protectCorners(const Shape &shape) {
122 stencil.reorient(shape.getYAxisOrientation());
123 for (std::vector<Contour>::const_iterator contour = shape.contours.begin(); contour != shape.contours.end(); ++contour)
124 if (!contour->edges.empty()) {
125 const EdgeSegment *prevEdge = contour->edges.back();
126 for (std::vector<EdgeHolder>::const_iterator edge = contour->edges.begin(); edge != contour->edges.end(); ++edge) {
127 int commonColor = prevEdge->color&(*edge)->color;
128 // If the color changes from prevEdge to edge, this is a corner.
129 if (!(commonColor&(commonColor-1))) {
130 // Find the four texels that envelop the corner and mark them as protected.
131 Point2 p = transformation.project((*edge)->point(0));
132 int l = (int) floor(p.x-.5);
133 int b = (int) floor(p.y-.5);
134 int r = l+1;
135 int t = b+1;
136 // Check that the positions are within bounds.
137 if (l < stencil.width && b < stencil.height && r >= 0 && t >= 0) {
138 if (l >= 0 && b >= 0)
139 *stencil(l, b) |= (byte) PROTECTED;
140 if (r < stencil.width && b >= 0)
141 *stencil(r, b) |= (byte) PROTECTED;
142 if (l >= 0 && t < stencil.height)
143 *stencil(l, t) |= (byte) PROTECTED;
144 if (r < stencil.width && t < stencil.height)
145 *stencil(r, t) |= (byte) PROTECTED;
146 }
147 }
148 prevEdge = *edge;
149 }
150 }
151}
152
153/// Determines if the channel contributes to an edge between the two texels a, b.
154static bool edgeBetweenTexelsChannel(const float *a, const float *b, int channel) {

Callers 1

msdfErrorCorrectionInnerFunction · 0.80

Calls 7

getYAxisOrientationMethod · 0.80
projectMethod · 0.80
reorientMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
pointMethod · 0.45

Tested by

no test coverage detected