]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
frame-buffer: fix flush_area fast-path
authorDavid Herrmann <dh.herrmann@googlemail.com>
Sun, 24 Jun 2012 10:06:07 +0000 (12:06 +0200)
committerRay Strode <rstrode@redhat.com>
Mon, 25 Jun 2012 15:32:56 +0000 (11:32 -0400)
plymouth uses a shadow framebuffer to cache screen contents for
quick compositing.  This shadow framebuffer may or may not have
the same memory layout as the hardware framebuffer.  In cases
where the size and layout of pixels are the same between the shadow
framebuffer and the hardware framebuffer we can memcpy()
the pixels line-by-line to the hardware.  If the width of area being
flushed is the same number of bytes as the width of the hardware buffer,
then we can memcpy() the entire flush area in one call to memcpy.

The check for this latter fast-path has a miscalculation that tests
the number of pixels in the flush area width to number of bytes in the
buffer width. This commit adds the * 4 multiplier to correctly compare
bytes with bytes instead of pixels with bytes.

This commit also adds a sanity check to make sure the byte size of the
hardware framebuffer width is equal to the advertised row stride.

src/plugins/renderers/frame-buffer/plugin.c

index 864a8c3d883aefabeff098666375efd5c51790b7..0e079431a48cd2989775c69aa983d6e1d16a079f 100644 (file)
@@ -225,7 +225,8 @@ flush_area_to_xrgb32_device (ply_renderer_backend_t *backend,
   dst = &head->map_address[y1 * backend->row_stride + x * backend->bytes_per_pixel];
   src = (char *) &shadow_buffer[y1 * head->area.width + x];
 
-  if (area_to_flush->width == backend->row_stride)
+  if (area_to_flush->width * 4 == backend->row_stride &&
+      head->area.width * 4 == backend->row_stride)
     {
       memcpy (dst, src, area_to_flush->width * area_to_flush->height * 4);
       return;