SDL  2.0
SDL_render.c File Reference
#include "../SDL_internal.h"
#include "SDL_assert.h"
#include "SDL_hints.h"
#include "SDL_log.h"
#include "SDL_render.h"
#include "SDL_sysrender.h"
#include "software/SDL_render_sw_c.h"
+ Include dependency graph for SDL_render.c:

Go to the source code of this file.

Macros

#define SDL_WINDOWRENDERDATA   "_SDL_WindowRenderData"
 
#define CHECK_RENDERER_MAGIC(renderer, retval)
 
#define CHECK_TEXTURE_MAGIC(texture, retval)
 
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
 
#define SDL_BLENDMODE_NONE_FULL
 
#define SDL_BLENDMODE_BLEND_FULL
 
#define SDL_BLENDMODE_ADD_FULL
 
#define SDL_BLENDMODE_MOD_FULL
 
#define SDL_BLENDMODE_MUL_FULL
 

Functions

static SDL_INLINE void DebugLogRenderCommands (const SDL_RenderCommand *cmd)
 
static int FlushRenderCommands (SDL_Renderer *renderer)
 
static int FlushRenderCommandsIfTextureNeeded (SDL_Texture *texture)
 
static SDL_INLINE int FlushRenderCommandsIfNotBatching (SDL_Renderer *renderer)
 
int SDL_RenderFlush (SDL_Renderer *renderer)
 Force the rendering context to flush any pending commands to the underlying rendering API. More...
 
voidSDL_AllocateRenderVertices (SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset)
 
static SDL_RenderCommandAllocateRenderCommand (SDL_Renderer *renderer)
 
static int QueueCmdSetViewport (SDL_Renderer *renderer)
 
static int QueueCmdSetClipRect (SDL_Renderer *renderer)
 
static int QueueCmdSetDrawColor (SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
 
static int QueueCmdClear (SDL_Renderer *renderer)
 
static int PrepQueueCmdDraw (SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
 
static SDL_RenderCommandPrepQueueCmdDrawSolid (SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype)
 
static int QueueCmdDrawPoints (SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
 
static int QueueCmdDrawLines (SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
 
static int QueueCmdFillRects (SDL_Renderer *renderer, const SDL_FRect *rects, const int count)
 
static SDL_RenderCommandPrepQueueCmdDrawTexture (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_RenderCommandType cmdtype)
 
static int QueueCmdCopy (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
 
static int QueueCmdCopyEx (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcquad, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
 
static int UpdateLogicalSize (SDL_Renderer *renderer)
 
int SDL_GetNumRenderDrivers (void)
 Get the number of 2D rendering drivers available for the current display. More...
 
int SDL_GetRenderDriverInfo (int index, SDL_RendererInfo *info)
 Get information about a specific 2D rendering driver for the current display. More...
 
static void GetWindowViewportValues (SDL_Renderer *renderer, int *logical_w, int *logical_h, SDL_Rect *viewport, SDL_FPoint *scale)
 
static int SDL_RendererEventWatch (void *userdata, SDL_Event *event)
 
int SDL_CreateWindowAndRenderer (int width, int height, Uint32 window_flags, SDL_Window **window, SDL_Renderer **renderer)
 Create a window and default renderer. More...
 
static SDL_INLINE void VerifyDrawQueueFunctions (const SDL_Renderer *renderer)
 
SDL_RendererSDL_CreateRenderer (SDL_Window *window, int index, Uint32 flags)
 Create a 2D rendering context for a window. More...
 
SDL_RendererSDL_CreateSoftwareRenderer (SDL_Surface *surface)
 Create a 2D software rendering context for a surface. More...
 
SDL_RendererSDL_GetRenderer (SDL_Window *window)
 Get the renderer associated with a window. More...
 
int SDL_GetRendererInfo (SDL_Renderer *renderer, SDL_RendererInfo *info)
 Get information about a rendering context. More...
 
int SDL_GetRendererOutputSize (SDL_Renderer *renderer, int *w, int *h)
 Get the output size in pixels of a rendering context. More...
 
static SDL_bool IsSupportedBlendMode (SDL_Renderer *renderer, SDL_BlendMode blendMode)
 
static SDL_bool IsSupportedFormat (SDL_Renderer *renderer, Uint32 format)
 
static Uint32 GetClosestSupportedFormat (SDL_Renderer *renderer, Uint32 format)
 
static SDL_ScaleMode SDL_GetScaleMode (void)
 
SDL_TextureSDL_CreateTexture (SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
 Create a texture for a rendering context. More...
 
SDL_TextureSDL_CreateTextureFromSurface (SDL_Renderer *renderer, SDL_Surface *surface)
 Create a texture from an existing surface. More...
 
int SDL_QueryTexture (SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h)
 Query the attributes of a texture. More...
 
int SDL_SetTextureColorMod (SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
 Set an additional color value used in render copy operations. More...
 
int SDL_GetTextureColorMod (SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b)
 Get the additional color value used in render copy operations. More...
 
int SDL_SetTextureAlphaMod (SDL_Texture *texture, Uint8 alpha)
 Set an additional alpha value used in render copy operations. More...
 
int SDL_GetTextureAlphaMod (SDL_Texture *texture, Uint8 *alpha)
 Get the additional alpha value used in render copy operations. More...
 
int SDL_SetTextureBlendMode (SDL_Texture *texture, SDL_BlendMode blendMode)
 Set the blend mode used for texture copy operations. More...
 
int SDL_GetTextureBlendMode (SDL_Texture *texture, SDL_BlendMode *blendMode)
 Get the blend mode used for texture copy operations. More...
 
int SDL_SetTextureScaleMode (SDL_Texture *texture, SDL_ScaleMode scaleMode)
 Set the scale mode used for texture scale operations. More...
 
int SDL_GetTextureScaleMode (SDL_Texture *texture, SDL_ScaleMode *scaleMode)
 Get the scale mode used for texture scale operations. More...
 
static int SDL_UpdateTextureYUV (SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
 
static int SDL_UpdateTextureNative (SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
 
int SDL_UpdateTexture (SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
 Update the given texture rectangle with new pixel data. More...
 
static int SDL_UpdateTextureYUVPlanar (SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
 
int SDL_UpdateYUVTexture (SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
 Update a rectangle within a planar YV12 or IYUV texture with new pixel data. More...
 
static int SDL_LockTextureYUV (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
 
static int SDL_LockTextureNative (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
 
int SDL_LockTexture (SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
 Lock a portion of the texture for write-only pixel access. More...
 
int SDL_LockTextureToSurface (SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface)
 Lock a portion of the texture for write-only pixel access. Expose it as a SDL surface. More...
 
static void SDL_UnlockTextureYUV (SDL_Texture *texture)
 
static void SDL_UnlockTextureNative (SDL_Texture *texture)
 
void SDL_UnlockTexture (SDL_Texture *texture)
 Unlock a texture, uploading the changes to video memory, if needed. If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed. More...
 
SDL_bool SDL_RenderTargetSupported (SDL_Renderer *renderer)
 Determines whether a window supports the use of render targets. More...
 
int SDL_SetRenderTarget (SDL_Renderer *renderer, SDL_Texture *texture)
 Set a texture as the current rendering target. More...
 
SDL_TextureSDL_GetRenderTarget (SDL_Renderer *renderer)
 Get the current render target or NULL for the default render target. More...
 
int SDL_RenderSetLogicalSize (SDL_Renderer *renderer, int w, int h)
 Set device independent resolution for rendering. More...
 
void SDL_RenderGetLogicalSize (SDL_Renderer *renderer, int *w, int *h)
 Get device independent resolution for rendering. More...
 
int SDL_RenderSetIntegerScale (SDL_Renderer *renderer, SDL_bool enable)
 Set whether to force integer scales for resolution-independent rendering. More...
 
SDL_bool SDL_RenderGetIntegerScale (SDL_Renderer *renderer)
 Get whether integer scales are forced for resolution-independent rendering. More...
 
int SDL_RenderSetViewport (SDL_Renderer *renderer, const SDL_Rect *rect)
 Set the drawing area for rendering on the current target. More...
 
void SDL_RenderGetViewport (SDL_Renderer *renderer, SDL_Rect *rect)
 Get the drawing area for the current target. More...
 
int SDL_RenderSetClipRect (SDL_Renderer *renderer, const SDL_Rect *rect)
 Set the clip rectangle for the current target. More...
 
void SDL_RenderGetClipRect (SDL_Renderer *renderer, SDL_Rect *rect)
 Get the clip rectangle for the current target. More...
 
SDL_bool SDL_RenderIsClipEnabled (SDL_Renderer *renderer)
 Get whether clipping is enabled on the given renderer. More...
 
int SDL_RenderSetScale (SDL_Renderer *renderer, float scaleX, float scaleY)
 Set the drawing scale for rendering on the current target. More...
 
void SDL_RenderGetScale (SDL_Renderer *renderer, float *scaleX, float *scaleY)
 Get the drawing scale for the current target. More...
 
int SDL_SetRenderDrawColor (SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
 Set the color used for drawing operations (Rect, Line and Clear). More...
 
int SDL_GetRenderDrawColor (SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
 Get the color used for drawing operations (Rect, Line and Clear). More...
 
int SDL_SetRenderDrawBlendMode (SDL_Renderer *renderer, SDL_BlendMode blendMode)
 Set the blend mode used for drawing operations (Fill and Line). More...
 
int SDL_GetRenderDrawBlendMode (SDL_Renderer *renderer, SDL_BlendMode *blendMode)
 Get the blend mode used for drawing operations. More...
 
int SDL_RenderClear (SDL_Renderer *renderer)
 Clear the current rendering target with the drawing color. More...
 
int SDL_RenderDrawPoint (SDL_Renderer *renderer, int x, int y)
 Draw a point on the current rendering target. More...
 
int SDL_RenderDrawPointF (SDL_Renderer *renderer, float x, float y)
 Draw a point on the current rendering target. More...
 
static int RenderDrawPointsWithRects (SDL_Renderer *renderer, const SDL_Point *points, const int count)
 
int SDL_RenderDrawPoints (SDL_Renderer *renderer, const SDL_Point *points, int count)
 Draw multiple points on the current rendering target. More...
 
static int RenderDrawPointsWithRectsF (SDL_Renderer *renderer, const SDL_FPoint *fpoints, const int count)
 
int SDL_RenderDrawPointsF (SDL_Renderer *renderer, const SDL_FPoint *points, int count)
 Draw multiple points on the current rendering target. More...
 
int SDL_RenderDrawLine (SDL_Renderer *renderer, int x1, int y1, int x2, int y2)
 Draw a line on the current rendering target. More...
 
int SDL_RenderDrawLineF (SDL_Renderer *renderer, float x1, float y1, float x2, float y2)
 Draw a line on the current rendering target. More...
 
static int RenderDrawLinesWithRects (SDL_Renderer *renderer, const SDL_Point *points, const int count)
 
static int RenderDrawLinesWithRectsF (SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
 
int SDL_RenderDrawLines (SDL_Renderer *renderer, const SDL_Point *points, int count)
 Draw a series of connected lines on the current rendering target. More...
 
int SDL_RenderDrawLinesF (SDL_Renderer *renderer, const SDL_FPoint *points, int count)
 Draw a series of connected lines on the current rendering target. More...
 
int SDL_RenderDrawRect (SDL_Renderer *renderer, const SDL_Rect *rect)
 Draw a rectangle on the current rendering target. More...
 
int SDL_RenderDrawRectF (SDL_Renderer *renderer, const SDL_FRect *rect)
 Draw a rectangle on the current rendering target. More...
 
int SDL_RenderDrawRects (SDL_Renderer *renderer, const SDL_Rect *rects, int count)
 Draw some number of rectangles on the current rendering target. More...
 
int SDL_RenderDrawRectsF (SDL_Renderer *renderer, const SDL_FRect *rects, int count)
 Draw some number of rectangles on the current rendering target. More...
 
int SDL_RenderFillRect (SDL_Renderer *renderer, const SDL_Rect *rect)
 Fill a rectangle on the current rendering target with the drawing color. More...
 
int SDL_RenderFillRectF (SDL_Renderer *renderer, const SDL_FRect *rect)
 Fill a rectangle on the current rendering target with the drawing color. More...
 
int SDL_RenderFillRects (SDL_Renderer *renderer, const SDL_Rect *rects, int count)
 Fill some number of rectangles on the current rendering target with the drawing color. More...
 
int SDL_RenderFillRectsF (SDL_Renderer *renderer, const SDL_FRect *rects, int count)
 Fill some number of rectangles on the current rendering target with the drawing color. More...
 
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty (const SDL_FRect *r)
 
static SDL_bool SDL_HasIntersectionF (const SDL_FRect *A, const SDL_FRect *B)
 
int SDL_RenderCopy (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
 Copy a portion of the texture to the current rendering target. More...
 
int SDL_RenderCopyF (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
 Copy a portion of the texture to the current rendering target. More...
 
int SDL_RenderCopyEx (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_Rect *dstrect, const double angle, const SDL_Point *center, const SDL_RendererFlip flip)
 Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center. More...
 
int SDL_RenderCopyExF (SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
 Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center. More...
 
int SDL_RenderReadPixels (SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
 Read pixels from the current rendering target. More...
 
void SDL_RenderPresent (SDL_Renderer *renderer)
 Update the screen with rendering performed. More...
 
void SDL_DestroyTexture (SDL_Texture *texture)
 Destroy the specified texture. More...
 
void SDL_DestroyRenderer (SDL_Renderer *renderer)
 Destroy the rendering context for a window and free associated textures. More...
 
int SDL_GL_BindTexture (SDL_Texture *texture, float *texw, float *texh)
 Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions. More...
 
int SDL_GL_UnbindTexture (SDL_Texture *texture)
 Unbind a texture from the current OpenGL/ES/ES2 context. More...
 
voidSDL_RenderGetMetalLayer (SDL_Renderer *renderer)
 Get the CAMetalLayer associated with the given Metal renderer. More...
 
voidSDL_RenderGetMetalCommandEncoder (SDL_Renderer *renderer)
 Get the Metal command encoder for the current frame. More...
 
static SDL_BlendMode SDL_GetShortBlendMode (SDL_BlendMode blendMode)
 
static SDL_BlendMode SDL_GetLongBlendMode (SDL_BlendMode blendMode)
 
SDL_BlendMode SDL_ComposeCustomBlendMode (SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, SDL_BlendOperation colorOperation, SDL_BlendFactor srcAlphaFactor, SDL_BlendFactor dstAlphaFactor, SDL_BlendOperation alphaOperation)
 Create a custom blend mode, which may or may not be supported by a given renderer. More...
 
SDL_BlendFactor SDL_GetBlendModeSrcColorFactor (SDL_BlendMode blendMode)
 
SDL_BlendFactor SDL_GetBlendModeDstColorFactor (SDL_BlendMode blendMode)
 
SDL_BlendOperation SDL_GetBlendModeColorOperation (SDL_BlendMode blendMode)
 
SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor (SDL_BlendMode blendMode)
 
SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor (SDL_BlendMode blendMode)
 
SDL_BlendOperation SDL_GetBlendModeAlphaOperation (SDL_BlendMode blendMode)
 

Variables

static const SDL_RenderDriverrender_drivers []
 
static char renderer_magic
 
static char texture_magic
 

Macro Definition Documentation

◆ CHECK_RENDERER_MAGIC

#define CHECK_RENDERER_MAGIC (   renderer,
  retval 
)
Value:
SDL_SetError("Invalid renderer"); \
return retval; \
}

Definition at line 38 of file SDL_render.c.

◆ CHECK_TEXTURE_MAGIC

#define CHECK_TEXTURE_MAGIC (   texture,
  retval 
)
Value:
if (!texture || texture->magic != &texture_magic) { \
SDL_SetError("Invalid texture"); \
return retval; \
}

Definition at line 45 of file SDL_render.c.

◆ SDL_BLENDMODE_ADD_FULL

◆ SDL_BLENDMODE_BLEND_FULL

◆ SDL_BLENDMODE_MOD_FULL

◆ SDL_BLENDMODE_MUL_FULL

◆ SDL_BLENDMODE_NONE_FULL

◆ SDL_COMPOSE_BLENDMODE

#define SDL_COMPOSE_BLENDMODE (   srcColorFactor,
  dstColorFactor,
  colorOperation,
  srcAlphaFactor,
  dstAlphaFactor,
  alphaOperation 
)
Value:
(SDL_BlendMode)(((Uint32)colorOperation << 0) | \
((Uint32)srcColorFactor << 4) | \
((Uint32)dstColorFactor << 8) | \
((Uint32)alphaOperation << 16) | \
((Uint32)srcAlphaFactor << 20) | \
((Uint32)dstAlphaFactor << 24))

Definition at line 53 of file SDL_render.c.

◆ SDL_WINDOWRENDERDATA

#define SDL_WINDOWRENDERDATA   "_SDL_WindowRenderData"

Definition at line 36 of file SDL_render.c.

Function Documentation

◆ AllocateRenderCommand()

static SDL_RenderCommand* AllocateRenderCommand ( SDL_Renderer renderer)
static

Definition at line 297 of file SDL_render.c.

298 {
300 
301  /* !!! FIXME: are there threading limitations in SDL's render API? If not, we need to mutex this. */
303  if (retval != NULL) {
305  retval->next = NULL;
306  } else {
307  retval = SDL_calloc(1, sizeof (*retval));
308  if (!retval) {
309  SDL_OutOfMemory();
310  return NULL;
311  }
312  }
313 
317  } else {
319  }
321 
322  return retval;
323 }

References SDL_RenderCommand::next, NULL, SDL_Renderer::render_commands, SDL_Renderer::render_commands_pool, SDL_Renderer::render_commands_tail, renderer, retval, SDL_assert, SDL_calloc, and SDL_OutOfMemory.

Referenced by PrepQueueCmdDrawSolid(), PrepQueueCmdDrawTexture(), QueueCmdClear(), QueueCmdSetClipRect(), QueueCmdSetDrawColor(), and QueueCmdSetViewport().

◆ DebugLogRenderCommands()

static SDL_INLINE void DebugLogRenderCommands ( const SDL_RenderCommand cmd)
static

Definition at line 118 of file SDL_render.c.

119 {
120 #if 0
121  unsigned int i = 1;
122  SDL_Log("Render commands to flush:");
123  while (cmd) {
124  switch (cmd->command) {
125  case SDL_RENDERCMD_NO_OP:
126  SDL_Log(" %u. no-op", i++);
127  break;
128 
130  SDL_Log(" %u. set viewport (first=%u, rect={(%d, %d), %dx%d})", i++,
131  (unsigned int) cmd->data.viewport.first,
132  cmd->data.viewport.rect.x, cmd->data.viewport.rect.y,
133  cmd->data.viewport.rect.w, cmd->data.viewport.rect.h);
134  break;
135 
137  SDL_Log(" %u. set cliprect (enabled=%s, rect={(%d, %d), %dx%d})", i++,
138  cmd->data.cliprect.enabled ? "true" : "false",
139  cmd->data.cliprect.rect.x, cmd->data.cliprect.rect.y,
140  cmd->data.cliprect.rect.w, cmd->data.cliprect.rect.h);
141  break;
142 
144  SDL_Log(" %u. set draw color (first=%u, r=%d, g=%d, b=%d, a=%d)", i++,
145  (unsigned int) cmd->data.color.first,
146  (int) cmd->data.color.r, (int) cmd->data.color.g,
147  (int) cmd->data.color.b, (int) cmd->data.color.a);
148  break;
149 
150  case SDL_RENDERCMD_CLEAR:
151  SDL_Log(" %u. clear (first=%u, r=%d, g=%d, b=%d, a=%d)", i++,
152  (unsigned int) cmd->data.color.first,
153  (int) cmd->data.color.r, (int) cmd->data.color.g,
154  (int) cmd->data.color.b, (int) cmd->data.color.a);
155  break;
156 
158  SDL_Log(" %u. draw points (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d)", i++,
159  (unsigned int) cmd->data.draw.first,
160  (unsigned int) cmd->data.draw.count,
161  (int) cmd->data.draw.r, (int) cmd->data.draw.g,
162  (int) cmd->data.draw.b, (int) cmd->data.draw.a,
163  (int) cmd->data.draw.blend);
164  break;
165 
167  SDL_Log(" %u. draw lines (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d)", i++,
168  (unsigned int) cmd->data.draw.first,
169  (unsigned int) cmd->data.draw.count,
170  (int) cmd->data.draw.r, (int) cmd->data.draw.g,
171  (int) cmd->data.draw.b, (int) cmd->data.draw.a,
172  (int) cmd->data.draw.blend);
173  break;
174 
176  SDL_Log(" %u. fill rects (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d)", i++,
177  (unsigned int) cmd->data.draw.first,
178  (unsigned int) cmd->data.draw.count,
179  (int) cmd->data.draw.r, (int) cmd->data.draw.g,
180  (int) cmd->data.draw.b, (int) cmd->data.draw.a,
181  (int) cmd->data.draw.blend);
182  break;
183 
184  case SDL_RENDERCMD_COPY:
185  SDL_Log(" %u. copy (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d, tex=%p)", i++,
186  (unsigned int) cmd->data.draw.first,
187  (unsigned int) cmd->data.draw.count,
188  (int) cmd->data.draw.r, (int) cmd->data.draw.g,
189  (int) cmd->data.draw.b, (int) cmd->data.draw.a,
190  (int) cmd->data.draw.blend, cmd->data.draw.texture);
191  break;
192 
193 
195  SDL_Log(" %u. copyex (first=%u, count=%u, r=%d, g=%d, b=%d, a=%d, blend=%d, tex=%p)", i++,
196  (unsigned int) cmd->data.draw.first,
197  (unsigned int) cmd->data.draw.count,
198  (int) cmd->data.draw.r, (int) cmd->data.draw.g,
199  (int) cmd->data.draw.b, (int) cmd->data.draw.a,
200  (int) cmd->data.draw.blend, cmd->data.draw.texture);
201  break;
202  }
203  cmd = cmd->next;
204  }
205 #endif
206 }

References SDL_RenderCommand::cliprect, SDL_RenderCommand::color, SDL_RenderCommand::command, SDL_RenderCommand::data, SDL_RenderCommand::draw, i, SDL_RenderCommand::next, SDL_Log, SDL_RENDERCMD_CLEAR, SDL_RENDERCMD_COPY, SDL_RENDERCMD_COPY_EX, SDL_RENDERCMD_DRAW_LINES, SDL_RENDERCMD_DRAW_POINTS, SDL_RENDERCMD_FILL_RECTS, SDL_RENDERCMD_NO_OP, SDL_RENDERCMD_SETCLIPRECT, SDL_RENDERCMD_SETDRAWCOLOR, SDL_RENDERCMD_SETVIEWPORT, and SDL_RenderCommand::viewport.

Referenced by FlushRenderCommands().

◆ FlushRenderCommands()

static int FlushRenderCommands ( SDL_Renderer renderer)
static

Definition at line 209 of file SDL_render.c.

210 {
211  int retval;
212 
214 
215  if (renderer->render_commands == NULL) { /* nothing to do! */
217  return 0;
218  }
219 
221 
223 
224  /* Move the whole render command queue to the unused pool so we can reuse them next time. */
230  }
236  return retval;
237 }

References SDL_Renderer::cliprect_queued, SDL_Renderer::color_queued, DebugLogRenderCommands(), SDL_RenderCommand::next, NULL, SDL_Renderer::render_command_generation, SDL_Renderer::render_commands, SDL_Renderer::render_commands_pool, SDL_Renderer::render_commands_tail, renderer, retval, SDL_Renderer::RunCommandQueue, SDL_assert, SDL_FALSE, SDL_Renderer::vertex_data, SDL_Renderer::vertex_data_used, and SDL_Renderer::viewport_queued.

Referenced by FlushRenderCommandsIfNotBatching(), FlushRenderCommandsIfTextureNeeded(), SDL_RenderFlush(), SDL_RenderGetMetalCommandEncoder(), SDL_RenderGetMetalLayer(), SDL_RenderPresent(), SDL_RenderReadPixels(), and SDL_SetRenderTarget().

◆ FlushRenderCommandsIfNotBatching()

◆ FlushRenderCommandsIfTextureNeeded()

static int FlushRenderCommandsIfTextureNeeded ( SDL_Texture texture)
static

Definition at line 240 of file SDL_render.c.

241 {
242  SDL_Renderer *renderer = texture->renderer;
243  if (texture->last_command_generation == renderer->render_command_generation) {
244  /* the current command queue depends on this texture, flush the queue now before it changes */
246  }
247  return 0;
248 }

References FlushRenderCommands(), SDL_Renderer::render_command_generation, and renderer.

Referenced by SDL_DestroyTexture(), SDL_GL_BindTexture(), SDL_GL_UnbindTexture(), SDL_LockTexture(), SDL_UpdateTexture(), and SDL_UpdateYUVTexture().

◆ GetClosestSupportedFormat()

static Uint32 GetClosestSupportedFormat ( SDL_Renderer renderer,
Uint32  format 
)
static

Definition at line 1001 of file SDL_render.c.

1002 {
1003  Uint32 i;
1004 
1006  /* Look for an exact match */
1007  for (i = 0; i < renderer->info.num_texture_formats; ++i) {
1008  if (renderer->info.texture_formats[i] == format) {
1009  return renderer->info.texture_formats[i];
1010  }
1011  }
1012  } else {
1014 
1015  /* We just want to match the first format that has the same channels */
1016  for (i = 0; i < renderer->info.num_texture_formats; ++i) {
1019  return renderer->info.texture_formats[i];
1020  }
1021  }
1022  }
1023  return renderer->info.texture_formats[0];
1024 }

References i, SDL_Renderer::info, SDL_RendererInfo::num_texture_formats, renderer, SDL_ISPIXELFORMAT_ALPHA, SDL_ISPIXELFORMAT_FOURCC, and SDL_RendererInfo::texture_formats.

Referenced by SDL_CreateTexture().

◆ GetWindowViewportValues()

◆ IsSupportedBlendMode()

static SDL_bool IsSupportedBlendMode ( SDL_Renderer renderer,
SDL_BlendMode  blendMode 
)
static

Definition at line 970 of file SDL_render.c.

971 {
972  switch (blendMode)
973  {
974  /* These are required to be supported by all renderers */
975  case SDL_BLENDMODE_NONE:
976  case SDL_BLENDMODE_BLEND:
977  case SDL_BLENDMODE_ADD:
978  case SDL_BLENDMODE_MOD:
979  case SDL_BLENDMODE_MUL:
980  return SDL_TRUE;
981 
982  default:
984  }
985 }

References blendMode, renderer, SDL_BLENDMODE_ADD, SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD, SDL_BLENDMODE_MUL, SDL_BLENDMODE_NONE, SDL_TRUE, and SDL_Renderer::SupportsBlendMode.

Referenced by SDL_SetRenderDrawBlendMode(), and SDL_SetTextureBlendMode().

◆ IsSupportedFormat()

static SDL_bool IsSupportedFormat ( SDL_Renderer renderer,
Uint32  format 
)
static

Definition at line 988 of file SDL_render.c.

989 {
990  Uint32 i;
991 
992  for (i = 0; i < renderer->info.num_texture_formats; ++i) {
993  if (renderer->info.texture_formats[i] == format) {
994  return SDL_TRUE;
995  }
996  }
997  return SDL_FALSE;
998 }

References i, SDL_Renderer::info, SDL_RendererInfo::num_texture_formats, renderer, SDL_FALSE, SDL_TRUE, and SDL_RendererInfo::texture_formats.

Referenced by SDL_CreateTexture().

◆ PrepQueueCmdDraw()

static int PrepQueueCmdDraw ( SDL_Renderer renderer,
const Uint8  r,
const Uint8  g,
const Uint8  b,
const Uint8  a 
)
static

Definition at line 417 of file SDL_render.c.

418 {
420 
421  /* Set the viewport and clip rect directly before draws, so the backends
422  * don't have to worry about that state not being valid at draw time. */
423  if (retval == 0 && !renderer->viewport_queued) {
425  }
426  if (retval == 0 && !renderer->cliprect_queued) {
428  }
429  return retval;
430 }

References SDL_Renderer::cliprect_queued, QueueCmdSetClipRect(), QueueCmdSetDrawColor(), QueueCmdSetViewport(), renderer, retval, and SDL_Renderer::viewport_queued.

Referenced by PrepQueueCmdDrawSolid(), and PrepQueueCmdDrawTexture().

◆ PrepQueueCmdDrawSolid()

static SDL_RenderCommand* PrepQueueCmdDrawSolid ( SDL_Renderer renderer,
const SDL_RenderCommandType  cmdtype 
)
static

Definition at line 433 of file SDL_render.c.

434 {
435  /* !!! FIXME: drop this draw if viewport w or h is zero. */
436  SDL_RenderCommand *cmd = NULL;
439  if (cmd != NULL) {
440  cmd->command = cmdtype;
441  cmd->data.draw.first = 0; /* render backend will fill this in. */
442  cmd->data.draw.count = 0; /* render backend will fill this in. */
443  cmd->data.draw.r = renderer->r;
444  cmd->data.draw.g = renderer->g;
445  cmd->data.draw.b = renderer->b;
446  cmd->data.draw.a = renderer->a;
447  cmd->data.draw.blend = renderer->blendMode;
448  cmd->data.draw.texture = NULL; /* no texture. */
449  }
450  }
451  return cmd;
452 }

References SDL_Renderer::a, AllocateRenderCommand(), SDL_Renderer::b, SDL_Renderer::blendMode, SDL_RenderCommand::command, SDL_RenderCommand::data, SDL_RenderCommand::draw, SDL_Renderer::g, NULL, PrepQueueCmdDraw(), SDL_Renderer::r, and renderer.

Referenced by QueueCmdDrawLines(), QueueCmdDrawPoints(), and QueueCmdFillRects().

◆ PrepQueueCmdDrawTexture()

static SDL_RenderCommand* PrepQueueCmdDrawTexture ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_RenderCommandType  cmdtype 
)
static

Definition at line 497 of file SDL_render.c.

498 {
499  /* !!! FIXME: drop this draw if viewport w or h is zero. */
500  SDL_RenderCommand *cmd = NULL;
501  if (PrepQueueCmdDraw(renderer, texture->r, texture->g, texture->b, texture->a) == 0) {
503  if (cmd != NULL) {
504  cmd->command = cmdtype;
505  cmd->data.draw.first = 0; /* render backend will fill this in. */
506  cmd->data.draw.count = 0; /* render backend will fill this in. */
507  cmd->data.draw.r = texture->r;
508  cmd->data.draw.g = texture->g;
509  cmd->data.draw.b = texture->b;
510  cmd->data.draw.a = texture->a;
511  cmd->data.draw.blend = texture->blendMode;
512  cmd->data.draw.texture = texture;
513  }
514  }
515  return cmd;
516 }

References AllocateRenderCommand(), SDL_RenderCommand::command, SDL_RenderCommand::data, SDL_RenderCommand::draw, NULL, PrepQueueCmdDraw(), SDL_Renderer::r, and renderer.

Referenced by QueueCmdCopy(), and QueueCmdCopyEx().

◆ QueueCmdClear()

static int QueueCmdClear ( SDL_Renderer renderer)
static

Definition at line 400 of file SDL_render.c.

401 {
403  if (cmd == NULL) {
404  return -1;
405  }
406 
408  cmd->data.color.first = 0;
409  cmd->data.color.r = renderer->r;
410  cmd->data.color.g = renderer->g;
411  cmd->data.color.b = renderer->b;
412  cmd->data.color.a = renderer->a;
413  return 0;
414 }

References SDL_Renderer::a, AllocateRenderCommand(), SDL_Renderer::b, SDL_RenderCommand::color, SDL_RenderCommand::command, SDL_RenderCommand::data, SDL_Renderer::g, NULL, SDL_Renderer::r, renderer, and SDL_RENDERCMD_CLEAR.

Referenced by SDL_RenderClear().

◆ QueueCmdCopy()

static int QueueCmdCopy ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_Rect srcrect,
const SDL_FRect dstrect 
)
static

Definition at line 519 of file SDL_render.c.

520 {
522  int retval = -1;
523  if (cmd != NULL) {
524  retval = renderer->QueueCopy(renderer, cmd, texture, srcrect, dstrect);
525  if (retval < 0) {
527  }
528  }
529  return retval;
530 }

References SDL_RenderCommand::command, NULL, PrepQueueCmdDrawTexture(), SDL_Renderer::QueueCopy, renderer, retval, SDL_RENDERCMD_COPY, and SDL_RENDERCMD_NO_OP.

Referenced by SDL_RenderCopyF().

◆ QueueCmdCopyEx()

static int QueueCmdCopyEx ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_Rect srcquad,
const SDL_FRect dstrect,
const double  angle,
const SDL_FPoint center,
const SDL_RendererFlip  flip 
)
static

Definition at line 533 of file SDL_render.c.

536 {
538  int retval = -1;
539  SDL_assert(renderer->QueueCopyEx != NULL); /* should have caught at higher level. */
540  if (cmd != NULL) {
541  retval = renderer->QueueCopyEx(renderer, cmd, texture, srcquad, dstrect, angle, center, flip);
542  if (retval < 0) {
544  }
545  }
546  return retval;
547 }

References SDL_RenderCommand::command, NULL, PrepQueueCmdDrawTexture(), SDL_Renderer::QueueCopyEx, renderer, retval, SDL_assert, SDL_RENDERCMD_COPY_EX, and SDL_RENDERCMD_NO_OP.

Referenced by SDL_RenderCopyExF().

◆ QueueCmdDrawLines()

static int QueueCmdDrawLines ( SDL_Renderer renderer,
const SDL_FPoint points,
const int  count 
)
static

◆ QueueCmdDrawPoints()

static int QueueCmdDrawPoints ( SDL_Renderer renderer,
const SDL_FPoint points,
const int  count 
)
static

Definition at line 455 of file SDL_render.c.

456 {
458  int retval = -1;
459  if (cmd != NULL) {
461  if (retval < 0) {
463  }
464  }
465  return retval;
466 }

References SDL_RenderCommand::command, NULL, PrepQueueCmdDrawSolid(), SDL_Renderer::QueueDrawPoints, renderer, retval, SDL_RENDERCMD_DRAW_POINTS, and SDL_RENDERCMD_NO_OP.

Referenced by SDL_RenderDrawPoints(), and SDL_RenderDrawPointsF().

◆ QueueCmdFillRects()

static int QueueCmdFillRects ( SDL_Renderer renderer,
const SDL_FRect rects,
const int  count 
)
static

◆ QueueCmdSetClipRect()

◆ QueueCmdSetDrawColor()

static int QueueCmdSetDrawColor ( SDL_Renderer renderer,
const Uint8  r,
const Uint8  g,
const Uint8  b,
const Uint8  a 
)
static

Definition at line 371 of file SDL_render.c.

372 {
373  const Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b);
374  int retval = 0;
375 
378  retval = -1;
379 
380  if (cmd != NULL) {
382  cmd->data.color.first = 0; /* render backend will fill this in. */
383  cmd->data.color.r = r;
384  cmd->data.color.g = g;
385  cmd->data.color.b = b;
386  cmd->data.color.a = a;
388  if (retval < 0) {
390  } else {
393  }
394  }
395  }
396  return retval;
397 }

References AllocateRenderCommand(), SDL_RenderCommand::color, SDL_Renderer::color_queued, SDL_RenderCommand::command, SDL_RenderCommand::data, SDL_Renderer::last_queued_color, NULL, SDL_Renderer::QueueSetDrawColor, renderer, retval, SDL_RENDERCMD_NO_OP, SDL_RENDERCMD_SETDRAWCOLOR, and SDL_TRUE.

Referenced by PrepQueueCmdDraw().

◆ QueueCmdSetViewport()

static int QueueCmdSetViewport ( SDL_Renderer renderer)
static

◆ RenderDrawLinesWithRects()

static int RenderDrawLinesWithRects ( SDL_Renderer renderer,
const SDL_Point points,
const int  count 
)
static

Definition at line 2446 of file SDL_render.c.

2448 {
2449  SDL_FRect *frect;
2450  SDL_FRect *frects;
2451  SDL_FPoint fpoints[2];
2452  int i, nrects = 0;
2453  int retval = 0;
2454  SDL_bool isstack;
2455 
2456  frects = SDL_small_alloc(SDL_FRect, count-1, &isstack);
2457  if (!frects) {
2458  return SDL_OutOfMemory();
2459  }
2460 
2461  for (i = 0; i < count-1; ++i) {
2462  if (points[i].x == points[i+1].x) {
2463  const int minY = SDL_min(points[i].y, points[i+1].y);
2464  const int maxY = SDL_max(points[i].y, points[i+1].y);
2465 
2466  frect = &frects[nrects++];
2467  frect->x = points[i].x * renderer->scale.x;
2468  frect->y = minY * renderer->scale.y;
2469  frect->w = renderer->scale.x;
2470  frect->h = (maxY - minY + 1) * renderer->scale.y;
2471  } else if (points[i].y == points[i+1].y) {
2472  const int minX = SDL_min(points[i].x, points[i+1].x);
2473  const int maxX = SDL_max(points[i].x, points[i+1].x);
2474 
2475  frect = &frects[nrects++];
2476  frect->x = minX * renderer->scale.x;
2477  frect->y = points[i].y * renderer->scale.y;
2478  frect->w = (maxX - minX + 1) * renderer->scale.x;
2479  frect->h = renderer->scale.y;
2480  } else {
2481  /* FIXME: We can't use a rect for this line... */
2482  fpoints[0].x = points[i].x * renderer->scale.x;
2483  fpoints[0].y = points[i].y * renderer->scale.y;
2484  fpoints[1].x = points[i+1].x * renderer->scale.x;
2485  fpoints[1].y = points[i+1].y * renderer->scale.y;
2486  retval += QueueCmdDrawLines(renderer, fpoints, 2);
2487  }
2488  }
2489 
2490  retval += QueueCmdFillRects(renderer, frects, nrects);
2491 
2492  SDL_small_free(frects, isstack);
2493 
2494  if (retval < 0) {
2495  retval = -1;
2496  }
2498 }

References FlushRenderCommandsIfNotBatching(), SDL_FRect::h, i, QueueCmdDrawLines(), QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_max, SDL_min, SDL_OutOfMemory, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawLines().

◆ RenderDrawLinesWithRectsF()

static int RenderDrawLinesWithRectsF ( SDL_Renderer renderer,
const SDL_FPoint points,
const int  count 
)
static

Definition at line 2501 of file SDL_render.c.

2503 {
2504  SDL_FRect *frect;
2505  SDL_FRect *frects;
2506  SDL_FPoint fpoints[2];
2507  int i, nrects = 0;
2508  int retval = 0;
2509  SDL_bool isstack;
2510 
2511  frects = SDL_small_alloc(SDL_FRect, count-1, &isstack);
2512  if (!frects) {
2513  return SDL_OutOfMemory();
2514  }
2515 
2516  for (i = 0; i < count-1; ++i) {
2517  if (points[i].x == points[i+1].x) {
2518  const int minY = (int)SDL_min(points[i].y, points[i+1].y);
2519  const int maxY = (int)SDL_max(points[i].y, points[i+1].y);
2520 
2521  frect = &frects[nrects++];
2522  frect->x = points[i].x * renderer->scale.x;
2523  frect->y = minY * renderer->scale.y;
2524  frect->w = renderer->scale.x;
2525  frect->h = (maxY - minY + 1) * renderer->scale.y;
2526  } else if (points[i].y == points[i+1].y) {
2527  const int minX = (int)SDL_min(points[i].x, points[i+1].x);
2528  const int maxX = (int)SDL_max(points[i].x, points[i+1].x);
2529 
2530  frect = &frects[nrects++];
2531  frect->x = minX * renderer->scale.x;
2532  frect->y = points[i].y * renderer->scale.y;
2533  frect->w = (maxX - minX + 1) * renderer->scale.x;
2534  frect->h = renderer->scale.y;
2535  } else {
2536  /* FIXME: We can't use a rect for this line... */
2537  fpoints[0].x = points[i].x * renderer->scale.x;
2538  fpoints[0].y = points[i].y * renderer->scale.y;
2539  fpoints[1].x = points[i+1].x * renderer->scale.x;
2540  fpoints[1].y = points[i+1].y * renderer->scale.y;
2541  retval += QueueCmdDrawLines(renderer, fpoints, 2);
2542  }
2543  }
2544 
2545  retval += QueueCmdFillRects(renderer, frects, nrects);
2546 
2547  SDL_small_free(frects, isstack);
2548 
2549  if (retval < 0) {
2550  retval = -1;
2551  }
2553 }

References FlushRenderCommandsIfNotBatching(), SDL_FRect::h, i, QueueCmdDrawLines(), QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_max, SDL_min, SDL_OutOfMemory, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawLinesF().

◆ RenderDrawPointsWithRects()

static int RenderDrawPointsWithRects ( SDL_Renderer renderer,
const SDL_Point points,
const int  count 
)
static

Definition at line 2284 of file SDL_render.c.

2286 {
2287  int retval = -1;
2288  SDL_bool isstack;
2289  SDL_FRect *frects = SDL_small_alloc(SDL_FRect, count, &isstack);
2290  int i;
2291 
2292  if (!frects) {
2293  return SDL_OutOfMemory();
2294  }
2295 
2296  for (i = 0; i < count; ++i) {
2297  frects[i].x = points[i].x * renderer->scale.x;
2298  frects[i].y = points[i].y * renderer->scale.y;
2299  frects[i].w = renderer->scale.x;
2300  frects[i].h = renderer->scale.y;
2301  }
2302 
2303  retval = QueueCmdFillRects(renderer, frects, count);
2304 
2305  SDL_small_free(frects, isstack);
2306 
2308 }

References FlushRenderCommandsIfNotBatching(), SDL_FRect::h, i, QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawPoints().

◆ RenderDrawPointsWithRectsF()

static int RenderDrawPointsWithRectsF ( SDL_Renderer renderer,
const SDL_FPoint fpoints,
const int  count 
)
static

Definition at line 2354 of file SDL_render.c.

2356 {
2357  int retval = -1;
2358  SDL_bool isstack;
2359  SDL_FRect *frects = SDL_small_alloc(SDL_FRect, count, &isstack);
2360  int i;
2361 
2362  if (!frects) {
2363  return SDL_OutOfMemory();
2364  }
2365 
2366  for (i = 0; i < count; ++i) {
2367  frects[i].x = fpoints[i].x * renderer->scale.x;
2368  frects[i].y = fpoints[i].y * renderer->scale.y;
2369  frects[i].w = renderer->scale.x;
2370  frects[i].h = renderer->scale.y;
2371  }
2372 
2373  retval = QueueCmdFillRects(renderer, frects, count);
2374 
2375  SDL_small_free(frects, isstack);
2376 
2378 }

References FlushRenderCommandsIfNotBatching(), SDL_FRect::h, i, QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawPointsF().

◆ SDL_AllocateRenderVertices()

void* SDL_AllocateRenderVertices ( SDL_Renderer renderer,
const size_t  numbytes,
const size_t  alignment,
size_t offset 
)

Definition at line 263 of file SDL_render.c.

264 {
265  const size_t needed = renderer->vertex_data_used + numbytes + alignment;
266  size_t current_offset = renderer->vertex_data_used;
267 
268  size_t aligner = (alignment && ((current_offset & (alignment - 1)) != 0)) ? (alignment - (current_offset & (alignment - 1))) : 0;
269  size_t aligned = current_offset + aligner;
270 
271  if (renderer->vertex_data_allocation < needed) {
272  const size_t current_allocation = renderer->vertex_data ? renderer->vertex_data_allocation : 1024;
273  size_t newsize = current_allocation * 2;
274  void *ptr;
275  while (newsize < needed) {
276  newsize *= 2;
277  }
278  ptr = SDL_realloc(renderer->vertex_data, newsize);
279  if (ptr == NULL) {
280  SDL_OutOfMemory();
281  return NULL;
282  }
284  renderer->vertex_data_allocation = newsize;
285  }
286 
287  if (offset) {
288  *offset = aligned;
289  }
290 
291  renderer->vertex_data_used += aligner + numbytes;
292 
293  return ((Uint8 *) renderer->vertex_data) + aligned;
294 }

References NULL, numbytes, ptr, renderer, SDL_OutOfMemory, SDL_realloc, SDL_Renderer::vertex_data, SDL_Renderer::vertex_data_allocation, and SDL_Renderer::vertex_data_used.

Referenced by SW_QueueCopy(), SW_QueueCopyEx(), SW_QueueDrawPoints(), and SW_QueueFillRects().

◆ SDL_ComposeCustomBlendMode()

SDL_BlendMode SDL_ComposeCustomBlendMode ( SDL_BlendFactor  srcColorFactor,
SDL_BlendFactor  dstColorFactor,
SDL_BlendOperation  colorOperation,
SDL_BlendFactor  srcAlphaFactor,
SDL_BlendFactor  dstAlphaFactor,
SDL_BlendOperation  alphaOperation 
)

Create a custom blend mode, which may or may not be supported by a given renderer.

Parameters
srcColorFactorsource color factor
dstColorFactordestination color factor
colorOperationcolor operation
srcAlphaFactorsource alpha factor
dstAlphaFactordestination alpha factor
alphaOperationalpha operation

The result of the blend mode operation will be: dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor and dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor

Definition at line 3352 of file SDL_render.c.

3356 {
3357  SDL_BlendMode blendMode = SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation,
3358  srcAlphaFactor, dstAlphaFactor, alphaOperation);
3360 }

References blendMode, SDL_COMPOSE_BLENDMODE, and SDL_GetShortBlendMode().

◆ SDL_CreateRenderer()

SDL_Renderer* SDL_CreateRenderer ( SDL_Window window,
int  index,
Uint32  flags 
)

Create a 2D rendering context for a window.

Parameters
windowThe window where rendering is displayed.
indexThe index of the rendering driver to initialize, or -1 to initialize the first one supporting the requested flags.
flagsSDL_RendererFlags.
Returns
A valid rendering context or NULL if there was an error.
See also
SDL_CreateSoftwareRenderer()
SDL_GetRendererInfo()
SDL_DestroyRenderer()

Definition at line 765 of file SDL_render.c.

766 {
767 #if !SDL_RENDER_DISABLED
769  int n = SDL_GetNumRenderDrivers();
770  SDL_bool batching = SDL_TRUE;
771  const char *hint;
772 
773 #if defined(__ANDROID__)
775 #endif
776 
777  if (!window) {
778  SDL_SetError("Invalid window");
779  goto error;
780  }
781 
782  if (SDL_GetRenderer(window)) {
783  SDL_SetError("Renderer already associated with window");
784  goto error;
785  }
786 
790  } else {
792  }
793  }
794 
795  if (index < 0) {
797  if (hint) {
798  for (index = 0; index < n; ++index) {
799  const SDL_RenderDriver *driver = render_drivers[index];
800 
801  if (SDL_strcasecmp(hint, driver->info.name) == 0) {
802  /* Create a new renderer instance */
803  renderer = driver->CreateRenderer(window, flags);
804  if (renderer) {
805  batching = SDL_FALSE;
806  }
807  break;
808  }
809  }
810  }
811 
812  if (!renderer) {
813  for (index = 0; index < n; ++index) {
814  const SDL_RenderDriver *driver = render_drivers[index];
815 
816  if ((driver->info.flags & flags) == flags) {
817  /* Create a new renderer instance */
818  renderer = driver->CreateRenderer(window, flags);
819  if (renderer) {
820  /* Yay, we got one! */
821  break;
822  }
823  }
824  }
825  }
826  if (index == n) {
827  SDL_SetError("Couldn't find matching render driver");
828  goto error;
829  }
830  } else {
831  if (index >= SDL_GetNumRenderDrivers()) {
832  SDL_SetError("index must be -1 or in the range of 0 - %d",
834  goto error;
835  }
836  /* Create a new renderer instance */
838  batching = SDL_FALSE;
839  }
840 
841  if (!renderer) {
842  goto error;
843  }
844 
846 
847  /* let app/user override batching decisions. */
848  if (renderer->always_batch) {
849  batching = SDL_TRUE;
852  }
853 
854  renderer->batching = batching;
858  renderer->scale.x = 1.0f;
859  renderer->scale.y = 1.0f;
860  renderer->dpi_scale.x = 1.0f;
861  renderer->dpi_scale.y = 1.0f;
862 
863  /* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */
865 
866  if (window && renderer->GetOutputSize) {
867  int window_w, window_h;
868  int output_w, output_h;
869  if (renderer->GetOutputSize(renderer, &output_w, &output_h) == 0) {
871  renderer->dpi_scale.x = (float)window_w / output_w;
872  renderer->dpi_scale.y = (float)window_h / output_h;
873  }
874  }
875 
878  } else {
880  }
881 
883 
885 
887 
889  "Created renderer: %s", renderer->info.name);
890 
891 #if defined(__ANDROID__)
893 #endif
894  return renderer;
895 
896 error:
897 
898 #if defined(__ANDROID__)
900 #endif
901  return NULL;
902 
903 #else
904  SDL_SetError("SDL not built with rendering support");
905  return NULL;
906 #endif
907 }

References SDL_Renderer::always_batch, Android_ActivityMutex_Lock_Running(), Android_ActivityMutex_Unlock(), SDL_Renderer::batching, SDL_RenderDriver::CreateRenderer, SDL_Renderer::dpi_scale, SDL_RendererInfo::flags, SDL_Renderer::GetOutputSize, SDL_Renderer::hidden, SDL_Renderer::info, SDL_RenderDriver::info, SDL_Renderer::magic, SDL_RendererInfo::name, NULL, SDL_Renderer::render_command_generation, render_drivers, renderer, renderer_magic, SDL_Renderer::scale, SDL_AddEventWatch, SDL_CreateMutex, SDL_FALSE, SDL_GetHint, SDL_GetHintBoolean, SDL_GetNumRenderDrivers(), SDL_GetRenderer(), SDL_GetWindowFlags, SDL_GetWindowSize, SDL_HINT_RENDER_BATCHING, SDL_HINT_RENDER_DRIVER, SDL_HINT_RENDER_VSYNC, SDL_LOG_CATEGORY_RENDER, SDL_LogInfo, SDL_RENDERER_PRESENTVSYNC, SDL_RendererEventWatch(), SDL_RenderSetViewport(), SDL_SetError, SDL_SetWindowData, SDL_strcasecmp, SDL_TRUE, SDL_WINDOW_HIDDEN, SDL_WINDOW_MINIMIZED, SDL_WINDOWRENDERDATA, SDL_Renderer::target_mutex, VerifyDrawQueueFunctions(), SDL_Renderer::window, window_h, window_w, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_CreateWindowAndRenderer().

◆ SDL_CreateSoftwareRenderer()

SDL_Renderer* SDL_CreateSoftwareRenderer ( SDL_Surface surface)

Create a 2D software rendering context for a surface.

Parameters
surfaceThe surface where rendering is done.
Returns
A valid rendering context or NULL if there was an error.
See also
SDL_CreateRenderer()
SDL_DestroyRenderer()

Definition at line 910 of file SDL_render.c.

911 {
912 #if !SDL_RENDER_DISABLED && SDL_VIDEO_RENDER_SW
914 
916 
917  if (renderer) {
921  renderer->scale.x = 1.0f;
922  renderer->scale.y = 1.0f;
923 
924  /* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */
926 
928  }
929  return renderer;
930 #else
931  SDL_SetError("SDL not built with rendering support");
932  return NULL;
933 #endif /* !SDL_RENDER_DISABLED */
934 }

References SDL_Renderer::magic, NULL, SDL_Renderer::render_command_generation, renderer, renderer_magic, SDL_Renderer::scale, SDL_CreateMutex, SDL_RenderSetViewport(), SDL_SetError, SW_CreateRendererForSurface(), SDL_Renderer::target_mutex, VerifyDrawQueueFunctions(), SDL_FPoint::x, and SDL_FPoint::y.

◆ SDL_CreateTexture()

SDL_Texture* SDL_CreateTexture ( SDL_Renderer renderer,
Uint32  format,
int  access,
int  w,
int  h 
)

Create a texture for a rendering context.

Parameters
rendererThe renderer.
formatThe format of the texture.
accessOne of the enumerated values in SDL_TextureAccess.
wThe width of the texture in pixels.
hThe height of the texture in pixels.
Returns
The created texture is returned, or NULL if no rendering context was active, the format was unsupported, or the width or height were out of range.
Note
The contents of the texture are not defined at creation.
See also
SDL_QueryTexture()
SDL_UpdateTexture()
SDL_DestroyTexture()

Definition at line 1043 of file SDL_render.c.

1044 {
1046 
1048 
1049  if (!format) {
1051  }
1052  if (SDL_BYTESPERPIXEL(format) == 0) {
1053  SDL_SetError("Invalid texture format");
1054  return NULL;
1055  }
1057  SDL_SetError("Palettized textures are not supported");
1058  return NULL;
1059  }
1060  if (w <= 0 || h <= 0) {
1061  SDL_SetError("Texture dimensions can't be 0");
1062  return NULL;
1063  }
1066  SDL_SetError("Texture dimensions are limited to %dx%d", renderer->info.max_texture_width, renderer->info.max_texture_height);
1067  return NULL;
1068  }
1069  texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
1070  if (!texture) {
1071  SDL_OutOfMemory();
1072  return NULL;
1073  }
1074  texture->magic = &texture_magic;
1075  texture->format = format;
1076  texture->access = access;
1077  texture->w = w;
1078  texture->h = h;
1079  texture->r = 255;
1080  texture->g = 255;
1081  texture->b = 255;
1082  texture->a = 255;
1083  texture->scaleMode = SDL_GetScaleMode();
1084  texture->renderer = renderer;
1085  texture->next = renderer->textures;
1086  if (renderer->textures) {
1088  }
1090 
1092  if (renderer->CreateTexture(renderer, texture) < 0) {
1094  return NULL;
1095  }
1096  } else {
1099  access, w, h);
1100  if (!texture->native) {
1102  return NULL;
1103  }
1104 
1105  /* Swap textures to have texture before texture->native in the list */
1106  texture->native->next = texture->next;
1107  if (texture->native->next) {
1108  texture->native->next->prev = texture->native;
1109  }
1110  texture->prev = texture->native->prev;
1111  if (texture->prev) {
1112  texture->prev->next = texture;
1113  }
1114  texture->native->prev = texture;
1115  texture->next = texture->native;
1117 
1118  if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
1119 #if SDL_HAVE_YUV
1121 #else
1122  SDL_SetError("SDL not built with YUV support");
1123 #endif
1124  if (!texture->yuv) {
1126  return NULL;
1127  }
1128  } else if (access == SDL_TEXTUREACCESS_STREAMING) {
1129  /* The pitch is 4 byte aligned */
1130  texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3);
1131  texture->pixels = SDL_calloc(1, texture->pitch * h);
1132  if (!texture->pixels) {
1134  return NULL;
1135  }
1136  }
1137  }
1138  return texture;
1139 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::CreateTexture, GetClosestSupportedFormat(), SDL_Renderer::info, IsSupportedFormat(), SDL_RendererInfo::max_texture_height, SDL_RendererInfo::max_texture_width, NULL, SDL_Texture::prev, renderer, SDL_BYTESPERPIXEL, SDL_calloc, SDL_DestroyTexture(), SDL_GetScaleMode(), SDL_ISPIXELFORMAT_FOURCC, SDL_ISPIXELFORMAT_INDEXED, SDL_OutOfMemory, SDL_SetError, SDL_SW_CreateYUVTexture(), SDL_TEXTUREACCESS_STREAMING, SDL_RendererInfo::texture_formats, texture_magic, and SDL_Renderer::textures.

