Skip to content

Commit

Permalink
Fix screen 8 from rendering half size. Other cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adeyblue authored and jayrm committed Jan 5, 2020
1 parent 19a289d commit d1c391e
Showing 1 changed file with 24 additions and 16 deletions.
40 changes: 24 additions & 16 deletions src/gfxlib2/win32/gfx_driver_gdi.c
Expand Up @@ -41,7 +41,9 @@ static void alpha_remover_blitter(unsigned char *dest, int pitch)
char *dirty = __fb_gfx->dirty;
int x, y;

for (y = __fb_gfx->h * __fb_gfx->scanline_size; y; y--) {
DBG_ASSERT((fb_win32.depth == 32) && (__fb_gfx->scanline_size == 1));

for (y = __fb_gfx->h; y; y--) {
if (*dirty) {
s = (unsigned int *)src;
d = (unsigned int *)dest;
Expand Down Expand Up @@ -165,25 +167,27 @@ static int gdi_init(void)
bitmap_info->bmiHeader.biClrUsed = 256;
bitmap_info->bmiHeader.biCompression = BI_RGB;

if ((fb_win32.depth >= 16) || (fb_win32.w & 0x3)) {
if (fb_win32.depth == 16) {
if ((fb_win32.depth >= 16) || (fb_win32.w & 0x3) || (__fb_gfx->scanline_size > 1)) {
if (fb_win32.flags & DRIVER_SHAPED_WINDOW)
{
if( fb_win32.depth == 32 )
fb_win32.blitter = alpha_remover_blitter;
}
else if (fb_win32.depth == 16) {
fb_win32.blitter = fb_hGetBlitter(15, FALSE);
if (!fb_win32.blitter)
return -1;
}
else if (fb_win32.w & 0x3) {
else if ((fb_win32.w & 0x3) || (__fb_gfx->scanline_size > 1)) {
fb_win32.blitter = fb_hGetBlitter(fb_win32.depth, FALSE);
if (!fb_win32.blitter)
return -1;
}
if (fb_win32.flags & DRIVER_SHAPED_WINDOW)
{
if( fb_win32.depth == 32 )
fb_win32.blitter = alpha_remover_blitter;
if(fb_win32.blitter) {
buffer = malloc(((fb_win32.w + 3) & ~3) * fb_win32.h * __fb_gfx->bpp);
if (!buffer)
return -1;
}
buffer = malloc(((fb_win32.w + 3) & ~3) * fb_win32.h * __fb_gfx->bpp);
if (!buffer)
return -1;
}

hdc = GetDC(fb_win32.wnd);
Expand Down Expand Up @@ -223,7 +227,7 @@ static DWORD WINAPI gdi_thread( LPVOID param )
#endif
{
HANDLE running_event = param;
int i, y1, y2, h;
int i, y1, y2, h, scanline_size;
unsigned char *source, keystate[256];
HDC hdc;
RECT rect;
Expand All @@ -239,6 +243,7 @@ static DWORD WINAPI gdi_thread( LPVOID param )
while (fb_win32.is_running)
{
fb_hWin32Lock();
scanline_size = __fb_gfx->scanline_size;

hdc = GetDC(fb_win32.wnd);
if (fb_win32.is_palette_changed) {
Expand All @@ -255,19 +260,22 @@ static DWORD WINAPI gdi_thread( LPVOID param )
fb_win32.is_palette_changed = FALSE;
}
/* Only do a single SetDIBitsToDevice call per frame */
for (y1 = 0; y1 < fb_win32.h; y1++) {
for (y1 = 0; y1 < __fb_gfx->h; y1++) {
if (__fb_gfx->dirty[y1]) {
for (y2 = fb_win32.h - 1; !__fb_gfx->dirty[y2]; y2--)
for (y2 = __fb_gfx->h - 1; !__fb_gfx->dirty[y2]; y2--)
;
h = y2 - y1 + 1;

if (fb_win32.blitter) {
fb_win32.blitter(buffer, (__fb_gfx->pitch + 3) & ~3);
y1 *= scanline_size;
y2 *= scanline_size;
fb_win32.blitter(buffer, (__fb_gfx->pitch + 3) & ~0x3);
source = buffer + (y1 * ((__fb_gfx->pitch + 3) & ~0x3));
}
else
{
source = __fb_gfx->framebuffer + (y1 * __fb_gfx->pitch);
}
h = (y2 - y1 + 1);

SetDIBitsToDevice(hdc, 0, y1, fb_win32.w, h, 0, 0, 0, h, source, bitmap_info, DIB_RGB_COLORS);

Expand Down

0 comments on commit d1c391e

Please sign in to comment.