]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[animation] Move frames from image to pixel-buffers
authorCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 18 Apr 2010 15:17:00 +0000 (16:17 +0100)
committerCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 18 Apr 2010 15:17:00 +0000 (16:17 +0100)
The frames are now stored as pixel-buffers which will be cleaner to draw from
in the future.

src/libply-splash-graphics/ply-animation.c

index 5596bbd3c65a9248d347172060e519131daa3881..76f822a01fd8a94fcc26f93a3125449b11828e74 100644 (file)
@@ -104,11 +104,11 @@ static void
 ply_animation_remove_frames (ply_animation_t *animation)
 {
   int i;
-  ply_image_t **frames;
+  ply_pixel_buffer_t **frames;
 
-  frames = (ply_image_t **) ply_array_steal_elements (animation->frames);
+  frames = (ply_pixel_buffer_t **) ply_array_steal_elements (animation->frames);
   for (i = 0; frames[i] != NULL; i++)
-    ply_image_free (frames[i]);
+    ply_pixel_buffer_free (frames[i]);
   free (frames);
 }
 
@@ -131,7 +131,7 @@ animate_at_time (ply_animation_t *animation,
                  double           time)
 {
   int number_of_frames;
-  ply_image_t * const * frames;
+  ply_pixel_buffer_t * const * frames;
   bool should_continue;
 
   number_of_frames = ply_array_get_size (animation->frames);
@@ -147,12 +147,10 @@ animate_at_time (ply_animation_t *animation,
   if (animation->stop_requested)
     should_continue = false;
 
-  frames = (ply_image_t * const *) ply_array_get_elements (animation->frames);
-
+  frames = (ply_pixel_buffer_t * const *) ply_array_get_elements (animation->frames);
+  ply_pixel_buffer_get_size (frames[animation->frame_number], &animation->frame_area);
   animation->frame_area.x = animation->x;
   animation->frame_area.y = animation->y;
-  animation->frame_area.width = ply_image_get_width (frames[animation->frame_number]);
-  animation->frame_area.height = ply_image_get_height (frames[animation->frame_number]);
 
   ply_pixel_display_draw_area (animation->display,
                                animation->x, animation->y,
@@ -207,6 +205,7 @@ ply_animation_add_frame (ply_animation_t *animation,
                          const char      *filename)
 {
   ply_image_t *image;
+  ply_pixel_buffer_t *frame;
 
   image = ply_image_new (filename);
 
@@ -216,10 +215,12 @@ ply_animation_add_frame (ply_animation_t *animation,
       return false;
     }
 
-  ply_array_add_element (animation->frames, image);
+  frame = ply_image_convert_to_pixel_buffer (image);
+
+  ply_array_add_element (animation->frames, frame);
 
-  animation->width = MAX (animation->width, ply_image_get_width (image));
-  animation->height = MAX (animation->height, ply_image_get_height (image));
+  animation->width = MAX (animation->width, ply_pixel_buffer_get_width (frame));
+  animation->height = MAX (animation->height, ply_pixel_buffer_get_height (frame));
 
   return true;
 }
@@ -365,7 +366,7 @@ ply_animation_draw_area (ply_animation_t    *animation,
                          unsigned long       width,
                          unsigned long       height)
 {
-  ply_image_t * const * frames;
+  ply_pixel_buffer_t * const * frames;
   uint32_t *frame_data;
   int number_of_frames;
   int frame_index;
@@ -376,8 +377,8 @@ ply_animation_draw_area (ply_animation_t    *animation,
   number_of_frames = ply_array_get_size (animation->frames);
   frame_index = MIN(animation->frame_number, number_of_frames - 1);
 
-  frames = (ply_image_t * const *) ply_array_get_elements (animation->frames);
-  frame_data = ply_image_get_data (frames[frame_index]);
+  frames = (ply_pixel_buffer_t * const *) ply_array_get_elements (animation->frames);
+  frame_data = ply_pixel_buffer_get_argb32_data (frames[frame_index]);
 
   ply_pixel_buffer_fill_with_argb32_data (buffer,
                                           &animation->frame_area,