From d2702b3fa2d9ded63e992c7980aa6d08ab11abd7 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Fri, 22 Dec 2006 13:08:15 +0000 Subject: [PATCH] 2006-12-22 Matthew Allum * psplash-fb.c: * psplash-fb.h: * psplash.c: Add -angle cmd line arg, hopefully fix rotation --- ChangeLog | 7 +++++++ psplash-fb.c | 19 ++++++++++++------- psplash-fb.h | 2 +- psplash.c | 15 ++++++++++++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a5fb38e..325b12f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-12-22 Matthew Allum + + * psplash-fb.c: + * psplash-fb.h: + * psplash.c: + Add -angle cmd line arg, hopefully fix rotation + 2006-12-19 Matthew Allum * psplash-fb.c: diff --git a/psplash-fb.c b/psplash-fb.c index f95583c..fe7f5db 100644 --- a/psplash-fb.c +++ b/psplash-fb.c @@ -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; } diff --git a/psplash-fb.h b/psplash-fb.h index ceb7b3f..6c661f9 100644 --- a/psplash-fb.h +++ b/psplash-fb.h @@ -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, diff --git a/psplash.c b/psplash.c index 685c28c..7964cfb 100644 --- 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 */ -- 2.7.4