[vid] Remove redundant direct, conbuffer and conrowbytes

This commit is contained in:
Bill Currie 2021-07-11 13:33:40 +09:00
parent 6db6f8f0e2
commit 12450fe6b8
7 changed files with 32 additions and 48 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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;

View file

@ -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");
}

View file

@ -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);
}

View file

@ -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

View file

@ -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