st/mesa: use new _mesa_expand_bitmap() function
This commit is contained in:
parent
278e76832f
commit
d5b6dd0001
|
@ -241,7 +241,7 @@ combined_bitmap_fragment_program(GLcontext *ctx)
|
|||
/**
|
||||
* Copy user-provide bitmap bits into texture buffer, expanding
|
||||
* bits into texels.
|
||||
* "On" bits will set texels to 0xff.
|
||||
* "On" bits will set texels to 0x0.
|
||||
* "Off" bits will not modify texels.
|
||||
* Note that the image is actually going to be upside down in
|
||||
* the texture. We deal with that with texcoords.
|
||||
|
@ -253,63 +253,10 @@ unpack_bitmap(struct st_context *st,
|
|||
const GLubyte *bitmap,
|
||||
ubyte *destBuffer, uint destStride)
|
||||
{
|
||||
GLint row, col;
|
||||
destBuffer += py * destStride + px;
|
||||
|
||||
#define SET_PIXEL(COL, ROW) \
|
||||
destBuffer[(py + (ROW)) * destStride + px + (COL)] = 0x0;
|
||||
|
||||
for (row = 0; row < height; row++) {
|
||||
const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
|
||||
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
|
||||
|
||||
if (unpack->LsbFirst) {
|
||||
/* Lsb first */
|
||||
GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
|
||||
for (col = 0; col < width; col++) {
|
||||
|
||||
if (*src & mask) {
|
||||
SET_PIXEL(col, row);
|
||||
}
|
||||
|
||||
if (mask == 128U) {
|
||||
src++;
|
||||
mask = 1U;
|
||||
}
|
||||
else {
|
||||
mask = mask << 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* get ready for next row */
|
||||
if (mask != 1)
|
||||
src++;
|
||||
}
|
||||
else {
|
||||
/* Msb first */
|
||||
GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
|
||||
for (col = 0; col < width; col++) {
|
||||
|
||||
if (*src & mask) {
|
||||
SET_PIXEL(col, row);
|
||||
}
|
||||
|
||||
if (mask == 1U) {
|
||||
src++;
|
||||
mask = 128U;
|
||||
}
|
||||
else {
|
||||
mask = mask >> 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* get ready for next row */
|
||||
if (mask != 128)
|
||||
src++;
|
||||
}
|
||||
|
||||
} /* row */
|
||||
|
||||
#undef SET_PIXEL
|
||||
_mesa_expand_bitmap(width, height, unpack, bitmap,
|
||||
destBuffer, destStride, 0x0);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue