From: Ray Strode Date: Thu, 17 Sep 2009 03:06:41 +0000 (-0400) Subject: [image] Drop test code X-Git-Tag: 0.8.0~188^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b71822f58c0995296dc2540c9c57910436899f4d;p=thirdparty%2Fplymouth.git [image] Drop test code It won't work when frame buffer is removed. I really want to redo how tests are done anyway, to be more automated. --- diff --git a/src/libplybootsplash/ply-image.c b/src/libplybootsplash/ply-image.c index 812313c5..94bc6afa 100644 --- a/src/libplybootsplash/ply-image.c +++ b/src/libplybootsplash/ply-image.c @@ -400,150 +400,4 @@ ply_image_rotate (ply_image_t *image, return new_image; } -#ifdef PLY_IMAGE_ENABLE_TEST - -#include "ply-frame-buffer.h" - -#include -#include -#include -#include -#include -#include - -#include - -#ifndef FRAMES_PER_SECOND -#define FRAMES_PER_SECOND 50 -#endif - -static int console_fd; - -static bool -hide_cursor (void) -{ - static const char invisible_cursor[] = "\033[?25l\033[?1c"; - - if (write (STDOUT_FILENO, invisible_cursor, - sizeof (invisible_cursor) - 1) != sizeof (invisible_cursor) - 1) - return false; - - return true; -} - -static double -get_current_time (void) -{ - const double microseconds_per_second = 1000000.0; - double timestamp; - struct timeval now = { 0L, /* zero-filled */ }; - - gettimeofday (&now, NULL); - timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) / - microseconds_per_second; - - return timestamp; -} - -double start_time = 0.0; -int num_frames = 0; - -static void -animate_at_time (ply_frame_buffer_t *buffer, - ply_image_t *image, - double time) -{ - ply_frame_buffer_area_t area; - uint32_t *data; - long width, height; - static double last_opacity = 0.0; - double opacity = 0.0; - - data = ply_image_get_data (image); - width = ply_image_get_width (image); - height = ply_image_get_height (image); - - ply_frame_buffer_get_size (buffer, &area); - area.x = (area.width / 2) - (width / 2); - area.y = (area.height / 2) - (height / 2); - area.width = width; - area.height = height; - - opacity = .5 * sin ((time / 4) * (2 * M_PI)) + .8; - opacity = CLAMP (opacity, 0, 1.0); - - num_frames++; - if (fabs (opacity - last_opacity) <= DBL_MIN) - return; - - last_opacity = opacity; - - ply_frame_buffer_pause_updates (buffer); - ply_frame_buffer_fill_with_color (buffer, &area, 0.1, 0.1, .7, 1.0); - ply_frame_buffer_fill_with_argb32_data_at_opacity (buffer, &area, - 0, 0, data, opacity); - ply_frame_buffer_unpause_updates (buffer); - - if (time > 10.0) - ioctl (console_fd, KDSETMODE, KD_TEXT); -} - -int -main (int argc, - char **argv) -{ - ply_image_t *image; - ply_frame_buffer_t *buffer; - int exit_code; - - exit_code = 0; - - hide_cursor (); - - if (argc == 1) - image = ply_image_new ("booting.png"); - else - image = ply_image_new (argv[1]); - - if (!ply_image_load (image)) - { - exit_code = errno; - perror ("could not load image"); - return exit_code; - } - - console_fd = open ("/dev/tty0", O_RDWR); - - buffer = ply_frame_buffer_new (NULL); - - if (!ply_frame_buffer_open (buffer)) - { - exit_code = errno; - perror ("could not open framebuffer"); - return exit_code; - } - - start_time = get_current_time (); - ply_frame_buffer_fill_with_color (buffer, NULL, 0.1, 0.1, .7, 1.0); - while ("we want to see ad-hoc animations") - { - long sleep_time; - double now; - - now = get_current_time (); - animate_at_time (buffer, image, now - start_time); - sleep_time = 1000000 / FRAMES_PER_SECOND; - sleep_time = MAX (sleep_time - ((get_current_time () - now) / 1000000), - 10000); - usleep (sleep_time); - } - ply_frame_buffer_close (buffer); - ply_frame_buffer_free (buffer); - - ply_image_free (image); - - return exit_code; -} - -#endif /* PLY_IMAGE_ENABLE_TEST */ /* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */