Ver código fonte

Fixed edge coloring not restored if lost during preprocessing

Chlumsky 3 anos atrás
pai
commit
f1797ada88
2 arquivos alterados com 10 adições e 13 exclusões
  1. 6 13
      ext/resolve-shape-geometry.cpp
  2. 4 0
      main.cpp

+ 6 - 13
ext/resolve-shape-geometry.cpp

@@ -24,19 +24,12 @@ void shapeToSkiaPath(SkPath &skPath, const Shape &shape) {
         if (!contour->edges.empty()) {
             skPath.moveTo(pointToSkiaPoint(contour->edges.front()->point(0)));
             for (std::vector<EdgeHolder>::const_iterator edge = contour->edges.begin(); edge != contour->edges.end(); ++edge) {
-                {
-                    const LinearSegment *linearSegment = dynamic_cast<const LinearSegment *>(&**edge);
-                    if (linearSegment)
-                        skPath.lineTo(pointToSkiaPoint(linearSegment->p[1]));
-                } {
-                    const QuadraticSegment *quadraticSegment = dynamic_cast<const QuadraticSegment *>(&**edge);
-                    if (quadraticSegment)
-                        skPath.quadTo(pointToSkiaPoint(quadraticSegment->p[1]), pointToSkiaPoint(quadraticSegment->p[2]));
-                } {
-                    const CubicSegment *cubicSegment = dynamic_cast<const CubicSegment *>(&**edge);
-                    if (cubicSegment)
-                        skPath.cubicTo(pointToSkiaPoint(cubicSegment->p[1]), pointToSkiaPoint(cubicSegment->p[2]), pointToSkiaPoint(cubicSegment->p[3]));
-                }
+                if (const LinearSegment *linearSegment = dynamic_cast<const LinearSegment *>(&**edge))
+                    skPath.lineTo(pointToSkiaPoint(linearSegment->p[1]));
+                else if (const QuadraticSegment *quadraticSegment = dynamic_cast<const QuadraticSegment *>(&**edge))
+                    skPath.quadTo(pointToSkiaPoint(quadraticSegment->p[1]), pointToSkiaPoint(quadraticSegment->p[2]));
+                else if (const CubicSegment *cubicSegment = dynamic_cast<const CubicSegment *>(&**edge))
+                    skPath.cubicTo(pointToSkiaPoint(cubicSegment->p[1]), pointToSkiaPoint(cubicSegment->p[2]), pointToSkiaPoint(cubicSegment->p[3]));
             }
         }
     }

+ 4 - 0
main.cpp

@@ -876,6 +876,10 @@ int main(int argc, const char * const *argv) {
         #ifdef MSDFGEN_USE_SKIA
             if (!resolveShapeGeometry(shape))
                 puts("Shape geometry preprocessing failed, skipping.");
+            else if (skipColoring) {
+                skipColoring = false;
+                puts("Note: Input shape coloring won't be preserved due to geometry preprocessing");
+            }
         #else
             ABORT("Shape geometry preprocessing (-preprocess) is not available in this version because the Skia library is not present.");
         #endif