SDL  2.0
SDL_sysrender.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../SDL_internal.h"
22 
23 #ifndef SDL_sysrender_h_
24 #define SDL_sysrender_h_
25 
26 #include "SDL_render.h"
27 #include "SDL_events.h"
28 #include "SDL_mutex.h"
29 #include "SDL_yuv_sw_c.h"
30 
31 /* The SDL 2D rendering system */
32 
33 typedef struct SDL_RenderDriver SDL_RenderDriver;
34 
35 /* Define the SDL texture structure */
37 {
38  const void *magic;
39  Uint32 format; /**< The pixel format of the texture */
40  int access; /**< SDL_TextureAccess */
41  int w; /**< The width of the texture */
42  int h; /**< The height of the texture */
43  int modMode; /**< The texture modulation mode */
44  SDL_BlendMode blendMode; /**< The texture blend mode */
45  SDL_ScaleMode scaleMode; /**< The texture scale mode */
46  Uint8 r, g, b, a; /**< Texture modulation values */
47 
49 
50  /* Support for formats not supported directly by the renderer */
53  void *pixels;
54  int pitch;
56  SDL_Surface *locked_surface; /**< Locked region exposed as a SDL surface */
57 
58  Uint32 last_command_generation; /* last command queue generation this texture was in. */
59 
60  void *driverdata; /**< Driver specific texture representation */
61 
64 };
65 
66 typedef enum
67 {
79 
80 typedef struct SDL_RenderCommand
81 {
83  union {
84  struct {
85  size_t first;
88  struct {
90  SDL_Rect rect;
92  struct {
93  size_t first;
94  size_t count;
95  Uint8 r, g, b, a;
98  } draw;
99  struct {
100  size_t first;
101  Uint8 r, g, b, a;
102  } color;
103  } data;
106 
107 
108 /* Define the SDL renderer structure */
110 {
111  const void *magic;
112 
114  int (*GetOutputSize) (SDL_Renderer * renderer, int *w, int *h);
120  int count);
122  int count);
124  int count);
126  const SDL_Rect * srcrect, const SDL_FRect * dstrect);
128  const SDL_Rect * srcquad, const SDL_FRect * dstrect,
129  const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip);
130  int (*RunCommandQueue) (SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize);
132  const SDL_Rect * rect, const void *pixels,
133  int pitch);
135  const SDL_Rect * rect,
136  const Uint8 *Yplane, int Ypitch,
137  const Uint8 *Uplane, int Upitch,
138  const Uint8 *Vplane, int Vpitch);
140  const SDL_Rect * rect, void **pixels, int *pitch);
145  Uint32 format, void * pixels, int pitch);
148 
150 
151  int (*GL_BindTexture) (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, float *texh);
153 
154  void *(*GetMetalLayer) (SDL_Renderer * renderer);
155  void *(*GetMetalCommandEncoder) (SDL_Renderer * renderer);
156 
157  /* The current renderer info */
159 
160  /* The window associated with the renderer */
163 
164  /* The logical resolution for rendering */
169 
170  /* Whether or not to force the viewport to even integer intervals */
172 
173  /* The drawable area within the window */
176 
177  /* The clip rectangle within the window */
180 
181  /* Wether or not the clipping rectangle is used. */
184 
185  /* The render output coordinate scale */
188 
189  /* The pixel to point coordinate scale */
191 
192  /* Whether or not to scale relative mouse motion */
194 
195  /* Remainder from scaled relative motion */
196  float xrel;
197  float yrel;
198 
199  /* The list of textures */
203 
204  Uint8 r, g, b, a; /**< Color for drawing operations values */
205  SDL_BlendMode blendMode; /**< The drawing blend mode */
206 
220 
221  void *vertex_data;
224 
225  void *driverdata;
226 };
227 
228 /* Define the SDL render driver structure */
230 {
231  SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags);
232 
233  /* Info about the renderer capabilities */
235 };
236 
237 /* Not all of these are available in a given build. Use #ifdefs, etc. */
247 
248 /* Blend mode functions */
255 
256 /* drivers call this during their Queue*() methods to make space in a array that are used
257  for a vertex buffer during RunCommandQueue(). Pointers returned here are only valid until
258  the next call, because it might be in an array that gets realloc()'d. */
259 extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset);
260 
261 #endif /* SDL_sysrender_h_ */
262 
263 /* vi: set ts=4 sw=4 expandtab: */
SDL_BlendOperation
The blend operation used when combining source and destination pixel components.
Definition: SDL_blendmode.h:66
SDL_BlendFactor
The normalized factor used to multiply pixel components.
Definition: SDL_blendmode.h:79
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:41
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLintptr offset
GLfloat angle
GLbitfield flags
GLenum GLenum GLuint texture
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
Definition: SDL_render.h:122
SDL_ScaleMode
The scaling mode for a texture.
Definition: SDL_render.h:92
SDL_bool
Definition: SDL_stdinc.h:168
uint8_t Uint8
Definition: SDL_stdinc.h:185
uint32_t Uint32
Definition: SDL_stdinc.h:209
SDL_BlendFactor SDL_GetBlendModeDstColorFactor(SDL_BlendMode blendMode)
Definition: SDL_render.c:3393
SDL_RenderDriver PSP_RenderDriver
SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode)
Definition: SDL_render.c:3386
void * SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset)
Definition: SDL_render.c:262
SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor(SDL_BlendMode blendMode)
Definition: SDL_render.c:3414
SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor(SDL_BlendMode blendMode)
Definition: SDL_render.c:3407
SDL_RenderDriver METAL_RenderDriver
SDL_RenderDriver DirectFB_RenderDriver
SDL_RenderDriver GLES2_RenderDriver
SDL_RenderDriver GL_RenderDriver
SDL_RenderDriver SW_RenderDriver
SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode)
Definition: SDL_render.c:3421
SDL_BlendOperation SDL_GetBlendModeColorOperation(SDL_BlendMode blendMode)
Definition: SDL_render.c:3400
SDL_RenderDriver D3D_RenderDriver
SDL_RenderDriver GLES_RenderDriver
SDL_RenderDriver D3D11_RenderDriver
SDL_RenderCommandType
Definition: SDL_sysrender.h:67
@ SDL_RENDERCMD_SETCLIPRECT
Definition: SDL_sysrender.h:70
@ SDL_RENDERCMD_DRAW_LINES
Definition: SDL_sysrender.h:74
@ SDL_RENDERCMD_SETVIEWPORT
Definition: SDL_sysrender.h:69
@ SDL_RENDERCMD_DRAW_POINTS
Definition: SDL_sysrender.h:73
@ SDL_RENDERCMD_NO_OP
Definition: SDL_sysrender.h:68
@ SDL_RENDERCMD_FILL_RECTS
Definition: SDL_sysrender.h:75
@ SDL_RENDERCMD_COPY
Definition: SDL_sysrender.h:76
@ SDL_RENDERCMD_CLEAR
Definition: SDL_sysrender.h:72
@ SDL_RENDERCMD_SETDRAWCOLOR
Definition: SDL_sysrender.h:71
@ SDL_RENDERCMD_COPY_EX
Definition: SDL_sysrender.h:77
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
EGLSurface EGLint * rects
Definition: eglext.h:282
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst numbytes
The structure that defines a point (floating point)
Definition: SDL_rect.h:61
A rectangle, with the origin at the upper left (floating point).
Definition: SDL_rect.h:88
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:78
struct SDL_RenderCommand::@38::@42 color
struct SDL_RenderCommand * next
struct SDL_RenderCommand::@38::@39 viewport
struct SDL_RenderCommand::@38::@41 draw
SDL_BlendMode blend
Definition: SDL_sysrender.h:96
SDL_RenderCommandType command
Definition: SDL_sysrender.h:82
union SDL_RenderCommand::@38 data
SDL_Texture * texture
Definition: SDL_sysrender.h:97
struct SDL_RenderCommand::@38::@40 cliprect
SDL_RendererInfo info
int(* QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
SDL_Rect last_queued_viewport
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
SDL_bool clipping_enabled
SDL_Window * window
const void * magic
SDL_Rect clip_rect_backup
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(* QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
void(* SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
SDL_RenderCommand * render_commands
SDL_Texture * textures
SDL_bool cliprect_queued
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
SDL_bool always_batch
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
SDL_bool batching
void(* DestroyRenderer)(SDL_Renderer *renderer)
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
size_t vertex_data_allocation
SDL_RenderCommand * render_commands_tail
SDL_mutex * target_mutex
SDL_Rect clip_rect
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
SDL_bool integer_scale
SDL_bool(* SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode)
void * vertex_data
SDL_bool color_queued
void(* RenderPresent)(SDL_Renderer *renderer)
SDL_FPoint scale
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
SDL_RenderCommand * render_commands_pool
SDL_Rect viewport
int(* QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
SDL_bool hidden
int(* QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
int(* RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
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(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
SDL_bool viewport_queued
SDL_FPoint scale_backup
int(* QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
SDL_RendererInfo info
SDL_Rect last_queued_cliprect
Uint32 render_command_generation
void * driverdata
size_t vertex_data_used
int(* GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
SDL_bool last_queued_cliprect_enabled
Uint32 last_queued_color
SDL_Texture * target
SDL_FPoint dpi_scale
SDL_bool clipping_enabled_backup
SDL_Rect viewport_backup
SDL_bool relative_scaling
SDL_BlendMode blendMode
int(* QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
Information on the capabilities of a render driver or context.
Definition: SDL_render.h:79
A collection of pixels used in software blitting.
Definition: SDL_surface.h:71
SDL_Renderer * renderer
Definition: SDL_sysrender.h:48
SDL_Texture * prev
Definition: SDL_sysrender.h:62
Uint32 last_command_generation
Definition: SDL_sysrender.h:58
SDL_Rect locked_rect
Definition: SDL_sysrender.h:55
SDL_SW_YUVTexture * yuv
Definition: SDL_sysrender.h:52
SDL_Surface * locked_surface
Definition: SDL_sysrender.h:56
Uint32 format
Definition: SDL_sysrender.h:39
void * pixels
Definition: SDL_sysrender.h:53
SDL_Texture * next
Definition: SDL_sysrender.h:63
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:44
const void * magic
Definition: SDL_sysrender.h:38
void * driverdata
Definition: SDL_sysrender.h:60
SDL_Texture * native
Definition: SDL_sysrender.h:51
SDL_ScaleMode scaleMode
Definition: SDL_sysrender.h:45
Window state change event data (event.window.*)
Definition: SDL_events.h:202
The type used to identify a window.
Definition: SDL_sysvideo.h:75
static SDL_Renderer * renderer
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_Rect rect
Definition: testrelative.c:27
typedef int(__stdcall *FARPROC)()