ALL: Huge upstream synch + PerRom DelaySI & CountPerOp parameters
[mupen64plus-pandora.git] / source / gles2glide64 / src / GlideHQ / tc-1.1+ / texstore.c
CommitLineData
98e75f2d 1/*
2 * Mesa 3-D graphics library
3 * Version: 6.3
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
98e75f2d 25#include <assert.h>
2d262872 26#include <string.h>
27#include <stdlib.h>
98e75f2d 28
29#include "types.h"
30#include "internal.h"
31
2d262872 32void reorder_source_3(byte *tex, dword width, dword height, int srcRowStride)
33{
34 byte *line;
35 byte t;
36 dword i, j;
37
38 for (i = 0; i < height; i++) {
39 line = &tex[srcRowStride * i];
40 for (j = 0; j < width; j++) {
41 t = line[2];
42 line[2] = line[0];
43 line[0] = t;
44 line += 3;
45 }
46 }
47}
98e75f2d 48
2d262872 49void *reorder_source_3_alloc(const byte *source, dword width, dword height, int srcRowStride)
98e75f2d 50{
2d262872 51 byte *tex;
98e75f2d 52
2d262872 53 tex = malloc(height * srcRowStride);
54 if (!tex)
55 goto out;
98e75f2d 56
2d262872 57 memcpy(tex, source, height * srcRowStride);
58 reorder_source_3(tex, width, height, srcRowStride);
59
60out:
61 return tex;
62}
63
64void reorder_source_4(byte *tex, dword width, dword height, int srcRowStride)
65{
66 byte *line;
67 byte t;
68 dword i, j;
69
70 for (i = 0; i < height; i++) {
71 line = &tex[srcRowStride * i];
72 for (j = 0; j < width; j++) {
73 t = line[2];
74 line[2] = line[0];
75 line[0] = t;
76 line += 4;
77 }
98e75f2d 78 }
2d262872 79}
80
81void *reorder_source_4_alloc(const byte *source, dword width, dword height, int srcRowStride)
82{
83 byte *tex;
84
85 tex = malloc(height * srcRowStride);
86 if (!tex)
87 goto out;
88
89 memcpy(tex, source, height * srcRowStride);
90 reorder_source_4(tex, width, height, srcRowStride);
91
92out:
93 return tex;
98e75f2d 94}