Referenced by SDL_CreateTextureFromSurface().

◆ SDL_CreateTextureFromSurface()

SDL_Texture* SDL_CreateTextureFromSurface ( SDL_Renderer renderer,
SDL_Surface surface 
)

Create a texture from an existing surface.

Parameters
rendererThe renderer.
surfaceThe surface containing pixel data used to fill the texture.
Returns
The created texture is returned, or NULL on error.
Note
The surface is not modified or freed by this function.
See also
SDL_QueryTexture()
SDL_DestroyTexture()

Definition at line 1142 of file SDL_render.c.

1143 {
1144  const SDL_PixelFormat *fmt;
1145  SDL_bool needAlpha;
1146  SDL_bool direct_update;
1147  int i;
1150 
1152 
1153  if (!surface) {
1154  SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface");
1155  return NULL;
1156  }
1157 
1158  /* See what the best texture format is */
1159  fmt = surface->format;
1160  if (fmt->Amask || SDL_HasColorKey(surface)) {
1161  needAlpha = SDL_TRUE;
1162  } else {
1163  needAlpha = SDL_FALSE;
1164  }
1165 
1166  /* If Palette contains alpha values, promotes to alpha format */
1167  if (fmt->palette) {
1168  for (i = 0; i < fmt->palette->ncolors; i++) {
1169  Uint8 alpha_value = fmt->palette->colors[i].a;
1170  if (alpha_value != 0 && alpha_value != SDL_ALPHA_OPAQUE) {
1171  needAlpha = SDL_TRUE;
1172  break;
1173  }
1174  }
1175  }
1176 
1177  /* Try to have the best pixel format for the texture */
1178  /* No alpha, but a colorkey => promote to alpha */
1179  if (!fmt->Amask && SDL_HasColorKey(surface)) {
1180  if (fmt->format == SDL_PIXELFORMAT_RGB888) {
1181  for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
1184  break;
1185  }
1186  }
1187  } else if (fmt->format == SDL_PIXELFORMAT_BGR888) {
1188  for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
1191  break;
1192  }
1193  }
1194  }
1195  } else {
1196  /* Exact match would be fine */
1197  for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
1198  if (renderer->info.texture_formats[i] == fmt->format) {
1199  format = fmt->format;
1200  break;
1201  }
1202  }
1203  }
1204 
1205  /* Fallback, choose a valid pixel format */
1208  for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
1212  break;
1213  }
1214  }
1215  }
1216 
1218  surface->w, surface->h);
1219  if (!texture) {
1220  return NULL;
1221  }
1222 
1223  if (format == surface->format->format) {
1224  if (surface->format->Amask && SDL_HasColorKey(surface)) {
1225  /* Surface and Renderer formats are identicals.
1226  * Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */
1227  direct_update = SDL_FALSE;
1228  } else {
1229  /* Update Texture directly */
1230  direct_update = SDL_TRUE;
1231  }
1232  } else {
1233  /* Surface and Renderer formats are differents, it needs an intermediate conversion. */
1234  direct_update = SDL_FALSE;
1235  }
1236 
1237  if (direct_update) {
1238  if (SDL_MUSTLOCK(surface)) {
1240  SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
1242  } else {
1243  SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
1244  }
1245  } else {
1246  SDL_PixelFormat *dst_fmt;
1247  SDL_Surface *temp = NULL;
1248 
1249  /* Set up a destination surface for the texture update */
1250  dst_fmt = SDL_AllocFormat(format);
1251  if (!dst_fmt) {
1253  return NULL;
1254  }
1255  temp = SDL_ConvertSurface(surface, dst_fmt, 0);
1256  SDL_FreeFormat(dst_fmt);
1257  if (temp) {
1258  SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
1259  SDL_FreeSurface(temp);
1260  } else {
1262  return NULL;
1263  }
1264  }
1265 
1266  {
1267  Uint8 r, g, b, a;
1269 
1272 
1275 
1276  if (SDL_HasColorKey(surface)) {
1277  /* We converted to a texture with alpha format */
1279  } else {
1282  }
1283  }
1284  return texture;
1285 }

References SDL_Color::a, SDL_PixelFormat::Amask, blendMode, CHECK_RENDERER_MAGIC, SDL_Palette::colors, SDL_PixelFormat::format, i, SDL_Renderer::info, SDL_Palette::ncolors, NULL, SDL_RendererInfo::num_texture_formats, SDL_PixelFormat::palette, SDL_Surface::pitch, SDL_Surface::pixels, renderer, SDL_AllocFormat, SDL_ALPHA_OPAQUE, SDL_BLENDMODE_BLEND, SDL_ConvertSurface, SDL_CreateTexture(), SDL_DestroyTexture(), SDL_FALSE, SDL_FreeFormat, SDL_FreeSurface, SDL_GetSurfaceAlphaMod, SDL_GetSurfaceBlendMode, SDL_GetSurfaceColorMod, SDL_HasColorKey, SDL_ISPIXELFORMAT_ALPHA, SDL_ISPIXELFORMAT_FOURCC, SDL_LockSurface, SDL_MUSTLOCK, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_UNKNOWN, SDL_SetError, SDL_SetTextureAlphaMod(), SDL_SetTextureBlendMode(), SDL_SetTextureColorMod(), SDL_TEXTUREACCESS_STATIC, SDL_TRUE, SDL_UnlockSurface, SDL_UpdateTexture(), and SDL_RendererInfo::texture_formats.

◆ SDL_CreateWindowAndRenderer()

int SDL_CreateWindowAndRenderer ( int  width,
int  height,
Uint32  window_flags,
SDL_Window **  window,
SDL_Renderer **  renderer 
)

Create a window and default renderer.

Parameters
widthThe width of the window
heightThe height of the window
window_flagsThe flags used to create the window
windowA pointer filled with the window, or NULL on error
rendererA pointer filled with the renderer, or NULL on error
Returns
0 on success, or -1 on error

Definition at line 731 of file SDL_render.c.

733 {
736  width, height, window_flags);
737  if (!*window) {
738  *renderer = NULL;
739  return -1;
740  }
741 
742  *renderer = SDL_CreateRenderer(*window, -1, 0);
743  if (!*renderer) {
744  return -1;
745  }
746 
747  return 0;
748 }

References NULL, renderer, SDL_CreateRenderer(), SDL_CreateWindow, and SDL_WINDOWPOS_UNDEFINED.

◆ SDL_DestroyRenderer()

void SDL_DestroyRenderer ( SDL_Renderer renderer)

Destroy the rendering context for a window and free associated textures.

See also
SDL_CreateRenderer()

Definition at line 3204 of file SDL_render.c.

3205 {
3206  SDL_RenderCommand *cmd;
3207 
3209 
3211 
3214  cmd = renderer->render_commands;
3215  } else {
3217  }
3218 
3222 
3223  while (cmd != NULL) {
3224  SDL_RenderCommand *next = cmd->next;
3225  SDL_free(cmd);
3226  cmd = next;
3227  }
3228 
3230 
3231  /* Free existing textures for this renderer */
3232  while (renderer->textures) {
3233  SDL_Texture *tex = renderer->textures; (void) tex;
3235  SDL_assert(tex != renderer->textures); /* satisfy static analysis. */
3236  }
3237 
3238  if (renderer->window) {
3240  }
3241 
3242  /* It's no longer magical... */
3243  renderer->magic = NULL;
3244 
3245  /* Free the target mutex */
3248 
3249  /* Free the renderer instance */
3251 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::DestroyRenderer, SDL_Renderer::magic, SDL_RenderCommand::next, NULL, SDL_Renderer::render_commands, SDL_Renderer::render_commands_pool, SDL_Renderer::render_commands_tail, renderer, SDL_assert, SDL_DelEventWatch, SDL_DestroyMutex, SDL_DestroyTexture(), SDL_free, SDL_RendererEventWatch(), SDL_SetWindowData, SDL_WINDOWRENDERDATA, SDL_Renderer::target_mutex, SDL_Renderer::textures, SDL_Renderer::vertex_data, void, and SDL_Renderer::window.

◆ SDL_DestroyTexture()

void SDL_DestroyTexture ( SDL_Texture texture)

Destroy the specified texture.

See also
SDL_CreateTexture()
SDL_CreateTextureFromSurface()

Definition at line 3161 of file SDL_render.c.

3162 {
3164 
3166 
3167  renderer = texture->renderer;
3168  if (texture == renderer->target) {
3169  SDL_SetRenderTarget(renderer, NULL); /* implies command queue flush */
3170  } else {
3172  }
3173 
3174  texture->magic = NULL;
3175 
3176  if (texture->next) {
3177  texture->next->prev = texture->prev;
3178  }
3179  if (texture->prev) {
3180  texture->prev->next = texture->next;
3181  } else {
3183  }
3184 
3185  if (texture->native) {
3186  SDL_DestroyTexture(texture->native);
3187  }
3188 #if SDL_HAVE_YUV
3189  if (texture->yuv) {
3191  }
3192 #endif
3193  SDL_free(texture->pixels);
3194 
3196 
3197  SDL_FreeSurface(texture->locked_surface);
3198  texture->locked_surface = NULL;
3199 
3200  SDL_free(texture);
3201 }

References CHECK_TEXTURE_MAGIC, SDL_Renderer::DestroyTexture, FlushRenderCommandsIfTextureNeeded(), SDL_Texture::next, NULL, renderer, SDL_free, SDL_FreeSurface, SDL_SetRenderTarget(), SDL_SW_DestroyYUVTexture(), SDL_Renderer::target, and SDL_Renderer::textures.

Referenced by SDL_CreateTexture(), SDL_CreateTextureFromSurface(), and SDL_DestroyRenderer().

◆ SDL_FRectEmpty()

SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty ( const SDL_FRect r)

Definition at line 2875 of file SDL_render.c.

2876 {
2877  return ((!r) || (r->w <= 0.0f) || (r->h <= 0.0f)) ? SDL_TRUE : SDL_FALSE;
2878 }

References SDL_FALSE, and SDL_TRUE.

Referenced by SDL_HasIntersectionF().

◆ SDL_GetBlendModeAlphaOperation()

SDL_BlendOperation SDL_GetBlendModeAlphaOperation ( SDL_BlendMode  blendMode)

Definition at line 3398 of file SDL_render.c.

3399 {
3401  return (SDL_BlendOperation)(((Uint32)blendMode >> 16) & 0xF);
3402 }

References blendMode, and SDL_GetLongBlendMode().

◆ SDL_GetBlendModeColorOperation()

SDL_BlendOperation SDL_GetBlendModeColorOperation ( SDL_BlendMode  blendMode)

Definition at line 3377 of file SDL_render.c.

3378 {
3380  return (SDL_BlendOperation)(((Uint32)blendMode >> 0) & 0xF);
3381 }

References blendMode, and SDL_GetLongBlendMode().

◆ SDL_GetBlendModeDstAlphaFactor()

SDL_BlendFactor SDL_GetBlendModeDstAlphaFactor ( SDL_BlendMode  blendMode)

Definition at line 3391 of file SDL_render.c.

3392 {
3394  return (SDL_BlendFactor)(((Uint32)blendMode >> 24) & 0xF);
3395 }

References blendMode, and SDL_GetLongBlendMode().

◆ SDL_GetBlendModeDstColorFactor()

SDL_BlendFactor SDL_GetBlendModeDstColorFactor ( SDL_BlendMode  blendMode)

Definition at line 3370 of file SDL_render.c.

3371 {
3373  return (SDL_BlendFactor)(((Uint32)blendMode >> 8) & 0xF);
3374 }

References blendMode, and SDL_GetLongBlendMode().

◆ SDL_GetBlendModeSrcAlphaFactor()

SDL_BlendFactor SDL_GetBlendModeSrcAlphaFactor ( SDL_BlendMode  blendMode)

Definition at line 3384 of file SDL_render.c.

3385 {
3387  return (SDL_BlendFactor)(((Uint32)blendMode >> 20) & 0xF);
3388 }

References blendMode, and SDL_GetLongBlendMode().

◆ SDL_GetBlendModeSrcColorFactor()

SDL_BlendFactor SDL_GetBlendModeSrcColorFactor ( SDL_BlendMode  blendMode)

Definition at line 3363 of file SDL_render.c.

3364 {
3366  return (SDL_BlendFactor)(((Uint32)blendMode >> 4) & 0xF);
3367 }

References blendMode, and SDL_GetLongBlendMode().

◆ SDL_GetLongBlendMode()

◆ SDL_GetNumRenderDrivers()

int SDL_GetNumRenderDrivers ( void  )

Get the number of 2D rendering drivers available for the current display.

A render driver is a set of code that handles rendering and texture management on a particular display. Normally there is only one, but some drivers may have several available with different capabilities.

See also
SDL_GetRenderDriverInfo()
SDL_CreateRenderer()

Definition at line 553 of file SDL_render.c.

554 {
555 #if !SDL_RENDER_DISABLED
557 #else
558  return 0;
559 #endif
560 }

References render_drivers, and SDL_arraysize.

Referenced by SDL_CreateRenderer(), and SDL_GetRenderDriverInfo().

◆ SDL_GetRenderDrawBlendMode()

int SDL_GetRenderDrawBlendMode ( SDL_Renderer renderer,
SDL_BlendMode blendMode 
)

Get the blend mode used for drawing operations.

Parameters
rendererThe renderer from which blend mode should be queried.
blendModeA pointer filled in with the current blend mode.
Returns
0 on success, or -1 on error
See also
SDL_SetRenderDrawBlendMode()

Definition at line 2244 of file SDL_render.c.

2245 {
2247 
2249  return 0;
2250 }

References blendMode, SDL_Renderer::blendMode, CHECK_RENDERER_MAGIC, and renderer.

◆ SDL_GetRenderDrawColor()

int SDL_GetRenderDrawColor ( SDL_Renderer renderer,
Uint8 r,
Uint8 g,
Uint8 b,
Uint8 a 
)

Get the color used for drawing operations (Rect, Line and Clear).

Parameters
rendererThe renderer from which drawing color should be queried.
rA pointer to the red value used to draw on the rendering target.
gA pointer to the green value used to draw on the rendering target.
bA pointer to the blue value used to draw on the rendering target.
aA pointer to the alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255).
Returns
0 on success, or -1 on error

Definition at line 2211 of file SDL_render.c.

2213 {
2215 
2216  if (r) {
2217  *r = renderer->r;
2218  }
2219  if (g) {
2220  *g = renderer->g;
2221  }
2222  if (b) {
2223  *b = renderer->b;
2224  }
2225  if (a) {
2226  *a = renderer->a;
2227  }
2228  return 0;
2229 }

References SDL_Renderer::a, SDL_Renderer::b, CHECK_RENDERER_MAGIC, SDL_Renderer::g, SDL_Renderer::r, and renderer.

◆ SDL_GetRenderDriverInfo()

int SDL_GetRenderDriverInfo ( int  index,
SDL_RendererInfo info 
)

Get information about a specific 2D rendering driver for the current display.

Parameters
indexThe index of the driver to query information about.
infoA pointer to an SDL_RendererInfo struct to be filled with information on the rendering driver.
Returns
0 on success, -1 if the index was out of range.
See also
SDL_CreateRenderer()

Definition at line 563 of file SDL_render.c.

564 {
565 #if !SDL_RENDER_DISABLED
567  return SDL_SetError("index must be in the range of 0 - %d",
569  }
570  *info = render_drivers[index]->info;
571  return 0;
572 #else
573  return SDL_SetError("SDL not built with rendering support");
574 #endif
575 }

References SDL_RenderDriver::info, render_drivers, SDL_GetNumRenderDrivers(), and SDL_SetError.

◆ SDL_GetRenderer()

SDL_Renderer* SDL_GetRenderer ( SDL_Window window)

Get the renderer associated with a window.

Definition at line 937 of file SDL_render.c.

938 {
940 }

References SDL_GetWindowData, and SDL_WINDOWRENDERDATA.

Referenced by SDL_CreateRenderer().

◆ SDL_GetRendererInfo()

int SDL_GetRendererInfo ( SDL_Renderer renderer,
SDL_RendererInfo info 
)

Get information about a rendering context.

Definition at line 943 of file SDL_render.c.

