]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
fix the fading effect in the test case
authorRay Strode <rstrode@redhat.com>
Sat, 12 May 2007 02:29:03 +0000 (22:29 -0400)
committerRay Strode <rstrode@redhat.com>
Sat, 12 May 2007 02:29:03 +0000 (22:29 -0400)
src/ply-image.c
src/ply-video-buffer.c

index 693f1d5a1a8b8ed72f478c654157ca777d68656c..b3acba81252e759cc8f53bdba1e909851ffeba5b 100644 (file)
@@ -318,7 +318,7 @@ animate_at_time (PlyVideoBuffer *buffer,
                                     60.0/256.0, 110.0/256.0, 180.0/256.0, 1.0);
   ply_video_buffer_fill_with_argb32_data_at_opacity (buffer, &area, 
                                                      0, 0, width, height, 
-                                                     data, 0.3);
+                                                     data, opacity);
   ply_video_buffer_unpause_updates (buffer);
 }
 
index b961952bdc89f48c26e2caf17fcd004ccc7f209f..f841d0d6313e8b0868b946ecd0fae5a2985ee7f8 100644 (file)
@@ -281,6 +281,25 @@ blend_two_pixel_values (uint32_t pixel_value_1,
   return PLY_VIDEO_BUFFER_COLOR_TO_PIXEL_VALUE (red, green, blue, alpha);
 }
 
+static uint32_t
+make_pixel_value_translucent (uint32_t pixel_value, 
+                              double   opacity)
+{
+  double alpha, red, green, blue;
+
+  alpha = (double) (pixel_value >> 24) / 255.0;
+  red = (double) ((pixel_value >> 16) & 0xff) / 255.0;
+  green = (double) ((pixel_value >> 8) & 0xff) / 255.0;
+  blue = (double) (pixel_value & 0xff) / 255.0;
+
+  alpha *= opacity;
+  red *= opacity;
+  green *= opacity;
+  blue *= opacity;
+
+  return PLY_VIDEO_BUFFER_COLOR_TO_PIXEL_VALUE (red, green, blue, alpha);
+}
+
 static void 
 ply_video_buffer_blend_value_at_pixel (PlyVideoBuffer *buffer,
                                        int             x,
@@ -625,8 +644,6 @@ ply_video_buffer_fill_with_argb32_data_at_opacity (PlyVideoBuffer     *buffer,
                                                    double              opacity)
 {
   long row, column;
-  bool is_translucent;
-  uint32_t alpha_pixel_value;
 
   assert (buffer != NULL);
   assert (ply_video_buffer_device_is_open (buffer));
@@ -634,17 +651,6 @@ ply_video_buffer_fill_with_argb32_data_at_opacity (PlyVideoBuffer     *buffer,
   if (area == NULL)
     area = &buffer->area;
 
-  alpha_pixel_value = 0x00000000;
-  if (abs (opacity - 1.0) > DBL_MIN)
-    {
-      uint8_t alpha;
-      alpha = (uint8_t) CLAMP (opacity * 255.0, 0.0, 255.0);
-      alpha_pixel_value |= alpha << 24;
-      is_translucent = true;
-    }
-  else
-    is_translucent = false;
-
   for (row = y; row < y + height; row++)
     {
       for (column = x; column < x + width; column++)
@@ -652,12 +658,7 @@ ply_video_buffer_fill_with_argb32_data_at_opacity (PlyVideoBuffer     *buffer,
           uint32_t pixel_value;
 
           pixel_value = data[width * row + column];
-
-          if (is_translucent)
-            {
-              pixel_value = 
-                blend_two_pixel_values (alpha_pixel_value, pixel_value);
-            }
+          pixel_value = make_pixel_value_translucent (pixel_value, opacity);
           ply_video_buffer_blend_value_at_pixel (buffer,
                                                  area->x + (column - x),
                                                  area->y + (row - y),