summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2008-05-24 01:44:55 -0400
committerRay Strode <rstrode@redhat.com>2008-05-24 01:44:55 -0400
commit5867cf994cc741d39536985faf4538de9f9661db (patch)
treee471ace46690bd1f63502153e647702fd152e1f8 /src
parent49c5e2654644c8952d9a086568bd020fc841eb5c (diff)
parent4928a01f2656f13b19a871f0a0a80cb09e618119 (diff)
downloadplymouth-5867cf994cc741d39536985faf4538de9f9661db.tar.gz
plymouth-5867cf994cc741d39536985faf4538de9f9661db.tar.xz
plymouth-5867cf994cc741d39536985faf4538de9f9661db.zip
Merge branch 'master' of git+ssh://halfline@git.freedesktop.org/git/plymouth
Diffstat (limited to 'src')
-rw-r--r--src/libply/ply-frame-buffer.c78
1 files changed, 35 insertions, 43 deletions
diff --git a/src/libply/ply-frame-buffer.c b/src/libply/ply-frame-buffer.c
index daa275c..d097adf 100644
--- a/src/libply/ply-frame-buffer.c
+++ b/src/libply/ply-frame-buffer.c
@@ -314,6 +314,24 @@ ply_frame_buffer_fill_area_with_pixel_value (ply_frame_buffer_t *buffer,
}
static void
+ply_frame_buffer_area_union (ply_frame_buffer_area_t *area1,
+ ply_frame_buffer_area_t *area2,
+ ply_frame_buffer_area_t *result)
+{
+ unsigned long x1, y1, x2, y2;
+
+ x1 = area1->x + area1->width;
+ y1 = area1->y + area1->height;
+ x2 = area2->x + area2->width;
+ y2 = area2->y + area2->height;
+
+ result->x = MIN(area1->x, area2->x);
+ result->y = MIN(area1->y, area2->y);
+ result->width = MAX(x1, x2) - result->x;
+ result->height = MAX(y1, y2) - result->y;
+}
+
+static void
ply_frame_buffer_add_area_to_flush_area (ply_frame_buffer_t *buffer,
ply_frame_buffer_area_t *area)
{
@@ -326,20 +344,9 @@ ply_frame_buffer_add_area_to_flush_area (ply_frame_buffer_t *buffer,
assert (area->width >= 0);
assert (area->height >= 0);
- if (area->x < buffer->area_to_flush.x)
- {
- buffer->area_to_flush.width += buffer->area_to_flush.x - area->x;
- buffer->area_to_flush.x = area->x;
- }
-
- if (area->y < buffer->area_to_flush.y)
- {
- buffer->area_to_flush.height += buffer->area_to_flush.y - area->y;
- buffer->area_to_flush.y = area->y;
- }
-
- buffer->area_to_flush.width = MAX (buffer->area_to_flush.width, area->width);
- buffer->area_to_flush.height = MAX (buffer->area_to_flush.height, area->height);
+ ply_frame_buffer_area_union (&buffer->area_to_flush,
+ area,
+ &buffer->area_to_flush);
}
static bool
@@ -564,36 +571,21 @@ ply_frame_buffer_get_size (ply_frame_buffer_t *buffer,
}
static void
-ply_frame_buffer_area_crop (ply_frame_buffer_area_t *area,
- ply_frame_buffer_area_t *mask_area,
- ply_frame_buffer_area_t *cropped_area)
+ply_frame_buffer_area_intersect (ply_frame_buffer_area_t *area1,
+ ply_frame_buffer_area_t *area2,
+ ply_frame_buffer_area_t *result)
{
- *cropped_area = *area;
- if (cropped_area->x <= mask_area->x)
- {
- cropped_area->x = mask_area->x;
- cropped_area->width -= mask_area->x - cropped_area->x;
- }
-
- if (cropped_area->y <= mask_area->y)
- {
- cropped_area->y = mask_area->y;
- cropped_area->height -= mask_area->y - cropped_area->y;
- }
-
- cropped_area->width = MIN (area->width, mask_area->width);
- cropped_area->height = MIN (area->height, mask_area->height);
-
- if (cropped_area->x + cropped_area->width > mask_area->x + mask_area->width)
- cropped_area->width = (mask_area->x + mask_area->width) - cropped_area->x;
+ unsigned long x1, y1, x2, y2;
- if (cropped_area->y + cropped_area->height > mask_area->y + mask_area->height)
- cropped_area->height = (mask_area->y + mask_area->height) - cropped_area->y;
+ x1 = area1->x + area1->width;
+ y1 = area1->y + area1->height;
+ x2 = area2->x + area2->width;
+ y2 = area2->y + area2->height;
- assert (cropped_area->x >= mask_area->x);
- assert (cropped_area->y >= mask_area->y);
- assert (cropped_area->x + cropped_area->width <= mask_area->x + mask_area->width);
- assert (cropped_area->y + cropped_area->height <= mask_area->x + mask_area->height);
+ result->x = MAX(area1->x, area2->x);
+ result->y = MAX(area1->y, area2->y);
+ result->width = MIN(x1, x2) - result->x;
+ result->height = MIN(y1, y2) - result->y;
}
bool
@@ -613,7 +605,7 @@ ply_frame_buffer_fill_with_color (ply_frame_buffer_t *buffer,
if (area == NULL)
area = &buffer->area;
- ply_frame_buffer_area_crop (area, &buffer->area, &cropped_area);
+ ply_frame_buffer_area_intersect (area, &buffer->area, &cropped_area);
red *= alpha;
green *= alpha;
@@ -646,7 +638,7 @@ ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buff
if (area == NULL)
area = &buffer->area;
- ply_frame_buffer_area_crop (area, &buffer->area, &cropped_area);
+ ply_frame_buffer_area_intersect (area, &buffer->area, &cropped_area);
opacity_as_byte = (uint8_t) (opacity * 255.0);