X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=mupen64plus-pandora.git;a=blobdiff_plain;f=source%2Fgles2glide64%2Fsrc%2FGlideHQ%2Ftc-1.1%2B%2Ftexstore.c;h=3898df750fcc708f8ca71537872a3c680d3b6ac3;hp=2eb0306feb17018afad7714dc9eabd398fd18543;hb=2d26287291331f2b1793a8e76ede08c75654fb7c;hpb=01d8ca6fb06a8261602900cab63c61e5a1b143c9 diff --git a/source/gles2glide64/src/GlideHQ/tc-1.1+/texstore.c b/source/gles2glide64/src/GlideHQ/tc-1.1+/texstore.c index 2eb0306..3898df7 100644 --- a/source/gles2glide64/src/GlideHQ/tc-1.1+/texstore.c +++ b/source/gles2glide64/src/GlideHQ/tc-1.1+/texstore.c @@ -22,72 +22,73 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* Copyright (C) 2007 Hiroshi Morii - * _mesa_upscale_teximage2d speedup - */ - #include +#include +#include #include "types.h" #include "internal.h" +void reorder_source_3(byte *tex, dword width, dword height, int srcRowStride) +{ + byte *line; + byte t; + dword i, j; + + for (i = 0; i < height; i++) { + line = &tex[srcRowStride * i]; + for (j = 0; j < width; j++) { + t = line[2]; + line[2] = line[0]; + line[0] = t; + line += 3; + } + } +} -void -_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) +void *reorder_source_3_alloc(const byte *source, dword width, dword height, int srcRowStride) { - unsigned int i, j, k; + byte *tex; - assert(outWidth >= inWidth); - assert(outHeight >= inHeight); + tex = malloc(height * srcRowStride); + if (!tex) + goto out; -#if 1 /* H.Morii - faster loops */ - 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]; - } - } - } - 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]; - } - } - } -#else - for (i = 0; i < outHeight; i++) { - const int ii = i % inHeight; - for (j = 0; j < outWidth; j++) { - const int jj = j % inWidth; - const int aa = (i * outWidth + j) * comps; - const int bb = ii * srcRowStride + jj * comps; - for (k = 0; k < comps; k++) { - dest[aa + k] = src[bb + k]; - } - } + memcpy(tex, source, height * srcRowStride); + reorder_source_3(tex, width, height, srcRowStride); + +out: + return tex; +} + +void reorder_source_4(byte *tex, dword width, dword height, int srcRowStride) +{ + byte *line; + byte t; + dword i, j; + + for (i = 0; i < height; i++) { + line = &tex[srcRowStride * i]; + for (j = 0; j < width; j++) { + t = line[2]; + line[2] = line[0]; + line[0] = t; + line += 4; + } } -#endif +} + +void *reorder_source_4_alloc(const byte *source, dword width, dword height, int srcRowStride) +{ + byte *tex; + + tex = malloc(height * srcRowStride); + if (!tex) + goto out; + + memcpy(tex, source, height * srcRowStride); + reorder_source_4(tex, width, height, srcRowStride); + +out: + return tex; }