/* for graphic displays only */ static void drv_MDM166A_blit(const int row, const int col, const int height, const int width) { int n, x, y, yb; unsigned char c; if (NeedRefresh == 0) { minX = width; maxX = 0; } for (y = row; y < row + height && y < SCREEN_H; ++y) for (x = col; x < col + width && x < SCREEN_W; ++x) { yb = (y / 8); n = x + (yb * SCREEN_W); c = *(mdm166a_framebuffer + n); if (drv_generic_graphic_black(y, x) ^ nDrawInverted) c |= 0x80 >> (y % 8); else c &= ~(0x80 >> (y % 8)); if (c != *(mdm166a_framebuffer + n)) { *(mdm166a_framebuffer + n) = c; minX = (minX < x) ? minX : x; maxX = (maxX > (x + 1)) ? maxX : (x + 1); NeedRefresh = 1; } }
static void drv_MOGX_blit(const int row, const int col, const int height, const int width) { int r, c; for (r = row; r < row + height; r++) { for (c = col; c < col + width; c++) MOGX_framebuffer[r * SCREEN_W + c] = drv_generic_graphic_black(r, c); } drv_MOGX_update_lcd(); }
static void drv_PICGraphic_blit(const int row, const int col, const int height, const int width) { /* update a rectangular portion of the display */ int r, c, index, status; unsigned char cmd[5]; debug("blit from (%d,%d) to (%d,%d) out of (%d,%d)", row, col, row + height, col + width, DROWS, DCOLS); if (!fbPG) return; for (c = min(col, DCOLS - 1); c < min(col + width, DCOLS); c++) { for (r = min(row, DROWS - 1); r < min(row + height, DROWS); r++) { index = DCOLS * (r / 8) + c; if (index < 0 || index >= DCOLS * DROWS / 8) { error("index too large: %d, r: %d, c: %d", index, r, c); break; } if (drv_generic_graphic_black(r, c)) { fbPG[index] |= (1 << (r % 8)); } else { fbPG[index] &= ~(1 << (r % 8)); } } } // send rectangular portion with height divisible by 8 #ifdef partialFrame if (delayDone) { delayDone = 0; int row8, height8; row8 = 8 * (row / 8); height8 = 8 * (height / 8) + ! !(height % 8); info("sending blit"); cmd[0] = 'b'; cmd[1] = row8; cmd[2] = col; cmd[3] = height8; cmd[4] = width; drv_PICGraphic_send(cmd, 5); for (r = min(row8, DROWS - 1); r < min(row8 + height8, DROWS); r += 8) { drv_PICGraphic_send(fbPG + DCOLS * (r / 8) + col, width); } } #else // send full frame if (delayDone) { delayDone = 0; info("sending frame"); cmd[0] = 'f'; drv_PICGraphic_send((char *) cmd, 1); drv_PICGraphic_send(fbPG, DROWS * DCOLS / 8); usleep(20000); // wait for reception of confirmation code status = drv_PICGraphic_recv((char *) cmd, 2, "ff"); if (!status) { info("received ff from device"); } else { info("did not receive ff from device"); } } #endif }
/* copy framebuffer to display */ static void drv_EA232graphic_blit(const int row, const int col, const int height, const int width) { int r, c, l, p; char *cmd; /* calculate length of command */ l = 0; switch (Model->protocol) { case 1: case 2: l = ((height + 7) / 8) * width; break; case 3: l = ((width + 7) / 8) * height; break; default: error("%s: undefined protocol type", Name); return; } /* add maximum length of command header */ cmd = (char *) malloc(l + 10); if (cmd == NULL) { error("%s: allocation of buffer failed: %s", Name, strerror(errno)); return; } p = 0; /* write command header */ switch (Model->protocol) { case 1: case 3: cmd[p++] = 'U'; cmd[p++] = col; cmd[p++] = row; cmd[p++] = width; cmd[p++] = height; break; case 2: cmd[p++] = ESC; cmd[p++] = 'U'; cmd[p++] = 'L'; cmd[p++] = col; cmd[p++] = row; cmd[p++] = width; cmd[p++] = height; break; default: error("%s: undefined protocol type", Name); free(cmd); return; } /* clear all pixels */ memset(cmd + p, 0, l); /* set pixels */ switch (Model->protocol) { case 1: case 2: for (r = 0; r < height; r++) { for (c = 0; c < width; c++) { if (drv_generic_graphic_black(r + row, c + col)) { cmd[(r / 8) * width + c + p] |= (LSB_BYTE << (r % 8)); } } } break; case 3: for (c = 0; c < width; c++) { for (r = 0; r < height; r++) { if (drv_generic_graphic_black(r + row, c + col)) { cmd[(c / 8) * height + r + p] |= (MSB_BYTE >> (c % 8)); } } } break; default: error("%s: undefined protocol type", Name); free(cmd); return; }