Thread: iLiad Fixing iPdf for iRex
View Single Post
Old 12-11-2006, 06:39 PM   #3
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
I never posted the sources of ipdf's 4 and 5 because I thought iRex and I would be able to work out some amicable agreement.

That never happened and I've pretty much given up hope that it ever will.

They recently released 2.8 and they attempted to implement my ipdf4 trick of writing directly to the /dev/fb as a memory mapped buffer.

They didn't do a very efficient job of it and it appears to me that they also introduced a bug in the process.

First the bug.

If you memory map something, you need to un-map it.

Code:
munmap(screenMem, screenSize);
They never un-map it: oops.

I could have sworn I sent M the code below, they must have lost it...

In any case, their version of it in 2.8 touches nearly every pixel to be drawn twice. That makes the code below nearly twice as quick at putting the image up on the display since it doesn't.

Code:
void XMgr::drawImage(SplashBitmap * bmp, 
                     int xSrc , int ySrc , 
                     int xDest, int yDest) 
{
    // Get our source image width and calculate delta frem screen width
    int srcWidth = bmp->getWidth();
    int deltaX = SCREEN_WIDTH - srcWidth;
    if (deltaX < 0) {
      // Source too wide, trim to screen width
      srcWidth = SCREEN_WIDTH;
    }

    // Get our source image height and calculate delta frem screen height
    int srcHeight = bmp->getHeight();
    int deltaY = CLIENT_AREA - srcHeight;
    if (deltaY < 0) {
      // Source too tall, trim to screen height
      srcHeight = CLIENT_AREA;
    }

    // Now move image data into shared memory buffer
    char *src = (char*)bmp->getDataPtr();
    char *dest = screenMem;
    for (int i = 0; i < srcHeight; i++) {
      // Copy source line of data
      memcpy(dest, src, srcWidth);
      src += srcWidth;
      dest += srcWidth;

      // Fill rest of line with white
      if (deltaX > 0) {
        memset(dest, 0xf0, deltaX);
        dest += deltaX;
      } else {
        // Skip extra source line material
        src -= deltaX;
      }
    }

    // Fill rest of page with white
    if (deltaY > 0) {
      memset(dest, 0xf0, deltaY * SCREEN_WIDTH);
    }
My code is also slightly better documented than theirs. Even though they know they are posting their code as "reference material" they still haven't done much to enhance their usage of comments.
scotty1024 is offline   Reply With Quote