Skip to content

Latest commit

 

History

History
270 lines (226 loc) · 9.61 KB

SDL_sysrender.h

File metadata and controls

270 lines (226 loc) · 9.61 KB
 
1
2
/*
Simple DirectMedia Layer
Jan 5, 2019
Jan 5, 2019
3
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
Nov 21, 2016
Nov 21, 2016
23
24
#ifndef SDL_sysrender_h_
#define SDL_sysrender_h_
25
26
27
#include "SDL_render.h"
#include "SDL_events.h"
Jun 18, 2018
Jun 18, 2018
28
#include "SDL_mutex.h"
29
30
31
32
33
34
#include "SDL_yuv_sw_c.h"
/* The SDL 2D rendering system */
typedef struct SDL_RenderDriver SDL_RenderDriver;
May 8, 2018
May 8, 2018
35
36
37
38
39
40
41
typedef enum
{
SDL_ScaleModeNearest,
SDL_ScaleModeLinear,
SDL_ScaleModeBest
} SDL_ScaleMode;
42
43
44
45
46
47
48
49
50
51
/* Define the SDL texture structure */
struct SDL_Texture
{
const void *magic;
Uint32 format; /**< The pixel format of the texture */
int access; /**< SDL_TextureAccess */
int w; /**< The width of the texture */
int h; /**< The height of the texture */
int modMode; /**< The texture modulation mode */
SDL_BlendMode blendMode; /**< The texture blend mode */
May 8, 2018
May 8, 2018
52
SDL_ScaleMode scaleMode; /**< The texture scale mode */
53
54
55
56
57
58
59
60
61
62
63
Uint8 r, g, b, a; /**< Texture modulation values */
SDL_Renderer *renderer;
/* Support for formats not supported directly by the renderer */
SDL_Texture *native;
SDL_SW_YUVTexture *yuv;
void *pixels;
int pitch;
SDL_Rect locked_rect;
Sep 20, 2018
Sep 20, 2018
64
65
Uint32 last_command_generation; /* last command queue generation this texture was in. */
66
67
68
69
70
71
void *driverdata; /**< Driver specific texture representation */
SDL_Texture *prev;
SDL_Texture *next;
};
Sep 20, 2018
Sep 20, 2018
72
73
74
75
76
typedef enum
{
SDL_RENDERCMD_NO_OP,
SDL_RENDERCMD_SETVIEWPORT,
SDL_RENDERCMD_SETCLIPRECT,
Sep 24, 2018
Sep 24, 2018
77
SDL_RENDERCMD_SETDRAWCOLOR,
Sep 20, 2018
Sep 20, 2018
78
79
80
81
82
83
84
85
86
87
88
89
SDL_RENDERCMD_CLEAR,
SDL_RENDERCMD_DRAW_POINTS,
SDL_RENDERCMD_DRAW_LINES,
SDL_RENDERCMD_FILL_RECTS,
SDL_RENDERCMD_COPY,
SDL_RENDERCMD_COPY_EX
} SDL_RenderCommandType;
typedef struct SDL_RenderCommand
{
SDL_RenderCommandType command;
union {
Sep 24, 2018
Sep 24, 2018
90
91
92
93
struct {
size_t first;
SDL_Rect rect;
} viewport;
Sep 20, 2018
Sep 20, 2018
94
95
96
97
98
99
100
101
102
103
104
105
struct {
SDL_bool enabled;
SDL_Rect rect;
} cliprect;
struct {
size_t first;
size_t count;
Uint8 r, g, b, a;
SDL_BlendMode blend;
SDL_Texture *texture;
} draw;
struct {
Sep 24, 2018
Sep 24, 2018
106
size_t first;
Sep 20, 2018
Sep 20, 2018
107
108
109
110
111
112
Uint8 r, g, b, a;
} color;
} data;
struct SDL_RenderCommand *next;
} SDL_RenderCommand;
Sep 24, 2018
Sep 24, 2018
113
114
115
116
117
118
119
typedef struct SDL_AllocVertGap
{
size_t offset;
size_t len;
struct SDL_AllocVertGap *next;
} SDL_AllocVertGap;
Sep 20, 2018
Sep 20, 2018
120
121
122
123
124
125
126
127
/* Define the SDL renderer structure */
struct SDL_Renderer
{
const void *magic;
void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event);
int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
Aug 14, 2017
Aug 14, 2017
128
SDL_bool (*SupportsBlendMode)(SDL_Renderer * renderer, SDL_BlendMode blendMode);
129
int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
Sep 24, 2018
Sep 24, 2018
130
131
int (*QueueSetViewport) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
int (*QueueSetDrawColor) (SDL_Renderer * renderer, SDL_RenderCommand *cmd);
Sep 20, 2018
Sep 20, 2018
132
133
134
135
136
137
138
139
140
141
142
143
int (*QueueDrawPoints) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
int count);
int (*QueueDrawLines) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points,
int count);
int (*QueueFillRects) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects,
int count);
int (*QueueCopy) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_FRect * dstrect);
int (*QueueCopyEx) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture,
const SDL_Rect * srcquad, const SDL_FRect * dstrect,
const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
int (*RunCommandQueue) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels,
int pitch);
int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect,
const Uint8 *Yplane, int Ypitch,
const Uint8 *Uplane, int Upitch,
const Uint8 *Vplane, int Vpitch);
int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, void **pixels, int *pitch);
void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
int (*SetRenderTarget) (SDL_Renderer * renderer, SDL_Texture * texture);
int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
Uint32 format, void * pixels, int pitch);
void (*RenderPresent) (SDL_Renderer * renderer);
void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
void (*DestroyRenderer) (SDL_Renderer * renderer);
int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
int (*GL_UnbindTexture) (SDL_Renderer * renderer, SDL_Texture *texture);
Dec 8, 2017
Dec 8, 2017
166
167
168
void *(*GetMetalLayer) (SDL_Renderer * renderer);
void *(*GetMetalCommandEncoder) (SDL_Renderer * renderer);
169
170
171
172
173
174
175
176
177
178
179
180
181
/* The current renderer info */
SDL_RendererInfo info;
/* The window associated with the renderer */
SDL_Window *window;
SDL_bool hidden;
/* The logical resolution for rendering */
int logical_w;
int logical_h;
int logical_w_backup;
int logical_h_backup;
Jan 5, 2016
Jan 5, 2016
182
183
184
/* Whether or not to force the viewport to even integer intervals */
SDL_bool integer_scale;
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/* The drawable area within the window */
SDL_Rect viewport;
SDL_Rect viewport_backup;
/* The clip rectangle within the window */
SDL_Rect clip_rect;
SDL_Rect clip_rect_backup;
/* Wether or not the clipping rectangle is used. */
SDL_bool clipping_enabled;
SDL_bool clipping_enabled_backup;
/* The render output coordinate scale */
SDL_FPoint scale;
SDL_FPoint scale_backup;
Aug 2, 2017
Aug 2, 2017
201
202
203
/* The pixel to point coordinate scale */
SDL_FPoint dpi_scale;
204
205
206
/* The list of textures */
SDL_Texture *textures;
SDL_Texture *target;
Jun 18, 2018
Jun 18, 2018
207
SDL_mutex *target_mutex;
208
209
210
211
Uint8 r, g, b, a; /**< Color for drawing operations values */
SDL_BlendMode blendMode; /**< The drawing blend mode */
Sep 24, 2018
Sep 24, 2018
212
SDL_bool always_batch;
Sep 20, 2018
Sep 20, 2018
213
214
215
216
217
SDL_bool batching;
SDL_RenderCommand *render_commands;
SDL_RenderCommand *render_commands_tail;
SDL_RenderCommand *render_commands_pool;
Uint32 render_command_generation;
Sep 24, 2018
Sep 24, 2018
218
219
220
221
222
223
224
Uint32 last_queued_color;
SDL_Rect last_queued_viewport;
SDL_Rect last_queued_cliprect;
SDL_bool last_queued_cliprect_enabled;
SDL_bool color_queued;
SDL_bool viewport_queued;
SDL_bool cliprect_queued;
Sep 20, 2018
Sep 20, 2018
225
226
227
228
void *vertex_data;
size_t vertex_data_used;
size_t vertex_data_allocation;
Sep 24, 2018
Sep 24, 2018
229
230
SDL_AllocVertGap vertex_data_gaps;
SDL_AllocVertGap *vertex_data_gaps_pool;
Sep 20, 2018
Sep 20, 2018
231
232
233
234
235
236
237
238
239
240
241
242
243
void *driverdata;
};
/* Define the SDL render driver structure */
struct SDL_RenderDriver
{
SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
/* Info about the renderer capabilities */
SDL_RendererInfo info;
};
Feb 26, 2017
Feb 26, 2017
244
/* Not all of these are available in a given build. Use #ifdefs, etc. */
245
246
247
248
249
250
extern SDL_RenderDriver D3D_RenderDriver;
extern SDL_RenderDriver D3D11_RenderDriver;
extern SDL_RenderDriver GL_RenderDriver;
extern SDL_RenderDriver GLES2_RenderDriver;
extern SDL_RenderDriver GLES_RenderDriver;
extern SDL_RenderDriver DirectFB_RenderDriver;
Apr 21, 2016
Apr 21, 2016
251
extern SDL_RenderDriver METAL_RenderDriver;
252
253
254
extern SDL_RenderDriver PSP_RenderDriver;
extern SDL_RenderDriver SW_RenderDriver;
Aug 14, 2017
Aug 14, 2017
255
256
257
258
259
260
261
262
/* Blend mode functions */
extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode);
extern SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode);
extern SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode);
extern SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode);
extern SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode);
extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode);
Sep 20, 2018
Sep 20, 2018
263
264
265
/* drivers call this during their Queue*() methods to make space in a array that are used
for a vertex buffer during RunCommandQueue(). Pointers returned here are only valid until
the next call, because it might be in an array that gets realloc()'d. */
Sep 24, 2018
Sep 24, 2018
266
extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
Sep 20, 2018
Sep 20, 2018
267
Nov 21, 2016
Nov 21, 2016
268
#endif /* SDL_sysrender_h_ */
269
270
/* vi: set ts=4 sw=4 expandtab: */