summaryrefslogtreecommitdiff
path: root/include/egg/gfx/eggTextureBuffer.h
blob: f14ecaf8ee334b980b425959883b0e6e3e97a77a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef EGG_TEXTURE_BUFFER_H
#define EGG_TEXTURE_BUFFER_H

#include "egg/gfx/eggCapTexture.h"
#include "rvl/GX/GXTypes.h"

namespace EGG {

class TextureBuffer : public CapTexture {
public:
    enum EBufferState {
        STATE_FREE,
        STATE_ALLOCED
    };

    static void initialize(u32, Heap *);
    static TextureBuffer *getNotJoin();

    static void append(TextureBuffer *buf) {
        if (spTailNotJoin != NULL) {
            spTailNotJoin->mpNext = buf;
        }

        buf->mpPrev = spTailNotJoin;
        buf->mpNext = NULL;

        spTailNotJoin = buf;
    }

    TextureBuffer();
    virtual ~TextureBuffer() {} // at 0x8
    virtual void configure();   // at 0xC

    void alloc(u32 size);
    static TextureBuffer *alloc(u16 w, u16 h, GXTexFmt fmt);
    void free();
    static void setIncludesHeader(bool);

private:
    static bool includesHeader();

    u32 mSize;             // at 0x2C
    EBufferState mState;   // at 0x30
    TextureBuffer *mpNext; // at 0x34
    TextureBuffer *mpPrev; // at 0x38

    static const int NUM_BUFFERS = 128;
    static TextureBuffer *spHead;
    static TextureBuffer *spTailNotJoin;
    static char *spBufferAll;
    static u32 sBufferAllSize;
    static u32 sBufferSize;
    static u32 sBufferRestSizeMin;
    static bool sIncludesHeader;
    static TextureBuffer *spBufferTable[NUM_BUFFERS];
};

} // namespace EGG

#endif