[Libdlo] Bitmap-drawing bug

Quentin Stafford-Fraser quentin at pobox.com
Sun May 24 10:48:56 PDT 2009


Hello all - good stuff happening here!

I managed to get segfaults when using dlo_copy_host_bmp().

This uses cmd_stripe24 to draw the raw pixels to the device, and it  
turns out that if you have big bitmaps to draw, this can overflow its  
buffer before it flushes it to the device.

There's a patch for dlo_grfx.c below.

All the best,
Quentin

----
Dr Quentin Stafford-Fraser
CEO, CamVine
quentin at camvine.com
61 Selwyn Road, Cambridge CB3 9EA, UK
Skype: quentinsf
tel:  +44 1223 852132 / 690771
mob: +44 7798 851702
camvine.com

Registered in England No: 6200773
Registered Office: Salisbury House, Station Road, Cambridge CB1 2LA



diff --git a/src/dlo_grfx.c b/src/dlo_grfx.c
index 3e9008a..54f41ed 100644
--- a/src/dlo_grfx.c
+++ b/src/dlo_grfx.c
@@ -690,6 +690,10 @@ static dlo_retcode_t cmd_stripe24(dlo_device_t *  
const dev, dlo_ptr_t base16, dl
      *(dev->bufptr)++ = (char)(base16 & 0xFF);
      *(dev->bufptr)++ = rem >= RAW_MAX_PIXELS ? 0 : rem;

+    /* Flush the command buffer if it's getting full */
+    if (dev->bufend - dev->bufptr - BYTES_PER_16BPP * RAW_MAX_PIXELS  
< BUF_HIGH_WATER_MARK)
+        ERR(dlo_usb_write(dev));
+
      for (pix = 0; pix < (rem >= RAW_MAX_PIXELS ? RAW_MAX_PIXELS :  
rem); pix++)
      {
        dlo_col16_t col = *ptr_col16++;
@@ -711,6 +715,10 @@ static dlo_retcode_t cmd_stripe24(dlo_device_t *  
const dev, dlo_ptr_t base16, dl
      *(dev->bufptr)++ = (char)(base8 & 0xFF);
      *(dev->bufptr)++ = rem >= RAW_MAX_PIXELS ? 0 : rem;

+    /* Flush the command buffer if it's getting full */
+    if (dev->bufend - dev->bufptr - BYTES_PER_8BPP * RAW_MAX_PIXELS <  
BUF_HIGH_WATER_MARK)
+        ERR(dlo_usb_write(dev));
+
      for (pix = 0; pix < (rem >= RAW_MAX_PIXELS ? RAW_MAX_PIXELS :  
rem); pix++)
        *(dev->bufptr)++ = (char)(*ptr_col8++);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/libdlo/attachments/20090524/df19411a/attachment.html 


More information about the Libdlo mailing list