From: Ray Strode Date: Sat, 12 May 2007 02:29:03 +0000 (-0400) Subject: fix the fading effect in the test case X-Git-Tag: 0.1.0~313 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4da04c9487ba39956221e99d5ff9784ea2708060;p=thirdparty%2Fplymouth.git fix the fading effect in the test case --- diff --git a/src/ply-image.c b/src/ply-image.c index 693f1d5a..b3acba81 100644 --- a/src/ply-image.c +++ b/src/ply-image.c @@ -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); } diff --git a/src/ply-video-buffer.c b/src/ply-video-buffer.c index b961952b..f841d0d6 100644 --- a/src/ply-video-buffer.c +++ b/src/ply-video-buffer.c @@ -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),