project64/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c

72 lines
2.2 KiB
C
Raw Normal View History

2021-03-02 02:13:17 +00:00
// Project64 - A Nintendo 64 emulator
// https://www.pj64-emu.com/
2021-03-02 02:13:17 +00:00
// Copyright(C) 2001-2021 Project64
// Copyright(C) 2007 Hiroshi Morii
// Copyright(C) 2004 Daniel Borca
// GNU/GPLv2 licensed: https://gnu.org/licenses/gpl-2.0.html
2013-04-17 10:30:38 +00:00
#include <assert.h>
#include "types.h"
#include "internal.h"
void
2017-04-26 10:23:36 +00:00
_mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight,
unsigned int outWidth, unsigned int outHeight,
unsigned int comps,
const byte *src, int srcRowStride,
byte *dest)
2013-04-17 10:30:38 +00:00
{
unsigned int i, j, k;
assert(outWidth >= inWidth);
assert(outHeight >= inHeight);
#if 1 /* H.Morii - faster loops */
2017-04-26 10:23:36 +00:00
for (i = 0; i < inHeight; i++) {
for (j = 0; j < inWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = i * srcRowStride + j * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
for (; j < outWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = i * srcRowStride + (j - inWidth) * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
2013-04-17 10:30:38 +00:00
}
2017-04-26 10:23:36 +00:00
for (; i < outHeight; i++) {
for (j = 0; j < inWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = (i - inHeight) * srcRowStride + j * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
for (; j < outWidth; j++) {
const int aa = (i * outWidth + j) * comps;
const int bb = (i - inHeight) * srcRowStride + (j - inWidth) * comps;
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
2013-04-17 10:30:38 +00:00
}
#else
for (i = 0; i < outHeight; i++) {
2017-04-26 10:23:36 +00:00
const int ii = i % inHeight;
for (j = 0; j < outWidth; j++) {
const int jj = j % inWidth;
2013-04-17 10:30:38 +00:00
const int aa = (i * outWidth + j) * comps;
const int bb = ii * srcRowStride + jj * comps;
2017-04-26 10:23:36 +00:00
for (k = 0; k < comps; k++) {
dest[aa + k] = src[bb + k];
}
}
2013-04-17 10:30:38 +00:00
}
#endif
}