2006-12-22 Matthew Allum <mallum@openedhand.com>
authorMatthew Allum <mallum@openedhand.com>
Fri, 22 Dec 2006 13:08:15 +0000 (13:08 +0000)
committerMatthew Allum <mallum@openedhand.com>
Fri, 22 Dec 2006 13:08:15 +0000 (13:08 +0000)
        * psplash-fb.c:
        * psplash-fb.h:
        * psplash.c:
        Add -angle cmd line arg, hopefully fix rotation

ChangeLog
psplash-fb.c
psplash-fb.h
psplash.c

index a5fb38e..325b12f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-12-22  Matthew Allum  <mallum@openedhand.com>
+
+       * psplash-fb.c:
+       * psplash-fb.h:
+       * psplash.c:
+       Add -angle cmd line arg, hopefully fix rotation
+
 2006-12-19  Matthew Allum  <mallum@openedhand.com>
 
        * psplash-fb.c:
index f95583c..fe7f5db 100644 (file)
@@ -26,7 +26,7 @@ psplash_fb_destroy (PSplashFB *fb)
 }
 
 PSplashFB*
-psplash_fb_new (void)
+psplash_fb_new (int angle)
 {
   struct fb_var_screeninfo fb_var;
   struct fb_fix_screeninfo fb_fix;
@@ -118,6 +118,8 @@ psplash_fb_new (void)
   status = 2;
 #endif
 
+  fb->angle = angle;
+
   switch (fb->angle)
     {
     case 270:
@@ -141,6 +143,8 @@ psplash_fb_new (void)
   return NULL;
 }
 
+#define OFFSET(fb,x,y) (((y) * (fb)->stride) + ((x) * ((fb)->bpp >> 3)))
+
 inline void
 psplash_fb_plot_pixel (PSplashFB    *fb, 
                       int          x, 
@@ -151,22 +155,23 @@ psplash_fb_plot_pixel (PSplashFB    *fb,
 {
   int off;
 
+  if (x < 0 || x > fb->width-1 || y < 0 || y > fb->height-1)
+    return;
+
   switch (fb->angle)
     {
     case 270:
-      off = ((fb->width - x) * fb->stride) + (y * (fb->bpp >> 3));
+      off = OFFSET (fb, fb->real_height - y - 1, x);
       break;
     case 180:
-      off = ((fb->height - y) * fb->stride) + ((fb->width - x) * (fb->bpp >> 3));
+      off = OFFSET (fb, fb->real_width - x - 1, fb->real_height - y - 1);
       break;
     case 90:
-      off = (x * fb->stride) + (y * (fb->bpp >> 3));
+      off = OFFSET (fb, y, fb->real_width - x - 1);
       break;
     case 0:
     default:
-      if (x < 0 || x > fb->width-1 || y < 0 || y > fb->height-1)
-       return;
-      off = (y * fb->stride) + (x * (fb->bpp >> 3));
+      off = OFFSET (fb, x, y);
       break;
     }
 
index ceb7b3f..6c661f9 100644 (file)
@@ -39,7 +39,7 @@ void
 psplash_fb_destroy (PSplashFB *fb);
 
 PSplashFB*
-psplash_fb_new (void);
+psplash_fb_new (int angle);
 
 inline void
 psplash_fb_plot_pixel (PSplashFB    *fb, 
index 685c28c..7964cfb 100644 (file)
--- a/psplash.c
+++ b/psplash.c
@@ -178,7 +178,7 @@ int
 main (int argc, char** argv) 
 {
   char      *tmpdir;
-  int        pipe_fd, i = 0;
+  int        pipe_fd, i = 0, angle = 0;
   PSplashFB *fb;
   bool       disable_console_switch = FALSE;
   
@@ -193,7 +193,16 @@ main (int argc, char** argv)
          disable_console_switch = TRUE;
          continue;
        }
-      fprintf(stderr, "Usage: %s [-n|--no-console-switch]\n", argv[0]);
+
+      if (!strcmp(argv[i],"-a") || !strcmp(argv[i],"--angle"))
+        {
+         if (++i > argc) goto fail;
+         angle = atoi(argv[0]);
+         continue;
+       }
+      
+    fail:
+      fprintf(stderr, "Usage: %s [-n|--no-console-switch] [-a|--angle <0|90|180|270>]\n", argv[0]);
       exit(-1);
     }
 
@@ -224,7 +233,7 @@ main (int argc, char** argv)
   if (!disable_console_switch)
     psplash_console_switch ();
 
-  if ((fb = psplash_fb_new()) == NULL)
+  if ((fb = psplash_fb_new(angle)) == NULL)
     exit(-1);
 
   /* Clear the background with #ecece1 */