944 {
946 
947  *info = renderer->info;
948  return 0;
949 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::info, and renderer.

◆ SDL_GetRendererOutputSize()

int SDL_GetRendererOutputSize ( SDL_Renderer renderer,
int *  w,
int *  h 
)

Get the output size in pixels of a rendering context.

Definition at line 952 of file SDL_render.c.

953 {
955 
956  if (renderer->target) {
957  return SDL_QueryTexture(renderer->target, NULL, NULL, w, h);
958  } else if (renderer->GetOutputSize) {
959  return renderer->GetOutputSize(renderer, w, h);
960  } else if (renderer->window) {
962  return 0;
963  } else {
964  SDL_assert(0 && "This should never happen");
965  return SDL_SetError("Renderer doesn't support querying output size");
966  }
967 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::GetOutputSize, NULL, renderer, SDL_assert, SDL_GetWindowSize, SDL_QueryTexture(), SDL_SetError, SDL_Renderer::target, and SDL_Renderer::window.

Referenced by SDL_RenderSetViewport(), and UpdateLogicalSize().

◆ SDL_GetRenderTarget()

SDL_Texture* SDL_GetRenderTarget ( SDL_Renderer renderer)

Get the current render target or NULL for the default render target.

Returns
The current render target
See also
SDL_SetRenderTarget()

Definition at line 1933 of file SDL_render.c.

1934 {
1935  return renderer->target;
1936 }

References renderer, and SDL_Renderer::target.

Referenced by SDL_RendererEventWatch().

◆ SDL_GetScaleMode()

static SDL_ScaleMode SDL_GetScaleMode ( void  )
static

Definition at line 1027 of file SDL_render.c.

1028 {
1029  const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
1030 
1031  if (!hint || SDL_strcasecmp(hint, "nearest") == 0) {
1032  return SDL_ScaleModeNearest;
1033  } else if (SDL_strcasecmp(hint, "linear") == 0) {
1034  return SDL_ScaleModeLinear;
1035  } else if (SDL_strcasecmp(hint, "best") == 0) {
1036  return SDL_ScaleModeBest;
1037  } else {
1038  return (SDL_ScaleMode)SDL_atoi(hint);
1039  }
1040 }

References SDL_atoi, SDL_GetHint, SDL_HINT_RENDER_SCALE_QUALITY, SDL_ScaleModeBest, SDL_ScaleModeLinear, SDL_ScaleModeNearest, and SDL_strcasecmp.

Referenced by SDL_CreateTexture().

◆ SDL_GetShortBlendMode()

static SDL_BlendMode SDL_GetShortBlendMode ( SDL_BlendMode  blendMode)
static

◆ SDL_GetTextureAlphaMod()

int SDL_GetTextureAlphaMod ( SDL_Texture texture,
Uint8 alpha 
)

Get the additional alpha value used in render copy operations.

Parameters
textureThe texture to query.
alphaA pointer filled in with the current alpha value.
Returns
0 on success, or -1 if the texture is not valid.
See also
SDL_SetTextureAlphaMod()

Definition at line 1363 of file SDL_render.c.

1364 {
1366 
1367  if (alpha) {
1368  *alpha = texture->a;
1369  }
1370  return 0;
1371 }

References CHECK_TEXTURE_MAGIC.

◆ SDL_GetTextureBlendMode()

int SDL_GetTextureBlendMode ( SDL_Texture texture,
SDL_BlendMode blendMode 
)

Get the blend mode used for texture copy operations.

Parameters
textureThe texture to query.
blendModeA pointer filled in with the current blend mode.
Returns
0 on success, or -1 if the texture is not valid.
See also
SDL_SetTextureBlendMode()

Definition at line 1392 of file SDL_render.c.

1393 {
1395 
1396  if (blendMode) {
1397  *blendMode = texture->blendMode;
1398  }
1399  return 0;
1400 }

References blendMode, and CHECK_TEXTURE_MAGIC.

◆ SDL_GetTextureColorMod()

int SDL_GetTextureColorMod ( SDL_Texture texture,
Uint8 r,
Uint8 g,
Uint8 b 
)

Get the additional color value used in render copy operations.

Parameters
textureThe texture to query.
rA pointer filled in with the current red color value.
gA pointer filled in with the current green color value.
bA pointer filled in with the current blue color value.
Returns
0 on success, or -1 if the texture is not valid.
See also
SDL_SetTextureColorMod()

Definition at line 1328 of file SDL_render.c.

1330 {
1332 
1333  if (r) {
1334  *r = texture->r;
1335  }
1336  if (g) {
1337  *g = texture->g;
1338  }
1339  if (b) {
1340  *b = texture->b;
1341  }
1342  return 0;
1343 }

References CHECK_TEXTURE_MAGIC.

◆ SDL_GetTextureScaleMode()

int SDL_GetTextureScaleMode ( SDL_Texture texture,
SDL_ScaleMode scaleMode 
)

Get the scale mode used for texture scale operations.

Parameters
textureThe texture to query.
scaleModeA pointer filled in with the current scale mode.
Returns
0 on success, or -1 if the texture is not valid.
See also
SDL_SetTextureScaleMode()

Definition at line 1419 of file SDL_render.c.

1420 {
1422 
1423  if (scaleMode) {
1424  *scaleMode = texture->scaleMode;
1425  }
1426  return 0;
1427 }

References CHECK_TEXTURE_MAGIC.

◆ SDL_GL_BindTexture()

int SDL_GL_BindTexture ( SDL_Texture texture,
float *  texw,
float *  texh 
)

Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.

Parameters
textureThe SDL texture to bind
texwA pointer to a float that will be filled with the texture width
texhA pointer to a float that will be filled with the texture height
Returns
0 on success, or -1 if the operation is not supported

Definition at line 3253 of file SDL_render.c.

3254 {
3256 
3258  renderer = texture->renderer;
3259  if (texture->native) {
3260  return SDL_GL_BindTexture(texture->native, texw, texh);
3261  } else if (renderer && renderer->GL_BindTexture) {
3262  FlushRenderCommandsIfTextureNeeded(texture); /* in case the app is going to mess with it. */
3263  return renderer->GL_BindTexture(renderer, texture, texw, texh);
3264  } else {
3265  return SDL_Unsupported();
3266  }
3267 }

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Renderer::GL_BindTexture, renderer, and SDL_Unsupported.

◆ SDL_GL_UnbindTexture()

int SDL_GL_UnbindTexture ( SDL_Texture texture)

Unbind a texture from the current OpenGL/ES/ES2 context.

Parameters
textureThe SDL texture to unbind
Returns
0 on success, or -1 if the operation is not supported

Definition at line 3269 of file SDL_render.c.

3270 {
3272 
3274  renderer = texture->renderer;
3275  if (texture->native) {
3276  return SDL_GL_UnbindTexture(texture->native);
3277  } else if (renderer && renderer->GL_UnbindTexture) {
3278  FlushRenderCommandsIfTextureNeeded(texture); /* in case the app messed with it. */
3280  }
3281 
3282  return SDL_Unsupported();
3283 }

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Renderer::GL_UnbindTexture, renderer, and SDL_Unsupported.

◆ SDL_HasIntersectionF()

static SDL_bool SDL_HasIntersectionF ( const SDL_FRect A,
const SDL_FRect B 
)
static

Definition at line 2882 of file SDL_render.c.

2883 {
2884  float Amin, Amax, Bmin, Bmax;
2885 
2886  if (!A) {
2887  SDL_InvalidParamError("A");
2888  return SDL_FALSE;
2889  }
2890 
2891  if (!B) {
2892  SDL_InvalidParamError("B");
2893  return SDL_FALSE;
2894  }
2895 
2896  /* Special cases for empty rects */
2897  if (SDL_FRectEmpty(A) || SDL_FRectEmpty(B)) {
2898  return SDL_FALSE;
2899  }
2900 
2901  /* Horizontal intersection */
2902  Amin = A->x;
2903  Amax = Amin + A->w;
2904  Bmin = B->x;
2905  Bmax = Bmin + B->w;
2906  if (Bmin > Amin)
2907  Amin = Bmin;
2908  if (Bmax < Amax)
2909  Amax = Bmax;
2910  if (Amax <= Amin)
2911  return SDL_FALSE;
2912 
2913  /* Vertical intersection */
2914  Amin = A->y;
2915  Amax = Amin + A->h;
2916  Bmin = B->y;
2917  Bmax = Bmin + B->h;
2918  if (Bmin > Amin)
2919  Amin = Bmin;
2920  if (Bmax < Amax)
2921  Amax = Bmax;
2922  if (Amax <= Amin)
2923  return SDL_FALSE;
2924 
2925  return SDL_TRUE;
2926 }

References SDL_FRect::h, SDL_FALSE, SDL_FRectEmpty(), SDL_InvalidParamError, SDL_TRUE, SDL_FRect::w, SDL_FRect::x, and SDL_FRect::y.

Referenced by SDL_RenderCopyF().

◆ SDL_LockTexture()

int SDL_LockTexture ( SDL_Texture texture,
const SDL_Rect rect,
void **  pixels,
int *  pitch 
)

Lock a portion of the texture for write-only pixel access.

Parameters
textureThe texture to lock for access, which was created with SDL_TEXTUREACCESS_STREAMING.
rectA pointer to the rectangle to lock for access. If the rect is NULL, the entire texture will be locked.
pixelsThis is filled in with a pointer to the locked pixels, appropriately offset by the locked area.
pitchThis is filled in with the pitch of the locked pixels.
Returns
0 on success, or -1 if the texture is not valid or was not created with SDL_TEXTUREACCESS_STREAMING.
See also
SDL_UnlockTexture()

Definition at line 1701 of file SDL_render.c.

1703 {
1704  SDL_Rect full_rect;
1705 
1707 
1708  if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
1709  return SDL_SetError("SDL_LockTexture(): texture must be streaming");
1710  }
1711 
1712  if (!rect) {
1713  full_rect.x = 0;
1714  full_rect.y = 0;
1715  full_rect.w = texture->w;
1716  full_rect.h = texture->h;
1717  rect = &full_rect;
1718  }
1719 
1720 #if SDL_HAVE_YUV
1721  if (texture->yuv) {
1723  return -1;
1724  }
1725  return SDL_LockTextureYUV(texture, rect, pixels, pitch);
1726  } else
1727 #endif
1728  if (texture->native) {
1729  /* Calls a real SDL_LockTexture/SDL_UnlockTexture on unlock, flushing then. */
1730  return SDL_LockTextureNative(texture, rect, pixels, pitch);
1731  } else {
1732  SDL_Renderer *renderer = texture->renderer;
1734  return -1;
1735  }
1736  return renderer->LockTexture(renderer, texture, rect, pixels, pitch);
1737  }
1738 }

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Rect::h, SDL_Renderer::LockTexture, rect, renderer, SDL_LockTextureNative(), SDL_LockTextureYUV(), SDL_SetError, SDL_TEXTUREACCESS_STREAMING, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_LockTextureToSurface(), SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), and SDL_UpdateTextureYUVPlanar().

◆ SDL_LockTextureNative()

static int SDL_LockTextureNative ( SDL_Texture texture,
const SDL_Rect rect,
void **  pixels,
int *  pitch 
)
static

Definition at line 1689 of file SDL_render.c.

1691 {
1692  texture->locked_rect = *rect;
1693  *pixels = (void *) ((Uint8 *) texture->pixels +
1694  rect->y * texture->pitch +
1695  rect->x * SDL_BYTESPERPIXEL(texture->format));
1696  *pitch = texture->pitch;
1697  return 0;
1698 }

References rect, SDL_BYTESPERPIXEL, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_LockTexture().

◆ SDL_LockTextureToSurface()

int SDL_LockTextureToSurface ( SDL_Texture texture,
const SDL_Rect rect,
SDL_Surface **  surface 
)

Lock a portion of the texture for write-only pixel access. Expose it as a SDL surface.

Parameters
textureThe texture to lock for access, which was created with SDL_TEXTUREACCESS_STREAMING.
rectA pointer to the rectangle to lock for access. If the rect is NULL, the entire texture will be locked.
surfaceThis is filled in with a SDL surface representing the locked area Surface is freed internally after calling SDL_UnlockTexture or SDL_DestroyTexture.
Returns
0 on success, or -1 if the texture is not valid or was not created with SDL_TEXTUREACCESS_STREAMING.
See also
SDL_UnlockTexture()

Definition at line 1741 of file SDL_render.c.

1743 {
1744  SDL_Rect real_rect;
1745  void *pixels = NULL;
1746  int pitch, ret;
1747 
1748  if (texture == NULL || surface == NULL) {
1749  return -1;
1750  }
1751 
1752  real_rect.x = 0;
1753  real_rect.y = 0;
1754  real_rect.w = texture->w;
1755  real_rect.h = texture->h;
1756 
1757  if (rect) {
1758  SDL_IntersectRect(rect, &real_rect, &real_rect);
1759  }
1760 
1761  ret = SDL_LockTexture(texture, &real_rect, &pixels, &pitch);
1762  if (ret < 0) {
1763  return ret;
1764  }
1765 
1766  texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format);
1767  if (texture->locked_surface == NULL) {
1769  return -1;
1770  }
1771 
1772  *surface = texture->locked_surface;
1773  return 0;
1774 }

References SDL_Rect::h, NULL, rect, SDL_CreateRGBSurfaceWithFormatFrom, SDL_IntersectRect, SDL_LockTexture(), SDL_UnlockTexture(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

◆ SDL_LockTextureYUV()

static int SDL_LockTextureYUV ( SDL_Texture texture,
const SDL_Rect rect,
void **  pixels,
int *  pitch 
)
static

Definition at line 1681 of file SDL_render.c.

1683 {
1684  return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch);
1685 }

References rect, and SDL_SW_LockYUVTexture().

Referenced by SDL_LockTexture().

◆ SDL_QueryTexture()

int SDL_QueryTexture ( SDL_Texture texture,
Uint32 format,
int *  access,
int *  w,
int *  h 
)

Query the attributes of a texture.

Parameters
textureA texture to be queried.
formatA pointer filled in with the raw format of the texture. The actual format may differ, but pixel transfers will use this format.
accessA pointer filled in with the actual access to the texture.
wA pointer filled in with the width of the texture in pixels.
hA pointer filled in with the height of the texture in pixels.
Returns
0 on success, or -1 if the texture is not valid.

Definition at line 1288 of file SDL_render.c.

1290 {
1292 
1293  if (format) {
1294  *format = texture->format;
1295  }
1296  if (access) {
1297  *access = texture->access;
1298  }
1299  if (w) {
1300  *w = texture->w;
1301  }
1302  if (h) {
1303  *h = texture->h;
1304  }
1305  return 0;
1306 }

References CHECK_TEXTURE_MAGIC.

Referenced by SDL_GetRendererOutputSize().

◆ SDL_RenderClear()

int SDL_RenderClear ( SDL_Renderer renderer)

Clear the current rendering target with the drawing color.

This function clears the entire rendering target, ignoring the viewport and the clip rectangle.

Returns
0 on success, or -1 on error

Definition at line 2253 of file SDL_render.c.

2254 {
2255  int retval;
2259 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), QueueCmdClear(), renderer, and retval.

◆ SDL_RenderCopy()

int SDL_RenderCopy ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_Rect srcrect,
const SDL_Rect dstrect 
)

Copy a portion of the texture to the current rendering target.

Parameters
rendererThe renderer which should copy parts of a texture.
textureThe source texture.
srcrectA pointer to the source rectangle, or NULL for the entire texture.
dstrectA pointer to the destination rectangle, or NULL for the entire rendering target.
Returns
0 on success, or -1 on error

Definition at line 2929 of file SDL_render.c.

2931 {
2932  SDL_FRect dstfrect;
2933  SDL_FRect *pdstfrect = NULL;
2934  if (dstrect) {
2935  dstfrect.x = (float) dstrect->x;
2936  dstfrect.y = (float) dstrect->y;
2937  dstfrect.w = (float) dstrect->w;
2938  dstfrect.h = (float) dstrect->h;
2939  pdstfrect = &dstfrect;
2940  }
2941  return SDL_RenderCopyF(renderer, texture, srcrect, pdstfrect);
2942 }

References SDL_Rect::h, SDL_FRect::h, NULL, renderer, SDL_RenderCopyF(), SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

◆ SDL_RenderCopyEx()

int SDL_RenderCopyEx ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_Rect srcrect,
const SDL_Rect dstrect,
const double  angle,
const SDL_Point center,
const SDL_RendererFlip  flip 
)

Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center.

Parameters
rendererThe renderer which should copy parts of a texture.
textureThe source texture.
srcrectA pointer to the source rectangle, or NULL for the entire texture.
dstrectA pointer to the destination rectangle, or NULL for the entire rendering target.
angleAn angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
centerA pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
flipAn SDL_RendererFlip value stating which flipping actions should be performed on the texture
Returns
0 on success, or -1 on error

Definition at line 3004 of file SDL_render.c.

3007 {
3008  SDL_FRect dstfrect;
3009  SDL_FRect *pdstfrect = NULL;
3010  SDL_FPoint fcenter;
3011  SDL_FPoint *pfcenter = NULL;
3012 
3013  if (dstrect) {
3014  dstfrect.x = (float) dstrect->x;
3015  dstfrect.y = (float) dstrect->y;
3016  dstfrect.w = (float) dstrect->w;
3017  dstfrect.h = (float) dstrect->h;
3018  pdstfrect = &dstfrect;
3019  }
3020 
3021  if (center) {
3022  fcenter.x = (float) center->x;
3023  fcenter.y = (float) center->y;
3024  pfcenter = &fcenter;
3025  }
3026 
3027  return SDL_RenderCopyExF(renderer, texture, srcrect, pdstfrect, angle, pfcenter, flip);
3028 }

References SDL_Rect::h, SDL_FRect::h, NULL, renderer, SDL_RenderCopyExF(), SDL_Rect::w, SDL_FRect::w, SDL_Point::x, SDL_FPoint::x, SDL_Rect::x, SDL_FRect::x, SDL_Point::y, SDL_FPoint::y, SDL_Rect::y, and SDL_FRect::y.

◆ SDL_RenderCopyExF()

int SDL_RenderCopyExF ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_Rect srcrect,
const SDL_FRect dstrect,
const double  angle,
const SDL_FPoint center,
const SDL_RendererFlip  flip 
)

Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center.

Parameters
rendererThe renderer which should copy parts of a texture.
textureThe source texture.
srcrectA pointer to the source rectangle, or NULL for the entire texture.
dstrectA pointer to the destination rectangle, or NULL for the entire rendering target.
angleAn angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
centerA pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
flipAn SDL_RendererFlip value stating which flipping actions should be performed on the texture
Returns
0 on success, or -1 on error

Definition at line 3031 of file SDL_render.c.

3034 {
3035  SDL_Rect real_srcrect;
3036  SDL_FRect real_dstrect;
3037  SDL_FPoint real_center;
3038  int retval;
3039 
3040  if (flip == SDL_FLIP_NONE && (int)(angle/360) == angle/360) { /* fast path when we don't need rotation or flipping */
3041  return SDL_RenderCopyF(renderer, texture, srcrect, dstrect);
3042  }
3043 
3046 
3047  if (renderer != texture->renderer) {
3048  return SDL_SetError("Texture was not created with this renderer");
3049  }
3050  if (!renderer->QueueCopyEx) {
3051  return SDL_SetError("Renderer does not support RenderCopyEx");
3052  }
3053 
3054  /* Don't draw while we're hidden */
3055  if (renderer->hidden) {
3056  return 0;
3057  }
3058 
3059  real_srcrect.x = 0;
3060  real_srcrect.y = 0;
3061  real_srcrect.w = texture->w;
3062  real_srcrect.h = texture->h;
3063  if (srcrect) {
3064  if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
3065  return 0;
3066  }
3067  }
3068 
3069  /* We don't intersect the dstrect with the viewport as RenderCopy does because of potential rotation clipping issues... TODO: should we? */
3070  if (dstrect) {
3071  real_dstrect = *dstrect;
3072  } else {
3073  SDL_Rect r;
3074  SDL_zero(r);
3076  real_dstrect.x = 0.0f;
3077  real_dstrect.y = 0.0f;
3078  real_dstrect.w = (float) r.w;
3079  real_dstrect.h = (float) r.h;
3080  }
3081 
3082  if (texture->native) {
3083  texture = texture->native;
3084  }
3085 
3086  if (center) {
3087  real_center = *center;
3088  } else {
3089  real_center.x = real_dstrect.w / 2.0f;
3090  real_center.y = real_dstrect.h / 2.0f;
3091  }
3092 
3093  real_dstrect.x *= renderer->scale.x;
3094  real_dstrect.y *= renderer->scale.y;
3095  real_dstrect.w *= renderer->scale.x;
3096  real_dstrect.h *= renderer->scale.y;
3097 
3098  real_center.x *= renderer->scale.x;
3099  real_center.y *= renderer->scale.y;
3100 
3101  texture->last_command_generation = renderer->render_command_generation;
3102 
3103  retval = QueueCmdCopyEx(renderer, texture, &real_srcrect, &real_dstrect, angle, &real_center, flip);
3105 }

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, SDL_FRect::h, SDL_Renderer::hidden, QueueCmdCopyEx(), SDL_Renderer::QueueCopyEx, SDL_Renderer::render_command_generation, renderer, retval, SDL_Renderer::scale, SDL_FLIP_NONE, SDL_IntersectRect, SDL_RenderCopyF(), SDL_RenderGetViewport(), SDL_SetError, SDL_zero, SDL_Rect::w, SDL_FRect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FRect::x, SDL_FPoint::y, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderCopyEx().

◆ SDL_RenderCopyF()

int SDL_RenderCopyF ( SDL_Renderer renderer,
SDL_Texture texture,
const SDL_Rect srcrect,
const SDL_FRect dstrect 
)

Copy a portion of the texture to the current rendering target.

Parameters
rendererThe renderer which should copy parts of a texture.
textureThe source texture.
srcrectA pointer to the source rectangle, or NULL for the entire texture.
dstrectA pointer to the destination rectangle, or NULL for the entire rendering target.
Returns
0 on success, or -1 on error

Definition at line 2945 of file SDL_render.c.

2947 {
2948  SDL_Rect real_srcrect;
2949  SDL_FRect real_dstrect;
2950  SDL_Rect r;
2951  int retval;
2952 
2955 
2956  if (renderer != texture->renderer) {
2957  return SDL_SetError("Texture was not created with this renderer");
2958  }
2959 
2960  /* Don't draw while we're hidden */
2961  if (renderer->hidden) {
2962  return 0;
2963  }
2964 
2965  real_srcrect.x = 0;
2966  real_srcrect.y = 0;
2967  real_srcrect.w = texture->w;
2968  real_srcrect.h = texture->h;
2969  if (srcrect) {
2970  if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) {
2971  return 0;
2972  }
2973  }
2974 
2975  SDL_zero(r);
2977  real_dstrect.x = 0.0f;
2978  real_dstrect.y = 0.0f;
2979  real_dstrect.w = (float) r.w;
2980  real_dstrect.h = (float) r.h;
2981  if (dstrect) {
2982  if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) {
2983  return 0;
2984  }
2985  real_dstrect = *dstrect;
2986  }
2987 
2988  if (texture->native) {
2989  texture = texture->native;
2990  }
2991 
2992  real_dstrect.x *= renderer->scale.x;
2993  real_dstrect.y *= renderer->scale.y;
2994  real_dstrect.w *= renderer->scale.x;
2995  real_dstrect.h *= renderer->scale.y;
2996 
2997  texture->last_command_generation = renderer->render_command_generation;
2998 
2999  retval = QueueCmdCopy(renderer, texture, &real_srcrect, &real_dstrect);
3001 }

References CHECK_RENDERER_MAGIC, CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, SDL_FRect::h, SDL_Renderer::hidden, QueueCmdCopy(), SDL_Renderer::render_command_generation, renderer, retval, SDL_Renderer::scale, SDL_HasIntersectionF(), SDL_IntersectRect, SDL_RenderGetViewport(), SDL_SetError, SDL_zero, SDL_Rect::w, SDL_FRect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FRect::x, SDL_FPoint::y, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderCopy(), and SDL_RenderCopyExF().

◆ SDL_RenderDrawLine()

