MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / nsvgParseFromFileCardinal

Function nsvgParseFromFileCardinal

src/custom/dep.cpp:1202–1394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1200#endif // HEADLESS
1201
1202NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* const units, const float dpi)
1203{
1204 if (NSVGimage* const handle = nsvgParseFromFile(filename, units, dpi))
1205 {
1206 /*
1207 if (NSVGshape* const shapes = handle->shapes)
1208 {
1209 for (NSVGshape *next, *shape = shapes;;)
1210 {
1211 next = shape->next;
1212
1213 nsvg__deletePaint(&shape->fill);
1214 nsvg__deletePaint(&shape->stroke);
1215 std::free(shape);
1216
1217 if (next == nullptr)
1218 break;
1219
1220 shape = next;
1221 }
1222 }
1223 handle->shapes = static_cast<NSVGshape*>(std::calloc(1, sizeof(NSVGshape)));
1224 handle->shapes->stroke.color = 0xff00ff00;
1225 handle->shapes->stroke.type = NSVG_PAINT_COLOR;
1226 handle->shapes->fill.color = 0xff000000;
1227 handle->shapes->fill.type = NSVG_PAINT_COLOR;
1228 return handle;
1229 */
1230
1231 #ifndef HEADLESS
1232 const size_t filenamelen = std::strlen(filename);
1233
1234 bool hasDarkMode = false;
1235 bool hasLightMode = false;
1236 NSVGimage* handleOrig;
1237 NSVGimage* handleMOD = nullptr;
1238 NSVGshape* shapesOrig;
1239 NSVGshape* shapesMOD;
1240
1241 if (filenamelen < 18)
1242 {
1243 shapesOrig = shapesMOD = nullptr;
1244 goto postparse;
1245 }
1246
1247#if 0
1248 // Special case for GlueTheGiant
1249 if (std::strstr(filename, "/GlueTheGiant/res/") != nullptr)
1250 {
1251 printf("special hack for glue\n");
1252 if (std::strncmp(filename + (filenamelen - 13), "/BusDepot.svg", 13) == 0 ||
1253 std::strncmp(filename + (filenamelen - 13), "/BusRoute.svg", 13) == 0 ||
1254 std::strncmp(filename + (filenamelen - 13), "/EnterBus.svg", 13) == 0 ||
1255 std::strncmp(filename + (filenamelen - 12), "/ExitBus.svg", 12) == 0 ||
1256 std::strncmp(filename + (filenamelen - 11), "/GigBus.svg", 11) == 0 ||
1257 std::strncmp(filename + (filenamelen - 17), "/MetroCityBus.svg", 17) == 0 ||
1258 std::strncmp(filename + (filenamelen - 12), "/MiniBus.svg", 12) == 0 ||
1259 std::strncmp(filename + (filenamelen - 9), "/Road.svg", 9) == 0 ||

Callers

nothing calls this directly

Calls 5

nsvg__duplicateShapesFunction · 0.85
invertPaintForDarkModeFunction · 0.85
invertPaintForLightModeFunction · 0.85
c_strMethod · 0.80
push_backMethod · 0.80

Tested by

no test coverage detected