| 231 | } |
| 232 | |
| 233 | EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer) |
| 234 | { |
| 235 | EFI_STATUS Status; |
| 236 | |
| 237 | Icons.setEmpty(); |
| 238 | |
| 239 | // --- Parse theme.svg --- low case |
| 240 | NSVGparser *mainParser = nsvgParse((CHAR8*)buffer, 72, 1.f); //the buffer will be modified, it is how nanosvg works |
| 241 | SVGParser = (void *)mainParser; //store the pointer for future use |
| 242 | NSVGimage *SVGimage = mainParser->image; |
| 243 | if (!SVGimage) { |
| 244 | // DBG("Theme not parsed!\n"); |
| 245 | return EFI_NOT_STARTED; |
| 246 | } |
| 247 | |
| 248 | // --- Get scale as theme design height vs screen height |
| 249 | |
| 250 | // must be svg view-box. This is Design Width and Heigth |
| 251 | float vbx = mainParser->viewWidth; |
| 252 | float vby = mainParser->viewHeight; |
| 253 | DBG("Theme view-bounds: w=%f h=%f units=px\n", vbx, vby); //Theme view-bounds: w=1600.000000 h=900.000000 units=px |
| 254 | if (vby > 1.0f) { |
| 255 | SVGimage->height = vby; |
| 256 | } else { |
| 257 | SVGimage->height = 768.f; //default height |
| 258 | } |
| 259 | float ScaleF = UGAHeight / SVGimage->height; |
| 260 | DBG("using scale %f\n", ScaleF); // using scale 0.666667 |
| 261 | Scale = ScaleF; |
| 262 | CentreShift = (vbx * Scale - (float)UGAWidth) * 0.5f; |
| 263 | |
| 264 | Background = XImage(UGAWidth, UGAHeight); |
| 265 | if (!BigBack.isEmpty()) { |
| 266 | BigBack.setEmpty(); |
| 267 | } |
| 268 | Status = EFI_NOT_FOUND; |
| 269 | if (!ThemeX.Daylight) { |
| 270 | Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background_night"_XS8, &BigBack, NULL); //we should have a place for SVG background |
| 271 | } |
| 272 | if (EFI_ERROR(Status)) { |
| 273 | Status = ParseSVGXIcon(BUILTIN_ICON_BACKGROUND, "Background"_XS8, &BigBack, NULL); |
| 274 | } |
| 275 | DBG(" Background parsed [%lld, %lld]\n", BigBack.GetWidth(), BigBack.GetHeight()); //Background parsed [1067, 133] |
| 276 | // --- Make Banner |
| 277 | Banner.setEmpty(); //for the case of theme switch |
| 278 | Status = EFI_NOT_FOUND; |
| 279 | if (!ThemeX.Daylight) { |
| 280 | Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner_night"_XS8, &Banner, NULL); |
| 281 | } |
| 282 | if (EFI_ERROR(Status)) { |
| 283 | Status = ParseSVGXIcon(BUILTIN_ICON_BANNER, "Banner"_XS8, &Banner, NULL); |
| 284 | } |
| 285 | // DBG("Banner parsed\n"); |
| 286 | BanHeight = (int)(Banner.GetHeight() * Scale + 1.f); |
| 287 | DBG(" parsed banner->width=%lld height=%lld\n", Banner.GetWidth(), BanHeight); //parsed banner->width=467 height=89 |
| 288 | |
| 289 | // --- Make other icons |
| 290 | for (INTN i = BUILTIN_ICON_FUNC_ABOUT; i <= BUILTIN_CHECKBOX_CHECKED; ++i) { |
nothing calls this directly
no test coverage detected