int SDL_RenderDrawLine ( SDL_Renderer renderer,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw a line on the current rendering target.

Parameters
rendererThe renderer which should draw a line.
x1The x coordinate of the start point.
y1The y coordinate of the start point.
x2The x coordinate of the end point.
y2The y coordinate of the end point.
Returns
0 on success, or -1 on error

Definition at line 2424 of file SDL_render.c.

2425 {
2426  SDL_FPoint points[2];
2427  points[0].x = (float) x1;
2428  points[0].y = (float) y1;
2429  points[1].x = (float) x2;
2430  points[1].y = (float) y2;
2431  return SDL_RenderDrawLinesF(renderer, points, 2);
2432 }

References renderer, SDL_RenderDrawLinesF(), and SDL_FPoint::x.

◆ SDL_RenderDrawLineF()

int SDL_RenderDrawLineF ( SDL_Renderer renderer,
float  x1,
float  y1,
float  x2,
float  y2 
)

Draw a line on the current rendering target.

Parameters
rendererThe renderer which should draw a line.
x1The x coordinate of the start point.
y1The y coordinate of the start point.
x2The x coordinate of the end point.
y2The y coordinate of the end point.
Returns
0 on success, or -1 on error

Definition at line 2435 of file SDL_render.c.

2436 {
2437  SDL_FPoint points[2];
2438  points[0].x = x1;
2439  points[0].y = y1;
2440  points[1].x = x2;
2441  points[1].y = y2;
2442  return SDL_RenderDrawLinesF(renderer, points, 2);
2443 }

References renderer, SDL_RenderDrawLinesF(), and SDL_FPoint::x.

◆ SDL_RenderDrawLines()

int SDL_RenderDrawLines ( SDL_Renderer renderer,
const SDL_Point points,
int  count 
)

Draw a series of connected lines on the current rendering target.

Parameters
rendererThe renderer which should draw multiple lines.
pointsThe points along the lines
countThe number of points, drawing count-1 lines
Returns
0 on success, or -1 on error

Definition at line 2556 of file SDL_render.c.

2558 {
2559  SDL_FPoint *fpoints;
2560  int i;
2561  int retval;
2562  SDL_bool isstack;
2563 
2565 
2566  if (!points) {
2567  return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
2568  }
2569  if (count < 2) {
2570  return 0;
2571  }
2572 
2573  /* Don't draw while we're hidden */
2574  if (renderer->hidden) {
2575  return 0;
2576  }
2577 
2578  if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
2580  }
2581 
2582  fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
2583  if (!fpoints) {
2584  return SDL_OutOfMemory();
2585  }
2586  for (i = 0; i < count; ++i) {
2587  fpoints[i].x = points[i].x * renderer->scale.x;
2588  fpoints[i].y = points[i].y * renderer->scale.y;
2589  }
2590 
2591  retval = QueueCmdDrawLines(renderer, fpoints, count);
2592 
2593  SDL_small_free(fpoints, isstack);
2594 
2596 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawLines(), RenderDrawLinesWithRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

◆ SDL_RenderDrawLinesF()

int SDL_RenderDrawLinesF ( SDL_Renderer renderer,
const SDL_FPoint points,
int  count 
)

Draw a series of connected lines on the current rendering target.

Parameters
rendererThe renderer which should draw multiple lines.
pointsThe points along the lines
countThe number of points, drawing count-1 lines
Returns
0 on success, or -1 on error

Definition at line 2599 of file SDL_render.c.

2601 {
2602  SDL_FPoint *fpoints;
2603  int i;
2604  int retval;
2605  SDL_bool isstack;
2606 
2608 
2609  if (!points) {
2610  return SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
2611  }
2612  if (count < 2) {
2613  return 0;
2614  }
2615 
2616  /* Don't draw while we're hidden */
2617  if (renderer->hidden) {
2618  return 0;
2619  }
2620 
2621  if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
2623  }
2624 
2625  fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
2626  if (!fpoints) {
2627  return SDL_OutOfMemory();
2628  }
2629  for (i = 0; i < count; ++i) {
2630  fpoints[i].x = points[i].x * renderer->scale.x;
2631  fpoints[i].y = points[i].y * renderer->scale.y;
2632  }
2633 
2634  retval = QueueCmdDrawLines(renderer, fpoints, count);
2635 
2636  SDL_small_free(fpoints, isstack);
2637 
2639 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawLines(), RenderDrawLinesWithRectsF(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_RenderDrawLine(), SDL_RenderDrawLineF(), and SDL_RenderDrawRectF().

◆ SDL_RenderDrawPoint()

int SDL_RenderDrawPoint ( SDL_Renderer renderer,
int  x,
int  y 
)

Draw a point on the current rendering target.

Parameters
rendererThe renderer which should draw a point.
xThe x coordinate of the point.
yThe y coordinate of the point.
Returns
0 on success, or -1 on error

Definition at line 2266 of file SDL_render.c.

2267 {
2268  SDL_FPoint fpoint;
2269  fpoint.x = (float) x;
2270  fpoint.y = (float) y;
2271  return SDL_RenderDrawPointsF(renderer, &fpoint, 1);
2272 }

References renderer, SDL_RenderDrawPointsF(), SDL_FPoint::x, and SDL_FPoint::y.

◆ SDL_RenderDrawPointF()

int SDL_RenderDrawPointF ( SDL_Renderer renderer,
float  x,
float  y 
)

Draw a point on the current rendering target.

Parameters
rendererThe renderer which should draw a point.
xThe x coordinate of the point.
yThe y coordinate of the point.
Returns
0 on success, or -1 on error

Definition at line 2275 of file SDL_render.c.

2276 {
2277  SDL_FPoint fpoint;
2278  fpoint.x = x;
2279  fpoint.y = y;
2280  return SDL_RenderDrawPointsF(renderer, &fpoint, 1);
2281 }

References renderer, SDL_RenderDrawPointsF(), SDL_FPoint::x, and SDL_FPoint::y.

◆ SDL_RenderDrawPoints()

int SDL_RenderDrawPoints ( SDL_Renderer renderer,
const SDL_Point points,
int  count 
)

Draw multiple points on the current rendering target.

Parameters
rendererThe renderer which should draw multiple points.
pointsThe points to draw
countThe number of points to draw
Returns
0 on success, or -1 on error

Definition at line 2311 of file SDL_render.c.

2313 {
2314  SDL_FPoint *fpoints;
2315  int i;
2316  int retval;
2317  SDL_bool isstack;
2318 
2320 
2321  if (!points) {
2322  return SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
2323  }
2324  if (count < 1) {
2325  return 0;
2326  }
2327 
2328  /* Don't draw while we're hidden */
2329  if (renderer->hidden) {
2330  return 0;
2331  }
2332 
2333  if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
2335  }
2336 
2337  fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
2338  if (!fpoints) {
2339  return SDL_OutOfMemory();
2340  }
2341  for (i = 0; i < count; ++i) {
2342  fpoints[i].x = points[i].x * renderer->scale.x;
2343  fpoints[i].y = points[i].y * renderer->scale.y;
2344  }
2345 
2346  retval = QueueCmdDrawPoints(renderer, fpoints, count);
2347 
2348  SDL_small_free(fpoints, isstack);
2349 
2351 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawPoints(), RenderDrawPointsWithRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

◆ SDL_RenderDrawPointsF()

int SDL_RenderDrawPointsF ( SDL_Renderer renderer,
const SDL_FPoint points,
int  count 
)

Draw multiple points on the current rendering target.

Parameters
rendererThe renderer which should draw multiple points.
pointsThe points to draw
countThe number of points to draw
Returns
0 on success, or -1 on error

Definition at line 2381 of file SDL_render.c.

2383 {
2384  SDL_FPoint *fpoints;
2385  int i;
2386  int retval;
2387  SDL_bool isstack;
2388 
2390 
2391  if (!points) {
2392  return SDL_SetError("SDL_RenderDrawFPoints(): Passed NULL points");
2393  }
2394  if (count < 1) {
2395  return 0;
2396  }
2397 
2398  /* Don't draw while we're hidden */
2399  if (renderer->hidden) {
2400  return 0;
2401  }
2402 
2403  if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
2405  }
2406 
2407  fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
2408  if (!fpoints) {
2409  return SDL_OutOfMemory();
2410  }
2411  for (i = 0; i < count; ++i) {
2412  fpoints[i].x = points[i].x * renderer->scale.x;
2413  fpoints[i].y = points[i].y * renderer->scale.y;
2414  }
2415 
2416  retval = QueueCmdDrawPoints(renderer, fpoints, count);
2417 
2418  SDL_small_free(fpoints, isstack);
2419 
2421 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Renderer::hidden, i, QueueCmdDrawPoints(), RenderDrawPointsWithRectsF(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_RenderDrawPoint(), and SDL_RenderDrawPointF().

◆ SDL_RenderDrawRect()

int SDL_RenderDrawRect ( SDL_Renderer renderer,
const SDL_Rect rect 
)

Draw a rectangle on the current rendering target.

Parameters
rendererThe renderer which should draw a rectangle.
rectA pointer to the destination rectangle, or NULL to outline the entire rendering target.
Returns
0 on success, or -1 on error

Definition at line 2642 of file SDL_render.c.

2643 {
2644  SDL_FRect frect;
2645  SDL_FRect *prect = NULL;
2646 
2647  if (rect) {
2648  frect.x = (float) rect->x;
2649  frect.y = (float) rect->y;
2650  frect.w = (float) rect->w;
2651  frect.h = (float) rect->h;
2652  prect = &frect;
2653  }
2654 
2655  return SDL_RenderDrawRectF(renderer, prect);
2656 }

References SDL_Rect::h, SDL_FRect::h, NULL, rect, renderer, SDL_RenderDrawRectF(), SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawRects().

◆ SDL_RenderDrawRectF()

int SDL_RenderDrawRectF ( SDL_Renderer renderer,
const SDL_FRect rect 
)

Draw a rectangle on the current rendering target.

Parameters
rendererThe renderer which should draw a rectangle.
rectA pointer to the destination rectangle, or NULL to outline the entire rendering target.
Returns
0 on success, or -1 on error

Definition at line 2659 of file SDL_render.c.

2660 {
2661  SDL_FRect frect;
2662  SDL_FPoint points[5];
2663 
2665 
2666  /* If 'rect' == NULL, then outline the whole surface */
2667  if (!rect) {
2668  SDL_Rect r;
2670  frect.x = 0.0f;
2671  frect.y = 0.0f;
2672  frect.w = (float) r.w;
2673  frect.h = (float) r.h;
2674  rect = &frect;
2675  }
2676 
2677  points[0].x = rect->x;
2678  points[0].y = rect->y;
2679  points[1].x = rect->x+rect->w-1;
2680  points[1].y = rect->y;
2681  points[2].x = rect->x+rect->w-1;
2682  points[2].y = rect->y+rect->h-1;
2683  points[3].x = rect->x;
2684  points[3].y = rect->y+rect->h-1;
2685  points[4].x = rect->x;
2686  points[4].y = rect->y;
2687  return SDL_RenderDrawLinesF(renderer, points, 5);
2688 }

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_FRect::h, rect, renderer, SDL_RenderDrawLinesF(), SDL_RenderGetViewport(), SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

Referenced by SDL_RenderDrawRect(), and SDL_RenderDrawRectsF().

◆ SDL_RenderDrawRects()

int SDL_RenderDrawRects ( SDL_Renderer renderer,
const SDL_Rect rects,
int  count 
)

Draw some number of rectangles on the current rendering target.

Parameters
rendererThe renderer which should draw multiple rectangles.
rectsA pointer to an array of destination rectangles.
countThe number of rectangles.
Returns
0 on success, or -1 on error

Definition at line 2691 of file SDL_render.c.

2693 {
2694  int i;
2695 
2697 
2698  if (!rects) {
2699  return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
2700  }
2701  if (count < 1) {
2702  return 0;
2703  }
2704 
2705  /* Don't draw while we're hidden */
2706  if (renderer->hidden) {
2707  return 0;
2708  }
2709 
2710  for (i = 0; i < count; ++i) {
2711  if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) {
2712  return -1;
2713  }
2714  }
2715  return 0;
2716 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, i, renderer, SDL_RenderDrawRect(), and SDL_SetError.

◆ SDL_RenderDrawRectsF()

int SDL_RenderDrawRectsF ( SDL_Renderer renderer,
const SDL_FRect rects,
int  count 
)

Draw some number of rectangles on the current rendering target.

Parameters
rendererThe renderer which should draw multiple rectangles.
rectsA pointer to an array of destination rectangles.
countThe number of rectangles.
Returns
0 on success, or -1 on error

Definition at line 2719 of file SDL_render.c.

2721 {
2722  int i;
2723 
2725 
2726  if (!rects) {
2727  return SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
2728  }
2729  if (count < 1) {
2730  return 0;
2731  }
2732 
2733  /* Don't draw while we're hidden */
2734  if (renderer->hidden) {
2735  return 0;
2736  }
2737 
2738  for (i = 0; i < count; ++i) {
2739  if (SDL_RenderDrawRectF(renderer, &rects[i]) < 0) {
2740  return -1;
2741  }
2742  }
2743  return 0;
2744 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::hidden, i, renderer, SDL_RenderDrawRectF(), and SDL_SetError.

◆ SDL_RendererEventWatch()

static int SDL_RendererEventWatch ( void userdata,
SDL_Event event 
)
static

Definition at line 588 of file SDL_render.c.

589 {
590  SDL_Renderer *renderer = (SDL_Renderer *)userdata;
591 
592  if (event->type == SDL_WINDOWEVENT) {
593  SDL_Window *window = SDL_GetWindowFromID(event->window.windowID);
594  if (window == renderer->window) {
595  if (renderer->WindowEvent) {
597  }
598 
599  if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
600  /* Make sure we're operating on the default render target */
601  SDL_Texture *saved_target = SDL_GetRenderTarget(renderer);
602  if (saved_target) {
604  }
605 
606  if (renderer->logical_w) {
608  } else {
609  /* Window was resized, reset viewport */
610  int w, h;
611 
612  if (renderer->GetOutputSize) {
614  } else {
616  }
617 
618  if (renderer->target) {
623  } else {
624  renderer->viewport.x = 0;
625  renderer->viewport.y = 0;
626  renderer->viewport.w = w;
627  renderer->viewport.h = h;
630  }
631  }
632 
633  if (saved_target) {
634  SDL_SetRenderTarget(renderer, saved_target);
635  }
636  } else if (event->window.event == SDL_WINDOWEVENT_HIDDEN) {
638  } else if (event->window.event == SDL_WINDOWEVENT_SHOWN) {
641  }
642  } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) {
644  } else if (event->window.event == SDL_WINDOWEVENT_RESTORED ||
645  event->window.event == SDL_WINDOWEVENT_MAXIMIZED) {
648  }
649  }
650  }
651  } else if (event->type == SDL_MOUSEMOTION) {
652  SDL_Window *window = SDL_GetWindowFromID(event->motion.windowID);
653  if (window == renderer->window) {
654  int logical_w, logical_h;
657  GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale);
658  if (logical_w) {
659  event->motion.x -= (int)(viewport.x * renderer->dpi_scale.x);
660  event->motion.y -= (int)(viewport.y * renderer->dpi_scale.y);
661  event->motion.x = (int)(event->motion.x / (scale.x * renderer->dpi_scale.x));
662  event->motion.y = (int)(event->motion.y / (scale.y * renderer->dpi_scale.y));
663  if (event->motion.xrel > 0) {
664  event->motion.xrel = SDL_max(1, (int)(event->motion.xrel / (scale.x * renderer->dpi_scale.x)));
665  } else if (event->motion.xrel < 0) {
666  event->motion.xrel = SDL_min(-1, (int)(event->motion.xrel / (scale.x * renderer->dpi_scale.x)));
667  }
668  if (event->motion.yrel > 0) {
669  event->motion.yrel = SDL_max(1, (int)(event->motion.yrel / (scale.y * renderer->dpi_scale.y)));
670  } else if (event->motion.yrel < 0) {
671  event->motion.yrel = SDL_min(-1, (int)(event->motion.yrel / (scale.y * renderer->dpi_scale.y)));
672  }
673  }
674  }
675  } else if (event->type == SDL_MOUSEBUTTONDOWN ||
676  event->type == SDL_MOUSEBUTTONUP) {
677  SDL_Window *window = SDL_GetWindowFromID(event->button.windowID);
678  if (window == renderer->window) {
679  int logical_w, logical_h;
682  GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale);
683  if (logical_w) {
684  event->button.x -= (int)(viewport.x * renderer->dpi_scale.x);
685  event->button.y -= (int)(viewport.y * renderer->dpi_scale.y);
686  event->button.x = (int)(event->button.x / (scale.x * renderer->dpi_scale.x));
687  event->button.y = (int)(event->button.y / (scale.y * renderer->dpi_scale.y));
688  }
689  }
690  } else if (event->type == SDL_FINGERDOWN ||
691  event->type == SDL_FINGERUP ||
692  event->type == SDL_FINGERMOTION) {
693  int logical_w, logical_h;
696  GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale);
697  if (logical_w) {
698  int w, h;
699 
700  if (renderer->GetOutputSize) {
702  } else {
704  }
705 
706  event->tfinger.x *= (w - 1);
707  event->tfinger.y *= (h - 1);
708 
709  event->tfinger.x -= (viewport.x * renderer->dpi_scale.x);
710  event->tfinger.y -= (viewport.y * renderer->dpi_scale.y);
711  event->tfinger.x = (event->tfinger.x / (scale.x * renderer->dpi_scale.x));
712  event->tfinger.y = (event->tfinger.y / (scale.y * renderer->dpi_scale.y));
713 
714  if (logical_w > 1) {
715  event->tfinger.x = event->tfinger.x / (logical_w - 1);
716  } else {
717  event->tfinger.x = 0.5f;
718  }
719  if (logical_h > 1) {
720  event->tfinger.y = event->tfinger.y / (logical_h - 1);
721  } else {
722  event->tfinger.y = 0.5f;
723  }
724  }
725  }
726 
727  return 0;
728 }

References SDL_Renderer::dpi_scale, FlushRenderCommandsIfNotBatching(), SDL_Renderer::GetOutputSize, GetWindowViewportValues(), SDL_Rect::h, SDL_Renderer::hidden, SDL_Renderer::logical_w, NULL, QueueCmdSetViewport(), renderer, SDL_FALSE, SDL_FINGERDOWN, SDL_FINGERMOTION, SDL_FINGERUP, SDL_GetRenderTarget(), SDL_GetWindowFlags, SDL_GetWindowFromID, SDL_GetWindowSize, SDL_max, SDL_min, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEMOTION, SDL_SetRenderTarget(), SDL_TRUE, SDL_WINDOW_HIDDEN, SDL_WINDOW_MINIMIZED, SDL_WINDOWEVENT, SDL_WINDOWEVENT_HIDDEN, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_MINIMIZED, SDL_WINDOWEVENT_RESTORED, SDL_WINDOWEVENT_SHOWN, SDL_WINDOWEVENT_SIZE_CHANGED, SDL_Renderer::target, UpdateLogicalSize(), viewport, SDL_Renderer::viewport, SDL_Renderer::viewport_backup, SDL_Rect::w, SDL_Renderer::window, SDL_Renderer::WindowEvent, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_CreateRenderer(), and SDL_DestroyRenderer().

◆ SDL_RenderFillRect()

int SDL_RenderFillRect ( SDL_Renderer renderer,
const SDL_Rect rect 
)

Fill a rectangle on the current rendering target with the drawing color.

Parameters
rendererThe renderer which should fill a rectangle.
rectA pointer to the destination rectangle, or NULL for the entire rendering target.
Returns
0 on success, or -1 on error

Definition at line 2747 of file SDL_render.c.

2748 {
2749  SDL_FRect frect;
2750 
2752 
2753  /* If 'rect' == NULL, then outline the whole surface */
2754  if (rect) {
2755  frect.x = (float) rect->x;
2756  frect.y = (float) rect->y;
2757  frect.w = (float) rect->w;
2758  frect.h = (float) rect->h;
2759  } else {
2760  SDL_Rect r;
2761  SDL_zero(r);
2763  frect.x = 0.0f;
2764  frect.y = 0.0f;
2765  frect.w = (float) r.w;
2766  frect.h = (float) r.h;
2767  }
2768  return SDL_RenderFillRectsF(renderer, &frect, 1);
2769 }

References CHECK_RENDERER_MAGIC, SDL_Rect::h, SDL_FRect::h, rect, renderer, SDL_RenderFillRectsF(), SDL_RenderGetViewport(), SDL_zero, SDL_Rect::w, SDL_FRect::w, SDL_Rect::x, SDL_FRect::x, SDL_Rect::y, and SDL_FRect::y.

◆ SDL_RenderFillRectF()

int SDL_RenderFillRectF ( SDL_Renderer renderer,
const SDL_FRect rect 
)

Fill a rectangle on the current rendering target with the drawing color.

Parameters
rendererThe renderer which should fill a rectangle.
rectA pointer to the destination rectangle, or NULL for the entire rendering target.
Returns
0 on success, or -1 on error

Definition at line 2772 of file SDL_render.c.

2773 {
2774  SDL_FRect frect;
2775 
2777 
2778  /* If 'rect' == NULL, then outline the whole surface */
2779  if (!rect) {
2780  SDL_Rect r;
2781  SDL_zero(r);
2783  frect.x = 0.0f;
2784  frect.y = 0.0f;
2785  frect.w = (float) r.w;
2786  frect.h = (float) r.h;
2787  rect = &frect;
2788  }
2789  return SDL_RenderFillRectsF(renderer, rect, 1);
2790 }

References CHECK_RENDERER_MAGIC, SDL_FRect::h, rect, renderer, SDL_RenderFillRectsF(), SDL_RenderGetViewport(), SDL_zero, SDL_FRect::w, SDL_FRect::x, and SDL_FRect::y.

◆ SDL_RenderFillRects()

int SDL_RenderFillRects ( SDL_Renderer renderer,
const SDL_Rect rects,
int  count 
)

Fill some number of rectangles on the current rendering target with the drawing color.

Parameters
rendererThe renderer which should fill multiple rectangles.
rectsA pointer to an array of destination rectangles.
countThe number of rectangles.
Returns
0 on success, or -1 on error

Definition at line 2793 of file SDL_render.c.

2795 {
2796  SDL_FRect *frects;
2797  int i;
2798  int retval;
2799  SDL_bool isstack;
2800 
2802 
2803  if (!rects) {
2804  return SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
2805  }
2806  if (count < 1) {
2807  return 0;
2808  }
2809 
2810  /* Don't draw while we're hidden */
2811  if (renderer->hidden) {
2812  return 0;
2813  }
2814 
2815  frects = SDL_small_alloc(SDL_FRect, count, &isstack);
2816  if (!frects) {
2817  return SDL_OutOfMemory();
2818  }
2819  for (i = 0; i < count; ++i) {
2820  frects[i].x = rects[i].x * renderer->scale.x;
2821  frects[i].y = rects[i].y * renderer->scale.y;
2822  frects[i].w = rects[i].w * renderer->scale.x;
2823  frects[i].h = rects[i].h * renderer->scale.y;
2824  }
2825 
2826  retval = QueueCmdFillRects(renderer, frects, count);
2827 
2828  SDL_small_free(frects, isstack);
2829 
2831 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_FRect::h, SDL_Renderer::hidden, i, QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

◆ SDL_RenderFillRectsF()

int SDL_RenderFillRectsF ( SDL_Renderer renderer,
const SDL_FRect rects,
int  count 
)

Fill some number of rectangles on the current rendering target with the drawing color.

Parameters
rendererThe renderer which should fill multiple rectangles.
rectsA pointer to an array of destination rectangles.
countThe number of rectangles.
Returns
0 on success, or -1 on error

Definition at line 2834 of file SDL_render.c.

2836 {
2837  SDL_FRect *frects;
2838  int i;
2839  int retval;
2840  SDL_bool isstack;
2841 
2843 
2844  if (!rects) {
2845  return SDL_SetError("SDL_RenderFillFRects(): Passed NULL rects");
2846  }
2847  if (count < 1) {
2848  return 0;
2849  }
2850 
2851  /* Don't draw while we're hidden */
2852  if (renderer->hidden) {
2853  return 0;
2854  }
2855 
2856  frects = SDL_small_alloc(SDL_FRect, count, &isstack);
2857  if (!frects) {
2858  return SDL_OutOfMemory();
2859  }
2860  for (i = 0; i < count; ++i) {
2861  frects[i].x = rects[i].x * renderer->scale.x;
2862  frects[i].y = rects[i].y * renderer->scale.y;
2863  frects[i].w = rects[i].w * renderer->scale.x;
2864  frects[i].h = rects[i].h * renderer->scale.y;
2865  }
2866 
2867  retval = QueueCmdFillRects(renderer, frects, count);
2868 
2869  SDL_small_free(frects, isstack);
2870 
2872 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_FRect::h, SDL_Renderer::hidden, i, QueueCmdFillRects(), renderer, retval, SDL_Renderer::scale, SDL_OutOfMemory, SDL_SetError, SDL_small_alloc, SDL_small_free, SDL_FRect::w, SDL_FPoint::x, SDL_FRect::x, SDL_FPoint::y, and SDL_FRect::y.

Referenced by SDL_RenderFillRect(), and SDL_RenderFillRectF().

◆ SDL_RenderFlush()

int SDL_RenderFlush ( SDL_Renderer renderer)

Force the rendering context to flush any pending commands to the underlying rendering API.

You do not need to (and in fact, shouldn't) call this function unless you are planning to call into OpenGL/Direct3D/Metal/whatever directly in addition to using an SDL_Renderer.

This is for a very-specific case: if you are using SDL's render API, you asked for a specific renderer backend (OpenGL, Direct3D, etc), you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of this applies, you should call SDL_RenderFlush() between calls to SDL's render API and the low-level API you're using in cooperation.

In all other cases, you can ignore this function. This is only here to get maximum performance out of a specific situation. In all other cases, SDL will do the right thing, perhaps at a performance loss.

This function is first available in SDL 2.0.10, and is not needed in 2.0.9 and earlier, as earlier versions did not queue rendering commands at all, instead flushing them to the OS immediately.

Definition at line 257 of file SDL_render.c.

258 {
260 }

References FlushRenderCommands(), and renderer.

◆ SDL_RenderGetClipRect()

void SDL_RenderGetClipRect ( SDL_Renderer renderer,
SDL_Rect rect 
)

Get the clip rectangle for the current target.

Parameters
rendererThe renderer from which clip rectangle should be queried.
rectA pointer filled in with the current clip rectangle, or an empty rectangle if clipping is disabled.
See also
SDL_RenderSetClipRect()

Definition at line 2155 of file SDL_render.c.

2156 {
2158 
2159  if (rect) {
2160  rect->x = (int)(renderer->clip_rect.x / renderer->scale.x);
2161  rect->y = (int)(renderer->clip_rect.y / renderer->scale.y);
2162  rect->w = (int)(renderer->clip_rect.w / renderer->scale.x);
2163  rect->h = (int)(renderer->clip_rect.h / renderer->scale.y);
2164  }
2165 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::clip_rect, SDL_Rect::h, rect, renderer, SDL_Renderer::scale, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

◆ SDL_RenderGetIntegerScale()

SDL_bool SDL_RenderGetIntegerScale ( SDL_Renderer renderer)

Get whether integer scales are forced for resolution-independent rendering.

Parameters
rendererThe renderer from which integer scaling should be queried.
See also
SDL_RenderSetIntegerScale()

Definition at line 2091 of file SDL_render.c.

2092 {
2094 
2095  return renderer->integer_scale;
2096 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::integer_scale, renderer, and SDL_FALSE.

◆ SDL_RenderGetLogicalSize()

void SDL_RenderGetLogicalSize ( SDL_Renderer renderer,
int *  w,
int *  h 
)

Get device independent resolution for rendering.

Parameters
rendererThe renderer from which resolution should be queried.
wA pointer filled with the width of the logical resolution
hA pointer filled with the height of the logical resolution
See also
SDL_RenderSetLogicalSize()

Definition at line 2068 of file SDL_render.c.

2069 {
2071 
2072  if (w) {
2073  *w = renderer->logical_w;
2074  }
2075  if (h) {
2076  *h = renderer->logical_h;
2077  }
2078 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::logical_h, SDL_Renderer::logical_w, and renderer.

◆ SDL_RenderGetMetalCommandEncoder()

void* SDL_RenderGetMetalCommandEncoder ( SDL_Renderer renderer)

Get the Metal command encoder for the current frame.

Parameters
rendererThe renderer to query
Returns
id<MTLRenderCommandEncoder> on success, or NULL if the renderer isn't a Metal renderer
See also
SDL_RenderGetMetalLayer()

Definition at line 3298 of file SDL_render.c.

3299 {
3301 
3303  FlushRenderCommands(renderer); /* in case the app is going to mess with it. */
3305  }
3306  return NULL;
3307 }

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Renderer::GetMetalCommandEncoder, NULL, and renderer.

◆ SDL_RenderGetMetalLayer()

void* SDL_RenderGetMetalLayer ( SDL_Renderer renderer)

Get the CAMetalLayer associated with the given Metal renderer.

Parameters
rendererThe renderer to query
Returns
CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer
See also
SDL_RenderGetMetalCommandEncoder()

Definition at line 3286 of file SDL_render.c.

3287 {
3289 
3290  if (renderer->GetMetalLayer) {
3291  FlushRenderCommands(renderer); /* in case the app is going to mess with it. */
3292  return renderer->GetMetalLayer(renderer);
3293  }
3294  return NULL;
3295 }

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Renderer::GetMetalLayer, NULL, and renderer.

◆ SDL_RenderGetScale()

void SDL_RenderGetScale ( SDL_Renderer renderer,
float *  scaleX,
float *  scaleY 
)

Get the drawing scale for the current target.

Parameters
rendererThe renderer from which drawing scale should be queried.
scaleXA pointer filled in with the horizontal scaling factor
scaleYA pointer filled in with the vertical scaling factor
See also
SDL_RenderSetScale()

Definition at line 2185 of file SDL_render.c.

2186 {
2188 
2189  if (scaleX) {
2190  *scaleX = renderer->scale.x;
2191  }
2192  if (scaleY) {
2193  *scaleY = renderer->scale.y;
2194  }
2195 }

References CHECK_RENDERER_MAGIC, renderer, SDL_Renderer::scale, SDL_FPoint::x, and SDL_FPoint::y.

◆ SDL_RenderGetViewport()

void SDL_RenderGetViewport ( SDL_Renderer renderer,
SDL_Rect rect 
)

Get the drawing area for the current target.

See also
SDL_RenderSetViewport()

Definition at line 2121 of file SDL_render.c.

2122 {
2124 
2125  if (rect) {
2126  rect->x = (int)(renderer->viewport.x / renderer->scale.x);
2127  rect->y = (int)(renderer->viewport.y / renderer->scale.y);
2128  rect->w = (int)(renderer->viewport.w / renderer->scale.x);
2129  rect->h = (int)(renderer->viewport.h / renderer->scale.y);
2130  }
2131 }

References CHECK_RENDERER_MAGIC, SDL_Rect::h, rect, renderer, SDL_Renderer::scale, SDL_Renderer::viewport, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_RenderCopyExF(), SDL_RenderCopyF(), SDL_RenderDrawRectF(), SDL_RenderFillRect(), and SDL_RenderFillRectF().

◆ SDL_RenderIsClipEnabled()

SDL_bool SDL_RenderIsClipEnabled ( SDL_Renderer renderer)

Get whether clipping is enabled on the given renderer.

Parameters
rendererThe renderer from which clip state should be queried.
See also
SDL_RenderGetClipRect()

Definition at line 2168 of file SDL_render.c.

2169 {
2171  return renderer->clipping_enabled;
2172 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::clipping_enabled, renderer, and SDL_FALSE.

◆ SDL_RenderPresent()

void SDL_RenderPresent ( SDL_Renderer renderer)

Update the screen with rendering performed.

Definition at line 3147 of file SDL_render.c.

3148 {
3150 
3151  FlushRenderCommands(renderer); /* time to send everything to the GPU! */
3152 
3153  /* Don't present while we're hidden */
3154  if (renderer->hidden) {
3155  return;
3156  }
3158 }

References CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Renderer::hidden, renderer, and SDL_Renderer::RenderPresent.

◆ SDL_RenderReadPixels()

int SDL_RenderReadPixels ( SDL_Renderer renderer,
const SDL_Rect rect,
Uint32  format,
void pixels,
int  pitch 
)

Read pixels from the current rendering target.

Parameters
rendererThe renderer from which pixels should be read.
rectA pointer to the rectangle to read, or NULL for the entire render target.
formatThe desired format of the pixel data, or 0 to use the format of the rendering target
pixelsA pointer to be filled in with the pixel data
pitchThe pitch of the pixels parameter.
Returns
0 on success, or -1 if pixel reading is not supported.
Warning
This is a very slow operation, and should not be used frequently.

Definition at line 3108 of file SDL_render.c.

3110 {
3111  SDL_Rect real_rect;
3112 
3114 
3115  if (!renderer->RenderReadPixels) {
3116  return SDL_Unsupported();
3117  }
3118 
3119  FlushRenderCommands(renderer); /* we need to render before we read the results. */
3120 
3121  if (!format) {
3123  }
3124 
3125  real_rect.x = renderer->viewport.x;
3126  real_rect.y = renderer->viewport.y;
3127  real_rect.w = renderer->viewport.w;
3128  real_rect.h = renderer->viewport.h;
3129  if (rect) {
3130  if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
3131  return 0;
3132  }
3133  if (real_rect.y > rect->y) {
3134  pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y);
3135  }
3136  if (real_rect.x > rect->x) {
3137  int bpp = SDL_BYTESPERPIXEL(format);
3138  pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x);
3139  }
3140  }
3141 
3142  return renderer->RenderReadPixels(renderer, &real_rect,
3143  format, pixels, pitch);
3144 }

References bpp, CHECK_RENDERER_MAGIC, FlushRenderCommands(), SDL_Rect::h, rect, renderer, SDL_Renderer::RenderReadPixels, SDL_BYTESPERPIXEL, SDL_GetWindowPixelFormat, SDL_IntersectRect, SDL_Unsupported, SDL_Renderer::viewport, SDL_Rect::w, SDL_Renderer::window, SDL_Rect::x, and SDL_Rect::y.

◆ SDL_RenderSetClipRect()

int SDL_RenderSetClipRect ( SDL_Renderer renderer,
const SDL_Rect rect 
)

Set the clip rectangle for the current target.

Parameters
rendererThe renderer for which clip rectangle should be set.
rectA pointer to the rectangle to set as the clip rectangle, relative to the viewport, or NULL to disable clipping.
Returns
0 on success, or -1 on error
See also
SDL_RenderGetClipRect()

Definition at line 2134 of file SDL_render.c.

2135 {
2136  int retval;
2138 
2139  if (rect) {
2143  renderer->clip_rect.w = (int)SDL_ceil(rect->w * renderer->scale.x);
2144  renderer->clip_rect.h = (int)SDL_ceil(rect->h * renderer->scale.y);
2145  } else {
2148  }
2149 
2152 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::clip_rect, SDL_Renderer::clipping_enabled, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, QueueCmdSetClipRect(), rect, renderer, retval, SDL_Renderer::scale, SDL_ceil, SDL_FALSE, SDL_floor, SDL_TRUE, SDL_zero, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

◆ SDL_RenderSetIntegerScale()

int SDL_RenderSetIntegerScale ( SDL_Renderer renderer,
SDL_bool  enable 
)

Set whether to force integer scales for resolution-independent rendering.

Parameters
rendererThe renderer for which integer scaling should be set.
enableEnable or disable integer scaling

This function restricts the logical viewport to integer values - that is, when a resolution is between two multiples of a logical size, the viewport size is rounded down to the lower multiple.

See also
SDL_RenderSetLogicalSize()

Definition at line 2081 of file SDL_render.c.

2082 {
2084 
2086 
2087  return UpdateLogicalSize(renderer);
2088 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::integer_scale, renderer, and UpdateLogicalSize().

◆ SDL_RenderSetLogicalSize()

int SDL_RenderSetLogicalSize ( SDL_Renderer renderer,
int  w,
int  h 
)

Set device independent resolution for rendering.

Parameters
rendererThe renderer for which resolution should be set.
wThe width of the logical resolution
hThe height of the logical resolution

This function uses the viewport and scaling functionality to allow a fixed logical resolution for rendering, regardless of the actual output resolution. If the actual output resolution doesn't have the same aspect ratio the output rendering will be centered within the output display.

If the output display is a window, mouse events in the window will be filtered and scaled so they seem to arrive within the logical resolution.

Note
If this function results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints.
See also
SDL_RenderGetLogicalSize()
SDL_RenderSetScale()
SDL_RenderSetViewport()

Definition at line 2048 of file SDL_render.c.

2049 {
2051 
2052  if (!w || !h) {
2053  /* Clear any previous logical resolution */
2054  renderer->logical_w = 0;
2055  renderer->logical_h = 0;
2057  SDL_RenderSetScale(renderer, 1.0f, 1.0f);
2058  return 0;
2059  }
2060 
2061  renderer->logical_w = w;
2062  renderer->logical_h = h;
2063 
2064  return UpdateLogicalSize(renderer);
2065 }

References CHECK_RENDERER_MAGIC, SDL_Renderer::logical_h, SDL_Renderer::logical_w, NULL, renderer, SDL_RenderSetScale(), SDL_RenderSetViewport(), and UpdateLogicalSize().

◆ SDL_RenderSetScale()

int SDL_RenderSetScale ( SDL_Renderer renderer,
float  scaleX,
float  scaleY 
)

Set the drawing scale for rendering on the current target.

Parameters
rendererThe renderer for which the drawing scale should be set.
scaleXThe horizontal scaling factor
scaleYThe vertical scaling factor

The drawing coordinates are scaled by the x/y scaling factors before they are used by the renderer. This allows resolution independent drawing with a single coordinate system.

Note
If this results in scaling or subpixel drawing by the rendering backend, it will be handled using the appropriate quality hints. For best results use integer scaling factors.
See also
SDL_RenderGetScale()
SDL_RenderSetLogicalSize()

Definition at line 2175 of file SDL_render.c.

2176 {
2178 
2179  renderer->scale.x = scaleX;
2180  renderer->scale.y = scaleY;
2181  return 0;
2182 }

References CHECK_RENDERER_MAGIC, renderer, SDL_Renderer::scale, SDL_FPoint::x, and SDL_FPoint::y.

Referenced by SDL_RenderSetLogicalSize(), and UpdateLogicalSize().

◆ SDL_RenderSetViewport()

int SDL_RenderSetViewport ( SDL_Renderer renderer,
const SDL_Rect rect 
)

Set the drawing area for rendering on the current target.

Parameters
rendererThe renderer for which the drawing area should be set.
rectThe rectangle representing the drawing area, or NULL to set the viewport to the entire target.

The x,y of the viewport rect represents the origin for rendering.

Returns
0 on success, or -1 on error
Note
If the window associated with the renderer is resized, the viewport is automatically reset.
See also
SDL_RenderGetViewport()
SDL_RenderSetLogicalSize()

Definition at line 2099 of file SDL_render.c.

2100 {
2101  int retval;
2103 
2104  if (rect) {
2105  renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x);
2106  renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y);
2107  renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x);
2108  renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y);
2109  } else {
2110  renderer->viewport.x = 0;
2111  renderer->viewport.y = 0;
2113  return -1;
2114  }
2115  }
2118 }

