From ca876147d839a33fb1a397cda682d307554cb1d7 Mon Sep 17 00:00:00 2001
From: Olaf Mandel <o.man...@menlosystems.com>
Date: Tue, 7 Oct 2014 15:43:20 +0200
Subject: [PATCH 2/2] Make appearance more configurable

 * Allow not showing the startup message
 * Make the screen-split (between image and progress bar)
   configurable
 * Allow for fullscreen image (overlaid by progress bar)

Signed-off-by: Olaf Mandel <o.man...@menlosystems.com>
---
 ChangeLog        |    9 +++++++++
 Makefile.am      |    2 +-
 psplash-config.h |   34 ++++++++++++++++++++++++++++++++++
 psplash.c        |   28 +++++++++++++++++++++-------
 psplash.h        |    1 -
 5 files changed, 65 insertions(+), 9 deletions(-)
 create mode 100644 psplash-config.h

diff --git a/ChangeLog b/ChangeLog
index f4fd0ec..42163db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,15 @@
        * psplash.c:
        Images: handle rowstride != width*bytes_per_pixel
 
+       * psplash-config.h:
+       * psplash.c:
+       * psplash.h:
+       Make appearance more configurable:
+         - Allow not showing the startup message
+         - Make the screen-split (between image and progress bar)
+           configurable
+         - Allow for fullscreen image (overlaid by progress bar)
+
 2009-05-28  Richard Purdie <rpur...@linux.intel.com>
 
        * psplash-fb.c:
diff --git a/Makefile.am b/Makefile.am
index c90ebfa..a14152a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,7 @@ AM_CFLAGS = $(GCC_FLAGS) -D_GNU_SOURCE
 
 psplash_SOURCES = psplash.c psplash.h psplash-fb.c psplash-fb.h \
                   psplash-console.c psplash-console.h           \
-                 psplash-colors.h                              \
+                 psplash-colors.h psplash-config.h             \
                  psplash-poky-img.h psplash-bar-img.h radeon-font.h
 
 psplash_write_SOURCES = psplash-write.c psplash.h
diff --git a/psplash-config.h b/psplash-config.h
new file mode 100644
index 0000000..82bb76d
--- /dev/null
+++ b/psplash-config.h
@@ -0,0 +1,34 @@
+/*
+ *  pslash - a lightweight framebuffer splashscreen for embedded devices.
+ *
+ *  Copyright (c) 2014 MenloSystems GmbH
+ *  Author: Olaf Mandel <o.man...@menlosystems.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ */
+
+#ifndef _HAVE_PSPLASH_CONFIG_H
+#define _HAVE_PSPLASH_CONFIG_H
+
+/* Text to output on program start; if undefined, output nothing */
+#define PSPLASH_STARTUP_MSG ""
+
+/* Bool indicating if the image is fullscreen, as opposed to split screen */
+#define PSPLASH_IMG_FULLSCREEN 0
+
+/* Position of the image split from top edge, numerator of fraction */
+#define PSPLASH_IMG_SPLIT_NUMERATOR 5
+
+/* Position of the image split from top edge, denominator of fraction */
+#define PSPLASH_IMG_SPLIT_DENOMINATOR 6
+
+#endif
diff --git a/psplash.c b/psplash.c
index 543f67e..22af68d 100644
--- a/psplash.c
+++ b/psplash.c
@@ -19,11 +19,18 @@
  */
 
 #include "psplash.h"
+#include "psplash-config.h"
+#include "psplash-colors.h"
 #include "psplash-poky-img.h"
 #include "psplash-bar-img.h"
 #include "radeon-font.h"
 
-#define MSG ""
+#define SPLIT_LINE_POS(fb)                                  \
+       (  (fb)->height                                     \
+        - ((  PSPLASH_IMG_SPLIT_DENOMINATOR                \
+            - PSPLASH_IMG_SPLIT_NUMERATOR)                 \
+           * (fb)->height / PSPLASH_IMG_SPLIT_DENOMINATOR) \
+       )
 
 void
 psplash_exit (int signum)
@@ -46,14 +53,14 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
 
   psplash_fb_draw_rect (fb, 
                        0, 
-                       fb->height - (fb->height/6) - h, 
+                       SPLIT_LINE_POS(fb) - h, 
                        fb->width,
                        h,
                        PSPLASH_BACKGROUND_COLOR);
 
   psplash_fb_draw_text (fb,
                        (fb->width-w)/2, 
-                       fb->height - (fb->height/6) - h,
+                       SPLIT_LINE_POS(fb) - h,
                        PSPLASH_TEXT_COLOR,
                        &radeon_font,
                        msg);
@@ -66,7 +73,7 @@ psplash_draw_progress (PSplashFB *fb, int value)
 
   /* 4 pix border */
   x      = ((fb->width  - BAR_IMG_WIDTH)/2) + 4 ;
-  y      = fb->height - (fb->height/6) + 4;
+  y      = SPLIT_LINE_POS(fb) + 4;
   width  = BAR_IMG_WIDTH - 8; 
   height = BAR_IMG_HEIGHT - 8;
 
@@ -270,7 +277,12 @@ main (int argc, char** argv)
   /* Draw the Poky logo  */
   psplash_fb_draw_image (fb, 
                         (fb->width  - POKY_IMG_WIDTH)/2, 
-                        ((fb->height * 5) / 6 - POKY_IMG_HEIGHT)/2,
+#if PSPLASH_IMG_FULLSCREEN
+                        (fb->height - POKY_IMG_HEIGHT)/2,
+#else
+                        (fb->height * PSPLASH_IMG_SPLIT_NUMERATOR
+                         / PSPLASH_IMG_SPLIT_DENOMINATOR - POKY_IMG_HEIGHT)/2,
+#endif
                         POKY_IMG_WIDTH,
                         POKY_IMG_HEIGHT,
                         POKY_IMG_BYTES_PER_PIXEL,
@@ -280,7 +292,7 @@ main (int argc, char** argv)
   /* Draw progress bar border */
   psplash_fb_draw_image (fb, 
                         (fb->width  - BAR_IMG_WIDTH)/2, 
-                        fb->height - (fb->height/6), 
+                        SPLIT_LINE_POS(fb),
                         BAR_IMG_WIDTH,
                         BAR_IMG_HEIGHT,
                         BAR_IMG_BYTES_PER_PIXEL,
@@ -289,7 +301,9 @@ main (int argc, char** argv)
 
   psplash_draw_progress (fb, 0);
 
-  psplash_draw_msg (fb, MSG);
+#ifdef PSPLASH_STARTUP_MSG
+  psplash_draw_msg (fb, PSPLASH_STARTUP_MSG);
+#endif
 
   psplash_main (fb, pipe_fd, 0);
 
diff --git a/psplash.h b/psplash.h
index f78c117..22d73a3 100644
--- a/psplash.h
+++ b/psplash.h
@@ -83,6 +83,5 @@ PSplashFont;
 
 #include "psplash-fb.h"
 #include "psplash-console.h"
-#include "psplash-colors.h"
 
 #endif
-- 
1.7.10.4


Attachment: signature.asc
Description: OpenPGP digital signature

-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to