Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Commit

Permalink
Rework to fade logo in and out
Browse files Browse the repository at this point in the history
Don't display progress bar or text.
  • Loading branch information
Robert Spanton committed Sep 23, 2011
1 parent 09636cf commit 220eb45
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 72 deletions.
16 changes: 13 additions & 3 deletions psplash-fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,17 @@ psplash_fb_draw_rect (PSplashFB *fb,
psplash_fb_plot_pixel (fb, x+dx, y+dy, red, green, blue);
}

#define munge_pixel(p, mask) ( (((uint32_t)p) * mask) / 32 )

void
psplash_fb_draw_image (PSplashFB *fb,
int x,
int y,
int img_width,
int img_height,
int img_bytes_per_pixel,
uint8 *rle_data)
uint8 *rle_data,
uint8_t mask)
{
uint8 *p = rle_data;
int dx = 0, dy = 0, total_len;
Expand All @@ -398,7 +401,10 @@ psplash_fb_draw_image (PSplashFB *fb,
do
{
if (img_bytes_per_pixel < 4 || *(p+3))
psplash_fb_plot_pixel (fb, x+dx, y+dy, *(p), *(p+1), *(p+2));
psplash_fb_plot_pixel (fb, x+dx, y+dy,
munge_pixel((*p), mask),
munge_pixel((*(p+1)), mask),
munge_pixel((*(p+2)), mask) );
if (++dx >= img_width) { dx=0; dy++; }
}
while (--len && (p - rle_data) < total_len);
Expand All @@ -412,7 +418,11 @@ psplash_fb_draw_image (PSplashFB *fb,
do
{
if (img_bytes_per_pixel < 4 || *(p+3))
psplash_fb_plot_pixel (fb, x+dx, y+dy, *(p), *(p+1), *(p+2));
psplash_fb_plot_pixel (fb, x+dx, y+dy,
munge_pixel((*p), mask),
munge_pixel((*(p+1)), mask),
munge_pixel((*(p+2)), mask) );

if (++dx >= img_width) { dx=0; dy++; }
p += img_bytes_per_pixel;
}
Expand Down
3 changes: 2 additions & 1 deletion psplash-fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ psplash_fb_draw_image (PSplashFB *fb,
int img_width,
int img_height,
int img_bytes_pre_pixel,
uint8 *rle_data);
uint8 *rle_data,
uint8_t mask);

void
psplash_fb_text_size (PSplashFB *fb,
Expand Down
135 changes: 67 additions & 68 deletions psplash.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

#define MSG ""

static uint8_t img_mask = 0;
static enum { FADE_IN, FADE_OUT } img_fade = FADE_IN;

void
psplash_exit (int signum)
{
Expand All @@ -49,12 +52,12 @@ psplash_draw_msg (PSplashFB *fb, const char *msg)
fb->height - (fb->height/6) - h,
fb->width,
h,
0xec, 0xec, 0xe1);
0, 0, 0);

psplash_fb_draw_text (fb,
(fb->width-w)/2,
fb->height - (fb->height/6) - h,
0x6d, 0x6d, 0x70,
0xff, 0xff, 0xff,
&radeon_font,
msg);
}
Expand Down Expand Up @@ -111,11 +114,13 @@ parse_command (PSplashFB *fb, char *string, int length)

if (!strcmp(command,"PROGRESS"))
{
psplash_draw_progress (fb, atoi(strtok(NULL,"\0")));
/* Ignore this */
/* psplash_draw_progress (fb, atoi(strtok(NULL,"\0"))); */
}
else if (!strcmp(command,"MSG"))
{
psplash_draw_msg (fb, strtok(NULL,"\0"));
/* Ignore this */
/* psplash_draw_msg (fb, strtok(NULL,"\0")); */
}
else if (!strcmp(command,"QUIT"))
{
Expand All @@ -135,64 +140,78 @@ psplash_main (PSplashFB *fb, int pipe_fd, int timeout)
char *end;
char command[2048];

tv.tv_sec = timeout;
tv.tv_usec = 0;
tv.tv_sec = 0;
tv.tv_usec = 50000;

FD_ZERO(&descriptors);
FD_SET(pipe_fd, &descriptors);

end = command;

while (1)
{
err = select(pipe_fd+1, &descriptors, NULL, NULL, &tv);

if (err < 0)
return;

if (err > 0 )
{
if (timeout != 0)
err = select(pipe_fd+1, &descriptors, NULL, NULL, &tv);
else
err = select(pipe_fd+1, &descriptors, NULL, NULL, NULL);

if (err <= 0)
{
/*
if (errno == EINTR)
continue;
*/
return;
}

length += read (pipe_fd, end, sizeof(command) - (end - command));

if (length == 0)
{
/* Reopen to see if there's anything more for us */
close(pipe_fd);
pipe_fd = open(PSPLASH_FIFO,O_RDONLY|O_NONBLOCK);
goto out;
}
{
/* Reopen to see if there's anything more for us */
close(pipe_fd);
pipe_fd = open(PSPLASH_FIFO,O_RDONLY|O_NONBLOCK);
goto out;
}

if (command[length-1] == '\0')
{
if (parse_command(fb, command, strlen(command)))
return;
length = 0;
}
{
if (parse_command(fb, command, strlen(command)))
return;
length = 0;
}
else if (command[length-1] == '\n')
{
command[length-1] = '\0';
if (parse_command(fb, command, strlen(command)))
return;
length = 0;
}

{
command[length-1] = '\0';
if (parse_command(fb, command, strlen(command)))
return;
length = 0;
}
}
else
{
if( img_fade == FADE_IN ) {
img_mask += 2;
if( img_mask == 32 )
img_fade = FADE_OUT;
} else {
img_mask -= 2;
if( img_mask == 0 )
img_fade = FADE_IN;
}

/* Draw the logo */
psplash_fb_draw_image (fb,
(fb->width - POKY_IMG_WIDTH)/2,
(fb->height - POKY_IMG_HEIGHT)/2,
POKY_IMG_WIDTH,
POKY_IMG_HEIGHT,
POKY_IMG_BYTES_PER_PIXEL,
POKY_IMG_RLE_PIXEL_DATA, img_mask);
}

out:
end = &command[length];
out:
end = &command[length];

tv.tv_sec = timeout;
tv.tv_usec = 0;
tv.tv_sec = 0;
tv.tv_usec = 50000;

FD_ZERO(&descriptors);
FD_SET(pipe_fd,&descriptors);
}
FD_ZERO(&descriptors);
FD_SET(pipe_fd,&descriptors);
}

return;
}
Expand Down Expand Up @@ -263,33 +282,13 @@ main (int argc, char** argv)
goto fb_fail;
}