References CHECK_RENDERER_MAGIC, FlushRenderCommandsIfNotBatching(), SDL_Rect::h, QueueCmdSetViewport(), rect, renderer, retval, SDL_Renderer::scale, SDL_ceil, SDL_floor, SDL_GetRendererOutputSize(), SDL_Renderer::viewport, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_CreateRenderer(), SDL_CreateSoftwareRenderer(), SDL_RenderSetLogicalSize(), and UpdateLogicalSize().

◆ SDL_RenderTargetSupported()

SDL_bool SDL_RenderTargetSupported ( SDL_Renderer renderer)

Determines whether a window supports the use of render targets.

Parameters
rendererThe renderer that will be checked
Returns
SDL_TRUE if supported, SDL_FALSE if not.

Definition at line 1845 of file SDL_render.c.

1846 {
1847  if (!renderer || !renderer->SetRenderTarget) {
1848  return SDL_FALSE;
1849  }
1850  return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
1851 }

References SDL_RendererInfo::flags, SDL_Renderer::info, renderer, SDL_FALSE, SDL_RENDERER_TARGETTEXTURE, and SDL_Renderer::SetRenderTarget.

Referenced by SDL_SetRenderTarget().

◆ SDL_SetRenderDrawBlendMode()

int SDL_SetRenderDrawBlendMode ( SDL_Renderer renderer,
SDL_BlendMode  blendMode 
)

Set the blend mode used for drawing operations (Fill and Line).

Parameters
rendererThe renderer for which blend mode should be set.
blendModeSDL_BlendMode to use for blending.
Returns
0 on success, or -1 on error
Note
If the blend mode is not supported, the closest supported mode is chosen.
See also
SDL_GetRenderDrawBlendMode()

Definition at line 2232 of file SDL_render.c.

2233 {
2235 
2237  return SDL_Unsupported();
2238  }
2240  return 0;
2241 }

References blendMode, SDL_Renderer::blendMode, CHECK_RENDERER_MAGIC, IsSupportedBlendMode(), renderer, and SDL_Unsupported.

◆ SDL_SetRenderDrawColor()

int SDL_SetRenderDrawColor ( SDL_Renderer renderer,
Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a 
)

Set the color used for drawing operations (Rect, Line and Clear).

Parameters
rendererThe renderer for which drawing color should be set.
rThe red value used to draw on the rendering target.
gThe green value used to draw on the rendering target.
bThe blue value used to draw on the rendering target.
aThe alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255).
Returns
0 on success, or -1 on error

Definition at line 2198 of file SDL_render.c.

2200 {
2202 
2203  renderer->r = r;
2204  renderer->g = g;
2205  renderer->b = b;
2206  renderer->a = a;
2207  return 0;
2208 }

References SDL_Renderer::a, SDL_Renderer::b, CHECK_RENDERER_MAGIC, SDL_Renderer::g, SDL_Renderer::r, and renderer.

◆ SDL_SetRenderTarget()

int SDL_SetRenderTarget ( SDL_Renderer renderer,
SDL_Texture texture 
)

Set a texture as the current rendering target.

Parameters
rendererThe renderer.
textureThe targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
Returns
0 on success, or -1 on error
See also
SDL_GetRenderTarget()

Definition at line 1854 of file SDL_render.c.

1855 {
1857  return SDL_Unsupported();
1858  }
1859  if (texture == renderer->target) {
1860  /* Nothing to do! */
1861  return 0;
1862  }
1863 
1864  FlushRenderCommands(renderer); /* time to send everything to the GPU! */
1865 
1866  /* texture == NULL is valid and means reset the target to the window */
1867  if (texture) {
1869  if (renderer != texture->renderer) {
1870  return SDL_SetError("Texture was not created with this renderer");
1871  }
1872  if (texture->access != SDL_TEXTUREACCESS_TARGET) {
1873  return SDL_SetError("Texture not created with SDL_TEXTUREACCESS_TARGET");
1874  }
1875  if (texture->native) {
1876  /* Always render to the native texture */
1877  texture = texture->native;
1878  }
1879  }
1880 
1882 
1883  if (texture && !renderer->target) {
1884  /* Make a backup of the viewport */
1891  }
1892  renderer->target = texture;
1893 
1896  return -1;
1897  }
1898 
1899  if (texture) {
1900  renderer->viewport.x = 0;
1901  renderer->viewport.y = 0;
1902  renderer->viewport.w = texture->w;
1903  renderer->viewport.h = texture->h;
1906  renderer->scale.x = 1.0f;
1907  renderer->scale.y = 1.0f;
1908  renderer->logical_w = texture->w;
1909  renderer->logical_h = texture->h;
1910  } else {
1917  }
1918 
1920 
1921  if (QueueCmdSetViewport(renderer) < 0) {
1922  return -1;
1923  }
1924  if (QueueCmdSetClipRect(renderer) < 0) {
1925  return -1;
1926  }
1927 
1928  /* All set! */
1930 }

References CHECK_TEXTURE_MAGIC, SDL_Renderer::clip_rect, SDL_Renderer::clip_rect_backup, SDL_Renderer::clipping_enabled, SDL_Renderer::clipping_enabled_backup, FlushRenderCommands(), FlushRenderCommandsIfNotBatching(), SDL_Rect::h, SDL_Renderer::logical_h, SDL_Renderer::logical_h_backup, SDL_Renderer::logical_w, SDL_Renderer::logical_w_backup, QueueCmdSetClipRect(), QueueCmdSetViewport(), renderer, SDL_Renderer::scale, SDL_Renderer::scale_backup, SDL_FALSE, SDL_LockMutex, SDL_RenderTargetSupported(), SDL_SetError, SDL_TEXTUREACCESS_TARGET, SDL_UnlockMutex, SDL_Unsupported, SDL_zero, SDL_Renderer::SetRenderTarget, SDL_Renderer::target, SDL_Renderer::target_mutex, SDL_Renderer::viewport, SDL_Renderer::viewport_backup, SDL_Rect::w, SDL_FPoint::x, SDL_Rect::x, SDL_FPoint::y, and SDL_Rect::y.

Referenced by SDL_DestroyTexture(), and SDL_RendererEventWatch().

◆ SDL_SetTextureAlphaMod()

int SDL_SetTextureAlphaMod ( SDL_Texture texture,
Uint8  alpha 
)

Set an additional alpha value used in render copy operations.

Parameters
textureThe texture to update.
alphaThe alpha value multiplied into copy operations.
Returns
0 on success, or -1 if the texture is not valid or alpha modulation is not supported.
See also
SDL_GetTextureAlphaMod()

Definition at line 1346 of file SDL_render.c.

1347 {
1349 
1350  if (alpha < 255) {
1351  texture->modMode |= SDL_TEXTUREMODULATE_ALPHA;
1352  } else {
1353  texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA;
1354  }
1355  texture->a = alpha;
1356  if (texture->native) {
1357  return SDL_SetTextureAlphaMod(texture->native, alpha);
1358  }
1359  return 0;
1360 }

References CHECK_TEXTURE_MAGIC, and SDL_TEXTUREMODULATE_ALPHA.

Referenced by SDL_CreateTextureFromSurface().

◆ SDL_SetTextureBlendMode()

int SDL_SetTextureBlendMode ( SDL_Texture texture,
SDL_BlendMode  blendMode 
)

Set the blend mode used for texture copy operations.

Parameters
textureThe texture to update.
blendModeSDL_BlendMode to use for texture blending.
Returns
0 on success, or -1 if the texture is not valid or the blend mode is not supported.
Note
If the blend mode is not supported, the closest supported mode is chosen.
See also
SDL_GetTextureBlendMode()

Definition at line 1374 of file SDL_render.c.

1375 {
1377 
1379 
1380  renderer = texture->renderer;
1382  return SDL_Unsupported();
1383  }
1384  texture->blendMode = blendMode;
1385  if (texture->native) {
1386  return SDL_SetTextureBlendMode(texture->native, blendMode);
1387  }
1388  return 0;
1389 }

References blendMode, CHECK_TEXTURE_MAGIC, IsSupportedBlendMode(), renderer, and SDL_Unsupported.

Referenced by SDL_CreateTextureFromSurface().

◆ SDL_SetTextureColorMod()

int SDL_SetTextureColorMod ( SDL_Texture texture,
Uint8  r,
Uint8  g,
Uint8  b 
)

Set an additional color value used in render copy operations.

Parameters
textureThe texture to update.
rThe red color value multiplied into copy operations.
gThe green color value multiplied into copy operations.
bThe blue color value multiplied into copy operations.
Returns
0 on success, or -1 if the texture is not valid or color modulation is not supported.
See also
SDL_GetTextureColorMod()

Definition at line 1309 of file SDL_render.c.

1310 {
1312 
1313  if (r < 255 || g < 255 || b < 255) {
1314  texture->modMode |= SDL_TEXTUREMODULATE_COLOR;
1315  } else {
1316  texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR;
1317  }
1318  texture->r = r;
1319  texture->g = g;
1320  texture->b = b;
1321  if (texture->native) {
1322  return SDL_SetTextureColorMod(texture->native, r, g, b);
1323  }
1324  return 0;
1325 }

References CHECK_TEXTURE_MAGIC, and SDL_TEXTUREMODULATE_COLOR.

Referenced by SDL_CreateTextureFromSurface().

◆ SDL_SetTextureScaleMode()

int SDL_SetTextureScaleMode ( SDL_Texture texture,
SDL_ScaleMode  scaleMode 
)

Set the scale mode used for texture scale operations.

Parameters
textureThe texture to update.
scaleModeSDL_ScaleMode to use for texture scaling.
Returns
0 on success, or -1 if the texture is not valid.
Note
If the scale mode is not supported, the closest supported mode is chosen.
See also
SDL_GetTextureScaleMode()

Definition at line 1403 of file SDL_render.c.

1404 {
1406 
1408 
1409  renderer = texture->renderer;
1411  texture->scaleMode = scaleMode;
1412  if (texture->native) {
1413  return SDL_SetTextureScaleMode(texture->native, scaleMode);
1414  }
1415  return 0;
1416 }

References CHECK_TEXTURE_MAGIC, renderer, and SDL_Renderer::SetTextureScaleMode.

◆ SDL_UnlockTexture()

void SDL_UnlockTexture ( SDL_Texture texture)

Unlock a texture, uploading the changes to video memory, if needed. If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed.

See also
SDL_LockTexture()
SDL_LockTextureToSurface()

Definition at line 1821 of file SDL_render.c.

1822 {
1824 
1825  if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
1826  return;
1827  }
1828 #if SDL_HAVE_YUV
1829  if (texture->yuv) {
1831  } else
1832 #endif
1833  if (texture->native) {
1835  } else {
1836  SDL_Renderer *renderer = texture->renderer;
1838  }
1839 
1840  SDL_FreeSurface(texture->locked_surface);
1841  texture->locked_surface = NULL;
1842 }

References CHECK_TEXTURE_MAGIC, NULL, renderer, SDL_FreeSurface, SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), and SDL_Renderer::UnlockTexture.

Referenced by SDL_LockTextureToSurface(), SDL_UnlockTextureNative(), SDL_UnlockTextureYUV(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), and SDL_UpdateTextureYUVPlanar().

◆ SDL_UnlockTextureNative()

static void SDL_UnlockTextureNative ( SDL_Texture texture)
static

Definition at line 1800 of file SDL_render.c.

1801 {
1802  SDL_Texture *native = texture->native;
1803  void *native_pixels = NULL;
1804  int native_pitch = 0;
1805  const SDL_Rect *rect = &texture->locked_rect;
1806  const void* pixels = (void *) ((Uint8 *) texture->pixels +
1807  rect->y * texture->pitch +
1808  rect->x * SDL_BYTESPERPIXEL(texture->format));
1809  int pitch = texture->pitch;
1810 
1811  if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
1812  return;
1813  }
1815  texture->format, pixels, pitch,
1816  native->format, native_pixels, native_pitch);
1817  SDL_UnlockTexture(native);
1818 }

References SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, NULL, rect, SDL_BYTESPERPIXEL, SDL_ConvertPixels, SDL_LockTexture(), SDL_UnlockTexture(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_UnlockTexture().

◆ SDL_UnlockTextureYUV()

static void SDL_UnlockTextureYUV ( SDL_Texture texture)
static

Definition at line 1778 of file SDL_render.c.

1779 {
1780  SDL_Texture *native = texture->native;
1781  void *native_pixels = NULL;
1782  int native_pitch = 0;
1783  SDL_Rect rect;
1784 
1785  rect.x = 0;
1786  rect.y = 0;
1787  rect.w = texture->w;
1788  rect.h = texture->h;
1789 
1790  if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) {
1791  return;
1792  }
1793  SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format,
1794  rect.w, rect.h, native_pixels, native_pitch);
1795  SDL_UnlockTexture(native);
1796 }

References SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, NULL, rect, SDL_LockTexture(), SDL_SW_CopyYUVToRGB(), SDL_UnlockTexture(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_UnlockTexture().

◆ SDL_UpdateTexture()

int SDL_UpdateTexture ( SDL_Texture texture,
const SDL_Rect rect,
const void pixels,
int  pitch 
)

Update the given texture rectangle with new pixel data.

Parameters
textureThe texture to update
rectA pointer to the rectangle of pixels to update, or NULL to update the entire texture.
pixelsThe raw pixel data in the format of the texture.
pitchThe number of bytes in a row of pixel data, including padding between lines.

The pixel data must be in the format of the texture. The pixel format can be queried with SDL_QueryTexture.

Returns
0 on success, or -1 if the texture is not valid.
Note
This is a fairly slow function.

Definition at line 1519 of file SDL_render.c.

1521 {
1522  SDL_Rect full_rect;
1523 
1525 
1526  if (!pixels) {
1527  return SDL_InvalidParamError("pixels");
1528  }
1529  if (!pitch) {
1530  return SDL_InvalidParamError("pitch");
1531  }
1532 
1533  if (!rect) {
1534  full_rect.x = 0;
1535  full_rect.y = 0;
1536  full_rect.w = texture->w;
1537  full_rect.h = texture->h;
1538  rect = &full_rect;
1539  }
1540 
1541  if ((rect->w == 0) || (rect->h == 0)) {
1542  return 0; /* nothing to do. */
1543 #if SDL_HAVE_YUV
1544  } else if (texture->yuv) {
1545  return SDL_UpdateTextureYUV(texture, rect, pixels, pitch);
1546 #endif
1547  } else if (texture->native) {
1548  return SDL_UpdateTextureNative(texture, rect, pixels, pitch);
1549  } else {
1550  SDL_Renderer *renderer = texture->renderer;
1552  return -1;
1553  }
1554  return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
1555  }
1556 }

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Rect::h, rect, renderer, SDL_InvalidParamError, SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), SDL_Renderer::UpdateTexture, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_CreateTextureFromSurface(), SDL_UpdateTextureNative(), SDL_UpdateTextureYUV(), and SDL_UpdateTextureYUVPlanar().

◆ SDL_UpdateTextureNative()

static int SDL_UpdateTextureNative ( SDL_Texture texture,
const SDL_Rect rect,
const void pixels,
int  pitch 
)
static

Definition at line 1478 of file SDL_render.c.

1480 {
1481  SDL_Texture *native = texture->native;
1482 
1483  if (!rect->w || !rect->h) {
1484  return 0; /* nothing to do. */
1485  }
1486 
1487  if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
1488  /* We can lock the texture and copy to it */
1489  void *native_pixels = NULL;
1490  int native_pitch = 0;
1491 
1492  if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
1493  return -1;
1494  }
1496  texture->format, pixels, pitch,
1497  native->format, native_pixels, native_pitch);
1498  SDL_UnlockTexture(native);
1499  } else {
1500  /* Use a temporary buffer for updating */
1501  const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
1502  const size_t alloclen = rect->h * temp_pitch;
1503  if (alloclen > 0) {
1504  void *temp_pixels = SDL_malloc(alloclen);
1505  if (!temp_pixels) {
1506  return SDL_OutOfMemory();
1507  }
1509  texture->format, pixels, pitch,
1510  native->format, temp_pixels, temp_pitch);
1511  SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
1512  SDL_free(temp_pixels);
1513  }
1514  }
1515  return 0;
1516 }

References SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, NULL, rect, SDL_BYTESPERPIXEL, SDL_ConvertPixels, SDL_free, SDL_LockTexture(), SDL_malloc, SDL_OutOfMemory, SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTexture(), SDL_UpdateTexture(), and SDL_Rect::w.

Referenced by SDL_UpdateTexture().

◆ SDL_UpdateTextureYUV()

static int SDL_UpdateTextureYUV ( SDL_Texture texture,
const SDL_Rect rect,
const void pixels,
int  pitch 
)
static

Definition at line 1431 of file SDL_render.c.

1433 {
1434  SDL_Texture *native = texture->native;
1435  SDL_Rect full_rect;
1436 
1437  if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) {
1438  return -1;
1439  }
1440 
1441  full_rect.x = 0;
1442  full_rect.y = 0;
1443  full_rect.w = texture->w;
1444  full_rect.h = texture->h;
1445  rect = &full_rect;
1446 
1447  if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
1448  /* We can lock the texture and copy to it */
1449  void *native_pixels = NULL;
1450  int native_pitch = 0;
1451 
1452  if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
1453  return -1;
1454  }
1455  SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
1456  rect->w, rect->h, native_pixels, native_pitch);
1457  SDL_UnlockTexture(native);
1458  } else {
1459  /* Use a temporary buffer for updating */
1460  const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
1461  const size_t alloclen = rect->h * temp_pitch;
1462  if (alloclen > 0) {
1463  void *temp_pixels = SDL_malloc(alloclen);
1464  if (!temp_pixels) {
1465  return SDL_OutOfMemory();
1466  }
1467  SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
1468  rect->w, rect->h, temp_pixels, temp_pitch);
1469  SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
1470  SDL_free(temp_pixels);
1471  }
1472  }
1473  return 0;
1474 }

References SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, NULL, rect, SDL_BYTESPERPIXEL, SDL_free, SDL_LockTexture(), SDL_malloc, SDL_OutOfMemory, SDL_SW_CopyYUVToRGB(), SDL_SW_UpdateYUVTexture(), SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTexture(), SDL_UpdateTexture(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_UpdateTexture().

◆ SDL_UpdateTextureYUVPlanar()

static int SDL_UpdateTextureYUVPlanar ( SDL_Texture texture,
const SDL_Rect rect,
const Uint8 Yplane,
int  Ypitch,
const Uint8 Uplane,
int  Upitch,
const Uint8 Vplane,
int  Vpitch 
)
static

Definition at line 1560 of file SDL_render.c.

1564 {
1565  SDL_Texture *native = texture->native;
1566  SDL_Rect full_rect;
1567 
1568  if (SDL_SW_UpdateYUVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch) < 0) {
1569  return -1;
1570  }
1571 
1572  full_rect.x = 0;
1573  full_rect.y = 0;
1574  full_rect.w = texture->w;
1575  full_rect.h = texture->h;
1576  rect = &full_rect;
1577 
1578  if (!rect->w || !rect->h) {
1579  return 0; /* nothing to do. */
1580  }
1581 
1582  if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
1583  /* We can lock the texture and copy to it */
1584  void *native_pixels = NULL;
1585  int native_pitch = 0;
1586 
1587  if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) {
1588  return -1;
1589  }
1590  SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
1591  rect->w, rect->h, native_pixels, native_pitch);
1592  SDL_UnlockTexture(native);
1593  } else {
1594  /* Use a temporary buffer for updating */
1595  const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3);
1596  const size_t alloclen = rect->h * temp_pitch;
1597  if (alloclen > 0) {
1598  void *temp_pixels = SDL_malloc(alloclen);
1599  if (!temp_pixels) {
1600  return SDL_OutOfMemory();
1601  }
1602  SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
1603  rect->w, rect->h, temp_pixels, temp_pitch);
1604  SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch);
1605  SDL_free(temp_pixels);
1606  }
1607  }
1608  return 0;
1609 }

References SDL_Texture::format, SDL_Rect::h, SDL_Texture::native, NULL, rect, SDL_BYTESPERPIXEL, SDL_free, SDL_LockTexture(), SDL_malloc, SDL_OutOfMemory, SDL_SW_CopyYUVToRGB(), SDL_SW_UpdateYUVTexturePlanar(), SDL_TEXTUREACCESS_STREAMING, SDL_UnlockTexture(), SDL_UpdateTexture(), SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_UpdateYUVTexture().

◆ SDL_UpdateYUVTexture()

int SDL_UpdateYUVTexture ( SDL_Texture texture,
const SDL_Rect rect,
const Uint8 Yplane,
int  Ypitch,
const Uint8 Uplane,
int  Upitch,
const Uint8 Vplane,
int  Vpitch 
)

Update a rectangle within a planar YV12 or IYUV texture with new pixel data.

Parameters
textureThe texture to update
rectA pointer to the rectangle of pixels to update, or NULL to update the entire texture.
YplaneThe raw pixel data for the Y plane.
YpitchThe number of bytes between rows of pixel data for the Y plane.
UplaneThe raw pixel data for the U plane.
UpitchThe number of bytes between rows of pixel data for the U plane.
VplaneThe raw pixel data for the V plane.
VpitchThe number of bytes between rows of pixel data for the V plane.
Returns
0 on success, or -1 if the texture is not valid.
Note
You can use SDL_UpdateTexture() as long as your pixel data is a contiguous block of Y and U/V planes in the proper order, but this function is available if your pixel data is not contiguous.

Definition at line 1612 of file SDL_render.c.

1616 {
1617 #if SDL_HAVE_YUV
1619  SDL_Rect full_rect;
1620 
1622 
1623  if (!Yplane) {
1624  return SDL_InvalidParamError("Yplane");
1625  }
1626  if (!Ypitch) {
1627  return SDL_InvalidParamError("Ypitch");
1628  }
1629  if (!Uplane) {
1630  return SDL_InvalidParamError("Uplane");
1631  }
1632  if (!Upitch) {
1633  return SDL_InvalidParamError("Upitch");
1634  }
1635  if (!Vplane) {
1636  return SDL_InvalidParamError("Vplane");
1637  }
1638  if (!Vpitch) {
1639  return SDL_InvalidParamError("Vpitch");
1640  }
1641 
1642  if (texture->format != SDL_PIXELFORMAT_YV12 &&
1643  texture->format != SDL_PIXELFORMAT_IYUV) {
1644  return SDL_SetError("Texture format must by YV12 or IYUV");
1645  }
1646 
1647  if (!rect) {
1648  full_rect.x = 0;
1649  full_rect.y = 0;
1650  full_rect.w = texture->w;
1651  full_rect.h = texture->h;
1652  rect = &full_rect;
1653  }
1654 
1655  if (!rect->w || !rect->h) {
1656  return 0; /* nothing to do. */
1657  }
1658 
1659  if (texture->yuv) {
1660  return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
1661  } else {
1662  SDL_assert(!texture->native);
1663  renderer = texture->renderer;
1665  if (renderer->UpdateTextureYUV) {
1667  return -1;
1668  }
1669  return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch);
1670  } else {
1671  return SDL_Unsupported();
1672  }
1673  }
1674 #else
1675  return -1;
1676 #endif
1677 }

References CHECK_TEXTURE_MAGIC, FlushRenderCommandsIfTextureNeeded(), SDL_Rect::h, rect, renderer, SDL_assert, SDL_InvalidParamError, SDL_PIXELFORMAT_IYUV, SDL_PIXELFORMAT_YV12, SDL_SetError, SDL_Unsupported, SDL_UpdateTextureYUVPlanar(), SDL_Renderer::UpdateTextureYUV, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

◆ UpdateLogicalSize()

static int UpdateLogicalSize ( SDL_Renderer renderer)
static

Definition at line 1939 of file SDL_render.c.

1940 {
1941  int w = 1, h = 1;
1942  float want_aspect;
1943  float real_aspect;
1944  float scale;
1946  /* 0 is for letterbox, 1 is for overscan */
1947  int scale_policy = 0;
1948  const char *hint;
1949 
1950  if (!renderer->logical_w || !renderer->logical_h) {
1951  return 0;
1952  }
1953  if (SDL_GetRendererOutputSize(renderer, &w, &h) < 0) {
1954  return -1;
1955  }
1956 
1958  if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) {
1959 #if SDL_VIDEO_RENDER_D3D
1960  SDL_bool overscan_supported = SDL_TRUE;
1961  /* Unfortunately, Direct3D 9 doesn't support negative viewport numbers
1962  which the overscan implementation relies on.
1963  */
1964  if (SDL_strcasecmp(SDL_GetCurrentVideoDriver(), "direct3d") == 0) {
1965  overscan_supported = SDL_FALSE;
1966  }
1967  if (overscan_supported) {
1968  scale_policy = 1;
1969  }
1970 #else
1971  scale_policy = 1;
1972 #endif
1973  }
1974 
1975  want_aspect = (float)renderer->logical_w / renderer->logical_h;
1976  real_aspect = (float)w / h;
1977 
1978  /* Clear the scale because we're setting viewport in output coordinates */
1979  SDL_RenderSetScale(renderer, 1.0f, 1.0f);
1980 
1981  if (renderer->integer_scale) {
1982  if (want_aspect > real_aspect) {
1983  scale = (float)(w / renderer->logical_w);
1984  } else {
1985  scale = (float)(h / renderer->logical_h);
1986  }
1988  viewport.x = (w - viewport.w) / 2;
1990  viewport.y = (h - viewport.h) / 2;
1991 
1993  } else if (SDL_fabs(want_aspect-real_aspect) < 0.0001) {
1994  /* The aspect ratios are the same, just scale appropriately */
1995  scale = (float)w / renderer->logical_w;
1997  } else if (want_aspect > real_aspect) {
1998  if (scale_policy == 1) {
1999  /* We want a wider aspect ratio than is available -
2000  zoom so logical height matches the real height
2001  and the width will grow off the screen
2002  */
2003  scale = (float)h / renderer->logical_h;
2004  viewport.y = 0;
2005  viewport.h = h;
2007  viewport.x = (w - viewport.w) / 2;
2009  } else {
2010  /* We want a wider aspect ratio than is available - letterbox it */
2011  scale = (float)w / renderer->logical_w;
2012  viewport.x = 0;
2013  viewport.w = w;
2015  viewport.y = (h - viewport.h) / 2;
2017  }
2018  } else {
2019  if (scale_policy == 1) {
2020  /* We want a narrower aspect ratio than is available -
2021  zoom so logical width matches the real width
2022  and the height will grow off the screen
2023  */
2024  scale = (float)w / renderer->logical_w;
2025  viewport.x = 0;
2026  viewport.w = w;
2028  viewport.y = (h - viewport.h) / 2;
2030  } else {
2031  /* We want a narrower aspect ratio than is available - use side-bars */
2032  scale = (float)h / renderer->logical_h;
2033  viewport.y = 0;
2034  viewport.h = h;
2036  viewport.x = (w - viewport.w) / 2;
2038  }
2039  }
2040 
2041  /* Set the new scale */
2043 
2044  return 0;
2045 }

References SDL_Rect::h, SDL_Renderer::integer_scale, SDL_Renderer::logical_h, SDL_Renderer::logical_w, NULL, renderer, SDL_ceil, SDL_fabs, SDL_FALSE, SDL_GetCurrentVideoDriver, SDL_GetHint, SDL_GetRendererOutputSize(), SDL_HINT_RENDER_LOGICAL_SIZE_MODE, SDL_RenderSetScale(), SDL_RenderSetViewport(), SDL_strcasecmp, SDL_TRUE, viewport, SDL_Rect::w, SDL_Rect::x, and SDL_Rect::y.

Referenced by SDL_RendererEventWatch(), SDL_RenderSetIntegerScale(), and SDL_RenderSetLogicalSize().

◆ VerifyDrawQueueFunctions()

static SDL_INLINE void VerifyDrawQueueFunctions ( const SDL_Renderer renderer)
static

Definition at line 751 of file SDL_render.c.

752 {
753  /* all of these functions are required to be implemented, even as no-ops, so we don't
754  have to check that they aren't NULL over and over. */
762 }

References NULL, SDL_Renderer::QueueCopy, SDL_Renderer::QueueDrawLines, SDL_Renderer::QueueDrawPoints, SDL_Renderer::QueueFillRects, SDL_Renderer::QueueSetDrawColor, SDL_Renderer::QueueSetViewport, renderer, SDL_Renderer::RunCommandQueue, and SDL_assert.

Referenced by SDL_CreateRenderer(), and SDL_CreateSoftwareRenderer().

Variable Documentation

◆ render_drivers

const SDL_RenderDriver* render_drivers[]
static
Initial value:

Definition at line 83 of file SDL_render.c.

Referenced by SDL_CreateRenderer(), SDL_GetNumRenderDrivers(), and SDL_GetRenderDriverInfo().

◆ renderer_magic

char renderer_magic
static

Definition at line 114 of file SDL_render.c.

Referenced by SDL_CreateRenderer(), and SDL_CreateSoftwareRenderer().

◆ texture_magic

char texture_magic
static

Definition at line 115 of file SDL_render.c.

Referenced by SDL_CreateTexture().

