Do a const-correctness run on palettes.

This commit is contained in:
Bill Currie 2013-01-27 19:57:40 +09:00
parent c56a075199
commit 1740e14d2a
11 changed files with 29 additions and 24 deletions

View file

@ -29,15 +29,16 @@
#ifndef __QF_image_h
#define __QF_image_h
#include "QF/qtypes.h"
#include "QF/quakeio.h"
// could not use texture_t as that is used for models.
typedef struct tex_s {
int width;
int height;
int format;
unsigned char *palette; // 0 = 32 bit, otherwise 8
unsigned char data[4]; // variable length
int width;
int height;
int format;
const byte *palette; // 0 = 32 bit, otherwise 8
byte data[4]; // variable length
} tex_t;
#define tex_palette 0

View file

@ -62,8 +62,8 @@ typedef struct
\return A pointer to the newly-coded PCX data.
\warning Uses Hunk_TempAlloc() to allocate the output PCX content.
*/
pcx_t *EncodePCX (byte *data, int width, int height, int rowbytes,
byte *palette, qboolean flip, int *length);
pcx_t *EncodePCX (const byte *data, int width, int height, int rowbytes,
const byte *palette, qboolean flip, int *length);
/**
Load a texture from a PCX file.
@ -75,6 +75,6 @@ pcx_t *EncodePCX (byte *data, int width, int height, int rowbytes,
\return A pointer to the texture.
\warning Uses Hunk_TempAlloc() to allocate the texture.
*/
struct tex_s *LoadPCX (QFile *f, qboolean convert, byte *pal);
struct tex_s *LoadPCX (QFile *f, qboolean convert, const byte *pal);
#endif // __pcx_h

View file

@ -41,7 +41,7 @@ typedef struct {
short *zbuffer;
void *surfcache;
byte *gammatable; // 256
byte *basepal; // 256 * 3
const byte *basepal; // 256 * 3
byte *palette; // 256 * 3
byte *colormap8; // 256 * VID_GRADES size
unsigned short *colormap16; // 256 * VID_GRADES size

View file

@ -12,7 +12,7 @@ extern unsigned short sw32_8to16table[256];
void VID_GetWindowSize (int def_w, int def_h);
void VID_InitGamma (unsigned char *);
void VID_InitGamma (const byte *);
qboolean VID_SetGamma (double);
void VID_UpdateGamma (struct cvar_s *);

View file

@ -47,7 +47,7 @@
VISIBLE tex_t *
LoadPCX (QFile *f, qboolean convert, byte *pal)
LoadPCX (QFile *f, qboolean convert, const byte *pal)
{
pcx_t *pcx;
int pcx_mark;
@ -141,12 +141,13 @@ LoadPCX (QFile *f, qboolean convert, byte *pal)
}
VISIBLE pcx_t *
EncodePCX (byte * data, int width, int height,
int rowbytes, byte * palette, qboolean flip, int *length)
EncodePCX (const byte *data, int width, int height,
int rowbytes, const byte *palette, qboolean flip, int *length)
{
int i, run, pix, size;
pcx_t *pcx;
byte *pack, *dataend;
int i, run, pix, size;
pcx_t *pcx;
byte *pack;
const byte *dataend;
size = width * height * 2 + 1000;
if (!(pcx = Hunk_TempAlloc (size))) {

View file

@ -132,7 +132,8 @@ build_skin_32 (tex_t *tex, int texnum, byte *translate,
unsigned i, j;
int samples = alpha ? gl_alpha_format : gl_solid_format;
unsigned frac, fracstep;
byte pixels[512 * 256 * 4], *out, *pal;
byte pixels[512 * 256 * 4], *out;
const byte *pal;
byte c;
out = pixels;

View file

@ -67,7 +67,7 @@ glsl_Skin_ProcessTranslation (int cmap, const byte *translation)
for (i = 0, dst = top; i < VID_GRADES; i++, src += 256 - 16) {
for (j = 0; j < 16; j++) {
byte c = *src++;
byte *in = vid.palette + c * 3;
const byte *in = vid.palette + c * 3;
*dst++ = *in++;
*dst++ = *in++;
*dst++ = *in++;
@ -78,7 +78,7 @@ glsl_Skin_ProcessTranslation (int cmap, const byte *translation)
for (i = 0, dst = bottom; i < VID_GRADES; i++, src += 256 - 16) {
for (j = 0; j < 16; j++) {
byte c = *src++;
byte *in = vid.palette + c * 3;
const byte *in = vid.palette + c * 3;
*dst++ = *in++;
*dst++ = *in++;
*dst++ = *in++;
@ -129,7 +129,7 @@ glsl_Skin_InitTranslations (void)
for (i = 0, dst = map, src = vid.colormap8; i < 256 * VID_GRADES; i++) {
byte c = *src++;
byte *in = vid.palette + c * 3;
const byte *in = vid.palette + c * 3;
*dst++ = *in++;
*dst++ = *in++;
*dst++ = *in++;

View file

@ -805,7 +805,8 @@ void
Draw_BlendScreen (quat_t color)
{
int r, g, b, i;
byte *basepal, *newpal;
const byte *basepal;
byte *newpal;
byte pal[768];
basepal = vid.basepal;
newpal = pal;

View file

@ -1275,7 +1275,8 @@ void
sw32_Draw_BlendScreen (quat_t color)
{
int r, g, b, i;
byte *basepal, *newpal;
const byte *basepal;
byte *newpal;
byte pal[768];
switch(sw32_r_pixbytes) {

View file

@ -230,7 +230,7 @@ VID_UpdateGamma (cvar_t *vid_gamma)
Initialize the vid_gamma Cvar, and set up the palette
*/
void
VID_InitGamma (unsigned char *pal)
VID_InitGamma (const byte *pal)
{
int i;
double gamma = 1.0;

View file

@ -104,7 +104,7 @@ load_image (const char *name)
switch (tex->format) {
case tex_palette:
for (i = 0, s = tex->data, d = image->data; i < pixels; i++) {
byte *v = tex->palette + *s++ * 3;
const byte *v = tex->palette + *s++ * 3;
*d++ = *v++;
*d++ = *v++;
*d++ = *v++;