From 8b6d3c88cf15804b6ec1b4fa9d4a21dbcbab0699 Mon Sep 17 00:00:00 2001
From: L zard <[EMAIL REDACTED]>
Date: Sun, 3 Nov 2024 10:51:33 +0100
Subject: [PATCH] Fix `#ifdef`s to have config flags either defined as 1 or
undefined
See 387774ab8a32151d12f3e76653d5b5bc070a28ce
---
src/SDL_internal.h | 40 +++++++++++-------------
src/render/SDL_render.c | 22 ++++++-------
src/render/SDL_sysrender.h | 2 +-
src/render/SDL_yuv_sw.c | 2 +-
src/render/direct3d/SDL_render_d3d.c | 36 ++++++++++-----------
src/render/direct3d11/SDL_render_d3d11.c | 22 ++++++-------
src/render/direct3d12/SDL_render_d3d12.c | 20 ++++++------
src/render/metal/SDL_render_metal.m | 22 ++++++-------
src/render/opengl/SDL_render_gl.c | 20 ++++++------
src/render/opengl/SDL_shaders_gl.c | 2 +-
src/render/opengl/SDL_shaders_gl.h | 2 +-
src/render/opengles2/SDL_render_gles2.c | 30 +++++++++---------
src/render/opengles2/SDL_shaders_gles2.c | 4 +--
src/render/opengles2/SDL_shaders_gles2.h | 2 +-
src/render/vitagxm/SDL_render_vita_gxm.c | 10 +++---
src/render/vulkan/SDL_render_vulkan.c | 12 +++----
src/video/SDL_RLEaccel.c | 2 +-
src/video/SDL_blit.c | 16 +++++-----
src/video/SDL_blit_0.c | 2 +-
src/video/SDL_blit_1.c | 2 +-
src/video/SDL_blit_A.c | 2 +-
src/video/SDL_blit_N.c | 6 ++--
src/video/SDL_blit_auto.c | 2 +-
src/video/SDL_blit_auto.h | 2 +-
src/video/SDL_pixels.c | 4 +--
src/video/SDL_surface.c | 8 ++---
src/video/SDL_yuv.c | 8 ++---
src/video/sdlgenblit.pl | 2 +-
src/video/yuv2rgb/yuv_rgb_lsx.c | 2 +-
src/video/yuv2rgb/yuv_rgb_sse.c | 2 +-
src/video/yuv2rgb/yuv_rgb_std.c | 2 +-
31 files changed, 154 insertions(+), 156 deletions(-)
diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index e0d7ace11827d..acbf7c2f3382c 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -129,66 +129,64 @@
/* A few #defines to reduce SDL footprint.
Only effective when library is statically linked.
You have to manually edit this file. */
-#ifndef SDL_LEAN_AND_MEAN
-#define SDL_LEAN_AND_MEAN 0
-#endif
+#undef SDL_LEAN_AND_MEAN
/* Optimized functions from 'SDL_blit_0.c'
- blit with source bits_per_pixel < 8, palette */
-#ifndef SDL_HAVE_BLIT_0
-#define SDL_HAVE_BLIT_0 !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_BLIT_0) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_BLIT_0 1
#endif
/* Optimized functions from 'SDL_blit_1.c'
- blit with source bytes_per_pixel == 1, palette */
-#ifndef SDL_HAVE_BLIT_1
-#define SDL_HAVE_BLIT_1 !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_BLIT_1) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_BLIT_1 1
#endif
/* Optimized functions from 'SDL_blit_A.c'
- blit with 'SDL_BLENDMODE_BLEND' blending mode */
-#ifndef SDL_HAVE_BLIT_A
-#define SDL_HAVE_BLIT_A !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_BLIT_A) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_BLIT_A 1
#endif
/* Optimized functions from 'SDL_blit_N.c'
- blit with COLORKEY mode, or nothing */
-#ifndef SDL_HAVE_BLIT_N
-#define SDL_HAVE_BLIT_N !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_BLIT_N) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_BLIT_N 1
#endif
/* Optimized functions from 'SDL_blit_N.c'
- RGB565 conversion with Lookup tables */
-#ifndef SDL_HAVE_BLIT_N_RGB565
-#define SDL_HAVE_BLIT_N_RGB565 !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_BLIT_N_RGB565) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_BLIT_N_RGB565 1
#endif
/* Optimized functions from 'SDL_blit_AUTO.c'
- blit with modulate color, modulate alpha, any blending mode
- scaling or not */
-#ifndef SDL_HAVE_BLIT_AUTO
-#define SDL_HAVE_BLIT_AUTO !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_BLIT_AUTO) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_BLIT_AUTO 1
#endif
/* Run-Length-Encoding
- SDL_SetSurfaceColorKey() called with SDL_RLEACCEL flag */
-#ifndef SDL_HAVE_RLE
-#define SDL_HAVE_RLE !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_RLE) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_RLE 1
#endif
/* Software SDL_Renderer
- creation of software renderer
- *not* general blitting functions
- {blend,draw}{fillrect,line,point} internal functions */
-#ifndef SDL_VIDEO_RENDER_SW
-#define SDL_VIDEO_RENDER_SW !SDL_LEAN_AND_MEAN
+#if !defined(SDL_VIDEO_RENDER_SW) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_VIDEO_RENDER_SW 1
#endif
/* YUV formats
- handling of YUV surfaces
- blitting and conversion functions */
-#ifndef SDL_HAVE_YUV
-#define SDL_HAVE_YUV !SDL_LEAN_AND_MEAN
+#if !defined(SDL_HAVE_YUV) && !defined(SDL_LEAN_AND_MEAN)
+#define SDL_HAVE_YUV 1
#endif
#ifdef SDL_RENDER_DISABLED
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index a742700c250ae..a7b4c5e253bea 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1450,7 +1450,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
renderer->textures = texture;
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
texture->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->colorspace, w, h);
#else
SDL_SetError("SDL not built with YUV support");
@@ -1971,7 +1971,7 @@ bool SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode)
return true;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect,
const void *pixels, int pitch)
{
@@ -2083,7 +2083,7 @@ bool SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *p
if (real_rect.w == 0 || real_rect.h == 0) {
return true; // nothing to do.
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
} else if (texture->yuv) {
return SDL_UpdateTextureYUV(texture, &real_rect, pixels, pitch);
#endif
@@ -2098,7 +2098,7 @@ bool SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *p
}
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
const Uint8 *Uplane, int Upitch,
@@ -2207,7 +2207,7 @@ bool SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect,
const Uint8 *Uplane, int Upitch,
const Uint8 *Vplane, int Vpitch)
{
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
SDL_Renderer *renderer;
SDL_Rect real_rect;
@@ -2273,7 +2273,7 @@ bool SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
const Uint8 *UVplane, int UVpitch)
{
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
SDL_Renderer *renderer;
SDL_Rect real_rect;
@@ -2329,7 +2329,7 @@ bool SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect,
#endif
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool SDL_LockTextureYUV(SDL_Texture *texture, const SDL_Rect *rect,
void **pixels, int *pitch)
{
@@ -2366,7 +2366,7 @@ bool SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels,
rect = &full_rect;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->yuv) {
if (!FlushRenderCommandsIfTextureNeeded(texture)) {
return false;
@@ -2418,7 +2418,7 @@ bool SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Su
return true;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static void SDL_UnlockTextureYUV(SDL_Texture *texture)
{
SDL_Texture *native = texture->native;
@@ -2467,7 +2467,7 @@ void SDL_UnlockTexture(SDL_Texture *texture)
if (texture->access != SDL_TEXTUREACCESS_STREAMING) {
return;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->yuv) {
SDL_UnlockTextureYUV(texture);
} else
@@ -5148,7 +5148,7 @@ static void SDL_DestroyTextureInternal(SDL_Texture *texture, bool is_destroying)
if (texture->native) {
SDL_DestroyTextureInternal(texture->native, is_destroying);
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->yuv) {
SDL_SW_DestroyYUVTexture(texture->yuv);
}
diff --git a/src/render/SDL_sysrender.h b/src/render/SDL_sysrender.h
index 381b516fd9fb2..d3421cb40a4f2 100644
--- a/src/render/SDL_sysrender.h
+++ b/src/render/SDL_sysrender.h
@@ -203,7 +203,7 @@ struct SDL_Renderer
bool (*UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect, const void *pixels,
int pitch);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
bool (*UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c
index e7e9fe4eded91..251330e055df9 100644
--- a/src/render/SDL_yuv_sw.c
+++ b/src/render/SDL_yuv_sw.c
@@ -22,7 +22,7 @@
// This is the software implementation of the YUV texture support
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
#include "SDL_yuv_sw_c.h"
#include "../video/SDL_surface_c.h"
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index ec79455b79c01..2f2f9c4304b9f 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -65,7 +65,7 @@ typedef struct
IDirect3DSurface9 *defaultRenderTarget;
IDirect3DSurface9 *currentRenderTarget;
void *d3dxDLL;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
LPDIRECT3DPIXELSHADER9 shaders[NUM_SHADERS];
#endif
LPDIRECT3DVERTEXBUFFER9 vertexBuffers[8];
@@ -93,7 +93,7 @@ typedef struct
D3D9_Shader shader;
const float *shader_params;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
// YV12 texture support
bool yuv;
D3D_TextureRep utexture;
@@ -546,7 +546,7 @@ static bool D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_
if (!D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->format, PixelFormatToD3DFMT(texture->format), texture->w, texture->h)) {
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
texturedata->yuv = true;
@@ -581,7 +581,7 @@ static bool D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (!D3D_RecreateTextureRep(data->device, &texturedata->texture)) {
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata->yuv) {
if (!D3D_RecreateTextureRep(data->device, &texturedata->utexture)) {
return false;
@@ -608,7 +608,7 @@ static bool D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
if (!D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch)) {
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata->yuv) {
// Skip to the correct offset into the next texture
pixels = (const void *)((const Uint8 *)pixels + rect->h * pitch);
@@ -627,7 +627,7 @@ static bool D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
return true;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
@@ -664,7 +664,7 @@ static bool D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
if (!texturedata) {
return SDL_SetError("Texture is not currently available");
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
texturedata->locked_rect = *rect;
if (texturedata->yuv) {
@@ -714,7 +714,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (!texturedata) {
return;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata->yuv) {
const SDL_Rect *rect = &texturedata->locked_rect;
void *pixels =
@@ -971,7 +971,7 @@ static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_Te
if (!BindTextureRep(data->device, &texturedata->texture, 0)) {
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata->yuv) {
UpdateTextureScaleMode(data, texturedata, 1);
UpdateTextureScaleMode(data, texturedata, 2);
@@ -995,7 +995,7 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
const SDL_BlendMode blend = cmd->data.draw.blend;
if (texture != data->drawstate.texture) {
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
D3D_TextureData *oldtexturedata = data->drawstate.texture ? (D3D_TextureData *)data->drawstate.texture->internal : NULL;
D3D_TextureData *newtexturedata = texture ? (D3D_TextureData *)texture->internal : NULL;
#endif
@@ -1006,7 +1006,7 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
if (!texture) {
IDirect3DDevice9_SetTexture(data->device, 0, NULL);
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if ((!newtexturedata || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) {
IDirect3DDevice9_SetTexture(data->device, 1, NULL);
IDirect3DDevice9_SetTexture(data->device, 2, NULL);
@@ -1016,7 +1016,7 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (shader != data->drawstate.shader) {
const HRESULT result = IDirect3DDevice9_SetPixelShader(data->device, data->shaders[shader]);
if (FAILED(result)) {
@@ -1041,7 +1041,7 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
} else if (texture) {
D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal;
UpdateDirtyTexture(data->device, &texturedata->texture);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata->yuv) {
UpdateDirtyTexture(data->device, &texturedata->utexture);
UpdateDirtyTexture(data->device, &texturedata->vtexture);
@@ -1424,7 +1424,7 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
renderdata->drawstate.shader_params = NULL;
IDirect3DDevice9_SetPixelShader(renderdata->device, NULL);
IDirect3DDevice9_SetTexture(renderdata->device, 0, NULL);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (data->yuv) {
IDirect3DDevice9_SetTexture(renderdata->device, 1, NULL);
IDirect3DDevice9_SetTexture(renderdata->device, 2, NULL);
@@ -1437,7 +1437,7 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
}
D3D_DestroyTextureRep(&data->texture);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
D3D_DestroyTextureRep(&data->utexture);
D3D_DestroyTextureRep(&data->vtexture);
SDL_free(data->pixels);
@@ -1462,7 +1462,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer)
IDirect3DSurface9_Release(data->currentRenderTarget);
data->currentRenderTarget = NULL;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
for (i = 0; i < SDL_arraysize(data->shaders); ++i) {
if (data->shaders[i]) {
IDirect3DPixelShader9_Release(data->shaders[i]);
@@ -1648,7 +1648,7 @@ static bool D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
renderer->SupportsBlendMode = D3D_SupportsBlendMode;
renderer->CreateTexture = D3D_CreateTexture;
renderer->UpdateTexture = D3D_UpdateTexture;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
renderer->UpdateTextureYUV = D3D_UpdateTextureYUV;
#endif
renderer->LockTexture = D3D_LockTexture;
@@ -1751,7 +1751,7 @@ static bool D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P
// Set up parameters for rendering
D3D_InitRenderState(data);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (caps.MaxSimultaneousTextures >= 3) {
int i;
for (i = SHADER_NONE + 1; i < SDL_arraysize(data->shaders); ++i) {
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 5c2b5419b9f3b..604d7829a53b7 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -125,7 +125,7 @@ typedef struct
D3D11_FILTER scaleMode;
D3D11_Shader shader;
const float *YCbCr_matrix;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
// YV12 texture support
bool yuv;
ID3D11Texture2D *mainTextureU;
@@ -1215,7 +1215,7 @@ static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
}
}
SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER, textureData->mainTexture);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
textureData->yuv = true;
@@ -1289,7 +1289,7 @@ static bool D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv) {
result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
(ID3D11Resource *)textureData->mainTextureU,
@@ -1358,7 +1358,7 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer,
SAFE_RELEASE(data->mainTextureResourceView);
SAFE_RELEASE(data->mainTextureRenderTargetView);
SAFE_RELEASE(data->stagingTexture);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
SAFE_RELEASE(data->mainTextureU);
SAFE_RELEASE(data->mainTextureResourceViewU);
SAFE_RELEASE(data->mainTextureV);
@@ -1473,7 +1473,7 @@ static bool D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Te
return true;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
@@ -1497,7 +1497,7 @@ static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
return SDL_SetError("Texture is not currently available");
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->nv12) {
const Uint8 *Yplane = (const Uint8 *)srcPixels;
const Uint8 *UVplane = Yplane + rect->h * srcPitch;
@@ -1525,7 +1525,7 @@ static bool D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
return true;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
@@ -1677,7 +1677,7 @@ static bool D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
if (!textureData) {
return SDL_SetError("Texture is not currently available");
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv || textureData->nv12) {
// It's more efficient to upload directly...
if (!textureData->pixels) {
@@ -1754,7 +1754,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (!textureData) {
return;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv || textureData->nv12) {
const SDL_Rect *rect = &textureData->locked_rect;
void *pixels =
@@ -2333,7 +2333,7 @@ static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *
default:
return SDL_SetError("Unknown scale mode: %d\n", textureData->scaleMode);
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv) {
ID3D11ShaderResourceView *shaderResources[3];
@@ -2693,7 +2693,7 @@ static bool D3D11_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL
renderer->SupportsBlendMode = D3D11_SupportsBlendMode;
renderer->CreateTexture = D3D11_CreateTexture;
renderer->UpdateTexture = D3D11_UpdateTexture;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV;
renderer->UpdateTextureNV = D3D11_UpdateTextureNV;
#endif
diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c
index 7e0d846c83dc4..63017077a5100 100644
--- a/src/render/direct3d12/SDL_render_d3d12.c
+++ b/src/render/direct3d12/SDL_render_d3d12.c
@@ -127,7 +127,7 @@ typedef struct
D3D12_FILTER scaleMode;
D3D12_Shader shader;
const float *YCbCr_matrix;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
// YV12 texture support
bool yuv;
ID3D12Resource *mainTextureU;
@@ -1619,7 +1619,7 @@ static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
}
textureData->mainResourceState = D3D12_RESOURCE_STATE_COPY_DEST;
SDL_SetPointerProperty(SDL_GetTextureProperties(texture), SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER, textureData->mainTexture);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
textureData->yuv = true;
@@ -1706,7 +1706,7 @@ static bool D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
textureData->mainTexture,
&resourceViewDesc,
textureData->mainTextureResourceView);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv) {
D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU);
textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer);
@@ -1781,7 +1781,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
D3D_SAFE_RELEASE(textureData->mainTexture);
D3D_SAFE_RELEASE(textureData->stagingBuffer);
D3D12_FreeSRVIndex(renderer, textureData->mainSRVIndex);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
D3D_SAFE_RELEASE(textureData->mainTextureU);
D3D_SAFE_RELEASE(textureData->mainTextureV);
if (textureData->yuv) {
@@ -1949,7 +1949,7 @@ static bool D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
if (!D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 0, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch, &textureData->mainResourceState)) {
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv) {
// Skip to the correct offset into the next texture
srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch);
@@ -1982,7 +1982,7 @@ static bool D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
return true;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
@@ -2048,7 +2048,7 @@ static bool D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
if (!textureData) {
return SDL_SetError("Texture is not currently available");
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv || textureData->nv12) {
// It's more efficient to upload directly...
if (!textureData->pixels) {
@@ -2167,7 +2167,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
if (!textureData) {
return;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv || textureData->nv12) {
const SDL_Rect *rect = &textureData->lockedRect;
void *pixels =
@@ -2760,7 +2760,7 @@ static bool D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *
default:
return SDL_SetError("Unknown scale mode: %d\n", textureData->scaleMode);
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (textureData->yuv) {
D3D12_CPU_DESCRIPTOR_HANDLE shaderResources[3];
@@ -3229,7 +3229,7 @@ bool D3D12_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Proper
renderer->SupportsBlendMode = D3D12_SupportsBlendMode;
renderer->CreateTexture = D3D12_CreateTexture;
renderer->UpdateTexture = D3D12_UpdateTexture;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
renderer->UpdateTextureYUV = D3D12_UpdateTextureYUV;
renderer->UpdateTextureNV = D3D12_UpdateTextureNV;
#endif
diff --git a/src/render/metal/SDL_render_metal.m b/src/render/metal/SDL_render_metal.m
index 40ca278cbdb79..55c17826458f6 100644
--- a/src/render/metal/SDL_render_metal.m
+++ b/src/render/metal/SDL_render_metal.m
@@ -158,7 +158,7 @@ @interface SDL3METAL_TextureData : NSObject
@property(nonatomic, retain) id<MTLTexture> mtltexture;
@property(nonatomic, retain) id<MTLTexture> mtltextureUv;
@property(nonatomic, assign) SDL_MetalFragmentFunction fragmentFunction;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
@property(nonatomic, assign) BOOL yuv;
@property(nonatomic, assign) BOOL nv12;
@property(nonatomic, assign) size_t conversionBufferOffset;
@@ -711,7 +711,7 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
}
mtltextureUv = nil;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
BOOL yuv = (texture->format == SDL_PIXELFORMAT_IYUV || texture->format == SDL_PIXELFORMAT_YV12);
BOOL nv12 = (texture->format == SDL_PIXELFORMAT_NV12 || texture->format == SDL_PIXELFORMAT_NV21 || texture->format == SDL_PIXELFORMAT_P010);
@@ -747,7 +747,7 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
texturedata = [[SDL3METAL_TextureData alloc] init];
if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_SRGB) {
texturedata.fragmentFunction = SDL_METAL_FRAGMENT_COPY;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
} else if (yuv) {
texturedata.fragmentFunction = SDL_METAL_FRAGMENT_YUV;
#endif
@@ -756,7 +756,7 @@ static bool METAL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SD
}
texturedata.mtltexture = mtltexture;
texturedata.mtltextureUv = mtltextureUv;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
texturedata.yuv = yuv;
texturedata.nv12 = nv12;
if (yuv || nv12) {
@@ -870,7 +870,7 @@ static bool METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
if (!METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, pixels, pitch)) {
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata.yuv) {
int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0;
int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1;
@@ -907,7 +907,7 @@ static bool METAL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
}
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
static bool METAL_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
const SDL_Rect *rect,
const Uint8 *Yplane, int Ypitch,
@@ -984,7 +984,7 @@ static bool METAL_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
}
*pitch = SDL_BYTESPERPIXEL(texture->format) * rect->w;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata.yuv || texturedata.nv12) {
buffersize = ((*pitch) * rect->h) + (2 * (*pitch + 1) / 2) * ((rect->h + 1) / 2);
} else
@@ -1014,7 +1014,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
id<MTLBlitCommandEncoder> blitcmd;
SDL_Rect rect = texturedata.lockedrect;
int pitch = SDL_BYTESPERPIXEL(texture->format) * rect.w;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
SDL_Rect UVrect = { rect.x / 2, rect.y / 2, (rect.w + 1) / 2, (rect.h + 1) / 2 };
#endif
@@ -1042,7 +1042,7 @@ static void METAL_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
destinationSlice:0
destinationLevel:0
destinationOrigin:MTLOriginMake(rect.x, rect.y, 0)];
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata.yuv) {
int Uslice = texture->format == SDL_PIXELFORMAT_YV12 ? 1 : 0;
int Vslice = texture->format == SDL_PIXELFORMAT_YV12 ? 0 : 1;
@@ -1522,7 +1522,7 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, c
[data.mtlcmdencoder setFragmentSamplerState:mtlsampler atIndex:0];
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltexture atIndex:0];
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texturedata.yuv || texturedata.nv12) {
[data.mtlcmdencoder setFragmentTexture:texturedata.mtltextureUv atIndex:1];
[data.mtlcmdencoder setFragmentBuffer:data.mtlbufconstants offset:texturedata.conversionBufferOffset atIndex:1];
@@ -2151,7 +2151,7 @@ in case we want to use it later (recreating the renderer)
renderer->SupportsBlendMode = METAL_SupportsBlendMode;
renderer->CreateTexture = METAL_CreateTexture;
renderer->UpdateTexture = METAL_UpdateTexture;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
renderer->UpdateTextureYUV = METAL_UpdateTextureYUV;
renderer->UpdateTextureNV = METAL_UpdateTextureNV;
#endif
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index b598098a599f1..a721021e17b96 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -138,7 +138,7 @@ typedef struct
int pitch;
SDL_Rect locked_rect;
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
// YUV texture support
bool yuv;
bool nv12;
@@ -577,7 +577,7 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
return false;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (texture->format == SDL_PIXELFORMAT_YV12 ||
texture->format == SDL_PIXELFORMAT_IYUV) {
data->yuv = true;
@@ -641,7 +641,7 @@ static bool GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
data->shader = SHADER_RGB;
}
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (data->yuv || data->nv12) {
if (data->yuv) {
data->shader = SHADER_YUV;
@@ -688,7 +688,7 @@ static bool GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w,
rect->h, data->format, data->formattype,
pixels);
-#if SDL_HAVE_YUV
+#ifdef SDL_HAVE_YUV
if (data->yuv) {
renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2));
@@ -729,7 +729,7 @@ static bool GL_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
return GL_Check
(Patch may be truncated, please check the link at the top of this post.)