/* Clear the background with #ecece1 */
/* Set the background to black */
psplash_fb_draw_rect (fb, 0, 0, fb->width, fb->height, 0, 0, 0);

/* Draw the Poky logo */
psplash_fb_draw_image (fb,
(fb->width - POKY_IMG_WIDTH)/2,
((fb->height * 5) / 6 - POKY_IMG_HEIGHT)/2,
POKY_IMG_WIDTH,
POKY_IMG_HEIGHT,
POKY_IMG_BYTES_PER_PIXEL,
POKY_IMG_RLE_PIXEL_DATA);

/* Draw progress bar border */
psplash_fb_draw_image (fb,
(fb->width - BAR_IMG_WIDTH)/2,
fb->height - (fb->height/6),
BAR_IMG_WIDTH,
BAR_IMG_HEIGHT,
BAR_IMG_BYTES_PER_PIXEL,
BAR_IMG_RLE_PIXEL_DATA);

psplash_draw_progress (fb, 0);

psplash_draw_msg (fb, MSG);

psplash_main (fb, pipe_fd, 0);

/* Clear the display before quitting */
psplash_fb_draw_rect (fb, 0, 0, fb->width, fb->height, 0, 0, 0);

psplash_fb_destroy (fb);

Expand Down

0 comments on commit 220eb45

Please sign in to comment.