summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2008-05-28 18:22:33 -0400
committerKristian Høgsberg <krh@redhat.com>2008-05-29 10:30:38 -0400
commit6e5fe71076fe38e5236f68d4c05dcc5bcbc4dbd7 (patch)
tree728de7aee1a21a815cad61ff65dc072122e8f299 /src
parentddabea638d1490496238d389cfe027b138b2af80 (diff)
downloadplymouth-6e5fe71076fe38e5236f68d4c05dcc5bcbc4dbd7.tar.gz
plymouth-6e5fe71076fe38e5236f68d4c05dcc5bcbc4dbd7.tar.xz
plymouth-6e5fe71076fe38e5236f68d4c05dcc5bcbc4dbd7.zip
Do the shadow buffer to frame buffer copy through a function pointer.
This allows us to hook in pixel format specific functions for this, but for now the patch just sets up the old code as the generic fallback.
Diffstat (limited to 'src')
-rw-r--r--src/libply/ply-frame-buffer.c95
1 files changed, 46 insertions, 49 deletions
diff --git a/src/libply/ply-frame-buffer.c b/src/libply/ply-frame-buffer.c
index c2c4246..2d3bbc1 100644
--- a/src/libply/ply-frame-buffer.c
+++ b/src/libply/ply-frame-buffer.c
@@ -71,6 +71,7 @@ struct _ply_frame_buffer
ply_frame_buffer_area_t area;
ply_frame_buffer_area_t area_to_flush;
+ void (*flush)(ply_frame_buffer_t *buffer);
uint32_t is_paused : 1;
};
@@ -137,6 +138,48 @@ ply_frame_buffer_close_device (ply_frame_buffer_t *buffer)
}
}
+static void
+flush_generic (ply_frame_buffer_t *buffer)
+{
+ unsigned long row, column;
+ char *row_buffer;
+ size_t bytes_per_row;
+ unsigned long x1, y1, x2, y2;
+
+ x1 = buffer->area_to_flush.x;
+ y1 = buffer->area_to_flush.y;
+ x2 = x1 + buffer->area_to_flush.width;
+ y2 = y1 + buffer->area_to_flush.height;
+
+ bytes_per_row = buffer->area_to_flush.width * buffer->bytes_per_pixel;
+ row_buffer = malloc (buffer->row_stride * buffer->bytes_per_pixel);
+ for (row = y1; row < y2; row++)
+ {
+ unsigned long offset;
+
+ for (column = x1; column < x2; column++)
+ {
+ uint32_t pixel_value;
+ uint_fast32_t device_pixel_value;
+
+ pixel_value = buffer->shadow_buffer[row * buffer->row_stride + column];
+
+ device_pixel_value =
+ ply_frame_buffer_pixel_value_to_device_pixel_value (buffer,
+ pixel_value);
+
+ memcpy (row_buffer + column * buffer->bytes_per_pixel,
+ &device_pixel_value, buffer->bytes_per_pixel);
+ }
+
+ offset = row * buffer->row_stride * buffer->bytes_per_pixel;
+ memcpy (buffer->map_address + offset, row_buffer,
+ buffer->area_to_flush.width * buffer->bytes_per_pixel);
+ }
+ free (row_buffer);
+}
+
+
static bool
ply_frame_buffer_query_device (ply_frame_buffer_t *buffer)
{
@@ -177,6 +220,8 @@ ply_frame_buffer_query_device (ply_frame_buffer_t *buffer)
buffer->row_stride = fixed_screen_info.line_length / buffer->bytes_per_pixel;
buffer->size = buffer->area.height * buffer->row_stride * buffer->bytes_per_pixel;
+ buffer->flush = flush_generic;
+
return true;
}
@@ -350,49 +395,6 @@ ply_frame_buffer_add_area_to_flush_area (ply_frame_buffer_t *buffer,
}
static bool
-ply_frame_buffer_copy_to_device (ply_frame_buffer_t *buffer,
- unsigned long x,
- unsigned long y,
- unsigned long width,
- unsigned long height)
-{
- unsigned long row, column;
- char *row_buffer;
- size_t bytes_per_row;
-
- bytes_per_row = width * buffer->bytes_per_pixel;
-
- row_buffer = malloc (buffer->row_stride * buffer->bytes_per_pixel);
-
- for (row = y; row < y + height; row++)
- {
- unsigned long offset;
-
- for (column = x; column < x + width; column++)
- {
- uint32_t pixel_value;
- uint_fast32_t device_pixel_value;
-
- pixel_value = buffer->shadow_buffer[row * buffer->row_stride + column];
-
- device_pixel_value =
- ply_frame_buffer_pixel_value_to_device_pixel_value (buffer,
- pixel_value);
-
- memcpy (row_buffer + column * buffer->bytes_per_pixel,
- &device_pixel_value, buffer->bytes_per_pixel);
- }
-
- offset = row * buffer->row_stride * buffer->bytes_per_pixel + x * buffer->bytes_per_pixel;
- memcpy (buffer->map_address + offset, row_buffer + x * buffer->bytes_per_pixel,
- width * buffer->bytes_per_pixel);
- }
- free (row_buffer);
-
- return true;
-}
-
-static bool
ply_frame_buffer_flush (ply_frame_buffer_t *buffer)
{
assert (buffer != NULL);
@@ -400,12 +402,7 @@ ply_frame_buffer_flush (ply_frame_buffer_t *buffer)
if (buffer->is_paused)
return true;
- if (!ply_frame_buffer_copy_to_device (buffer,
- buffer->area_to_flush.x,
- buffer->area_to_flush.y,
- buffer->area_to_flush.width,
- buffer->area_to_flush.height))
- return false;
+ (*buffer->flush) (buffer);
buffer->area_to_flush.x = buffer->area.width - 1;
buffer->area_to_flush.y = buffer->area.height - 1;