Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ba415d7 authored by Rebecca Schultz Zavin's avatar Rebecca Schultz Zavin Committed by Android Git Automerger
Browse files

am 0779a177: am 6388fe80: Merge change 25383 into eclair

Merge commit '0779a177'

* commit '0779a177':
  Add bitfields to header for screen shots.  This will allow ddms to distinguish
parents 6b13368e 0779a177
Loading
Loading
Loading
Loading
+36 −9
Original line number Original line Diff line number Diff line
@@ -30,6 +30,24 @@
/* TODO:
/* TODO:
** - sync with vsync to avoid tearing
** - sync with vsync to avoid tearing
*/
*/
/* This version number defines the format of the fbinfo struct.
   It must match versioning in ddms where this data is consumed. */
#define DDMS_RAWIMAGE_VERSION 1
struct fbinfo {
    unsigned int version;
    unsigned int bpp;
    unsigned int size;
    unsigned int width;
    unsigned int height;
    unsigned int red_offset;
    unsigned int red_length;
    unsigned int blue_offset;
    unsigned int blue_length;
    unsigned int green_offset;
    unsigned int green_length;
    unsigned int alpha_offset;
    unsigned int alpha_length;
} __attribute__((packed));


void framebuffer_service(int fd, void *cookie)
void framebuffer_service(int fd, void *cookie)
{
{
@@ -37,7 +55,7 @@ void framebuffer_service(int fd, void *cookie)
    int fb, offset;
    int fb, offset;
    char x[256];
    char x[256];


    unsigned fbinfo[4];
    struct fbinfo fbinfo;
    unsigned i, bytespp;
    unsigned i, bytespp;


    fb = open("/dev/graphics/fb0", O_RDONLY);
    fb = open("/dev/graphics/fb0", O_RDONLY);
@@ -48,10 +66,19 @@ void framebuffer_service(int fd, void *cookie)


    bytespp = vinfo.bits_per_pixel / 8;
    bytespp = vinfo.bits_per_pixel / 8;


    fbinfo[0] = vinfo.bits_per_pixel;
    fbinfo.version = DDMS_RAWIMAGE_VERSION;
    fbinfo[1] = vinfo.xres * vinfo.yres * bytespp;
    fbinfo.bpp = vinfo.bits_per_pixel;
    fbinfo[2] = vinfo.xres;
    fbinfo.size = vinfo.xres * vinfo.yres * bytespp;
    fbinfo[3] = vinfo.yres;
    fbinfo.width = vinfo.xres;
    fbinfo.height = vinfo.yres;
    fbinfo.red_offset = vinfo.red.offset;
    fbinfo.red_length = vinfo.red.length;
    fbinfo.green_offset = vinfo.green.offset;
    fbinfo.green_length = vinfo.green.length;
    fbinfo.blue_offset = vinfo.blue.offset;
    fbinfo.blue_length = vinfo.blue.length;
    fbinfo.alpha_offset = vinfo.transp.offset;
    fbinfo.alpha_length = vinfo.transp.length;


    /* HACK: for several of our 3d cores a specific alignment
    /* HACK: for several of our 3d cores a specific alignment
     * is required so the start of the fb may not be an integer number of lines
     * is required so the start of the fb may not be an integer number of lines
@@ -62,16 +89,16 @@ void framebuffer_service(int fd, void *cookie)


    offset += vinfo.xres * vinfo.yoffset * bytespp;
    offset += vinfo.xres * vinfo.yoffset * bytespp;


    if(writex(fd, fbinfo, sizeof(fbinfo))) goto done;
    if(writex(fd, &fbinfo, sizeof(fbinfo))) goto done;


    lseek(fb, offset, SEEK_SET);
    lseek(fb, offset, SEEK_SET);
    for(i = 0; i < fbinfo[1]; i += 256) {
    for(i = 0; i < fbinfo.size; i += 256) {
      if(readx(fb, &x, 256)) goto done;
      if(readx(fb, &x, 256)) goto done;
      if(writex(fd, &x, 256)) goto done;
      if(writex(fd, &x, 256)) goto done;
    }
    }


    if(readx(fb, &x, fbinfo[1] % 256)) goto done;
    if(readx(fb, &x, fbinfo.size % 256)) goto done;
    if(writex(fd, &x, fbinfo[1] % 256)) goto done;
    if(writex(fd, &x, fbinfo.size % 256)) goto done;


done:
done:
    if(fb >= 0) close(fb);
    if(fb >= 0) close(fb);