From 12450fe6b86bf76b9ba44d857cb7700cebd610bc Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 11 Jul 2021 13:33:40 +0900 Subject: [PATCH] [vid] Remove redundant direct, conbuffer and conrowbytes --- include/QF/vid.h | 4 ---- libs/video/renderer/sw/draw.c | 10 +++++----- libs/video/renderer/sw32/draw.c | 34 ++++++++++++++++----------------- libs/video/targets/vid.c | 10 +++++----- libs/video/targets/vid_win.c | 10 +++++----- libs/video/targets/vid_win_sw.c | 8 -------- libs/video/targets/vid_x11_sw.c | 4 ---- 7 files changed, 32 insertions(+), 48 deletions(-) diff --git a/include/QF/vid.h b/include/QF/vid.h index 2d6a94698..9255e7210 100644 --- a/include/QF/vid.h +++ b/include/QF/vid.h @@ -54,11 +54,7 @@ typedef struct { qboolean recalc_refdef; // if true, recalc vid-based stuff qboolean cshift_changed; quat_t cshift_color; - void *conbuffer; - int conrowbytes; struct view_s *conview; - byte *direct; // direct drawing to framebuffer, if not - // NULL struct vid_internal_s *vid_internal; } viddef_t; diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index a73b9a734..a24117118 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -280,7 +280,7 @@ Draw_Character (int x, int y, unsigned int chr) } else drawline = 8; - dest = ((byte*)vid.conbuffer) + y * vid.conrowbytes + x; + dest = ((byte*)vid.buffer) + y * vid.rowbytes + x; while (drawline--) { if (source[0]) @@ -300,7 +300,7 @@ Draw_Character (int x, int y, unsigned int chr) if (source[7]) dest[7] = source[7]; source += 128; - dest += vid.conrowbytes; + dest += vid.rowbytes; } } @@ -340,7 +340,7 @@ Draw_Pixel (int x, int y, byte color) { byte *dest; - dest = ((byte*)vid.conbuffer) + y * vid.conrowbytes + x; + dest = ((byte*)vid.buffer) + y * vid.rowbytes + x; *dest = color; } @@ -621,9 +621,9 @@ Draw_ConsoleBackground (int lines, byte alpha) conback = Draw_CachePic ("gfx/conback.lmp", false); // draw the pic - dest = vid.conbuffer; + dest = vid.buffer; - for (y = 0; y < lines; y++, dest += vid.conrowbytes) { + for (y = 0; y < lines; y++, dest += vid.rowbytes) { v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen; src = conback->data + v * 320; if (vid.conview->xlen == 320) diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index ea630fc28..6c8621097 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -287,7 +287,7 @@ sw32_Draw_Character (int x, int y, unsigned int chr) switch(sw32_ctx->pixbytes) { case 1: { - byte *dest = (byte *) vid.conbuffer + y * vid.conrowbytes + x; + byte *dest = (byte *) vid.buffer + y * vid.rowbytes + x; while (drawline--) { if (source[0]) @@ -307,14 +307,14 @@ sw32_Draw_Character (int x, int y, unsigned int chr) if (source[7]) dest[7] = source[7]; source += 128; - dest += vid.conrowbytes; + dest += vid.rowbytes; } } break; case 2: { - unsigned short *dest = (unsigned short *) vid.conbuffer + y * - (vid.conrowbytes >> 1) + x; + unsigned short *dest = (unsigned short *) vid.buffer + y * + (vid.rowbytes >> 1) + x; while (drawline--) { if (source[0]) @@ -335,14 +335,14 @@ sw32_Draw_Character (int x, int y, unsigned int chr) dest[7] = sw32_8to16table[source[7]]; source += 128; - dest += (vid.conrowbytes >> 1); + dest += (vid.rowbytes >> 1); } } break; case 4: { - unsigned int *dest = (unsigned int *) vid.conbuffer + y * - (vid.conrowbytes >> 2) + x; + unsigned int *dest = (unsigned int *) vid.buffer + y * + (vid.rowbytes >> 2) + x; while (drawline--) { if (source[0]) @@ -363,7 +363,7 @@ sw32_Draw_Character (int x, int y, unsigned int chr) dest[7] = d_8to24table[source[7]]; source += 128; - dest += (vid.conrowbytes >> 2); + dest += (vid.rowbytes >> 2); } } break; @@ -407,14 +407,14 @@ Draw_Pixel (int x, int y, byte color) switch(sw32_ctx->pixbytes) { case 1: - ((byte *) vid.conbuffer)[y * vid.conrowbytes + x] = color; + ((byte *) vid.buffer)[y * vid.rowbytes + x] = color; break; case 2: - ((unsigned short *) vid.conbuffer)[y * (vid.conrowbytes >> 1) + x] = + ((unsigned short *) vid.buffer)[y * (vid.rowbytes >> 1) + x] = sw32_8to16table[color]; break; case 4: - ((unsigned int *) vid.conbuffer)[y * (vid.conrowbytes >> 2) + x] = + ((unsigned int *) vid.buffer)[y * (vid.rowbytes >> 2) + x] = d_8to24table[color]; break; default: @@ -745,9 +745,9 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha) switch(sw32_ctx->pixbytes) { case 1: { - byte *dest = vid.conbuffer; + byte *dest = vid.buffer; - for (y = 0; y < lines; y++, dest += vid.conrowbytes) { + for (y = 0; y < lines; y++, dest += vid.rowbytes) { v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen; src = conback->data + v * 320; if (vid.conview->xlen == 320) @@ -771,9 +771,9 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha) break; case 2: { - unsigned short *dest = (unsigned short *) vid.conbuffer; + unsigned short *dest = (unsigned short *) vid.buffer; - for (y = 0; y < lines; y++, dest += (vid.conrowbytes >> 1)) { + for (y = 0; y < lines; y++, dest += (vid.rowbytes >> 1)) { // FIXME: pre-expand to native format? // FIXME: does the endian switching go away in production? v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen; @@ -795,8 +795,8 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha) break; case 4: { - unsigned int *dest = (unsigned int *) vid.conbuffer; - for (y = 0; y < lines; y++, dest += (vid.conrowbytes >> 2)) { + unsigned int *dest = (unsigned int *) vid.buffer; + for (y = 0; y < lines; y++, dest += (vid.rowbytes >> 2)) { v = (vid.conview->ylen - lines + y) * 200 / vid.conview->ylen; src = conback->data + v * 320; f = 0; diff --git a/libs/video/targets/vid.c b/libs/video/targets/vid.c index 4c73fced2..682d301d5 100644 --- a/libs/video/targets/vid.c +++ b/libs/video/targets/vid.c @@ -280,11 +280,11 @@ VID_InitBuffers (void) // Free the old screen buffer if (viddef.buffer) { free (viddef.buffer); - viddef.conbuffer = viddef.buffer = NULL; + viddef.buffer = NULL; } // Allocate the new screen buffer - viddef.conbuffer = viddef.buffer = calloc (buffersize, 1); - if (!viddef.conbuffer) { + viddef.buffer = calloc (buffersize, 1); + if (!viddef.buffer) { Sys_Error ("Not enough memory for video mode"); } } @@ -292,7 +292,7 @@ VID_InitBuffers (void) viddef.zbuffer = calloc (zbuffersize, 1); if (!viddef.zbuffer) { free (viddef.buffer); - viddef.conbuffer = viddef.buffer = NULL; + viddef.buffer = NULL; Sys_Error ("Not enough memory for video mode"); } // Allocate the new surface cache; free the z-buffer if we fail @@ -300,7 +300,7 @@ VID_InitBuffers (void) if (!viddef.surfcache) { free (viddef.buffer); free (viddef.zbuffer); - viddef.conbuffer = viddef.buffer = NULL; + viddef.buffer = NULL; viddef.zbuffer = NULL; Sys_Error ("Not enough memory for video mode"); } diff --git a/libs/video/targets/vid_win.c b/libs/video/targets/vid_win.c index 2a0cbaa38..d09f64d43 100644 --- a/libs/video/targets/vid_win.c +++ b/libs/video/targets/vid_win.c @@ -50,16 +50,16 @@ D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height) if (!viddef.initialized || !win_sw_context) return; - if (!viddef.direct) + if (!viddef.buffer) return; for (i = 0; i < (height << repshift); i += reps) { for (j = 0; j < reps; j++) { memcpy (&backingbuf[(i + j) * 24], - viddef.direct + x + ((y << repshift) + i + + viddef.buffer + x + ((y << repshift) + i + j) * viddef.rowbytes, width); - memcpy (viddef.direct + x + + memcpy (viddef.buffer + x + ((y << repshift) + i + j) * viddef.rowbytes, &pbitmap[(i >> repshift) * width], width); } @@ -84,12 +84,12 @@ D_EndDirectRect (int x, int y, int width, int height) if (!viddef.initialized || !win_sw_context) return; - if (!viddef.direct) + if (!viddef.buffer) return; for (i = 0; i < (height << repshift); i += reps) { for (j = 0; j < reps; j++) { - memcpy (viddef.direct + x + + memcpy (viddef.buffer + x + ((y << repshift) + i + j) * viddef.rowbytes, &backingbuf[(i + j) * 24], width); } diff --git a/libs/video/targets/vid_win_sw.c b/libs/video/targets/vid_win_sw.c index dd0bf4155..9ded596fb 100644 --- a/libs/video/targets/vid_win_sw.c +++ b/libs/video/targets/vid_win_sw.c @@ -312,14 +312,6 @@ win_init_bufers (void *data) { Win_UnloadAllDrivers (); Win_CreateDriver (); - // set the rest of the buffers we need (why not just use one single buffer - // instead of all this crap? oh well, it's Quake...) - viddef.direct = viddef.buffer; - viddef.conbuffer = viddef.buffer; - - // more crap for the console - viddef.conrowbytes = viddef.rowbytes; - } static void diff --git a/libs/video/targets/vid_x11_sw.c b/libs/video/targets/vid_x11_sw.c index f36847f56..938e085ba 100644 --- a/libs/video/targets/vid_x11_sw.c +++ b/libs/video/targets/vid_x11_sw.c @@ -643,7 +643,6 @@ x11_init_buffers (void *data) current_framebuffer = 0; - viddef.direct = 0; viddef.rowbytes = ctx->pixbytes * viddef.width; if (x_visinfo->depth != 8) { if (viddef.buffer) @@ -654,9 +653,6 @@ x11_init_buffers (void *data) } else { viddef.buffer = x_framebuffer[current_framebuffer]->data; } - viddef.conbuffer = viddef.buffer; - - viddef.conrowbytes = viddef.rowbytes; } static void