summaryrefslogtreecommitdiff
path: root/src/libs/graphics/drawcmd.h
blob: 6d44153ce53f392423434e7c967dea26c17fbe16 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
//Copyright Paul Reiche, Fred Ford. 1992-2002

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef DRAWCMD_H
#define DRAWCMD_H

#include "libs/graphics/tfb_draw.h"

enum
{
	TFB_DRAWCOMMANDTYPE_LINE,
	TFB_DRAWCOMMANDTYPE_RECTANGLE,
	TFB_DRAWCOMMANDTYPE_IMAGE,
	TFB_DRAWCOMMANDTYPE_FILLEDIMAGE,
	TFB_DRAWCOMMANDTYPE_FONTCHAR,

	TFB_DRAWCOMMANDTYPE_COPY,
	TFB_DRAWCOMMANDTYPE_COPYTOIMAGE,

	TFB_DRAWCOMMANDTYPE_SCISSORENABLE,
	TFB_DRAWCOMMANDTYPE_SCISSORDISABLE,

	TFB_DRAWCOMMANDTYPE_SETMIPMAP,
	TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
	TFB_DRAWCOMMANDTYPE_DELETEDATA,
	TFB_DRAWCOMMANDTYPE_SENDSIGNAL,
	TFB_DRAWCOMMANDTYPE_REINITVIDEO,
	TFB_DRAWCOMMANDTYPE_CALLBACK,
};

typedef struct tfb_dc_line
{
	int x1, y1, x2, y2;
	Color color;
	DrawMode drawMode;
	SCREEN destBuffer;
} TFB_DrawCommand_Line;

typedef struct tfb_dc_rect
{
	RECT rect;
	Color color;
	DrawMode drawMode;
	SCREEN destBuffer;
} TFB_DrawCommand_Rect;

typedef struct tfb_dc_img
{
	TFB_Image *image;
	int x, y;
	SCREEN destBuffer;
	TFB_ColorMap *colormap;
	DrawMode drawMode;
	int scale;
	int scaleMode;
} TFB_DrawCommand_Image;

typedef struct tfb_dc_filledimg
{
	TFB_Image *image;
	int x, y;
	Color color;
	SCREEN destBuffer;
	DrawMode drawMode;
	int scale;
	int scaleMode;
} TFB_DrawCommand_FilledImage;

typedef struct tfb_dc_fontchar
{
	TFB_Char *fontchar;
	TFB_Image *backing;
	int x, y;
	DrawMode drawMode;
	SCREEN destBuffer;
} TFB_DrawCommand_FontChar;

typedef struct tfb_dc_copy
{
	RECT rect;
	SCREEN srcBuffer, destBuffer;
} TFB_DrawCommand_Copy;

typedef struct tfb_dc_copyimg
{
	TFB_Image *image;
	RECT rect;
	SCREEN srcBuffer;
} TFB_DrawCommand_CopyToImage;

typedef struct tfb_dc_scissor
{
	RECT rect;
} TFB_DrawCommand_Scissor;

typedef struct tfb_dc_setmip
{
	TFB_Image *image;
	TFB_Image *mipmap;
	int hotx, hoty;
} TFB_DrawCommand_SetMipmap;

typedef struct tfb_dc_delimg
{
	TFB_Image *image;
} TFB_DrawCommand_DeleteImage;

typedef struct tfb_dc_deldata
{
	void *data;
		// data must be a result of HXalloc() call
} TFB_DrawCommand_DeleteData;

typedef struct tfb_dc_signal
{
	Semaphore sem;
} TFB_DrawCommand_SendSignal;

typedef struct tfb_dc_reinit_video
{
	int driver, flags, width, height;
} TFB_DrawCommand_ReinitVideo;

typedef struct tfb_dc_callback
{
	void (*callback)(void *arg);
	void *arg;
} TFB_DrawCommand_Callback;

typedef struct tfb_drawcommand
{
	int Type;
	union {
		TFB_DrawCommand_Line line;
		TFB_DrawCommand_Rect rect;
		TFB_DrawCommand_Image image;
		TFB_DrawCommand_FilledImage filledimage;
		TFB_DrawCommand_FontChar fontchar;
		TFB_DrawCommand_Copy copy;
		TFB_DrawCommand_CopyToImage copytoimage;
		TFB_DrawCommand_Scissor scissor;
		TFB_DrawCommand_SetMipmap setmipmap;
		TFB_DrawCommand_DeleteImage deleteimage;
		TFB_DrawCommand_DeleteData deletedata;
		TFB_DrawCommand_SendSignal sendsignal;
		TFB_DrawCommand_ReinitVideo reinitvideo;
		TFB_DrawCommand_Callback callback;
	} data;
} TFB_DrawCommand;

// Queue Stuff

typedef struct tfb_drawcommandqueue
{
	int Front;
	int Back;
	int InsertionPoint;
	int Batching;
	volatile int FullSize;
	volatile int Size;
} TFB_DrawCommandQueue;

void Init_DrawCommandQueue (void);

void Uninit_DrawCommandQueue (void);

void TFB_BatchGraphics (void);

void TFB_UnbatchGraphics (void);

void TFB_BatchReset (void);

void TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command);

int TFB_DrawCommandQueue_Pop (TFB_DrawCommand* Command);

void TFB_DrawCommandQueue_Clear (void);

extern TFB_DrawCommandQueue DrawCommandQueue;

void TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand);

void Lock_DCQ (int slots);

void Unlock_DCQ (void);

#endif