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

78 lines
2.9 KiB
C
Raw Normal View History

2017-04-26 10:23:36 +00:00
/***************************************************************************
* *
* Project64-video - A Nintendo 64 gfx plugin. *
* http://www.pj64-emu.com/ *
* Copyright (C) 2017 Project64. All rights reserved. *
* Copyright (C) 2007 Hiroshi Morii *
* Copyright (C) 2004 Daniel Borca *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* version 2 of the License, or (at your option) any later version. *
* *
****************************************************************************/
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
2017-04-26 10:23:36 +00:00
}