QueueCmdSetViewport
static int QueueCmdSetViewport(SDL_Renderer *renderer)
Definition: SDL_render.c:326
SDL_zero
#define SDL_zero(x)
Definition: SDL_stdinc.h:418
SDL_UnlockSurface
#define SDL_UnlockSurface
Definition: SDL_dynapi_overrides.h:449
SDL_Texture::native
SDL_Texture * native
Definition: SDL_sysrender.h:51
SDL_SetRenderTarget
int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
Set a texture as the current rendering target.
Definition: SDL_render.c:1854
SDL_FRectEmpty
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
Definition: SDL_render.c:2875
SDL_Renderer::blendMode
SDL_BlendMode blendMode
Definition: SDL_sysrender.h:198
SW_CreateRendererForSurface
SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface *surface)
Definition: SDL_render_sw.c:807
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
points
GLfixed GLfixed GLint GLint GLfixed points
Definition: SDL_opengl_glext.h:4561
SDL_Point::x
int x
Definition: SDL_rect.h:50
SDL_ScaleModeLinear
@ SDL_ScaleModeLinear
Definition: SDL_render.h:94
RenderDrawPointsWithRectsF
static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer, const SDL_FPoint *fpoints, const int count)
Definition: SDL_render.c:2354
Uint32
uint32_t Uint32
Definition: SDL_stdinc.h:203
SDL_UnlockTexture
void SDL_UnlockTexture(SDL_Texture *texture)
Unlock a texture, uploading the changes to video memory, if needed. If SDL_LockTextureToSurface() was...
Definition: SDL_render.c:1821
SDL_Renderer::GL_UnbindTexture
int(* GL_UnbindTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:152
SDL_RenderCopyExF
int SDL_RenderCopyExF(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
Copy a portion of the source texture to the current rendering target, rotating it by angle around the...
Definition: SDL_render.c:3031
SDL_HINT_RENDER_VSYNC
#define SDL_HINT_RENDER_VSYNC
A variable controlling whether updates to the SDL screen surface should be synchronized with the vert...
Definition: SDL_hints.h:154
SDL_CreateTexture
SDL_Texture * SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h)
Create a texture for a rendering context.
Definition: SDL_render.c:1043
SDL_Renderer::clip_rect_backup
SDL_Rect clip_rect_backup
Definition: SDL_sysrender.h:179
SDL_small_free
#define SDL_small_free(ptr, isstack)
Definition: SDL_internal.h:40
FlushRenderCommands
static int FlushRenderCommands(SDL_Renderer *renderer)
Definition: SDL_render.c:209
offset
GLintptr offset
Definition: SDL_opengl_glext.h:541
SDL_HINT_RENDER_BATCHING
#define SDL_HINT_RENDER_BATCHING
A variable controlling whether the 2D render API is compatible or efficient.
Definition: SDL_hints.h:1171
SDL_GL_UnbindTexture
int SDL_GL_UnbindTexture(SDL_Texture *texture)
Unbind a texture from the current OpenGL/ES/ES2 context.
Definition: SDL_render.c:3269
scale
GLenum GLenum GLenum GLenum GLenum scale
Definition: SDL_opengl_glext.h:9378
SDL_GetWindowData
#define SDL_GetWindowData
Definition: SDL_dynapi_overrides.h:523
SDL_Palette::ncolors
int ncolors
Definition: SDL_pixels.h:309
blendMode
static SDL_BlendMode blendMode
Definition: testdraw2.c:34
SDL_SetTextureAlphaMod
int SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha)
Set an additional alpha value used in render copy operations.
Definition: SDL_render.c:1346
SDL_Surface
A collection of pixels used in software blitting.
Definition: SDL_surface.h:70
SDL_BLENDOPERATION_ADD
@ SDL_BLENDOPERATION_ADD
Definition: SDL_blendmode.h:67
SDL_Renderer::render_command_generation
Uint32 render_command_generation
Definition: SDL_sysrender.h:205
SDL_BLENDFACTOR_SRC_ALPHA
@ SDL_BLENDFACTOR_SRC_ALPHA
Definition: SDL_blendmode.h:84
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
@ SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
Definition: SDL_blendmode.h:85
SDL_UpdateTextureYUV
static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:1431
SDL_Renderer::GetMetalLayer
void *(* GetMetalLayer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:154
SDL_WINDOW_MINIMIZED
@ SDL_WINDOW_MINIMIZED
Definition: SDL_video.h:105
VerifyDrawQueueFunctions
static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer)
Definition: SDL_render.c:751
if
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 abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
Definition: pixman-arm-neon-asm.h:469
SDL_Renderer::QueueCopyEx
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)
Definition: SDL_sysrender.h:127
IsSupportedBlendMode
static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Definition: SDL_render.c:970
SDL_PIXELFORMAT_RGB888
@ SDL_PIXELFORMAT_RGB888
Definition: SDL_pixels.h:239
SDL_BLENDMODE_ADD
@ SDL_BLENDMODE_ADD
Definition: SDL_blendmode.h:47
SDL_RenderTargetSupported
SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer)
Determines whether a window supports the use of render targets.
Definition: SDL_render.c:1845
SDL_TEXTUREMODULATE_COLOR
@ SDL_TEXTUREMODULATE_COLOR
Definition: SDL_render.h:114
SDL_LockMutex
#define SDL_LockMutex
Definition: SDL_dynapi_overrides.h:260
window_w
int window_w
Definition: testoverlay2.c:145
SDL_Renderer::RunCommandQueue
int(* RunCommandQueue)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
Definition: SDL_sysrender.h:130
SDL_fabs
#define SDL_fabs
Definition: SDL_dynapi_overrides.h:430
SDL_FPoint::x
float x
Definition: SDL_rect.h:62
SDL_ceil
#define SDL_ceil
Definition: SDL_dynapi_overrides.h:426
SDL_FRect::h
float h
Definition: SDL_rect.h:92
NULL
#define NULL
Definition: begin_code.h:167
surface
EGLSurface surface
Definition: eglext.h:248
SDL_PixelFormat::format
Uint32 format
Definition: SDL_pixels.h:320
SDL_ALPHA_OPAQUE
#define SDL_ALPHA_OPAQUE
Definition: SDL_pixels.h:46
b
GLboolean GLboolean GLboolean b
Definition: SDL_opengl_glext.h:1112
SDL_Renderer::SetRenderTarget
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:143
enable
GLboolean enable
Definition: SDL_opengl_glext.h:4999
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
SDL_Surface::pixels
void * pixels
Definition: SDL_surface.h:76
g
GLboolean GLboolean g
Definition: SDL_opengl_glext.h:1112
access
GLuint GLint GLboolean GLint GLenum access
Definition: SDL_opengl_glext.h:2165
render_drivers
static const SDL_RenderDriver * render_drivers[]
Definition: SDL_render.c:83
SDL_Renderer::g
Uint8 g
Definition: SDL_sysrender.h:197
SDL_UpdateTextureNative
static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_render.c:1478
SDL_COMPOSE_BLENDMODE
#define SDL_COMPOSE_BLENDMODE(srcColorFactor, dstColorFactor, colorOperation, srcAlphaFactor, dstAlphaFactor, alphaOperation)
Definition: SDL_render.c:53
count
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
SDL_UnlockTextureNative
static void SDL_UnlockTextureNative(SDL_Texture *texture)
Definition: SDL_render.c:1800
SDL_SW_LockYUVTexture
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_yuv_sw.c:304
SDL_GetWindowFlags
#define SDL_GetWindowFlags
Definition: SDL_dynapi_overrides.h:518
SDL_RenderDrawLinesF
int SDL_RenderDrawLinesF(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Draw a series of connected lines on the current rendering target.
Definition: SDL_render.c:2599
SDL_RenderCommand::next
struct SDL_RenderCommand * next
Definition: SDL_sysrender.h:104
SDL_PIXELFORMAT_BGR888
@ SDL_PIXELFORMAT_BGR888
Definition: SDL_pixels.h:245
SDL_BlendOperation
SDL_BlendOperation
The blend operation used when combining source and destination pixel components.
Definition: SDL_blendmode.h:65
SDL_Renderer::hidden
SDL_bool hidden
Definition: SDL_sysrender.h:162
SDL_Renderer::scale
SDL_FPoint scale
Definition: SDL_sysrender.h:186
SDL_HINT_RENDER_SCALE_QUALITY
#define SDL_HINT_RENDER_SCALE_QUALITY
A variable controlling the scaling quality.
Definition: SDL_hints.h:143
r
GLdouble GLdouble GLdouble r
Definition: SDL_opengl.h:2079
SDL_MOUSEBUTTONUP
@ SDL_MOUSEBUTTONUP
Definition: SDL_events.h:107
SDL_ConvertSurface
#define SDL_ConvertSurface
Definition: SDL_dynapi_overrides.h:463
SDL_realloc
#define SDL_realloc
Definition: SDL_dynapi_overrides.h:376
SDL_InvalidParamError
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
viewport
static SDL_Rect viewport
Definition: testviewport.c:28
SDL_Renderer::last_queued_color
Uint32 last_queued_color
Definition: SDL_sysrender.h:206
SDL_CreateMutex
#define SDL_CreateMutex
Definition: SDL_dynapi_overrides.h:259
SDL_WINDOWPOS_UNDEFINED
#define SDL_WINDOWPOS_UNDEFINED
Definition: SDL_video.h:129
SDL_MUSTLOCK
#define SDL_MUSTLOCK(S)
Definition: SDL_surface.h:62
SDL_Renderer::vertex_data
void * vertex_data
Definition: SDL_sysrender.h:214
SDL_IntersectRect
#define SDL_IntersectRect
Definition: SDL_dynapi_overrides.h:294
SDL_UpdateTextureYUVPlanar
static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Definition: SDL_render.c:1560
SDL_floor
#define SDL_floor
Definition: SDL_dynapi_overrides.h:431
SDL_RenderDriver
Definition: SDL_sysrender.h:222
SDL_Renderer::color_queued
SDL_bool color_queued
Definition: SDL_sysrender.h:210
SDL_FRect::x
float x
Definition: SDL_rect.h:89
SDL_Renderer::last_queued_viewport
SDL_Rect last_queued_viewport
Definition: SDL_sysrender.h:207
SDL_ISPIXELFORMAT_INDEXED
#define SDL_ISPIXELFORMAT_INDEXED(format)
Definition: SDL_pixels.h:134
SDL_Renderer::dpi_scale
SDL_FPoint dpi_scale
Definition: SDL_sysrender.h:190
SDL_Renderer::textures
SDL_Texture * textures
Definition: SDL_sysrender.h:193
SDL_Renderer::WindowEvent
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
Definition: SDL_sysrender.h:113
SDL_ScaleModeBest
@ SDL_ScaleModeBest
Definition: SDL_render.h:95
SDL_GetRendererOutputSize
int SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h)
Get the output size in pixels of a rendering context.
Definition: SDL_render.c:952
SDL_Renderer::vertex_data_used
size_t vertex_data_used
Definition: SDL_sysrender.h:215
index
GLuint index
Definition: SDL_opengl_glext.h:663
SDL_GetRenderTarget
SDL_Texture * SDL_GetRenderTarget(SDL_Renderer *renderer)
Get the current render target or NULL for the default render target.
Definition: SDL_render.c:1933
SDL_FPoint::y
float y
Definition: SDL_rect.h:63
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8586
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1112
SDL_GetHint
#define SDL_GetHint
Definition: SDL_dynapi_overrides.h:191
SDL_CreateWindow
#define SDL_CreateWindow
Definition: SDL_dynapi_overrides.h:514
renderer_magic
static char renderer_magic
Definition: SDL_render.c:114
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1949
SDL_small_alloc
#define SDL_small_alloc(type, count, pisstack)
Definition: SDL_internal.h:39
SDL_Renderer::target_mutex
SDL_mutex * target_mutex
Definition: SDL_sysrender.h:195
SDL_LockTexture
int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Lock a portion of the texture for write-only pixel access.
Definition: SDL_render.c:1701
SDL_GetSurfaceBlendMode
#define SDL_GetSurfaceBlendMode
Definition: SDL_dynapi_overrides.h:460
SDL_QueryTexture
int SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h)
Query the attributes of a texture.
Definition: SDL_render.c:1288
SDL_Rect::x
int x
Definition: SDL_rect.h:79
SDL_BLENDMODE_MUL_FULL
#define SDL_BLENDMODE_MUL_FULL
Definition: SDL_render.c:78
SDL_RENDERCMD_COPY
@ SDL_RENDERCMD_COPY
Definition: SDL_sysrender.h:76
SDL_Renderer::viewport_queued
SDL_bool viewport_queued
Definition: SDL_sysrender.h:211
FlushRenderCommandsIfTextureNeeded
static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture)
Definition: SDL_render.c:240
SDL_CreateRenderer
SDL_Renderer * SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
Create a 2D rendering context for a window.
Definition: SDL_render.c:765
SDL_Renderer::logical_w
int logical_w
Definition: SDL_sysrender.h:165
SDL_Renderer::viewport_backup
SDL_Rect viewport_backup
Definition: SDL_sysrender.h:175
SDL_RENDERCMD_SETCLIPRECT
@ SDL_RENDERCMD_SETCLIPRECT
Definition: SDL_sysrender.h:70
SDL_PIXELFORMAT_IYUV
@ SDL_PIXELFORMAT_IYUV
Definition: SDL_pixels.h:282
SDL_AllocFormat
#define SDL_AllocFormat
Definition: SDL_dynapi_overrides.h:280
SDL_RenderFillRectsF
int SDL_RenderFillRectsF(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
Fill some number of rectangles on the current rendering target with the drawing color.
Definition: SDL_render.c:2834
SDL_Texture::prev
SDL_Texture * prev
Definition: SDL_sysrender.h:62
SDL_ScaleModeNearest
@ SDL_ScaleModeNearest
Definition: SDL_render.h:93
SDL_GetNumRenderDrivers
int SDL_GetNumRenderDrivers(void)
Get the number of 2D rendering drivers available for the current display.
Definition: SDL_render.c:553
SDL_Rect::w
int w
Definition: SDL_rect.h:80
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:74
SDL_Color::a
Uint8 a
Definition: SDL_pixels.h:303
maxY
GLfloat GLfloat GLfloat GLfloat GLfloat maxY
Definition: gl2ext.h:446
n
GLdouble n
Definition: SDL_opengl_glext.h:1955
SDL_RenderGetViewport
void SDL_RenderGetViewport(SDL_Renderer *renderer, SDL_Rect *rect)
Get the drawing area for the current target.
Definition: SDL_render.c:2121
SDL_strcasecmp
#define SDL_strcasecmp
Definition: SDL_dynapi_overrides.h:419
alpha
GLfloat GLfloat GLfloat alpha
Definition: SDL_opengl_glext.h:415
SDL_WINDOWEVENT_SHOWN
@ SDL_WINDOWEVENT_SHOWN
Definition: SDL_video.h:148
SDL_RenderDriver::CreateRenderer
SDL_Renderer *(* CreateRenderer)(SDL_Window *window, Uint32 flags)
Definition: SDL_sysrender.h:224
SDL_GetWindowSize
#define SDL_GetWindowSize
Definition: SDL_dynapi_overrides.h:527
SDL_SW_CopyYUVToRGB
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
Definition: SDL_yuv_sw.c:336
SDL_FINGERUP
@ SDL_FINGERUP
Definition: SDL_events.h:129
QueueCmdClear
static int QueueCmdClear(SDL_Renderer *renderer)
Definition: SDL_render.c:400
SDL_LockTextureNative
static int SDL_LockTextureNative(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:1689
SDL_Surface::pitch
int pitch
Definition: SDL_surface.h:75
SDL_Renderer::viewport
SDL_Rect viewport
Definition: SDL_sysrender.h:174
SDL_BLENDMODE_MOD
@ SDL_BLENDMODE_MOD
Definition: SDL_blendmode.h:50
SDL_BLENDMODE_NONE
@ SDL_BLENDMODE_NONE
Definition: SDL_blendmode.h:42
SDL_RenderSetScale
int SDL_RenderSetScale(SDL_Renderer *renderer, float scaleX, float scaleY)
Set the drawing scale for rendering on the current target.
Definition: SDL_render.c:2175
SDL_memcpy
#define SDL_memcpy
Definition: SDL_dynapi_overrides.h:387
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
event
struct _cl_event * event
Definition: SDL_opengl_glext.h:2652
SDL_Renderer
Definition: SDL_sysrender.h:109
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
SDL_MOUSEMOTION
@ SDL_MOUSEMOTION
Definition: SDL_events.h:105
SDL_Renderer::QueueSetDrawColor
int(* QueueSetDrawColor)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
Definition: SDL_sysrender.h:118
SDL_GL_BindTexture
int SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh)
Bind the texture to the current OpenGL/ES/ES2 context for use with OpenGL instructions.
Definition: SDL_render.c:3253
SDL_FPoint
The structure that defines a point (floating point)
Definition: SDL_rect.h:60
SDL_Palette::colors
SDL_Color * colors
Definition: SDL_pixels.h:310
SDL_BLENDMODE_ADD_FULL
#define SDL_BLENDMODE_ADD_FULL
Definition: SDL_render.c:70
SDL_FRect::y
float y
Definition: SDL_rect.h:90
SDL_Renderer::integer_scale
SDL_bool integer_scale
Definition: SDL_sysrender.h:171
SDL_FINGERDOWN
@ SDL_FINGERDOWN
Definition: SDL_events.h:128
SDL_RenderCommand::color
struct SDL_RenderCommand::@23::@27 color
SDL_Renderer::b
Uint8 b
Definition: SDL_sysrender.h:197
Android_ActivityMutex_Lock_Running
void Android_ActivityMutex_Lock_Running(void)
SDL_FRect::w
float w
Definition: SDL_rect.h:91
SDL_Renderer::last_queued_cliprect_enabled
SDL_bool last_queued_cliprect_enabled
Definition: SDL_sysrender.h:209
SDL_SetTextureScaleMode
int SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode)
Set the scale mode used for texture scale operations.
Definition: SDL_render.c:1403
retval
SDL_bool retval
Definition: testgamecontroller.c:65
SDL_Renderer::scale_backup
SDL_FPoint scale_backup
Definition: SDL_sysrender.h:187
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
window_h
int window_h
Definition: testoverlay2.c:146
color
GLuint color
Definition: SDL_opengl_glext.h:1151
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
SDL_Log
#define SDL_Log
Definition: SDL_dynapi_overrides.h:31
SDL_SetWindowData
#define SDL_SetWindowData
Definition: SDL_dynapi_overrides.h:522
SDL_Renderer::SetTextureScaleMode
void(* SetTextureScaleMode)(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ScaleMode scaleMode)
Definition: SDL_sysrender.h:142
SDL_RendererInfo::flags
Uint32 flags
Definition: SDL_render.h:81
SDL_Rect::y
int y
Definition: SDL_rect.h:79
SDL_Renderer::render_commands_tail
SDL_RenderCommand * render_commands_tail
Definition: SDL_sysrender.h:203
SDL_UpdateTexture
int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Update the given texture rectangle with new pixel data.
Definition: SDL_render.c:1519
SDL_memcmp
#define SDL_memcmp
Definition: SDL_dynapi_overrides.h:389
SDL_BLENDMODE_MOD_FULL
#define SDL_BLENDMODE_MOD_FULL
Definition: SDL_render.c:74
SDL_Rect::h
int h
Definition: SDL_rect.h:80
SDL_Renderer::logical_h_backup
int logical_h_backup
Definition: SDL_sysrender.h:168
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
SDL_TEXTUREACCESS_STATIC
@ SDL_TEXTUREACCESS_STATIC
Definition: SDL_render.h:103
minY
GLfloat minY
Definition: gl2ext.h:446
QueueCmdFillRects
static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, const int count)
Definition: SDL_render.c:483
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
SDL_max
#define SDL_max(x, y)
Definition: SDL_stdinc.h:407
SDL_Renderer::SupportsBlendMode
SDL_bool(* SupportsBlendMode)(SDL_Renderer *renderer, SDL_BlendMode blendMode)
Definition: SDL_sysrender.h:115
SDL_RENDERCMD_SETVIEWPORT
@ SDL_RENDERCMD_SETVIEWPORT
Definition: SDL_sysrender.h:69
UpdateLogicalSize
static int UpdateLogicalSize(SDL_Renderer *renderer)
Definition: SDL_render.c:1939
SDL_BLENDMODE_MUL
@ SDL_BLENDMODE_MUL
Definition: SDL_blendmode.h:53
SDL_Renderer::QueueDrawLines
int(* QueueDrawLines)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
Definition: SDL_sysrender.h:121
SDL_RENDERER_PRESENTVSYNC
@ SDL_RENDERER_PRESENTVSYNC
Definition: SDL_render.h:69
SDL_DestroyTexture
void SDL_DestroyTexture(SDL_Texture *texture)
Destroy the specified texture.
Definition: SDL_render.c:3161
SDL_RENDERCMD_DRAW_POINTS
@ SDL_RENDERCMD_DRAW_POINTS
Definition: SDL_sysrender.h:73
rect
SDL_Rect rect
Definition: testrelative.c:27
SDL_FreeSurface
#define SDL_FreeSurface
Definition: SDL_dynapi_overrides.h:446
SDL_PixelFormat::palette
SDL_Palette * palette
Definition: SDL_pixels.h:321
SDL_Renderer::render_commands
SDL_RenderCommand * render_commands
Definition: SDL_sysrender.h:202
SDL_LockTextureYUV
static int SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_render.c:1681
SDL_BlendFactor
SDL_BlendFactor
The normalized factor used to multiply pixel components.
Definition: SDL_blendmode.h:78
SDL_GetWindowFromID
#define SDL_GetWindowFromID
Definition: SDL_dynapi_overrides.h:517
SDL_SW_DestroyYUVTexture
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
Definition: SDL_yuv_sw.c:406
SDL_HasIntersectionF
static SDL_bool SDL_HasIntersectionF(const SDL_FRect *A, const SDL_FRect *B)
Definition: SDL_render.c:2882
SDL_Renderer::last_queued_cliprect
SDL_Rect last_queued_cliprect
Definition: SDL_sysrender.h:208
SDL_min
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
SDL_FINGERMOTION
@ SDL_FINGERMOTION
Definition: SDL_events.h:130
RenderDrawPointsWithRects
static int RenderDrawPointsWithRects(SDL_Renderer *renderer, const SDL_Point *points, const int count)
Definition: SDL_render.c:2284
AllocateRenderCommand
static SDL_RenderCommand * AllocateRenderCommand(SDL_Renderer *renderer)
Definition: SDL_render.c:297
SDL_Renderer::always_batch
SDL_bool always_batch
Definition: SDL_sysrender.h:200
FlushRenderCommandsIfNotBatching
static SDL_INLINE int FlushRenderCommandsIfNotBatching(SDL_Renderer *renderer)
Definition: SDL_render.c:251
PrepQueueCmdDrawTexture
static SDL_RenderCommand * PrepQueueCmdDrawTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_RenderCommandType cmdtype)
Definition: SDL_render.c:497
SDL_UnlockTextureYUV
static void SDL_UnlockTextureYUV(SDL_Texture *texture)
Definition: SDL_render.c:1778
RenderDrawLinesWithRectsF
static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
Definition: SDL_render.c:2501
SDL_FreeFormat
#define SDL_FreeFormat
Definition: SDL_dynapi_overrides.h:281
SDL_PixelFormat::Amask
Uint32 Amask
Definition: SDL_pixels.h:328
SDL_Texture::next
SDL_Texture * next
Definition: SDL_sysrender.h:63
SDL_WINDOWEVENT_SIZE_CHANGED
@ SDL_WINDOWEVENT_SIZE_CHANGED
Definition: SDL_video.h:155
SDL_Renderer::GL_BindTexture
int(* GL_BindTexture)(SDL_Renderer *renderer, SDL_Texture *texture, float *texw, float *texh)
Definition: SDL_sysrender.h:151
SDL_Renderer::vertex_data_allocation
size_t vertex_data_allocation
Definition: SDL_sysrender.h:216
QueueCmdCopyEx
static int QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcquad, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
Definition: SDL_render.c:533
SDL_Renderer::batching
SDL_bool batching
Definition: SDL_sysrender.h:201
SDL_RenderCommand::command
SDL_RenderCommandType command
Definition: SDL_sysrender.h:82
SDL_RENDERCMD_NO_OP
@ SDL_RENDERCMD_NO_OP
Definition: SDL_sysrender.h:68
SDL_Renderer::QueueSetViewport
int(* QueueSetViewport)(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
Definition: SDL_sysrender.h:117
SDL_PIXELFORMAT_ARGB8888
@ SDL_PIXELFORMAT_ARGB8888
Definition: SDL_pixels.h:251
SDL_PixelFormat
Definition: SDL_pixels.h:318
SDL_HINT_RENDER_LOGICAL_SIZE_MODE
#define SDL_HINT_RENDER_LOGICAL_SIZE_MODE
A variable controlling the scaling policy for SDL_RenderSetLogicalSize.
Definition: SDL_hints.h:131
QueueCmdSetDrawColor
static int QueueCmdSetDrawColor(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
Definition: SDL_render.c:371
SDL_SW_UpdateYUVTexturePlanar
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
Definition: SDL_yuv_sw.c:249
GetWindowViewportValues
static void GetWindowViewportValues(SDL_Renderer *renderer, int *logical_w, int *logical_h, SDL_Rect *viewport, SDL_FPoint *scale)
Definition: SDL_render.c:577
SDL_TEXTUREMODULATE_ALPHA
@ SDL_TEXTUREMODULATE_ALPHA
Definition: SDL_render.h:115
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_BLENDFACTOR_ZERO
@ SDL_BLENDFACTOR_ZERO
Definition: SDL_blendmode.h:80
SDL_WINDOWEVENT_MINIMIZED
@ SDL_WINDOWEVENT_MINIMIZED
Definition: SDL_video.h:158
pixels
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
Definition: SDL_opengl.h:1572
SDL_RENDERCMD_DRAW_LINES
@ SDL_RENDERCMD_DRAW_LINES
Definition: SDL_sysrender.h:74
SDL_Renderer::GetOutputSize
int(* GetOutputSize)(SDL_Renderer *renderer, int *w, int *h)
Definition: SDL_sysrender.h:114
maxX
GLfloat GLfloat GLfloat GLfloat maxX
Definition: gl2ext.h:446
SDL_BLENDFACTOR_DST_COLOR
@ SDL_BLENDFACTOR_DST_COLOR
Definition: SDL_blendmode.h:86
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
SDL_Renderer::CreateTexture
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:116
SDL_BLENDMODE_BLEND
@ SDL_BLENDMODE_BLEND
Definition: SDL_blendmode.h:44
SDL_RenderCommand::data
union SDL_RenderCommand::@23 data
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_Texture::format
Uint32 format
Definition: SDL_sysrender.h:39
bpp
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 abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
Definition: pixman-arm-neon-asm.h:146
SDL_RENDERCMD_FILL_RECTS
@ SDL_RENDERCMD_FILL_RECTS
Definition: SDL_sysrender.h:75
SDL_LockSurface
#define SDL_LockSurface
Definition: SDL_dynapi_overrides.h:448
SDL_Renderer::DestroyRenderer
void(* DestroyRenderer)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:149
SDL_Renderer::LockTexture
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
Definition: SDL_sysrender.h:139
SDL_Renderer::GetMetalCommandEncoder
void *(* GetMetalCommandEncoder)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:155
SDL_SW_CreateYUVTexture
SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
Definition: SDL_yuv_sw.c:33
SDL_GetSurfaceAlphaMod
#define SDL_GetSurfaceAlphaMod
Definition: SDL_dynapi_overrides.h:458
SDL_Renderer::cliprect_queued
SDL_bool cliprect_queued
Definition: SDL_sysrender.h:212
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
SDL_atoi
#define SDL_atoi
Definition: SDL_dynapi_overrides.h:410
SDL_GetLongBlendMode
static SDL_BlendMode SDL_GetLongBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:3331
SDL_Renderer::logical_h
int logical_h
Definition: SDL_sysrender.h:166
SDL_LogInfo
#define SDL_LogInfo
Definition: SDL_dynapi_overrides.h:34
SDL_Renderer::RenderReadPixels
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
Definition: SDL_sysrender.h:144
QueueCmdSetClipRect
static int QueueCmdSetClipRect(SDL_Renderer *renderer)
Definition: SDL_render.c:349
SDL_RENDERCMD_COPY_EX
@ SDL_RENDERCMD_COPY_EX
Definition: SDL_sysrender.h:77
Android_ActivityMutex_Unlock
void Android_ActivityMutex_Unlock(void)
SDL_RenderCommand
Definition: SDL_sysrender.h:80
SW_RenderDriver
SDL_RenderDriver SW_RenderDriver
Definition: SDL_render_sw.c:872
renderer
static SDL_Renderer * renderer
Definition: testaudiocapture.c:21
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
RenderDrawLinesWithRects
static int RenderDrawLinesWithRects(SDL_Renderer *renderer, const SDL_Point *points, const int count)
Definition: SDL_render.c:2446
QueueCmdDrawPoints
static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
Definition: SDL_render.c:455
SDL_WINDOW_HIDDEN
@ SDL_WINDOW_HIDDEN
Definition: SDL_video.h:102
SDL_GetCurrentVideoDriver
#define SDL_GetCurrentVideoDriver
Definition: SDL_dynapi_overrides.h:500
SDL_ISPIXELFORMAT_FOURCC
#define SDL_ISPIXELFORMAT_FOURCC(format)
Definition: SDL_pixels.h:167
SDL_GetRenderer
SDL_Renderer * SDL_GetRenderer(SDL_Window *window)
Get the renderer associated with a window.
Definition: SDL_render.c:937
SDL_RenderCommand::cliprect
struct SDL_RenderCommand::@23::@25 cliprect
SDL_RenderDrawRectF
int SDL_RenderDrawRectF(SDL_Renderer *renderer, const SDL_FRect *rect)
Draw a rectangle on the current rendering target.
Definition: SDL_render.c:2659
SDL_Renderer::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:158
SDL_RENDERER_TARGETTEXTURE
@ SDL_RENDERER_TARGETTEXTURE
Definition: SDL_render.h:71
SDL_GetWindowPixelFormat
#define SDL_GetWindowPixelFormat
Definition: SDL_dynapi_overrides.h:513
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4586
CHECK_TEXTURE_MAGIC
#define CHECK_TEXTURE_MAGIC(texture, retval)
Definition: SDL_render.c:45
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
SDL_Renderer::RenderPresent
void(* RenderPresent)(SDL_Renderer *renderer)
Definition: SDL_sysrender.h:146
SDL_BYTESPERPIXEL
#define SDL_BYTESPERPIXEL(X)
Definition: SDL_pixels.h:128
SDL_RenderSetViewport
int SDL_RenderSetViewport(SDL_Renderer *renderer, const SDL_Rect *rect)
Set the drawing area for rendering on the current target.
Definition: SDL_render.c:2099
SDL_Rect
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:77
SDL_RendererInfo::max_texture_width
int max_texture_width
Definition: SDL_render.h:84
SDL_GetScaleMode
static SDL_ScaleMode SDL_GetScaleMode(void)
Definition: SDL_render.c:1027
SDL_BLENDFACTOR_SRC_COLOR
@ SDL_BLENDFACTOR_SRC_COLOR
Definition: SDL_blendmode.h:82
IsSupportedFormat
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:988
SDL_Texture
Definition: SDL_sysrender.h:36
SDL_Renderer::QueueFillRects
int(* QueueFillRects)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FRect *rects, int count)
Definition: SDL_sysrender.h:123
SDL_Renderer::UpdateTexture
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_sysrender.h:131
SDL_TEXTUREACCESS_TARGET
@ SDL_TEXTUREACCESS_TARGET
Definition: SDL_render.h:105
y1
GLfixed y1
Definition: SDL_opengl_glext.h:4586
SDL_BLENDMODE_BLEND_FULL
#define SDL_BLENDMODE_BLEND_FULL
Definition: SDL_render.c:66
SDL_FLIP_NONE
@ SDL_FLIP_NONE
Definition: SDL_render.h:123
SDL_DestroyMutex
#define SDL_DestroyMutex
Definition: SDL_dynapi_overrides.h:263
SDL_PIXELFORMAT_UNKNOWN
@ SDL_PIXELFORMAT_UNKNOWN
Definition: SDL_pixels.h:173
SDL_RendererEventWatch
static int SDL_RendererEventWatch(void *userdata, SDL_Event *event)
Definition: SDL_render.c:588
SDL_AddEventWatch
#define SDL_AddEventWatch
Definition: SDL_dynapi_overrides.h:128
SDL_FRect
A rectangle, with the origin at the upper left (floating point).
Definition: SDL_rect.h:87
y2
GLfixed GLfixed GLfixed y2
Definition: SDL_opengl_glext.h:4586
SDL_CreateRGBSurfaceWithFormatFrom
#define SDL_CreateRGBSurfaceWithFormatFrom
Definition: SDL_dynapi_overrides.h:607
SDL_GetSurfaceColorMod
#define SDL_GetSurfaceColorMod
Definition: SDL_dynapi_overrides.h:456
SDL_RenderDriver::info
SDL_RendererInfo info
Definition: SDL_sysrender.h:227
SDL_ConvertPixels
#define SDL_ConvertPixels
Definition: SDL_dynapi_overrides.h:465
numbytes
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
Definition: pixman-arm-neon-asm.h:112
SDL_MOUSEBUTTONDOWN
@ SDL_MOUSEBUTTONDOWN
Definition: SDL_events.h:106
angle
GLfloat angle
Definition: SDL_opengl_glext.h:6100
SDL_BLENDFACTOR_DST_ALPHA
@ SDL_BLENDFACTOR_DST_ALPHA
Definition: SDL_blendmode.h:88
SDL_Renderer::logical_w_backup
int logical_w_backup
Definition: SDL_sysrender.h:167
SDL_Renderer::clipping_enabled
SDL_bool clipping_enabled
Definition: SDL_sysrender.h:182
SDL_Renderer::magic
const void * magic
Definition: SDL_sysrender.h:111
SDL_RenderCopyF
int SDL_RenderCopyF(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Copy a portion of the texture to the current rendering target.
Definition: SDL_render.c:2945
SDL_RendererInfo::name
const char * name
Definition: SDL_render.h:80
SDL_BLENDMODE_NONE_FULL
#define SDL_BLENDMODE_NONE_FULL
Definition: SDL_render.c:62
SDL_ScaleMode
SDL_ScaleMode
The scaling mode for a texture.
Definition: SDL_render.h:91
SDL_WINDOWEVENT_HIDDEN
@ SDL_WINDOWEVENT_HIDDEN
Definition: SDL_video.h:149
SDL_SetTextureColorMod
int SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b)
Set an additional color value used in render copy operations.
Definition: SDL_render.c:1309
CHECK_RENDERER_MAGIC
#define CHECK_RENDERER_MAGIC(renderer, retval)
Definition: SDL_render.c:38
PrepQueueCmdDraw
static int PrepQueueCmdDraw(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
Definition: SDL_render.c:417
SDL_WINDOWEVENT
@ SDL_WINDOWEVENT
Definition: SDL_events.h:92
SDL_HINT_RENDER_DRIVER
#define SDL_HINT_RENDER_DRIVER
A variable specifying which render driver to use.
Definition: SDL_hints.h:85
SDL_Renderer::QueueDrawPoints
int(* QueueDrawPoints)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count)
Definition: SDL_sysrender.h:119
SDL_WINDOWEVENT_RESTORED
@ SDL_WINDOWEVENT_RESTORED
Definition: SDL_video.h:160
PrepQueueCmdDrawSolid
static SDL_RenderCommand * PrepQueueCmdDrawSolid(SDL_Renderer *renderer, const SDL_RenderCommandType cmdtype)
Definition: SDL_render.c:433
SDL_ISPIXELFORMAT_ALPHA
#define SDL_ISPIXELFORMAT_ALPHA(format)
Definition: SDL_pixels.h:154
SDL_Renderer::r
Uint8 r
Definition: SDL_sysrender.h:197
SDL_BLENDFACTOR_ONE
@ SDL_BLENDFACTOR_ONE
Definition: SDL_blendmode.h:81
SDL_Unsupported
#define SDL_Unsupported()
Definition: SDL_error.h:53
SDL_Renderer::render_commands_pool
SDL_RenderCommand * render_commands_pool
Definition: SDL_sysrender.h:204
SDL_Renderer::a
Uint8 a
Definition: SDL_sysrender.h:197
SDL_SetTextureBlendMode
int SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode)
Set the blend mode used for texture copy operations.
Definition: SDL_render.c:1374
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
SDL_RendererInfo::texture_formats
Uint32 texture_formats[16]
Definition: SDL_render.h:83
SDL_RendererInfo::max_texture_height
int max_texture_height
Definition: SDL_render.h:85
void
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
SDL_PIXELFORMAT_YV12
@ SDL_PIXELFORMAT_YV12
Definition: SDL_pixels.h:280
SDL_UnlockMutex
#define SDL_UnlockMutex
Definition: SDL_dynapi_overrides.h:262
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1483
SDL_RENDERCMD_SETDRAWCOLOR
@ SDL_RENDERCMD_SETDRAWCOLOR
Definition: SDL_sysrender.h:71
SDL_Renderer::QueueCopy
int(* QueueCopy)(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Definition: SDL_sysrender.h:125
SDL_Renderer::window
SDL_Window * window
Definition: SDL_sysrender.h:161
SDL_TEXTUREACCESS_STREAMING
@ SDL_TEXTUREACCESS_STREAMING
Definition: SDL_render.h:104
SDL_Renderer::target
SDL_Texture * target
Definition: SDL_sysrender.h:194
texture
GLenum GLenum GLuint texture
Definition: SDL_opengl_glext.h:1181
texture_magic
static char texture_magic
Definition: SDL_render.c:115
QueueCmdCopy
static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Definition: SDL_render.c:519
SDL_RenderCommand::viewport
struct SDL_RenderCommand::@23::@24 viewport
rects
EGLSurface EGLint * rects
Definition: eglext.h:282
SDL_RenderDrawPointsF
int SDL_RenderDrawPointsF(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
Draw multiple points on the current rendering target.
Definition: SDL_render.c:2381
SDL_PIXELFORMAT_ABGR8888
@ SDL_PIXELFORMAT_ABGR8888
Definition: SDL_pixels.h:257
DebugLogRenderCommands
static SDL_INLINE void DebugLogRenderCommands(const SDL_RenderCommand *cmd)
Definition: SDL_render.c:118
ptr
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
Definition: pixman-arm-simd-asm.h:171
SDL_BlendMode
SDL_BlendMode
The blend mode used in SDL_RenderCopy() and drawing operations.
Definition: SDL_blendmode.h:40
SDL_RenderDrawRect
int SDL_RenderDrawRect(SDL_Renderer *renderer, const SDL_Rect *rect)
Draw a rectangle on the current rendering target.
Definition: SDL_render.c:2642
SDL_RenderCommand::draw
struct SDL_RenderCommand::@23::@26 draw
SDL_LOG_CATEGORY_RENDER
@ SDL_LOG_CATEGORY_RENDER
Definition: SDL_log.h:72
SDL_Renderer::clipping_enabled_backup
SDL_bool clipping_enabled_backup
Definition: SDL_sysrender.h:183
i
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
SDL_HasColorKey
#define SDL_HasColorKey
Definition: SDL_dynapi_overrides.h:699
SDL_Renderer::clip_rect
SDL_Rect clip_rect
Definition: SDL_sysrender.h:178
SDL_RENDERCMD_CLEAR
@ SDL_RENDERCMD_CLEAR
Definition: SDL_sysrender.h:72
QueueCmdDrawLines
static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, const int count)
Definition: SDL_render.c:469
SDL_Point::y
int y
Definition: SDL_rect.h:51
SDL_WINDOWEVENT_MAXIMIZED
@ SDL_WINDOWEVENT_MAXIMIZED
Definition: SDL_video.h:159
SDL_WINDOWRENDERDATA
#define SDL_WINDOWRENDERDATA
Definition: SDL_render.c:36
GetClosestSupportedFormat
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, Uint32 format)
Definition: SDL_render.c:1001
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_Renderer::UnlockTexture
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:141
SDL_RendererInfo::num_texture_formats
Uint32 num_texture_formats
Definition: SDL_render.h:82
SDL_DelEventWatch
#define SDL_DelEventWatch
Definition: SDL_dynapi_overrides.h:129
SDL_GetShortBlendMode
static SDL_BlendMode SDL_GetShortBlendMode(SDL_BlendMode blendMode)
Definition: SDL_render.c:3310
SDL_SW_UpdateYUVTexture
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch)
Definition: SDL_yuv_sw.c:141
SDL_Renderer::DestroyTexture
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
Definition: SDL_sysrender.h:147
SDL_Renderer::UpdateTextureYUV
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)
Definition: SDL_sysrender.h:134
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:734
Uint8
uint8_t Uint8
Definition: SDL_stdinc.h:179