1 //Copyright Paul Reiche, Fred Ford. 1992-2002 2 3 /* 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 #ifndef DRAWCMD_H 20 #define DRAWCMD_H 21 22 #include "libs/graphics/tfb_draw.h" 23 24 enum 25 { 26 TFB_DRAWCOMMANDTYPE_LINE, 27 TFB_DRAWCOMMANDTYPE_RECTANGLE, 28 TFB_DRAWCOMMANDTYPE_IMAGE, 29 TFB_DRAWCOMMANDTYPE_FILLEDIMAGE, 30 TFB_DRAWCOMMANDTYPE_FONTCHAR, 31 32 TFB_DRAWCOMMANDTYPE_COPY, 33 TFB_DRAWCOMMANDTYPE_COPYTOIMAGE, 34 35 TFB_DRAWCOMMANDTYPE_SCISSORENABLE, 36 TFB_DRAWCOMMANDTYPE_SCISSORDISABLE, 37 38 TFB_DRAWCOMMANDTYPE_SETMIPMAP, 39 TFB_DRAWCOMMANDTYPE_DELETEIMAGE, 40 TFB_DRAWCOMMANDTYPE_DELETEDATA, 41 TFB_DRAWCOMMANDTYPE_SENDSIGNAL, 42 TFB_DRAWCOMMANDTYPE_REINITVIDEO, 43 TFB_DRAWCOMMANDTYPE_CALLBACK, 44 }; 45 46 typedef struct tfb_dc_line 47 { 48 int x1, y1, x2, y2; 49 Color color; 50 DrawMode drawMode; 51 SCREEN destBuffer; 52 } TFB_DrawCommand_Line; 53 54 typedef struct tfb_dc_rect 55 { 56 RECT rect; 57 Color color; 58 DrawMode drawMode; 59 SCREEN destBuffer; 60 } TFB_DrawCommand_Rect; 61 62 typedef struct tfb_dc_img 63 { 64 TFB_Image *image; 65 int x, y; 66 SCREEN destBuffer; 67 TFB_ColorMap *colormap; 68 DrawMode drawMode; 69 int scale; 70 int scaleMode; 71 } TFB_DrawCommand_Image; 72 73 typedef struct tfb_dc_filledimg 74 { 75 TFB_Image *image; 76 int x, y; 77 Color color; 78 SCREEN destBuffer; 79 DrawMode drawMode; 80 int scale; 81 int scaleMode; 82 } TFB_DrawCommand_FilledImage; 83 84 typedef struct tfb_dc_fontchar 85 { 86 TFB_Char *fontchar; 87 TFB_Image *backing; 88 int x, y; 89 DrawMode drawMode; 90 SCREEN destBuffer; 91 } TFB_DrawCommand_FontChar; 92 93 typedef struct tfb_dc_copy 94 { 95 RECT rect; 96 SCREEN srcBuffer, destBuffer; 97 } TFB_DrawCommand_Copy; 98 99 typedef struct tfb_dc_copyimg 100 { 101 TFB_Image *image; 102 RECT rect; 103 SCREEN srcBuffer; 104 } TFB_DrawCommand_CopyToImage; 105 106 typedef struct tfb_dc_scissor 107 { 108 RECT rect; 109 } TFB_DrawCommand_Scissor; 110 111 typedef struct tfb_dc_setmip 112 { 113 TFB_Image *image; 114 TFB_Image *mipmap; 115 int hotx, hoty; 116 } TFB_DrawCommand_SetMipmap; 117 118 typedef struct tfb_dc_delimg 119 { 120 TFB_Image *image; 121 } TFB_DrawCommand_DeleteImage; 122 123 typedef struct tfb_dc_deldata 124 { 125 void *data; 126 // data must be a result of HXalloc() call 127 } TFB_DrawCommand_DeleteData; 128 129 typedef struct tfb_dc_signal 130 { 131 Semaphore sem; 132 } TFB_DrawCommand_SendSignal; 133 134 typedef struct tfb_dc_reinit_video 135 { 136 int driver, flags, width, height; 137 } TFB_DrawCommand_ReinitVideo; 138 139 typedef struct tfb_dc_callback 140 { 141 void (*callback)(void *arg); 142 void *arg; 143 } TFB_DrawCommand_Callback; 144 145 typedef struct tfb_drawcommand 146 { 147 int Type; 148 union { 149 TFB_DrawCommand_Line line; 150 TFB_DrawCommand_Rect rect; 151 TFB_DrawCommand_Image image; 152 TFB_DrawCommand_FilledImage filledimage; 153 TFB_DrawCommand_FontChar fontchar; 154 TFB_DrawCommand_Copy copy; 155 TFB_DrawCommand_CopyToImage copytoimage; 156 TFB_DrawCommand_Scissor scissor; 157 TFB_DrawCommand_SetMipmap setmipmap; 158 TFB_DrawCommand_DeleteImage deleteimage; 159 TFB_DrawCommand_DeleteData deletedata; 160 TFB_DrawCommand_SendSignal sendsignal; 161 TFB_DrawCommand_ReinitVideo reinitvideo; 162 TFB_DrawCommand_Callback callback; 163 } data; 164 } TFB_DrawCommand; 165 166 // Queue Stuff 167 168 typedef struct tfb_drawcommandqueue 169 { 170 int Front; 171 int Back; 172 int InsertionPoint; 173 int Batching; 174 volatile int FullSize; 175 volatile int Size; 176 } TFB_DrawCommandQueue; 177 178 void Init_DrawCommandQueue (void); 179 180 void Uninit_DrawCommandQueue (void); 181 182 void TFB_BatchGraphics (void); 183 184 void TFB_UnbatchGraphics (void); 185 186 void TFB_BatchReset (void); 187 188 void TFB_DrawCommandQueue_Push (TFB_DrawCommand* Command); 189 190 int TFB_DrawCommandQueue_Pop (TFB_DrawCommand* Command); 191 192 void TFB_DrawCommandQueue_Clear (void); 193 194 extern TFB_DrawCommandQueue DrawCommandQueue; 195 196 void TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand); 197 198 void Lock_DCQ (int slots); 199 200 void Unlock_DCQ (void); 201 202 #endif 203