]> code.delx.au - refind/blobdiff - refind/screen.c
Moved ExtractLegacyLoaderPaths() from lib.c to legacy.c
[refind] / refind / screen.c
index 1676cb6118eab111e61c6dada73af9057da14a48..29d11c80b4582bddd504e522a8517a35416ab616 100644 (file)
@@ -34,7 +34,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 /*
- * Modifications copyright (c) 2012 Roderick W. Smith
+ * Modifications copyright (c) 2012-2014 Roderick W. Smith
  *
  * Modifications distributed under the terms of the GNU General Public
  * License (GPL) version 3 (GPLv3), a copy of which must be distributed
@@ -433,33 +433,38 @@ VOID SwitchToGraphicsAndClear(VOID)
         BltClearScreen(TRUE);
 }
 
-VOID BltClearScreen(IN BOOLEAN ShowBanner)
+VOID BltClearScreen(BOOLEAN ShowBanner)
 {
-    static EG_IMAGE *Banner = NULL, *CroppedBanner;
+    static EG_IMAGE *Banner = NULL;
+    EG_IMAGE *NewBanner = NULL;
     INTN BannerPosX, BannerPosY;
     EG_PIXEL Black = { 0x0, 0x0, 0x0, 0 };
 
     if (ShowBanner && !(GlobalConfig.HideUIFlags & HIDEUI_FLAG_BANNER)) {
         // load banner on first call
         if (Banner == NULL) {
-            if (GlobalConfig.BannerFileName == NULL) {
-                Banner = egPrepareEmbeddedImage(&egemb_refind_banner, FALSE);
-            } else {
+            if (GlobalConfig.BannerFileName)
                 Banner = egLoadImage(SelfDir, GlobalConfig.BannerFileName, FALSE);
-                if (Banner && ((Banner->Width > UGAWidth) || (Banner->Height > UGAHeight))) {
-                   CroppedBanner = egCropImage(Banner, 0, 0, (Banner->Width > UGAWidth) ? UGAWidth : Banner->Width,
-                                               (Banner->Height > UGAHeight) ? UGAHeight : Banner->Height);
-                   MyFreePool(Banner);
-                   Banner = CroppedBanner;
-                } // if image too big
-                if (Banner == NULL) {
-                   Banner = egPrepareEmbeddedImage(&egemb_refind_banner, FALSE);
-                } // if unusable image
-            }
-            if (Banner != NULL)
-               MenuBackgroundPixel = Banner->PixelData[0];
+            if (Banner == NULL)
+                Banner = egPrepareEmbeddedImage(&egemb_refind_banner, FALSE);
         }
 
+        if (Banner) {
+           if (GlobalConfig.BannerScale == BANNER_FILLSCREEN) {
+              if ((Banner->Height != UGAHeight) || (Banner->Width != UGAWidth)) {
+                 NewBanner = egScaleImage(Banner, UGAWidth, UGAHeight);
+              } // if
+           } else if ((Banner->Width > UGAWidth) || (Banner->Height > UGAHeight)) {
+              NewBanner = egCropImage(Banner, 0, 0, (Banner->Width > UGAWidth) ? UGAWidth : Banner->Width,
+                                      (Banner->Height > UGAHeight) ? UGAHeight : Banner->Height);
+           } // if/elseif
+           if (NewBanner) {
+              MyFreePool(Banner);
+              Banner = NewBanner;
+           }
+           MenuBackgroundPixel = Banner->PixelData[0];
+        } // if Banner exists
+
         // clear and draw banner
         if (GlobalConfig.ScreensaverTime != -1)
            egClearScreen(&MenuBackgroundPixel);
@@ -476,7 +481,7 @@ VOID BltClearScreen(IN BOOLEAN ShowBanner)
                BltImage(Banner, (UINTN) BannerPosX, (UINTN) BannerPosY);
         }
 
-    } else {
+    } else { // not showing banner
         // clear to menu background color
         egClearScreen(&MenuBackgroundPixel);
     }
@@ -484,7 +489,8 @@ VOID BltClearScreen(IN BOOLEAN ShowBanner)
     GraphicsScreenDirty = FALSE;
     egFreeImage(GlobalConfig.ScreenBackground);
     GlobalConfig.ScreenBackground = egCopyScreen();
-} /* VOID BltClearScreen() */
+} // VOID BltClearScreen()
+
 
 VOID BltImage(IN EG_IMAGE *Image, IN UINTN XPos, IN UINTN YPos)
 {
@@ -566,12 +572,14 @@ VOID BltImageCompositeBadge(IN EG_IMAGE *BaseImage, IN EG_IMAGE *TopImage, IN EG
      }
 
      // blit to screen and clean up
-     if (CompImage->HasAlpha)
-        egDrawImageWithTransparency(CompImage, NULL, XPos, YPos, CompImage->Width, CompImage->Height);
-     else
-        egDrawImage(CompImage, XPos, YPos);
-     egFreeImage(CompImage);
-     GraphicsScreenDirty = TRUE;
+     if (CompImage != NULL) {
+         if (CompImage->HasAlpha)
+             egDrawImageWithTransparency(CompImage, NULL, XPos, YPos, CompImage->Width, CompImage->Height);
+         else
+             egDrawImage(CompImage, XPos, YPos);
+         egFreeImage(CompImage);
+         GraphicsScreenDirty = TRUE;
+     }
 }
 
 // Line-editing functions borrowed from gummiboot (cursor_left(), cursor_right(), & line_edit()).