* The 4-bit VGA planar mode is now advertized as B_GRAY8 to the app_server.

* The app_server now detects that this mode is being used, and at least correctly copies
  the 32bit data to the first plane, meaning we have a monochrome output for now
  (it crashed before, as Stefano reported).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-12-19 18:45:40 +00:00
parent 6504001302
commit c46eb09e8f
2 changed files with 66 additions and 17 deletions

View File

@ -89,7 +89,8 @@ vesa_init(vesa_info &info)
info.shared_info->current_mode.virtual_height = bufferInfo->height;
switch (bufferInfo->depth) {
case 4:
// ???
info.shared_info->current_mode.space = B_GRAY8;
// the app_server is smart enough to translate this to VGA mode
break;
case 8:
info.shared_info->current_mode.space = B_CMAP8;

View File

@ -666,25 +666,73 @@ HWInterface::_CopyToFront(uint8* src, uint32 srcBPR,
break;
}
case B_GRAY8: {
// offset to left top pixel in dest buffer
dst += y * dstBPR + x;
int32 left = x;
// copy
// TODO: assumes BGR order, does this work on big endian as well?
for (; y <= bottom; y++) {
uint8* srcHandle = src;
uint8* dstHandle = dst;
for (x = left; x <= right; x++) {
*dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1] + 116 * srcHandle[0]) / 1024;
dstHandle ++;
srcHandle += 4;
case B_GRAY8:
if (frontBuffer->Width() > dstBPR) {
// VGA 16 color grayscale planar mode
dst += y * dstBPR + x / 8;
uint8* dstBase = dst;
uint8* srcBase = src;
int32 left = x;
// TODO: this is awfully slow...
// TODO: assumes BGR order
for (int32 plane = 0; plane < 1; plane++) {
// TODO: we need to select the plane here!
src = srcBase;
dst = dstBase;
for (; y <= bottom; y++) {
uint8* srcHandle = src;
uint8* dstHandle = dst;
uint8 current8 = dstHandle[0];
// we store 8 pixels before writing them back
for (x = left; x <= right; x++) {
uint8 pixel = (308 * srcHandle[2] + 600 * srcHandle[1]
+ 116 * srcHandle[0]) / 1024;
srcHandle += 4;
if (pixel > 128)
current8 |= 0x80 >> (x & 7);
else
current8 &= ~(0x80 >> (x & 7));
if ((x & 7) == 7) {
// last pixel in 8 pixel group
dstHandle[0] = current8;
dstHandle++;
current8 = dstHandle[0];
}
}
if (x & 7) {
// last pixel has not been written yet
dstHandle[0] = current8;
}
dst += dstBPR;
src += srcBPR;
}
}
} else {
// offset to left top pixel in dest buffer
dst += y * dstBPR + x;
int32 left = x;
// copy
// TODO: assumes BGR order, does this work on big endian as well?
for (; y <= bottom; y++) {
uint8* srcHandle = src;
uint8* dstHandle = dst;
for (x = left; x <= right; x++) {
*dstHandle = (308 * srcHandle[2] + 600 * srcHandle[1] + 116 * srcHandle[0]) / 1024;
dstHandle ++;
srcHandle += 4;
}
dst += dstBPR;
src += srcBPR;
}
dst += dstBPR;
src += srcBPR;
}
break;
}
default:
fprintf(stderr, "HWInterface::CopyBackToFront() - unsupported front buffer format!\n");
break;