mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-20 04:17:21 +08:00
[SDL2] pointer boolean (#8523)
This commit is contained in:
+76
-76
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
}
|
||||
|
||||
swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata));
|
||||
if (swdata == NULL) {
|
||||
if (!swdata) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *te
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
if (texture->staging == NULL) {
|
||||
if (!texture->staging) {
|
||||
result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0,
|
||||
texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
|
||||
if (FAILED(result)) {
|
||||
@@ -535,7 +535,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
DWORD usage;
|
||||
|
||||
texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata));
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
texturedata->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
@@ -573,7 +573,7 @@ static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
IDirect3DDevice9 *device = data->device;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -710,7 +710,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -738,7 +738,7 @@ static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -754,18 +754,18 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text
|
||||
IDirect3DDevice9 *device = data->device;
|
||||
|
||||
/* Release the previous render target if it wasn't the default one */
|
||||
if (data->currentRenderTarget != NULL) {
|
||||
if (data->currentRenderTarget) {
|
||||
IDirect3DSurface9_Release(data->currentRenderTarget);
|
||||
data->currentRenderTarget = NULL;
|
||||
}
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget);
|
||||
return 0;
|
||||
}
|
||||
|
||||
texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -845,7 +845,7 @@ static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(Vertex), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -939,9 +939,9 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIREC
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
SDL_assert(*shader == NULL);
|
||||
SDL_assert(!*shader);
|
||||
|
||||
if (texturedata == NULL) {
|
||||
if (!texturedata) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -993,11 +993,11 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
LPDIRECT3DPIXELSHADER9 shader = NULL;
|
||||
|
||||
/* disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. */
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
IDirect3DDevice9_SetTexture(data->device, 0, NULL);
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if ((newtexturedata == NULL || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) {
|
||||
if ((!newtexturedata || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) {
|
||||
IDirect3DDevice9_SetTexture(data->device, 1, NULL);
|
||||
IDirect3DDevice9_SetTexture(data->device, 2, NULL);
|
||||
}
|
||||
@@ -1391,7 +1391,7 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1417,7 +1417,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer)
|
||||
IDirect3DSurface9_Release(data->defaultRenderTarget);
|
||||
data->defaultRenderTarget = NULL;
|
||||
}
|
||||
if (data->currentRenderTarget != NULL) {
|
||||
if (data->currentRenderTarget) {
|
||||
IDirect3DSurface9_Release(data->currentRenderTarget);
|
||||
data->currentRenderTarget = NULL;
|
||||
}
|
||||
@@ -1468,7 +1468,7 @@ static int D3D_Reset(SDL_Renderer *renderer)
|
||||
IDirect3DSurface9_Release(data->defaultRenderTarget);
|
||||
data->defaultRenderTarget = NULL;
|
||||
}
|
||||
if (data->currentRenderTarget != NULL) {
|
||||
if (data->currentRenderTarget) {
|
||||
IDirect3DSurface9_Release(data->currentRenderTarget);
|
||||
data->currentRenderTarget = NULL;
|
||||
}
|
||||
@@ -1562,13 +1562,13 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
int displayIndex;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -385,7 +385,7 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen
|
||||
}
|
||||
|
||||
blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes));
|
||||
if (blendModes == NULL) {
|
||||
if (!blendModes) {
|
||||
SAFE_RELEASE(blendState);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -442,7 +442,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
|
||||
if (CreateDXGIFactoryFunc == NULL) {
|
||||
if (!CreateDXGIFactoryFunc) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -740,7 +740,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h)
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
|
||||
#ifdef __WINRT__
|
||||
IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer);
|
||||
const BOOL usingXAML = (coreWindow == NULL);
|
||||
const BOOL usingXAML = (!coreWindow);
|
||||
#else
|
||||
IUnknown *coreWindow = NULL;
|
||||
const BOOL usingXAML = FALSE;
|
||||
@@ -929,7 +929,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer)
|
||||
#endif
|
||||
} else {
|
||||
result = D3D11_CreateSwapChain(renderer, w, h);
|
||||
if (FAILED(result) || data->swapChain == NULL) {
|
||||
if (FAILED(result) || !data->swapChain) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -1071,7 +1071,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
}
|
||||
|
||||
textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData));
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
@@ -1232,7 +1232,7 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer,
|
||||
{
|
||||
D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1339,7 +1339,7 @@ static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1384,7 +1384,7 @@ static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1408,7 +1408,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1432,7 +1432,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D11_TEXTURE2D_DESC stagingTextureDesc;
|
||||
D3D11_MAPPED_SUBRESOURCE textureMemory;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -1511,7 +1511,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -1547,7 +1547,7 @@ static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
||||
{
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1559,7 +1559,7 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = NULL;
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
rendererData->currentOffscreenRenderTargetView = NULL;
|
||||
return 0;
|
||||
}
|
||||
@@ -1590,7 +1590,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1617,7 +1617,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1889,9 +1889,9 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (blendState == NULL) {
|
||||
if (!blendState) {
|
||||
blendState = D3D11_CreateBlendState(renderer, blendMode);
|
||||
if (blendState == NULL) {
|
||||
if (!blendState) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2144,13 +2144,13 @@ static int D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
D3D11_MAPPED_SUBRESOURCE textureMemory;
|
||||
|
||||
renderTargetView = D3D11_GetCurrentRenderTargetView(renderer);
|
||||
if (renderTargetView == NULL) {
|
||||
if (!renderTargetView) {
|
||||
SDL_SetError("%s, ID3D11DeviceContext::OMGetRenderTargets failed", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
|
||||
ID3D11View_GetResource(renderTargetView, (ID3D11Resource **)&backBuffer);
|
||||
if (backBuffer == NULL) {
|
||||
if (!backBuffer) {
|
||||
SDL_SetError("%s, ID3D11View::GetResource failed", __FUNCTION__);
|
||||
goto done;
|
||||
}
|
||||
@@ -2305,13 +2305,13 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
D3D11_RenderData *data;
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -46,7 +46,7 @@ extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *sdlWindow = renderer->window;
|
||||
if (renderer->window == NULL) {
|
||||
if (!renderer->window) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -633,7 +633,7 @@ static D3D12_PipelineState *D3D12_CreatePipelineState(SDL_Renderer *renderer,
|
||||
}
|
||||
|
||||
pipelineStates = (D3D12_PipelineState *)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates));
|
||||
if (pipelineStates == NULL) {
|
||||
if (!pipelineStates) {
|
||||
SAFE_RELEASE(pipelineState);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -748,7 +748,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (CreateEventExFunc == NULL) {
|
||||
if (!CreateEventExFunc) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -761,7 +761,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2");
|
||||
if (CreateDXGIFactoryFunc == NULL) {
|
||||
if (!CreateDXGIFactoryFunc) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -805,7 +805,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
|
||||
|
||||
/* If the debug hint is set, also create the DXGI factory in debug mode */
|
||||
DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
|
||||
if (DXGIGetDebugInterfaceFunc == NULL) {
|
||||
if (!DXGIGetDebugInterfaceFunc) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -1438,7 +1438,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
}
|
||||
|
||||
textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData));
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
@@ -1616,7 +1616,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1794,7 +1794,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1839,7 +1839,7 @@ static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1863,7 +1863,7 @@ static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1892,7 +1892,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
BYTE *textureMemory;
|
||||
int bpp;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -2011,7 +2011,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation;
|
||||
int bpp;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -2082,7 +2082,7 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu
|
||||
{
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (textureData == NULL) {
|
||||
if (!textureData) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2094,7 +2094,7 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = NULL;
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
if (rendererData->textureRenderTarget) {
|
||||
D3D12_TransitionResource(rendererData,
|
||||
rendererData->textureRenderTarget->mainTexture,
|
||||
@@ -2137,7 +2137,7 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2164,7 +2164,7 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2965,13 +2965,13 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
D3D12_RenderData *data;
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -186,7 +186,7 @@ GL_ClearErrors(SDL_Renderer *renderer)
|
||||
data->errors = 0;
|
||||
data->error_messages = NULL;
|
||||
}
|
||||
} else if (data->glGetError != NULL) {
|
||||
} else if (data->glGetError) {
|
||||
while (data->glGetError() != GL_NO_ERROR) {
|
||||
/* continue; */
|
||||
}
|
||||
@@ -306,7 +306,7 @@ static GL_FBOList *GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h)
|
||||
result = result->next;
|
||||
}
|
||||
|
||||
if (result == NULL) {
|
||||
if (!result) {
|
||||
result = SDL_malloc(sizeof(GL_FBOList));
|
||||
if (result) {
|
||||
result->w = w;
|
||||
@@ -471,7 +471,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
}
|
||||
|
||||
data = (GL_TextureData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
return 0;
|
||||
}
|
||||
@@ -918,7 +918,7 @@ static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -938,7 +938,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
const size_t vertlen = (sizeof(GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
@@ -983,7 +983,7 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||
size_t sz = 2 * sizeof(GLfloat) + 4 * sizeof(Uint8) + (texture ? 2 : 0) * sizeof(GLfloat);
|
||||
|
||||
verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1089,7 +1089,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const
|
||||
}
|
||||
|
||||
if ((cmd->data.draw.texture != NULL) != data->drawstate.texturing) {
|
||||
if (cmd->data.draw.texture == NULL) {
|
||||
if (!cmd->data.draw.texture) {
|
||||
data->glDisable(data->textype);
|
||||
data->drawstate.texturing = SDL_FALSE;
|
||||
} else {
|
||||
@@ -1294,7 +1294,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
SDL_BlendMode thisblend = cmd->data.draw.blend;
|
||||
|
||||
while (nextcmd != NULL) {
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
@@ -1328,7 +1328,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
size_t count = cmd->data.draw.count;
|
||||
int ret;
|
||||
while (nextcmd != NULL) {
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != thiscmdtype) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
@@ -1437,7 +1437,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
|
||||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch);
|
||||
if (temp_pixels == NULL) {
|
||||
if (!temp_pixels) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1502,7 +1502,7 @@ static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
renderdata->drawstate.target = NULL;
|
||||
}
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (data->texture) {
|
||||
@@ -1524,7 +1524,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer)
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data) {
|
||||
if (data->context != NULL) {
|
||||
if (data->context) {
|
||||
/* make sure we delete the right resources! */
|
||||
GL_ActivateRenderer(renderer);
|
||||
}
|
||||
@@ -1730,13 +1730,13 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
#endif
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GL_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
@@ -1831,7 +1831,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
}
|
||||
|
||||
hint = SDL_getenv("GL_ARB_texture_non_power_of_two");
|
||||
if (hint == NULL || *hint != '0') {
|
||||
if (!hint || *hint != '0') {
|
||||
SDL_bool isGL2 = SDL_FALSE;
|
||||
const char *verstr = (const char *)data->glGetString(GL_VERSION);
|
||||
if (verstr) {
|
||||
|
||||
@@ -497,7 +497,7 @@ GL_ShaderContext *GL_CreateShaderContext(void)
|
||||
int i;
|
||||
|
||||
ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (ctx == NULL) {
|
||||
if (!ctx) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ static GLES_FBOList *GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h)
|
||||
while ((result) && ((result->w != w) || (result->h != h))) {
|
||||
result = result->next;
|
||||
}
|
||||
if (result == NULL) {
|
||||
if (!result) {
|
||||
result = SDL_malloc(sizeof(GLES_FBOList));
|
||||
result->w = w;
|
||||
result->h = h;
|
||||
@@ -332,7 +332,7 @@ static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
}
|
||||
|
||||
data = (GLES_TextureData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ static int GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != srcPitch) {
|
||||
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
||||
if (blob == NULL) {
|
||||
if (!blob) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
@@ -510,7 +510,7 @@ static int GLES_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer);
|
||||
return 0;
|
||||
}
|
||||
@@ -537,7 +537,7 @@ static int GLES_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ static int GLES_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
const size_t vertlen = (sizeof(GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
@@ -602,7 +602,7 @@ static int GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD
|
||||
int sz = 2 + 4 + (texture ? 2 : 0);
|
||||
|
||||
verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz * sizeof(GLfloat), 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -911,7 +911,7 @@ static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
|
||||
temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
temp_pixels = SDL_malloc(rect->h * temp_pitch);
|
||||
if (temp_pixels == NULL) {
|
||||
if (!temp_pixels) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -970,7 +970,7 @@ static void GLES_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
renderdata->drawstate.target = NULL;
|
||||
}
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
if (data->texture) {
|
||||
@@ -1082,13 +1082,13 @@ static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GLES_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
GLES_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
|
||||
@@ -220,7 +220,7 @@ GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file,
|
||||
for (;;) {
|
||||
GLenum error = data->glGetError();
|
||||
if (error != GL_NO_ERROR) {
|
||||
if (prefix == NULL || prefix[0] == '\0') {
|
||||
if (!prefix || prefix[0] == '\0') {
|
||||
prefix = "generic";
|
||||
}
|
||||
SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error);
|
||||
@@ -275,7 +275,7 @@ static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h)
|
||||
while ((result) && ((result->w != w) || (result->h != h))) {
|
||||
result = result->next;
|
||||
}
|
||||
if (result == NULL) {
|
||||
if (!result) {
|
||||
result = SDL_malloc(sizeof(GLES2_FBOList));
|
||||
result->w = w;
|
||||
result->h = h;
|
||||
@@ -427,7 +427,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
|
||||
/* Create a program cache entry */
|
||||
entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
|
||||
if (entry == NULL) {
|
||||
if (!entry) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -488,7 +488,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
|
||||
if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) {
|
||||
data->glDeleteProgram(data->program_cache.tail->id);
|
||||
data->program_cache.tail = data->program_cache.tail->prev;
|
||||
if (data->program_cache.tail != NULL) {
|
||||
if (data->program_cache.tail) {
|
||||
SDL_free(data->program_cache.tail->next);
|
||||
data->program_cache.tail->next = NULL;
|
||||
}
|
||||
@@ -505,7 +505,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G
|
||||
const GLchar *shader_src_list[3];
|
||||
const GLchar *shader_body = GLES2_GetShader(type);
|
||||
|
||||
if (shader_body == NULL) {
|
||||
if (!shader_body) {
|
||||
SDL_SetError("No shader body src");
|
||||
return 0;
|
||||
}
|
||||
@@ -715,7 +715,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source,
|
||||
|
||||
/* Generate a matching program */
|
||||
program = GLES2_CacheProgram(data, vertex, fragment);
|
||||
if (program == NULL) {
|
||||
if (!program) {
|
||||
goto fault;
|
||||
}
|
||||
|
||||
@@ -748,7 +748,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -839,7 +839,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
|
||||
if (texture) {
|
||||
SDL_Vertex *verts = (SDL_Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -879,7 +879,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S
|
||||
|
||||
} else {
|
||||
SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -959,7 +959,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co
|
||||
}
|
||||
|
||||
if ((texture != NULL) != data->drawstate.texturing) {
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
data->glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD);
|
||||
data->drawstate.texturing = SDL_FALSE;
|
||||
} else {
|
||||
@@ -1282,7 +1282,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
SDL_BlendMode thisblend = cmd->data.draw.blend;
|
||||
|
||||
while (nextcmd != NULL) {
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
@@ -1316,7 +1316,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd,
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
size_t count = cmd->data.draw.count;
|
||||
int ret;
|
||||
while (nextcmd != NULL) {
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != thiscmdtype) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
@@ -1455,7 +1455,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
/* Allocate a texture struct */
|
||||
data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->texture = 0;
|
||||
@@ -1590,7 +1590,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != src_pitch) {
|
||||
blob = (Uint8 *)SDL_malloc(src_pitch * height);
|
||||
if (blob == NULL) {
|
||||
if (!blob) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
@@ -1607,7 +1607,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
|
||||
int i;
|
||||
Uint32 *src32 = (Uint32 *)src;
|
||||
blob2 = (Uint32 *)SDL_malloc(src_pitch * height);
|
||||
if (blob2 == NULL) {
|
||||
if (!blob2) {
|
||||
if (blob) {
|
||||
SDL_free(blob);
|
||||
}
|
||||
@@ -1868,7 +1868,7 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
data->drawstate.viewport_dirty = SDL_TRUE;
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer);
|
||||
} else {
|
||||
texturedata = (GLES2_TextureData *)texture->driverdata;
|
||||
@@ -1934,7 +1934,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
}
|
||||
|
||||
temp_pixels = SDL_malloc(buflen);
|
||||
if (temp_pixels == NULL) {
|
||||
if (!temp_pixels) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -2093,13 +2093,13 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
|
||||
/* Create the renderer struct */
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
|
||||
@@ -105,7 +105,7 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE));
|
||||
|
||||
if (ps2_tex == NULL) {
|
||||
if (!ps2_tex) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
gs_rgbaq rgbaq;
|
||||
int i;
|
||||
|
||||
if (vertices == NULL) {
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
GSPRIMUVPOINT *vertices = (GSPRIMUVPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMUVPOINT), 4, &cmd->data.draw.first);
|
||||
GSTEXTURE *ps2_tex = (GSTEXTURE *) texture->driverdata;
|
||||
|
||||
if (vertices == NULL) {
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
} else {
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
if (vertices == NULL) {
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -531,11 +531,11 @@ static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata;
|
||||
PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata;
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ps2_texture == NULL) {
|
||||
if (!ps2_texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -584,13 +584,13 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
SDL_bool dynamicVsync;
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
PS2_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -282,11 +282,11 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
src = (unsigned int *)psp_texture->data;
|
||||
|
||||
data = dst;
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
data = SDL_malloc(psp_texture->size);
|
||||
}
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -344,11 +344,11 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
|
||||
|
||||
data = dst;
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
data = SDL_malloc(psp_texture->size);
|
||||
}
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture
|
||||
if (psp_texture->swizzled) {
|
||||
// Texture was swizzled in vram, just copy to system memory
|
||||
void *sdata = SDL_malloc(psp_texture->size);
|
||||
if (sdata == NULL) {
|
||||
if (!sdata) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
PSP_RenderData *data = renderer->driverdata;
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture));
|
||||
|
||||
if (psp_texture == NULL) {
|
||||
if (!psp_texture) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -630,7 +630,7 @@ static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c
|
||||
VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertV), 4, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -656,10 +656,10 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
cmd->data.draw.count = count;
|
||||
size_indices = indices ? size_indices : 0;
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
VertCV *verts;
|
||||
verts = (VertCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertCV), 4, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -692,7 +692,7 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata;
|
||||
VertTCV *verts;
|
||||
verts = (VertTCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertTCV), 4, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -737,7 +737,7 @@ static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co
|
||||
VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertV), 4, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
|
||||
|
||||
if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) {
|
||||
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(VertTV), 4, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -809,7 +809,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
verts = (VertTV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertTV), 4, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -860,7 +860,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T
|
||||
float u1 = srcrect->x + srcrect->w;
|
||||
float v1 = srcrect->y + srcrect->h;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1011,7 +1011,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state)
|
||||
}
|
||||
|
||||
if (state->texture != current->texture) {
|
||||
if (state->texture != NULL) {
|
||||
if (state->texture) {
|
||||
TextureActivate(state->texture);
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
} else {
|
||||
@@ -1035,7 +1035,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
rendering backends report a reasonable maximum, so the higher level can flush
|
||||
if we appear to be exceeding that. */
|
||||
gpumem = (Uint8 *)sceGuGetMemory(vertsize);
|
||||
if (gpumem == NULL) {
|
||||
if (!gpumem) {
|
||||
return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int)vertsize);
|
||||
}
|
||||
SDL_memcpy(gpumem, vertices, vertsize);
|
||||
@@ -1177,7 +1177,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
|
||||
case SDL_RENDERCMD_GEOMETRY:
|
||||
{
|
||||
const size_t count = cmd->data.draw.count;
|
||||
if (cmd->data.draw.texture == NULL) {
|
||||
if (!cmd->data.draw.texture) {
|
||||
const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first);
|
||||
sceGuDisable(GU_TEXTURE_2D);
|
||||
/* In GU_SMOOTH mode */
|
||||
@@ -1245,11 +1245,11 @@ static void PSP_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
PSP_RenderData *renderdata = (PSP_RenderData *)renderer->driverdata;
|
||||
PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata;
|
||||
|
||||
if (renderdata == NULL) {
|
||||
if (!renderdata) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (psp_texture == NULL) {
|
||||
if (!psp_texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1300,13 +1300,13 @@ SDL_Renderer *PSP_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
void *doublebuffer = NULL;
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
PSP_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -211,7 +211,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRect(): dst");
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRects(): dst");
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
||||
break;
|
||||
}
|
||||
|
||||
if (func == NULL) {
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB;
|
||||
} else {
|
||||
|
||||
@@ -798,12 +798,12 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_BlendLine(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (func == NULL) {
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
@@ -826,12 +826,12 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_bool draw_end;
|
||||
BlendLineFunc func;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (func == NULL) {
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble
|
||||
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoints(): dst");
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
break;
|
||||
}
|
||||
|
||||
if (func == NULL) {
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB;
|
||||
} else {
|
||||
|
||||
@@ -137,12 +137,12 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_DrawLine(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (func == NULL) {
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
@@ -165,12 +165,12 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
SDL_bool draw_end;
|
||||
DrawLineFunc func;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_DrawLines(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (func == NULL) {
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
||||
int i;
|
||||
int x, y;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoints(): dst");
|
||||
}
|
||||
|
||||
|
||||
@@ -196,7 +196,7 @@ static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co
|
||||
SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Text
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Te
|
||||
{
|
||||
CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first);
|
||||
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
int blitRequired = SDL_FALSE;
|
||||
int isOpaque = SDL_FALSE;
|
||||
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch,
|
||||
src->format->Rmask, src->format->Gmask,
|
||||
src->format->Bmask, src->format->Amask);
|
||||
if (src_clone == NULL) {
|
||||
if (!src_clone) {
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
@@ -390,7 +390,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) {
|
||||
mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32,
|
||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
if (mask == NULL) {
|
||||
if (!mask) {
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD);
|
||||
@@ -404,7 +404,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
SDL_Rect scale_rect = tmp_rect;
|
||||
src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32,
|
||||
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||
if (src_scaled == NULL) {
|
||||
if (!src_scaled) {
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
|
||||
@@ -427,15 +427,15 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
src_rotated = SDLgfx_rotateSurface(src_clone, angle,
|
||||
(texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (src_rotated == NULL) {
|
||||
if (!src_rotated) {
|
||||
retval = -1;
|
||||
}
|
||||
if (!retval && mask != NULL) {
|
||||
if (!retval && mask) {
|
||||
/* The mask needed for the NONE blend mode gets rotated with the same parameters. */
|
||||
mask_rotated = SDLgfx_rotateSurface(mask, angle,
|
||||
SDL_FALSE, 0, 0,
|
||||
&rect_dest, cangle, sangle, center);
|
||||
if (mask_rotated == NULL) {
|
||||
if (!mask_rotated) {
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
@@ -487,7 +487,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
src_rotated->format->BitsPerPixel, src_rotated->pitch,
|
||||
src_rotated->format->Rmask, src_rotated->format->Gmask,
|
||||
src_rotated->format->Bmask, 0);
|
||||
if (src_rotated_rgb == NULL) {
|
||||
if (!src_rotated_rgb) {
|
||||
retval = -1;
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD);
|
||||
@@ -499,7 +499,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
}
|
||||
SDL_FreeSurface(mask_rotated);
|
||||
}
|
||||
if (src_rotated != NULL) {
|
||||
if (src_rotated) {
|
||||
SDL_FreeSurface(src_rotated);
|
||||
}
|
||||
}
|
||||
@@ -508,10 +508,10 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
if (mask != NULL) {
|
||||
if (mask) {
|
||||
SDL_FreeSurface(mask);
|
||||
}
|
||||
if (src_clone != NULL) {
|
||||
if (src_clone) {
|
||||
SDL_FreeSurface(src_clone);
|
||||
}
|
||||
return retval;
|
||||
@@ -538,10 +538,10 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_
|
||||
int i;
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
void *verts;
|
||||
size_t sz = texture != NULL ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
|
||||
size_t sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData);
|
||||
|
||||
verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (verts == NULL) {
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -641,9 +641,9 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
if (drawstate->surface_cliprect_dirty) {
|
||||
const SDL_Rect *viewport = drawstate->viewport;
|
||||
const SDL_Rect *cliprect = drawstate->cliprect;
|
||||
SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
SDL_assert_release(viewport); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */
|
||||
|
||||
if (cliprect != NULL) {
|
||||
if (cliprect) {
|
||||
SDL_Rect clip_rect;
|
||||
clip_rect.x = cliprect->x + viewport->x;
|
||||
clip_rect.y = cliprect->y + viewport->y;
|
||||
@@ -663,7 +663,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
@@ -739,7 +739,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
@@ -766,7 +766,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SetDrawState(surface, &drawstate);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
int i;
|
||||
for (i = 0; i < count; i++) {
|
||||
verts[i].x += drawstate.viewport->x;
|
||||
@@ -794,7 +794,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
dstrect->x += drawstate.viewport->x;
|
||||
dstrect->y += drawstate.viewport->y;
|
||||
}
|
||||
@@ -852,7 +852,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
copydata->dstrect.x += drawstate.viewport->x;
|
||||
copydata->dstrect.y += drawstate.viewport->y;
|
||||
}
|
||||
@@ -880,7 +880,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
PrepTextureForCopy(cmd);
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
@@ -903,7 +903,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
GeometryFillData *ptr = (GeometryFillData *) verts;
|
||||
|
||||
/* Apply viewport */
|
||||
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) {
|
||||
SDL_Point vp;
|
||||
vp.x = drawstate.viewport->x;
|
||||
vp.y = drawstate.viewport->y;
|
||||
@@ -938,7 +938,7 @@ static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
Uint32 src_format;
|
||||
void *src_pixels;
|
||||
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ static int SW_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
if (window == NULL) {
|
||||
if (!window) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_UpdateWindowSurface(window);
|
||||
@@ -995,19 +995,19 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
SDL_InvalidParamError("surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SW_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -1050,7 +1050,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
|
||||
/* Set the vsync hint based on our flags, if it's not already set */
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC);
|
||||
if (hint == NULL || !*hint) {
|
||||
if (!hint || !*hint) {
|
||||
no_hint_set = SDL_TRUE;
|
||||
} else {
|
||||
no_hint_set = SDL_FALSE;
|
||||
@@ -1067,7 +1067,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
|
||||
}
|
||||
|
||||
if (surface == NULL) {
|
||||
if (!surface) {
|
||||
return NULL;
|
||||
}
|
||||
return SW_CreateRendererForSurface(surface);
|
||||
|
||||
@@ -500,7 +500,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/* Sanity check */
|
||||
if (src == NULL) {
|
||||
if (!src) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
if (is8bit) {
|
||||
/* Target surface is 8 bit */
|
||||
rz_dst = SDL_CreateRGBSurfaceWithFormat(0, rect_dest->w, rect_dest->h + GUARD_ROWS, 8, src->format->format);
|
||||
if (rz_dst != NULL) {
|
||||
if (rz_dst) {
|
||||
if (src->format->palette) {
|
||||
for (i = 0; i < src->format->palette->ncolors; i++) {
|
||||
rz_dst->format->palette->colors[i] = src->format->palette->colors[i];
|
||||
@@ -540,7 +540,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
if (rz_dst == NULL) {
|
||||
if (!rz_dst) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
SDL_Surface *tmp = NULL;
|
||||
|
||||
if (dst == NULL) {
|
||||
if (!dst) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
/* Use an intermediate surface */
|
||||
tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect.w, dstrect.h, 0, format);
|
||||
if (tmp == NULL) {
|
||||
if (!tmp) {
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ int SDL_SW_BlitTriangle(
|
||||
|
||||
int has_modulation;
|
||||
|
||||
if (src == NULL || dst == NULL) {
|
||||
if (!src || !dst) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ void StartDrawing(SDL_Renderer *renderer)
|
||||
// data->colorFragmentProgram = in->color;
|
||||
// data->textureFragmentProgram = in->texture;
|
||||
|
||||
if (renderer->target == NULL) {
|
||||
if (!renderer->target) {
|
||||
sceGxmBeginScene(
|
||||
data->gxm_context,
|
||||
0,
|
||||
@@ -217,13 +217,13 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
VITA_GXM_RenderData *data;
|
||||
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
|
||||
if (renderer == NULL) {
|
||||
if (!renderer) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData));
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -295,7 +295,7 @@ static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata;
|
||||
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)SDL_calloc(1, sizeof(VITA_GXM_TextureData));
|
||||
|
||||
if (vita_texture == NULL) {
|
||||
if (!vita_texture) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -583,7 +583,7 @@ static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
||||
*pitch = vita_texture->pitch;
|
||||
|
||||
// make sure that rendering is finished on render target textures
|
||||
if (vita_texture->tex->gxm_rendertarget != NULL) {
|
||||
if (vita_texture->tex->gxm_rendertarget) {
|
||||
sceGxmFinish(data->gxm_context);
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
data,
|
||||
count * sizeof(texture_vertex));
|
||||
|
||||
if (vertices == NULL) {
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -772,7 +772,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd
|
||||
data,
|
||||
count * sizeof(color_vertex));
|
||||
|
||||
if (vertices == NULL) {
|
||||
if (!vertices) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1006,7 +1006,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c
|
||||
SDL_RenderCommand *nextcmd = cmd->next;
|
||||
size_t count = cmd->data.draw.count;
|
||||
int ret;
|
||||
while (nextcmd != NULL) {
|
||||
while (nextcmd) {
|
||||
const SDL_RenderCommandType nextcmdtype = nextcmd->command;
|
||||
if (nextcmdtype != thiscmdtype) {
|
||||
break; /* can't go any further on this draw call, different render command up next. */
|
||||
@@ -1103,7 +1103,7 @@ static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rec
|
||||
}
|
||||
|
||||
temp_pixels = SDL_malloc(buflen);
|
||||
if (temp_pixels == NULL) {
|
||||
if (!temp_pixels) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1186,15 +1186,15 @@ static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata;
|
||||
VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata;
|
||||
|
||||
if (data == NULL) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vita_texture == NULL) {
|
||||
if (!vita_texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vita_texture->tex == NULL) {
|
||||
if (!vita_texture->tex) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
{
|
||||
void *mem;
|
||||
|
||||
if (data->texturePool == NULL) {
|
||||
if (!data->texturePool) {
|
||||
int poolsize;
|
||||
int ret;
|
||||
SceKernelFreeMemorySizeInfo info;
|
||||
@@ -88,7 +88,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
}
|
||||
data->texturePool = sceClibMspaceCreate(mem, poolsize);
|
||||
|
||||
if (data->texturePool == NULL) {
|
||||
if (!data->texturePool) {
|
||||
return NULL;
|
||||
}
|
||||
ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE);
|
||||
@@ -101,7 +101,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
|
||||
void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr)
|
||||
{
|
||||
if (data->texturePool != NULL) {
|
||||
if (data->texturePool) {
|
||||
sceClibMspaceFree(data->texturePool, ptr);
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr)
|
||||
void vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (data->texturePool != NULL) {
|
||||
if (data->texturePool) {
|
||||
sceClibMspaceDestroy(data->texturePool);
|
||||
data->texturePool = NULL;
|
||||
if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0) {
|
||||
|
||||
@@ -1003,7 +1003,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig
|
||||
tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2;
|
||||
}
|
||||
|
||||
if (texture == NULL) {
|
||||
if (!texture) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1017,7 +1017,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig
|
||||
tex_size);
|
||||
|
||||
/* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */
|
||||
if (texture_data == NULL) {
|
||||
if (!texture_data) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n");
|
||||
texture_data = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
@@ -1030,7 +1030,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig
|
||||
texture->cdram = 1;
|
||||
}
|
||||
|
||||
if (texture_data == NULL) {
|
||||
if (!texture_data) {
|
||||
SDL_free(texture);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user