Cleanup add brace (#6545)
* Add braces after if conditions
* More add braces after if conditions
* Add braces after while() conditions
* Fix compilation because of macro being modified
* Add braces to for loop
* Add braces after if/goto
* Move comments up
* Remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements
* More remove extra () in the 'return ...;' statements after merge
* Fix inconsistent patterns are xxx == NULL vs !xxx
* More "{}" for "if() break;" and "if() continue;"
* More "{}" after if() short statement
* More "{}" after "if () return;" statement
* More fix inconsistent patterns are xxx == NULL vs !xxx
* Revert some modificaion on SDL_RLEaccel.c
* SDL_RLEaccel: no short statement
* Cleanup 'if' where the bracket is in a new line
* Cleanup 'while' where the bracket is in a new line
* Cleanup 'for' where the bracket is in a new line
* Cleanup 'else' where the bracket is in a new line
This commit is contained in:
@@ -330,7 +330,7 @@ AllocateRenderCommand(SDL_Renderer *renderer)
|
||||
retval->next = NULL;
|
||||
} else {
|
||||
retval = SDL_calloc(1, sizeof (*retval));
|
||||
if (!retval) {
|
||||
if (retval == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -963,7 +963,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
Android_ActivityMutex_Lock_Running();
|
||||
#endif
|
||||
|
||||
if (!window) {
|
||||
if (window == NULL) {
|
||||
SDL_InvalidParamError("window");
|
||||
goto error;
|
||||
}
|
||||
@@ -999,7 +999,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
}
|
||||
}
|
||||
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
for (index = 0; index < n; ++index) {
|
||||
const SDL_RenderDriver *driver = render_drivers[index];
|
||||
|
||||
@@ -1013,7 +1013,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_SetError("Couldn't find matching render driver");
|
||||
goto error;
|
||||
}
|
||||
@@ -1026,7 +1026,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
|
||||
/* Create a new renderer instance */
|
||||
renderer = render_drivers[index]->CreateRenderer(window, flags);
|
||||
batching = SDL_FALSE;
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@@ -1251,7 +1251,7 @@ static SDL_ScaleMode SDL_GetScaleMode(void)
|
||||
{
|
||||
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
|
||||
|
||||
if (!hint || SDL_strcasecmp(hint, "nearest") == 0) {
|
||||
if (hint == NULL || SDL_strcasecmp(hint, "nearest") == 0) {
|
||||
return SDL_ScaleModeNearest;
|
||||
} else if (SDL_strcasecmp(hint, "linear") == 0) {
|
||||
return SDL_ScaleModeLinear;
|
||||
@@ -1293,7 +1293,7 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int
|
||||
return NULL;
|
||||
}
|
||||
texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture));
|
||||
if (!texture) {
|
||||
if (texture == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -1385,7 +1385,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
SDL_InvalidParamError("SDL_CreateTextureFromSurface(): surface");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1449,7 +1449,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||
|
||||
texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC,
|
||||
surface->w, surface->h);
|
||||
if (!texture) {
|
||||
if (texture == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1481,7 +1481,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||
|
||||
/* Set up a destination surface for the texture update */
|
||||
dst_fmt = SDL_AllocFormat(format);
|
||||
if (!dst_fmt) {
|
||||
if (dst_fmt == NULL) {
|
||||
SDL_DestroyTexture(texture);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1712,7 +1712,7 @@ SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
@@ -1753,7 +1753,7 @@ SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
@@ -1774,7 +1774,7 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!pixels) {
|
||||
if (pixels == NULL) {
|
||||
return SDL_InvalidParamError("pixels");
|
||||
}
|
||||
if (!pitch) {
|
||||
@@ -1849,7 +1849,7 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
@@ -1900,7 +1900,7 @@ SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
const size_t alloclen = rect->h * temp_pitch;
|
||||
if (alloclen > 0) {
|
||||
void *temp_pixels = SDL_malloc(alloclen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
|
||||
@@ -1926,19 +1926,19 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!Yplane) {
|
||||
if (Yplane == NULL) {
|
||||
return SDL_InvalidParamError("Yplane");
|
||||
}
|
||||
if (!Ypitch) {
|
||||
return SDL_InvalidParamError("Ypitch");
|
||||
}
|
||||
if (!Uplane) {
|
||||
if (Uplane == NULL) {
|
||||
return SDL_InvalidParamError("Uplane");
|
||||
}
|
||||
if (!Upitch) {
|
||||
return SDL_InvalidParamError("Upitch");
|
||||
}
|
||||
if (!Vplane) {
|
||||
if (Vplane == NULL) {
|
||||
return SDL_InvalidParamError("Vplane");
|
||||
}
|
||||
if (!Vpitch) {
|
||||
@@ -1992,13 +1992,13 @@ int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
|
||||
CHECK_TEXTURE_MAGIC(texture, -1);
|
||||
|
||||
if (!Yplane) {
|
||||
if (Yplane == NULL) {
|
||||
return SDL_InvalidParamError("Yplane");
|
||||
}
|
||||
if (!Ypitch) {
|
||||
return SDL_InvalidParamError("Ypitch");
|
||||
}
|
||||
if (!UVplane) {
|
||||
if (UVplane == NULL) {
|
||||
return SDL_InvalidParamError("UVplane");
|
||||
}
|
||||
if (!UVpitch) {
|
||||
@@ -2077,7 +2077,7 @@ SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect,
|
||||
return SDL_SetError("SDL_LockTexture(): texture must be streaming");
|
||||
}
|
||||
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
full_rect.x = 0;
|
||||
full_rect.y = 0;
|
||||
full_rect.w = texture->w;
|
||||
@@ -2212,7 +2212,7 @@ SDL_UnlockTexture(SDL_Texture * texture)
|
||||
SDL_bool
|
||||
SDL_RenderTargetSupported(SDL_Renderer *renderer)
|
||||
{
|
||||
if (!renderer || !renderer->SetRenderTarget) {
|
||||
if (renderer == NULL || !renderer->SetRenderTarget) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0;
|
||||
@@ -2326,7 +2326,7 @@ UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd)
|
||||
}
|
||||
|
||||
hint = SDL_GetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE);
|
||||
if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) {
|
||||
if (hint && (*hint == '1' || SDL_strcasecmp(hint, "overscan") == 0)) {
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
SDL_bool overscan_supported = SDL_TRUE;
|
||||
/* Unfortunately, Direct3D 9 doesn't support negative viewport numbers
|
||||
@@ -2724,7 +2724,7 @@ RenderDrawPointsWithRects(SDL_Renderer * renderer,
|
||||
}
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -2753,7 +2753,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawPoints(): points");
|
||||
}
|
||||
if (count < 1) {
|
||||
@@ -2771,7 +2771,7 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer,
|
||||
retval = RenderDrawPointsWithRects(renderer, points, count);
|
||||
} else {
|
||||
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
|
||||
if (!fpoints) {
|
||||
if (fpoints == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
@@ -2800,7 +2800,7 @@ RenderDrawPointsWithRectsF(SDL_Renderer * renderer,
|
||||
}
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -2826,7 +2826,7 @@ SDL_RenderDrawPointsF(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawPointsF(): points");
|
||||
}
|
||||
if (count < 1) {
|
||||
@@ -2920,7 +2920,7 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x
|
||||
}
|
||||
|
||||
points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack);
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < numpixels; ++i) {
|
||||
@@ -2964,7 +2964,7 @@ RenderDrawLinesWithRectsF(SDL_Renderer * renderer,
|
||||
SDL_bool draw_last = SDL_FALSE;
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count-1, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -3035,7 +3035,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawLines(): points");
|
||||
}
|
||||
if (count < 2) {
|
||||
@@ -3050,7 +3050,7 @@ SDL_RenderDrawLines(SDL_Renderer * renderer,
|
||||
#endif
|
||||
|
||||
fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack);
|
||||
if (!fpoints) {
|
||||
if (fpoints == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -3074,7 +3074,7 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!points) {
|
||||
if (points == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawLinesF(): points");
|
||||
}
|
||||
if (count < 2) {
|
||||
@@ -3248,7 +3248,7 @@ SDL_RenderDrawRectF(SDL_Renderer * renderer, const SDL_FRect * rect)
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
@@ -3274,7 +3274,7 @@ SDL_RenderDrawRects(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawRects(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
@@ -3304,7 +3304,7 @@ SDL_RenderDrawRectsF(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderDrawRectsF(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
@@ -3353,7 +3353,7 @@ SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect)
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
/* If 'rect' == NULL, then outline the whole surface */
|
||||
if (!rect) {
|
||||
if (rect == NULL) {
|
||||
RenderGetViewportSize(renderer, &frect);
|
||||
rect = &frect;
|
||||
}
|
||||
@@ -3371,7 +3371,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderFillRects(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
@@ -3386,7 +3386,7 @@ SDL_RenderFillRects(SDL_Renderer * renderer,
|
||||
#endif
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
@@ -3414,7 +3414,7 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer,
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, -1);
|
||||
|
||||
if (!rects) {
|
||||
if (rects == NULL) {
|
||||
return SDL_InvalidParamError("SDL_RenderFillRectsF(): rects");
|
||||
}
|
||||
if (count < 1) {
|
||||
@@ -3429,7 +3429,7 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer,
|
||||
#endif
|
||||
|
||||
frects = SDL_small_alloc(SDL_FRect, count, &isstack);
|
||||
if (!frects) {
|
||||
if (frects == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
for (i = 0; i < count; ++i) {
|
||||
@@ -3981,7 +3981,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
|
||||
x2 = xy2_[0]; y2 = xy2_[1];
|
||||
|
||||
/* Check if triangle A B C is rectangle */
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)){
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) {
|
||||
/* ok */
|
||||
} else {
|
||||
is_quad = 0;
|
||||
@@ -3994,7 +3994,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
|
||||
x2 = xy2_[0]; y2 = xy2_[1];
|
||||
|
||||
/* Check if triangle A B C2 is rectangle */
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)){
|
||||
if ((x0 == x2 && y1 == y2) || (y0 == y2 && x1 == x2)) {
|
||||
/* ok */
|
||||
} else {
|
||||
is_quad = 0;
|
||||
@@ -4103,7 +4103,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
|
||||
prev[1] = k1;
|
||||
prev[2] = k2;
|
||||
}
|
||||
} /* End for(), next triangle */
|
||||
} /* End for (), next triangle */
|
||||
|
||||
if (prev[0] != -1) {
|
||||
/* flush the last triangle */
|
||||
@@ -4155,15 +4155,15 @@ SDL_RenderGeometryRaw(SDL_Renderer *renderer,
|
||||
}
|
||||
}
|
||||
|
||||
if (!xy) {
|
||||
if (xy == NULL) {
|
||||
return SDL_InvalidParamError("xy");
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
if (color == NULL) {
|
||||
return SDL_InvalidParamError("color");
|
||||
}
|
||||
|
||||
if (texture && !uv) {
|
||||
if (texture && uv == NULL) {
|
||||
return SDL_InvalidParamError("uv");
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
}
|
||||
|
||||
swdata = (SDL_SW_YUVTexture *) SDL_calloc(1, sizeof(*swdata));
|
||||
if (!swdata) {
|
||||
if (swdata == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
|
||||
}
|
||||
|
||||
/* We're all done.. */
|
||||
return (swdata);
|
||||
return swdata;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -345,8 +345,7 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
|
||||
if (rect
|
||||
&& (rect->x != 0 || rect->y != 0 || rect->w != swdata->w
|
||||
|| rect->h != swdata->h)) {
|
||||
return SDL_SetError
|
||||
("YV12, IYUV, NV12, NV21 textures only support full surface locks");
|
||||
return SDL_SetError("YV12, IYUV, NV12, NV21 textures only support full surface locks");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -406,7 +405,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask,
|
||||
Gmask, Bmask, Amask);
|
||||
if (!swdata->display) {
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!swdata->stretch) {
|
||||
@@ -417,7 +416,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
|
||||
SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask,
|
||||
Gmask, Bmask, Amask);
|
||||
if (!swdata->stretch) {
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
pixels = swdata->stretch->pixels;
|
||||
|
||||
@@ -549,7 +549,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
DWORD usage;
|
||||
|
||||
texturedata = (D3D_TextureData *) SDL_calloc(1, sizeof(*texturedata));
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
texturedata->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
|
||||
@@ -588,7 +588,7 @@ D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
IDirect3DDevice9 *device = data->device;
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -729,7 +729,7 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata;
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -739,8 +739,7 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
(void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch +
|
||||
rect->x * SDL_BYTESPERPIXEL(texture->format));
|
||||
D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0);
|
||||
@@ -759,7 +758,7 @@ D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scal
|
||||
{
|
||||
D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -787,7 +786,7 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
|
||||
texturedata = (D3D_TextureData *)texture->driverdata;
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -810,11 +809,11 @@ D3D_SetRenderTargetInternal(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
|
||||
result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture.texture, 0, &data->currentRenderTarget);
|
||||
if(FAILED(result)) {
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("GetSurfaceLevel()", result);
|
||||
}
|
||||
result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget);
|
||||
if(FAILED(result)) {
|
||||
if (FAILED(result)) {
|
||||
return D3D_SetError("SetRenderTarget()", result);
|
||||
}
|
||||
|
||||
@@ -846,7 +845,7 @@ D3D_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -872,7 +871,7 @@ D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
Vertex *verts = (Vertex *) SDL_AllocateRenderVertices(renderer, count * sizeof (Vertex), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -972,7 +971,7 @@ SetupTextureState(D3D_RenderData *data, SDL_Texture * texture, LPDIRECT3DPIXELSH
|
||||
|
||||
SDL_assert(*shader == NULL);
|
||||
|
||||
if (!texturedata) {
|
||||
if (texturedata == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1029,7 +1028,7 @@ SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd)
|
||||
IDirect3DDevice9_SetTexture(data->device, 0, NULL);
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
if ((!newtexturedata || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) {
|
||||
if ((newtexturedata == NULL || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) {
|
||||
IDirect3DDevice9_SetTexture(data->device, 1, NULL);
|
||||
IDirect3DDevice9_SetTexture(data->device, 2, NULL);
|
||||
}
|
||||
@@ -1420,7 +1419,7 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1601,13 +1600,13 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -389,7 +389,7 @@ D3D11_CreateBlendState(SDL_Renderer * renderer, SDL_BlendMode blendMode)
|
||||
}
|
||||
|
||||
blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes));
|
||||
if (!blendModes) {
|
||||
if (blendModes == NULL) {
|
||||
SAFE_RELEASE(blendState);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -448,7 +448,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
||||
}
|
||||
|
||||
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
|
||||
if (!CreateDXGIFactoryFunc) {
|
||||
if (CreateDXGIFactoryFunc == NULL) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
|
||||
textureData = (D3D11_TextureData*) SDL_calloc(1, sizeof(*textureData));
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
@@ -1275,7 +1275,7 @@ D3D11_DestroyTexture(SDL_Renderer * renderer,
|
||||
{
|
||||
D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1385,7 +1385,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1431,7 +1431,7 @@ D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1456,7 +1456,7 @@ D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1481,7 +1481,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D11_TEXTURE2D_DESC stagingTextureDesc;
|
||||
D3D11_MAPPED_SUBRESOURCE textureMemory;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -1562,7 +1562,7 @@ D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -1599,7 +1599,7 @@ D3D11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc
|
||||
{
|
||||
D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1645,7 +1645,7 @@ D3D11_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1673,7 +1673,7 @@ D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1885,8 +1885,7 @@ D3D11_GetCurrentRenderTargetView(SDL_Renderer * renderer)
|
||||
D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata;
|
||||
if (data->currentOffscreenRenderTargetView) {
|
||||
return data->currentOffscreenRenderTargetView;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return data->mainRenderTargetView;
|
||||
}
|
||||
}
|
||||
@@ -1954,9 +1953,9 @@ D3D11_SetDrawState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, ID3D11
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!blendState) {
|
||||
if (blendState == NULL) {
|
||||
blendState = D3D11_CreateBlendState(renderer, blendMode);
|
||||
if (!blendState) {
|
||||
if (blendState == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -2372,13 +2371,13 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
D3D11_RenderData *data;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D11_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -49,7 +49,7 @@ extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window * sdlWindow = renderer->window;
|
||||
if ( ! renderer->window ) {
|
||||
if (renderer->window == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ static const GUID SDL_IID_ID3D12InfoQueue = { 0x0742a90b, 0xc387, 0x483f, { 0xb9
|
||||
UINT
|
||||
D3D12_Align(UINT location, UINT alignment)
|
||||
{
|
||||
return ((location + (alignment - 1)) & ~(alignment - 1));
|
||||
return (location + (alignment - 1)) & ~(alignment - 1);
|
||||
}
|
||||
|
||||
Uint32
|
||||
@@ -402,8 +402,7 @@ D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap * heap, D3D12_CPU_DESCRIPTOR_HANDLE CP
|
||||
static void
|
||||
D3D12_WaitForGPU(D3D12_RenderData * data)
|
||||
{
|
||||
if (data->commandQueue && data->fence && data->fenceEvent)
|
||||
{
|
||||
if (data->commandQueue && data->fence && data->fenceEvent) {
|
||||
D3D_CALL(data->commandQueue, Signal, data->fence, data->fenceValue);
|
||||
if (D3D_CALL(data->fence, GetCompletedValue) < data->fenceValue) {
|
||||
D3D_CALL(data->fence, SetEventOnCompletion,
|
||||
@@ -646,7 +645,7 @@ D3D12_CreatePipelineState(SDL_Renderer * renderer,
|
||||
}
|
||||
|
||||
pipelineStates = (D3D12_PipelineState*)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates));
|
||||
if (!pipelineStates) {
|
||||
if (pipelineStates == NULL) {
|
||||
SAFE_RELEASE(pipelineState);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -764,7 +763,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!CreateEventExFunc) {
|
||||
if (CreateEventExFunc == NULL) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -777,7 +776,7 @@ D3D12_CreateDeviceResources(SDL_Renderer* renderer)
|
||||
}
|
||||
|
||||
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2");
|
||||
if (!CreateDXGIFactoryFunc) {
|
||||
if (CreateDXGIFactoryFunc == NULL) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -821,7 +820,7 @@ 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) {
|
||||
if (DXGIGetDebugInterfaceFunc == NULL) {
|
||||
result = E_FAIL;
|
||||
goto done;
|
||||
}
|
||||
@@ -1476,12 +1475,11 @@ D3D12_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
|
||||
|
||||
if (textureFormat == DXGI_FORMAT_UNKNOWN) {
|
||||
return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified",
|
||||
__FUNCTION__, texture->format);
|
||||
return SDL_SetError("%s, An unsupported SDL pixel format (0x%x) was specified", __FUNCTION__, texture->format);
|
||||
}
|
||||
|
||||
textureData = (D3D12_TextureData*) SDL_calloc(1, sizeof(*textureData));
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return -1;
|
||||
}
|
||||
@@ -1668,7 +1666,7 @@ D3D12_DestroyTexture(SDL_Renderer * renderer,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData*)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1852,7 +1850,7 @@ D3D12_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1898,7 +1896,7 @@ D3D12_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1923,7 +1921,7 @@ D3D12_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata;
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
|
||||
@@ -1953,7 +1951,7 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
BYTE *textureMemory;
|
||||
int bpp;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return SDL_SetError("Texture is not currently available");
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -2045,8 +2043,7 @@ D3D12_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
pitchedDesc.Depth = 1;
|
||||
if (pitchedDesc.Format == DXGI_FORMAT_R8_UNORM) {
|
||||
bpp = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
bpp = 4;
|
||||
}
|
||||
pitchedDesc.RowPitch = D3D12_Align(rect->w * bpp, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
||||
@@ -2077,7 +2074,7 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
D3D12_TEXTURE_COPY_LOCATION dstLocation;
|
||||
int bpp;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return;
|
||||
}
|
||||
#if SDL_HAVE_YUV
|
||||
@@ -2105,8 +2102,7 @@ D3D12_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
pitchedDesc.Depth = 1;
|
||||
if (pitchedDesc.Format == DXGI_FORMAT_R8_UNORM) {
|
||||
bpp = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
bpp = 4;
|
||||
}
|
||||
pitchedDesc.RowPitch = D3D12_Align(textureData->lockedRect.w * bpp, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
|
||||
@@ -2151,7 +2147,7 @@ D3D12_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc
|
||||
{
|
||||
D3D12_TextureData *textureData = (D3D12_TextureData *) texture->driverdata;
|
||||
|
||||
if (!textureData) {
|
||||
if (textureData == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2212,7 +2208,7 @@ D3D12_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2240,7 +2236,7 @@ D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
|
||||
int count = indices ? num_indices : num_vertices;
|
||||
VertexPositionColor *verts = (VertexPositionColor *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertexPositionColor), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2616,8 +2612,8 @@ D3D12_SetCopyState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, const
|
||||
D3D12_TransitionResource(rendererData, textureData->mainTextureV, textureData->mainResourceStateV, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
textureData->mainResourceStateV = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
|
||||
return D3D12_SetDrawState(renderer, cmd, shader, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE,
|
||||
SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix);
|
||||
return D3D12_SetDrawState(renderer, cmd, shader, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, SDL_arraysize(shaderResources), shaderResources,
|
||||
textureSampler, matrix);
|
||||
} else if (textureData->nv12) {
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE shaderResources[] = {
|
||||
textureData->mainTextureResourceView,
|
||||
@@ -2645,14 +2641,14 @@ D3D12_SetCopyState(SDL_Renderer * renderer, const SDL_RenderCommand *cmd, const
|
||||
D3D12_TransitionResource(rendererData, textureData->mainTextureNV, textureData->mainResourceStateNV, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
textureData->mainResourceStateNV = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
|
||||
return D3D12_SetDrawState(renderer, cmd, shader, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE,
|
||||
SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix);
|
||||
return D3D12_SetDrawState(renderer, cmd, shader, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, SDL_arraysize(shaderResources), shaderResources,
|
||||
textureSampler, matrix);
|
||||
}
|
||||
#endif /* SDL_HAVE_YUV */
|
||||
D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||
textureData->mainResourceState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
return D3D12_SetDrawState(renderer, cmd, SHADER_RGB, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE,
|
||||
1, &textureData->mainTextureResourceView, textureSampler, matrix);
|
||||
return D3D12_SetDrawState(renderer, cmd, SHADER_RGB, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, 1, &textureData->mainTextureResourceView,
|
||||
textureSampler, matrix);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3047,13 +3043,13 @@ D3D12_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
D3D12_RenderData *data;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (D3D12_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -172,8 +172,7 @@ GL_ClearErrors(SDL_Renderer *renderer)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
||||
|
||||
if (!data->debug_enabled)
|
||||
{
|
||||
if (!data->debug_enabled) {
|
||||
return;
|
||||
}
|
||||
if (data->GL_ARB_debug_output_supported) {
|
||||
@@ -200,8 +199,7 @@ GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file,
|
||||
GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
|
||||
int ret = 0;
|
||||
|
||||
if (!data->debug_enabled)
|
||||
{
|
||||
if (!data->debug_enabled) {
|
||||
return 0;
|
||||
}
|
||||
if (data->GL_ARB_debug_output_supported) {
|
||||
@@ -312,7 +310,7 @@ GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h)
|
||||
result = result->next;
|
||||
}
|
||||
|
||||
if (!result) {
|
||||
if (result == NULL) {
|
||||
result = SDL_malloc(sizeof(GL_FBOList));
|
||||
if (result) {
|
||||
result->w = w;
|
||||
@@ -477,7 +475,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
|
||||
data = (GL_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -579,8 +577,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, texture_w,
|
||||
texture_h, 0, format, type, data->pixels);
|
||||
renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
renderdata->glTexImage2D(textype, 0, internalFormat, texture_w,
|
||||
@@ -937,7 +934,7 @@ GL_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -958,7 +955,7 @@ GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPo
|
||||
const size_t vertlen = (sizeof (GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
@@ -1004,7 +1001,7 @@ GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
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) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1458,7 +1455,7 @@ GL_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) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1525,7 +1522,7 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
renderdata->drawstate.target = NULL;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
if (data->texture) {
|
||||
@@ -1759,13 +1756,13 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
#endif
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
@@ -1860,7 +1857,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
|
||||
hint = SDL_getenv("GL_ARB_texture_non_power_of_two");
|
||||
if (!hint || *hint != '0') {
|
||||
if (hint == NULL || *hint != '0') {
|
||||
SDL_bool isGL2 = SDL_FALSE;
|
||||
const char *verstr = (const char *)data->glGetString(GL_VERSION);
|
||||
if (verstr) {
|
||||
|
||||
@@ -477,7 +477,7 @@ CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data)
|
||||
}
|
||||
ctx->glUseProgramObjectARB(0);
|
||||
|
||||
return (ctx->glGetError() == GL_NO_ERROR);
|
||||
return ctx->glGetError() == GL_NO_ERROR;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -496,7 +496,7 @@ GL_CreateShaderContext(void)
|
||||
int i;
|
||||
|
||||
ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx));
|
||||
if (!ctx) {
|
||||
if (ctx == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -314,7 +314,7 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
}
|
||||
|
||||
data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != srcPitch) {
|
||||
blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
|
||||
if (!blob) {
|
||||
if (blob == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
@@ -529,7 +529,7 @@ GLES_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (GLfloat), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -550,7 +550,7 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
const size_t vertlen = (sizeof (GLfloat) * 2) * count;
|
||||
GLfloat *verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
cmd->data.draw.count = count;
|
||||
@@ -596,7 +596,7 @@ GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *
|
||||
int sz = 2 + 4 + (texture ? 2 : 0);
|
||||
|
||||
verts = (GLfloat *) SDL_AllocateRenderVertices(renderer, count * sz * sizeof (GLfloat), 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ 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) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -964,7 +964,7 @@ GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
renderdata->drawstate.target = NULL;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
if (data->texture) {
|
||||
@@ -1080,13 +1080,13 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
GLES_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
|
||||
@@ -418,7 +418,7 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment)
|
||||
|
||||
/* Create a program cache entry */
|
||||
entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
|
||||
if (!entry) {
|
||||
if (entry == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
@@ -497,7 +497,7 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_t
|
||||
const GLchar *shader_src_list[3];
|
||||
const GLchar *shader_body = GLES2_GetShader(type);
|
||||
|
||||
if (!shader_body) {
|
||||
if (shader_body == NULL) {
|
||||
SDL_SetError("No shader body src");
|
||||
return 0;
|
||||
}
|
||||
@@ -708,7 +708,7 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int
|
||||
|
||||
/* Generate a matching program */
|
||||
program = GLES2_CacheProgram(data, vertex, fragment);
|
||||
if (!program) {
|
||||
if (program == NULL) {
|
||||
goto fault;
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ GLES2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -777,7 +777,7 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_
|
||||
color.b = cmd->data.draw.b;
|
||||
color.a = cmd->data.draw.a;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -836,7 +836,7 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
|
||||
|
||||
if (texture) {
|
||||
SDL_Vertex *verts = (SDL_Vertex *) SDL_AllocateRenderVertices(renderer, count * sizeof (*verts), 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -876,7 +876,7 @@ GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture
|
||||
|
||||
} else {
|
||||
SDL_VertexSolid *verts = (SDL_VertexSolid *) SDL_AllocateRenderVertices(renderer, count * sizeof (*verts), 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1452,7 +1452,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
|
||||
/* Allocate a texture struct */
|
||||
data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
data->texture = 0;
|
||||
@@ -1588,12 +1588,11 @@ GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint
|
||||
src = (Uint8 *)pixels;
|
||||
if (pitch != src_pitch) {
|
||||
blob = (Uint8 *)SDL_malloc(src_pitch * height);
|
||||
if (!blob) {
|
||||
if (blob == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
src = blob;
|
||||
for (y = 0; y < height; ++y)
|
||||
{
|
||||
for (y = 0; y < height; ++y) {
|
||||
SDL_memcpy(src, pixels, src_pitch);
|
||||
src += src_pitch;
|
||||
pixels = (Uint8 *)pixels + pitch;
|
||||
@@ -1606,7 +1605,7 @@ GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint
|
||||
int i;
|
||||
Uint32 *src32 = (Uint32 *)src;
|
||||
blob2 = (Uint32 *)SDL_malloc(src_pitch * height);
|
||||
if (!blob2) {
|
||||
if (blob2 == NULL) {
|
||||
if (blob) {
|
||||
SDL_free(blob);
|
||||
}
|
||||
@@ -1943,7 +1942,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
}
|
||||
|
||||
temp_pixels = SDL_malloc(buflen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -2107,13 +2106,13 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
|
||||
/* Create the renderer struct */
|
||||
renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
||||
data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
|
||||
@@ -379,12 +379,15 @@ GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint()
|
||||
const char *texcoord_hint = SDL_GetHint("SDL_RENDER_OPENGLES2_TEXCOORD_PRECISION");
|
||||
GLES2_ShaderIncludeType value = GLES2_SHADER_FRAGMENT_INCLUDE_BEST_TEXCOORD_PRECISION;
|
||||
if (texcoord_hint) {
|
||||
if (SDL_strcmp(texcoord_hint, "undefined") == 0)
|
||||
if (SDL_strcmp(texcoord_hint, "undefined") == 0) {
|
||||
return GLES2_SHADER_FRAGMENT_INCLUDE_UNDEF_PRECISION;
|
||||
if (SDL_strcmp(texcoord_hint, "high") == 0)
|
||||
}
|
||||
if (SDL_strcmp(texcoord_hint, "high") == 0) {
|
||||
return GLES2_SHADER_FRAGMENT_INCLUDE_HIGH_TEXCOORD_PRECISION;
|
||||
if (SDL_strcmp(texcoord_hint, "medium") == 0)
|
||||
}
|
||||
if (SDL_strcmp(texcoord_hint, "medium") == 0) {
|
||||
return GLES2_SHADER_FRAGMENT_INCLUDE_MEDIUM_TEXCOORD_PRECISION;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,9 @@ static int vsync_handler()
|
||||
/* Copy of gsKit_sync_flip, but without the 'flip' */
|
||||
static void gsKit_sync(GSGLOBAL *gsGlobal)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame) WaitSema(vsync_sema_id);
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
WaitSema(vsync_sema_id);
|
||||
}
|
||||
while (PollSema(vsync_sema_id) >= 0)
|
||||
;
|
||||
}
|
||||
@@ -73,10 +75,8 @@ static void gsKit_sync(GSGLOBAL *gsGlobal)
|
||||
/* Copy of gsKit_sync_flip, but without the 'sync' */
|
||||
static void gsKit_flip(GSGLOBAL *gsGlobal)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame)
|
||||
{
|
||||
if (gsGlobal->DoubleBuffering == GS_SETTING_ON)
|
||||
{
|
||||
if (!gsGlobal->FirstFrame) {
|
||||
if (gsGlobal->DoubleBuffering == GS_SETTING_ON) {
|
||||
GS_SET_DISPFB2( gsGlobal->ScreenBuffer[
|
||||
gsGlobal->ActiveBuffer & 1] / 8192,
|
||||
gsGlobal->Width / 64, gsGlobal->PSM, 0, 0 );
|
||||
@@ -110,16 +110,16 @@ PS2_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
{
|
||||
GSTEXTURE* ps2_tex = (GSTEXTURE*) SDL_calloc(1, sizeof(GSTEXTURE));
|
||||
|
||||
if (!ps2_tex)
|
||||
if (ps2_tex == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
ps2_tex->Width = texture->w;
|
||||
ps2_tex->Height = texture->h;
|
||||
ps2_tex->PSM = PixelFormatToPS2PSM(texture->format);
|
||||
ps2_tex->Mem = memalign(128, gsKit_texture_size_ee(ps2_tex->Width, ps2_tex->Height, ps2_tex->PSM));
|
||||
|
||||
if (!ps2_tex->Mem)
|
||||
{
|
||||
if (!ps2_tex->Mem) {
|
||||
SDL_free(ps2_tex);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
@@ -214,7 +214,7 @@ PS2_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
gs_rgbaq rgbaq;
|
||||
int i;
|
||||
|
||||
if (!vertices) {
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
if (texture) {
|
||||
GSPRIMSTQPOINT *vertices = (GSPRIMSTQPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMSTQPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
if (!vertices) {
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
} else {
|
||||
GSPRIMPOINT *vertices = (GSPRIMPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof (GSPRIMPOINT), 4, &cmd->data.draw.first);
|
||||
|
||||
if (!vertices) {
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd)
|
||||
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
|
||||
if(cmd->data.cliprect.enabled){
|
||||
if (cmd->data.cliprect.enabled) {
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(rect->x, rect->y, rect->w, rect->h));
|
||||
} else {
|
||||
gsKit_set_scissor(data->gsGlobal, GS_SCISSOR_RESET);
|
||||
@@ -520,18 +520,20 @@ PS2_RenderPresent(SDL_Renderer * renderer)
|
||||
PS2_RenderData *data = (PS2_RenderData *) renderer->driverdata;
|
||||
|
||||
if (data->gsGlobal->DoubleBuffering == GS_SETTING_OFF) {
|
||||
if (data->vsync == 2) // Dynamic
|
||||
if (data->vsync == 2) { // Dynamic
|
||||
gsKit_sync(data->gsGlobal);
|
||||
else if (data->vsync == 1)
|
||||
} else if (data->vsync == 1) {
|
||||
gsKit_vsync_wait();
|
||||
}
|
||||
gsKit_queue_exec(data->gsGlobal);
|
||||
} else {
|
||||
gsKit_queue_exec(data->gsGlobal);
|
||||
gsKit_finish();
|
||||
if (data->vsync == 2) // Dynamic
|
||||
if (data->vsync == 2) { // Dynamic
|
||||
gsKit_sync(data->gsGlobal);
|
||||
else if (data->vsync == 1)
|
||||
} else if (data->vsync == 1) {
|
||||
gsKit_vsync_wait();
|
||||
}
|
||||
gsKit_flip(data->gsGlobal);
|
||||
}
|
||||
gsKit_TexManager_nextFrame(data->gsGlobal);
|
||||
@@ -545,11 +547,13 @@ 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 == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(ps2_texture == NULL)
|
||||
if (ps2_texture == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Free from vram
|
||||
gsKit_TexManager_free(data->gsGlobal, ps2_texture);
|
||||
@@ -573,8 +577,9 @@ PS2_DestroyRenderer(SDL_Renderer * renderer)
|
||||
SDL_free(data);
|
||||
}
|
||||
|
||||
if (vsync_sema_id >= 0)
|
||||
if (vsync_sema_id >= 0) {
|
||||
DeleteSema(vsync_sema_id);
|
||||
}
|
||||
|
||||
SDL_free(renderer);
|
||||
}
|
||||
@@ -598,13 +603,13 @@ PS2_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
SDL_bool dynamicVsync;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (PS2_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
PS2_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -181,19 +181,22 @@ static int
|
||||
TextureNextPow2(unsigned int w)
|
||||
{
|
||||
unsigned int n = 2;
|
||||
if(w == 0)
|
||||
if (w == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while(w > n)
|
||||
while (w > n) {
|
||||
n <<= 1;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static void psp_on_vblank(u32 sub, PSP_RenderData *data)
|
||||
{
|
||||
if (data)
|
||||
if (data) {
|
||||
data->vblank_not_reached = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -217,10 +220,10 @@ PixelFormatToPSPFMT(Uint32 format)
|
||||
///SECTION render target LRU management
|
||||
static void
|
||||
LRUTargetRelink(PSP_TextureData* psp_texture) {
|
||||
if(psp_texture->prevhotw) {
|
||||
if (psp_texture->prevhotw) {
|
||||
psp_texture->prevhotw->nexthotw = psp_texture->nexthotw;
|
||||
}
|
||||
if(psp_texture->nexthotw) {
|
||||
if (psp_texture->nexthotw) {
|
||||
psp_texture->nexthotw->prevhotw = psp_texture->prevhotw;
|
||||
}
|
||||
}
|
||||
@@ -228,11 +231,11 @@ LRUTargetRelink(PSP_TextureData* psp_texture) {
|
||||
static void
|
||||
LRUTargetPushFront(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
psp_texture->nexthotw = data->most_recent_target;
|
||||
if(data->most_recent_target) {
|
||||
if (data->most_recent_target) {
|
||||
data->most_recent_target->prevhotw = psp_texture;
|
||||
}
|
||||
data->most_recent_target = psp_texture;
|
||||
if(!data->least_recent_target) {
|
||||
if (!data->least_recent_target) {
|
||||
data->least_recent_target = psp_texture;
|
||||
}
|
||||
}
|
||||
@@ -240,10 +243,10 @@ LRUTargetPushFront(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
static void
|
||||
LRUTargetRemove(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
LRUTargetRelink(psp_texture);
|
||||
if(data->most_recent_target == psp_texture) {
|
||||
if (data->most_recent_target == psp_texture) {
|
||||
data->most_recent_target = psp_texture->nexthotw;
|
||||
}
|
||||
if(data->least_recent_target == psp_texture) {
|
||||
if (data->least_recent_target == psp_texture) {
|
||||
data->least_recent_target = psp_texture->prevhotw;
|
||||
}
|
||||
psp_texture->prevhotw = NULL;
|
||||
@@ -252,7 +255,7 @@ LRUTargetRemove(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
|
||||
static void
|
||||
LRUTargetBringFront(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
if(data->most_recent_target == psp_texture) {
|
||||
if (data->most_recent_target == psp_texture) {
|
||||
return; //nothing to do
|
||||
}
|
||||
LRUTargetRemove(data, psp_texture);
|
||||
@@ -261,7 +264,7 @@ LRUTargetBringFront(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
|
||||
static void
|
||||
TextureStorageFree(void* storage) {
|
||||
if(InVram(storage)) {
|
||||
if (InVram(storage)) {
|
||||
vfree(storage);
|
||||
} else {
|
||||
SDL_free(storage);
|
||||
@@ -278,8 +281,9 @@ TextureSwizzle(PSP_TextureData *psp_texture, void* dst)
|
||||
unsigned int *src = NULL;
|
||||
unsigned char *data = NULL;
|
||||
|
||||
if(psp_texture->swizzled)
|
||||
if (psp_texture->swizzled) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
|
||||
height = psp_texture->size / bytewidth;
|
||||
@@ -290,21 +294,21 @@ TextureSwizzle(PSP_TextureData *psp_texture, void* dst)
|
||||
src = (unsigned int*) psp_texture->data;
|
||||
|
||||
data = dst;
|
||||
if(!data) {
|
||||
if (data == NULL) {
|
||||
data = SDL_malloc(psp_texture->size);
|
||||
}
|
||||
|
||||
if(!data) {
|
||||
if (data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
for(j = 0; j < height; j++, blockaddress += 16)
|
||||
for (j = 0; j < height; j++, blockaddress += 16)
|
||||
{
|
||||
unsigned int *block;
|
||||
|
||||
block = (unsigned int*)&data[blockaddress];
|
||||
|
||||
for(i = 0; i < rowblocks; i++)
|
||||
for (i = 0; i < rowblocks; i++)
|
||||
{
|
||||
*block++ = *src++;
|
||||
*block++ = *src++;
|
||||
@@ -313,8 +317,9 @@ TextureSwizzle(PSP_TextureData *psp_texture, void* dst)
|
||||
block += 28;
|
||||
}
|
||||
|
||||
if((j & 0x7) == 0x7)
|
||||
if ((j & 0x7) == 0x7) {
|
||||
blockaddress += rowblocksadd;
|
||||
}
|
||||
}
|
||||
|
||||
TextureStorageFree(psp_texture->data);
|
||||
@@ -337,8 +342,9 @@ TextureUnswizzle(PSP_TextureData *psp_texture, void* dst)
|
||||
unsigned char *data = NULL;
|
||||
unsigned char *ydst = NULL;
|
||||
|
||||
if(!psp_texture->swizzled)
|
||||
if (!psp_texture->swizzled) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
|
||||
height = psp_texture->size / bytewidth;
|
||||
@@ -353,26 +359,27 @@ TextureUnswizzle(PSP_TextureData *psp_texture, void* dst)
|
||||
|
||||
data = dst;
|
||||
|
||||
if(!data) {
|
||||
if (data == NULL) {
|
||||
data = SDL_malloc(psp_texture->size);
|
||||
}
|
||||
|
||||
if(!data)
|
||||
if (data == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
ydst = (unsigned char *)data;
|
||||
|
||||
for(blocky = 0; blocky < heightblocks; ++blocky)
|
||||
for (blocky = 0; blocky < heightblocks; ++blocky)
|
||||
{
|
||||
unsigned char *xdst = ydst;
|
||||
|
||||
for(blockx = 0; blockx < widthblocks; ++blockx)
|
||||
for (blockx = 0; blockx < widthblocks; ++blockx)
|
||||
{
|
||||
unsigned int *block;
|
||||
|
||||
block = (unsigned int*)xdst;
|
||||
|
||||
for(j = 0; j < 8; ++j)
|
||||
for (j = 0; j < 8; ++j)
|
||||
{
|
||||
*(block++) = *(src++);
|
||||
*(block++) = *(src++);
|
||||
@@ -401,10 +408,10 @@ static int
|
||||
TextureSpillToSram(PSP_RenderData* data, PSP_TextureData* psp_texture)
|
||||
{
|
||||
// Assumes the texture is in VRAM
|
||||
if(psp_texture->swizzled) {
|
||||
if (psp_texture->swizzled) {
|
||||
//Texture was swizzled in vram, just copy to system memory
|
||||
void* sdata = SDL_malloc(psp_texture->size);
|
||||
if(!sdata) {
|
||||
if (sdata == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -422,7 +429,7 @@ TexturePromoteToVram(PSP_RenderData* data, PSP_TextureData* psp_texture, SDL_boo
|
||||
{
|
||||
// Assumes texture in sram and a large enough continuous block in vram
|
||||
void* tdata = vramalloc(psp_texture->size);
|
||||
if(psp_texture->swizzled && target) {
|
||||
if (psp_texture->swizzled && target) {
|
||||
return TextureUnswizzle(psp_texture, tdata);
|
||||
} else {
|
||||
SDL_memcpy(tdata, psp_texture->data, psp_texture->size);
|
||||
@@ -435,8 +442,8 @@ TexturePromoteToVram(PSP_RenderData* data, PSP_TextureData* psp_texture, SDL_boo
|
||||
static int
|
||||
TextureSpillLRU(PSP_RenderData* data, size_t wanted) {
|
||||
PSP_TextureData* lru = data->least_recent_target;
|
||||
if(lru) {
|
||||
if(TextureSpillToSram(data, lru) < 0) {
|
||||
if (lru) {
|
||||
if (TextureSpillToSram(data, lru) < 0) {
|
||||
return -1;
|
||||
}
|
||||
LRUTargetRemove(data, lru);
|
||||
@@ -450,8 +457,8 @@ TextureSpillLRU(PSP_RenderData* data, size_t wanted) {
|
||||
static int
|
||||
TextureSpillTargetsForSpace(PSP_RenderData* data, size_t size)
|
||||
{
|
||||
while(vlargestblock() < size) {
|
||||
if(TextureSpillLRU(data, size) < 0) {
|
||||
while (vlargestblock() < size) {
|
||||
if (TextureSpillLRU(data, size) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -462,12 +469,12 @@ static int
|
||||
TextureBindAsTarget(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
unsigned int dstFormat;
|
||||
|
||||
if(!InVram(psp_texture->data)) {
|
||||
if (!InVram(psp_texture->data)) {
|
||||
// Bring back the texture in vram
|
||||
if(TextureSpillTargetsForSpace(data, psp_texture->size) < 0) {
|
||||
if (TextureSpillTargetsForSpace(data, psp_texture->size) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if(TexturePromoteToVram(data, psp_texture, SDL_TRUE) < 0) {
|
||||
if (TexturePromoteToVram(data, psp_texture, SDL_TRUE) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -476,7 +483,7 @@ TextureBindAsTarget(PSP_RenderData* data, PSP_TextureData* psp_texture) {
|
||||
|
||||
// Stencil alpha dst hack
|
||||
dstFormat = psp_texture->format;
|
||||
if(dstFormat == GU_PSM_5551) {
|
||||
if (dstFormat == GU_PSM_5551) {
|
||||
sceGuEnable(GU_STENCIL_TEST);
|
||||
sceGuStencilOp(GU_REPLACE, GU_REPLACE, GU_REPLACE);
|
||||
sceGuStencilFunc(GU_GEQUAL, 0xff, 0xff);
|
||||
@@ -501,8 +508,9 @@ 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)
|
||||
if (psp_texture == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
psp_texture->swizzled = SDL_FALSE;
|
||||
psp_texture->width = texture->w;
|
||||
@@ -530,21 +538,20 @@ PSP_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||
|
||||
psp_texture->pitch = psp_texture->textureWidth * SDL_BYTESPERPIXEL(texture->format);
|
||||
psp_texture->size = psp_texture->textureHeight*psp_texture->pitch;
|
||||
if(texture->access & SDL_TEXTUREACCESS_TARGET) {
|
||||
if(TextureSpillTargetsForSpace(renderer->driverdata, psp_texture->size) < 0){
|
||||
if (texture->access & SDL_TEXTUREACCESS_TARGET) {
|
||||
if (TextureSpillTargetsForSpace(renderer->driverdata, psp_texture->size) < 0) {
|
||||
SDL_free(psp_texture);
|
||||
return -1;
|
||||
}
|
||||
psp_texture->data = vramalloc(psp_texture->size);
|
||||
if(psp_texture->data) {
|
||||
if (psp_texture->data) {
|
||||
LRUTargetPushFront(data, psp_texture);
|
||||
}
|
||||
} else {
|
||||
psp_texture->data = SDL_calloc(1, psp_texture->size);
|
||||
}
|
||||
|
||||
if(!psp_texture->data)
|
||||
{
|
||||
if (!psp_texture->data) {
|
||||
SDL_free(psp_texture);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
@@ -568,8 +575,7 @@ TextureActivate(SDL_Texture * texture)
|
||||
int scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GU_NEAREST : GU_LINEAR;
|
||||
|
||||
/* Swizzling is useless with small textures. */
|
||||
if (TextureShouldSwizzle(psp_texture, texture))
|
||||
{
|
||||
if (TextureShouldSwizzle(psp_texture, texture)) {
|
||||
TextureSwizzle(psp_texture, NULL);
|
||||
}
|
||||
|
||||
@@ -661,7 +667,7 @@ PSP_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F
|
||||
VertV *verts = (VertV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertV), 4, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -691,7 +697,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
if (texture == NULL) {
|
||||
VertCV *verts;
|
||||
verts = (VertCV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertCV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -724,7 +730,7 @@ PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *t
|
||||
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) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -770,7 +776,7 @@ PSP_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FR
|
||||
VertV *verts = (VertV *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertV), 4, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -805,10 +811,9 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
|
||||
const float u1 = srcrect->x + srcrect->w;
|
||||
const float v1 = srcrect->y + srcrect->h;
|
||||
|
||||
if((MathAbs(u1) - MathAbs(u0)) < 64.0f)
|
||||
{
|
||||
if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) {
|
||||
verts = (VertTV *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (VertTV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -827,9 +832,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
|
||||
verts->y = y + height;
|
||||
verts->z = 0;
|
||||
verts++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
float start, end;
|
||||
float curU = u0;
|
||||
float curX = x;
|
||||
@@ -839,18 +842,19 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
|
||||
size_t i;
|
||||
float ustep = (u1 - u0)/width * slice;
|
||||
|
||||
if(ustep < 0.0f)
|
||||
if (ustep < 0.0f) {
|
||||
ustep = -ustep;
|
||||
}
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
verts = (VertTV *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertTV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
for(i = 0, start = 0, end = width; i < count; i++, start += slice)
|
||||
for (i = 0, start = 0, end = width; i < count; i++, start += slice)
|
||||
{
|
||||
const float polyWidth = ((curX + slice) > endX) ? (endX - curX) : slice;
|
||||
const float sourceWidth = ((curU + ustep) > u1) ? (u1 - curU) : ustep;
|
||||
@@ -899,7 +903,7 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||
float u1 = srcrect->x + srcrect->w;
|
||||
float v1 = srcrect->y + srcrect->h;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -985,16 +989,16 @@ StartDrawing(SDL_Renderer * renderer)
|
||||
PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata;
|
||||
|
||||
// Check if we need to start GU displaylist
|
||||
if(!data->displayListAvail) {
|
||||
if (!data->displayListAvail) {
|
||||
sceGuStart(GU_DIRECT, DisplayList);
|
||||
data->displayListAvail = SDL_TRUE;
|
||||
//ResetBlendState(&data->blendState);
|
||||
}
|
||||
|
||||
// Check if we need a draw buffer change
|
||||
if(renderer->target != data->boundTarget) {
|
||||
if (renderer->target != data->boundTarget) {
|
||||
SDL_Texture* texture = renderer->target;
|
||||
if(texture) {
|
||||
if (texture) {
|
||||
PSP_TextureData* psp_texture = (PSP_TextureData*) texture->driverdata;
|
||||
// Set target, registering LRU
|
||||
TextureBindAsTarget(data, psp_texture);
|
||||
@@ -1043,16 +1047,16 @@ PSP_SetBlendState(PSP_RenderData* data, PSP_BlendState* state)
|
||||
}
|
||||
}
|
||||
|
||||
if(state->color != current->color) {
|
||||
if (state->color != current->color) {
|
||||
sceGuColor(state->color);
|
||||
}
|
||||
|
||||
if(state->shadeModel != current->shadeModel) {
|
||||
if (state->shadeModel != current->shadeModel) {
|
||||
sceGuShadeModel(state->shadeModel);
|
||||
}
|
||||
|
||||
if(state->texture != current->texture) {
|
||||
if(state->texture != NULL) {
|
||||
if (state->texture != current->texture) {
|
||||
if (state->texture != NULL) {
|
||||
TextureActivate(state->texture);
|
||||
sceGuEnable(GU_TEXTURE_2D);
|
||||
} else {
|
||||
@@ -1077,7 +1081,7 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
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) {
|
||||
if (gpumem == NULL) {
|
||||
return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int) vertsize);
|
||||
}
|
||||
SDL_memcpy(gpumem, vertices, vertsize);
|
||||
@@ -1098,7 +1102,7 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
|
||||
case SDL_RENDERCMD_SETCLIPRECT: {
|
||||
const SDL_Rect *rect = &cmd->data.cliprect.rect;
|
||||
if(cmd->data.cliprect.enabled){
|
||||
if (cmd->data.cliprect.enabled) {
|
||||
sceGuEnable(GU_SCISSOR_TEST);
|
||||
sceGuScissor(rect->x, rect->y, rect->w, rect->h);
|
||||
} else {
|
||||
@@ -1263,8 +1267,9 @@ PSP_RenderPresent(SDL_Renderer * renderer)
|
||||
sceGuFinish();
|
||||
sceGuSync(0,0);
|
||||
|
||||
if ((data->vsync) && (data->vblank_not_reached))
|
||||
if ((data->vsync) && (data->vblank_not_reached)) {
|
||||
sceDisplayWaitVblankStart();
|
||||
}
|
||||
data->vblank_not_reached = SDL_TRUE;
|
||||
|
||||
data->backbuffer = data->frontbuffer;
|
||||
@@ -1279,11 +1284,13 @@ 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 == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(psp_texture == NULL)
|
||||
if (psp_texture == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
LRUTargetRemove(renderdata, psp_texture);
|
||||
TextureStorageFree(psp_texture->data);
|
||||
@@ -1296,8 +1303,9 @@ PSP_DestroyRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata;
|
||||
if (data) {
|
||||
if (!data->initialized)
|
||||
if (!data->initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
StartDrawing(renderer);
|
||||
|
||||
@@ -1334,13 +1342,13 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
void* doublebuffer = NULL;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (PSP_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
PSP_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
|
||||
@@ -219,7 +219,7 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
|
||||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRect(): dst");
|
||||
}
|
||||
|
||||
@@ -290,7 +290,7 @@ 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) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRects(): dst");
|
||||
}
|
||||
|
||||
@@ -334,7 +334,7 @@ SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
if (func == NULL) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB;
|
||||
} else {
|
||||
|
||||
@@ -808,12 +808,12 @@ SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
|
||||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendLine(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
if (func == NULL) {
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
@@ -837,12 +837,12 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_bool draw_end;
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
if (!func) {
|
||||
if (func == NULL) {
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ int
|
||||
SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ 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) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoints(): dst");
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!func) {
|
||||
if (func == NULL) {
|
||||
if (!dst->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB;
|
||||
} else {
|
||||
|
||||
@@ -143,12 +143,12 @@ SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
|
||||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawLine(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
if (func == NULL) {
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
@@ -172,12 +172,12 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
SDL_bool draw_end;
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawLines(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
if (!func) {
|
||||
if (func == NULL) {
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
int
|
||||
SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count,
|
||||
int i;
|
||||
int x, y;
|
||||
|
||||
if (!dst) {
|
||||
if (dst == NULL) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoints(): dst");
|
||||
}
|
||||
|
||||
|
||||
@@ -141,8 +141,9 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
int row;
|
||||
size_t length;
|
||||
|
||||
if(SDL_MUSTLOCK(surface))
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_LockSurface(surface);
|
||||
}
|
||||
src = (Uint8 *) pixels;
|
||||
dst = (Uint8 *) surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
@@ -153,8 +154,9 @@ SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
src += pitch;
|
||||
dst += surface->pitch;
|
||||
}
|
||||
if(SDL_MUSTLOCK(surface))
|
||||
if (SDL_MUSTLOCK(surface)) {
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -206,7 +208,7 @@ SW_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FP
|
||||
SDL_Point *verts = (SDL_Point *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Point), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -226,7 +228,7 @@ SW_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRe
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, count * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
int i;
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -248,7 +250,7 @@ SW_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * text
|
||||
{
|
||||
SDL_Rect *verts = (SDL_Rect *) SDL_AllocateRenderVertices(renderer, 2 * sizeof (SDL_Rect), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -283,7 +285,7 @@ SW_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * te
|
||||
{
|
||||
CopyExData *verts = (CopyExData *) SDL_AllocateRenderVertices(renderer, sizeof (CopyExData), 0, &cmd->data.draw.first);
|
||||
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -339,7 +341,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex
|
||||
int blitRequired = SDL_FALSE;
|
||||
int isOpaque = SDL_FALSE;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -558,7 +560,7 @@ SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Texture *te
|
||||
int sz = texture ? sizeof (GeometryCopyData) : sizeof (GeometryFillData);
|
||||
|
||||
verts = (void *) SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
if (verts == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -683,7 +685,7 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic
|
||||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -959,7 +961,7 @@ SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||
Uint32 src_format;
|
||||
void *src_pixels;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -987,7 +989,7 @@ SW_RenderPresent(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window *window = renderer->window;
|
||||
|
||||
if (!window) {
|
||||
if (window == NULL) {
|
||||
return -1;
|
||||
}
|
||||
return SDL_UpdateWindowSurface(window);
|
||||
@@ -1110,19 +1112,19 @@ SW_CreateRendererForSurface(SDL_Surface * surface)
|
||||
SDL_Renderer *renderer;
|
||||
SW_RenderData *data;
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
SDL_InvalidParamError("surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SW_DestroyRenderer(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -1170,7 +1172,7 @@ 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 || !*hint) {
|
||||
if (hint == NULL || !*hint) {
|
||||
no_hint_set = SDL_TRUE;
|
||||
} else {
|
||||
no_hint_set = SDL_FALSE;
|
||||
@@ -1187,7 +1189,7 @@ SW_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
|
||||
}
|
||||
|
||||
if (!surface) {
|
||||
if (surface == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return SW_CreateRendererForSurface(surface);
|
||||
|
||||
@@ -151,10 +151,13 @@ SDLgfx_rotozoomSurfaceSizeTrig(int width, int height, double angle, const SDL_FP
|
||||
{
|
||||
/* The trig code below gets the wrong size (due to FP inaccuracy?) when angle is a multiple of 90 degrees */
|
||||
int angle90 = (int)(angle/90);
|
||||
if(angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */
|
||||
if (angle90 == angle/90) { /* if the angle is a multiple of 90 degrees */
|
||||
angle90 %= 4;
|
||||
if(angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
if(angle90 & 1) {
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
}
|
||||
|
||||
if (angle90 & 1) {
|
||||
rect_dest->w = height;
|
||||
rect_dest->h = width;
|
||||
*cangle = 0;
|
||||
@@ -283,8 +286,12 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
for (x = 0; x < dst->w; x++) {
|
||||
int dx = (sdx >> 16);
|
||||
int dy = (sdy >> 16);
|
||||
if (flipx) dx = sw - dx;
|
||||
if (flipy) dy = sh - dy;
|
||||
if (flipx) {
|
||||
dx = sw - dx;
|
||||
}
|
||||
if (flipy) {
|
||||
dy = sh - dy;
|
||||
}
|
||||
if ((dx > -1) && (dy > -1) && (dx < (src->w-1)) && (dy < (src->h-1))) {
|
||||
int ex, ey;
|
||||
int t1, t2;
|
||||
@@ -340,8 +347,12 @@ transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int isin, int icos,
|
||||
int dx = (sdx >> 16);
|
||||
int dy = (sdy >> 16);
|
||||
if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
|
||||
if(flipx) dx = sw - dx;
|
||||
if(flipy) dy = sh - dy;
|
||||
if (flipx) {
|
||||
dx = sw - dx;
|
||||
}
|
||||
if (flipy) {
|
||||
dy = sh - dy;
|
||||
}
|
||||
*pc = *((tColorRGBA *)((Uint8 *)src->pixels + src->pitch * dy) + dx);
|
||||
}
|
||||
sdx += icos;
|
||||
@@ -410,8 +421,12 @@ transformSurfaceY(SDL_Surface * src, SDL_Surface * dst, int isin, int icos, int
|
||||
int dx = (sdx >> 16);
|
||||
int dy = (sdy >> 16);
|
||||
if ((unsigned)dx < (unsigned)src->w && (unsigned)dy < (unsigned)src->h) {
|
||||
if (flipx) dx = sw - dx;
|
||||
if (flipy) dy = sh- dy;
|
||||
if (flipx) {
|
||||
dx = sw - dx;
|
||||
}
|
||||
if (flipy) {
|
||||
dy = sh - dy;
|
||||
}
|
||||
*pc = *((tColorY *)src->pixels + src->pitch * dy + dx);
|
||||
}
|
||||
sdx += icos;
|
||||
@@ -462,8 +477,9 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/* Sanity check */
|
||||
if (src == NULL)
|
||||
if (src == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_HasColorKey(src)) {
|
||||
if (SDL_GetColorKey(src, &colorkey) == 0) {
|
||||
@@ -472,8 +488,9 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
}
|
||||
/* This function requires a 32-bit surface or 8-bit surface with a colorkey */
|
||||
is8bit = src->format->BitsPerPixel == 8 && colorKeyAvailable;
|
||||
if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask)))
|
||||
if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Calculate target factors from sine/cosine and zoom */
|
||||
sangleinv = sangle*65536.0;
|
||||
@@ -500,8 +517,9 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
if (rz_dst == NULL)
|
||||
if (rz_dst == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Adjust for guard rows */
|
||||
rz_dst->h = rect_dest->h;
|
||||
@@ -541,14 +559,17 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int
|
||||
angle90 = (int)(angle/90);
|
||||
if (angle90 == angle/90) {
|
||||
angle90 %= 4;
|
||||
if (angle90 < 0) angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
if (angle90 < 0) {
|
||||
angle90 += 4; /* 0:0 deg, 1:90 deg, 2:180 deg, 3:270 deg */
|
||||
}
|
||||
|
||||
} else {
|
||||
angle90 = -1;
|
||||
}
|
||||
|
||||
if (is8bit) {
|
||||
/* Call the 8-bit transformation routine to do the rotation */
|
||||
if(angle90 >= 0) {
|
||||
if (angle90 >= 0) {
|
||||
transformSurfaceY90(src, rz_dst, angle90, flipx, flipy);
|
||||
} else {
|
||||
transformSurfaceY(src, rz_dst, (int)sangleinv, (int)cangleinv,
|
||||
|
||||
@@ -519,14 +519,26 @@ int SDL_SW_BlitTriangle(
|
||||
maxx = srcrect.x + srcrect.w;
|
||||
maxy = srcrect.y + srcrect.h;
|
||||
if (srcrect.w > 0) {
|
||||
if (s0->x == maxx) s0->x--;
|
||||
if (s1->x == maxx) s1->x--;
|
||||
if (s2->x == maxx) s2->x--;
|
||||
if (s0->x == maxx) {
|
||||
s0->x--;
|
||||
}
|
||||
if (s1->x == maxx) {
|
||||
s1->x--;
|
||||
}
|
||||
if (s2->x == maxx) {
|
||||
s2->x--;
|
||||
}
|
||||
}
|
||||
if (srcrect.h > 0) {
|
||||
if (s0->y == maxy) s0->y--;
|
||||
if (s1->y == maxy) s1->y--;
|
||||
if (s2->y == maxy) s2->y--;
|
||||
if (s0->y == maxy) {
|
||||
s0->y--;
|
||||
}
|
||||
if (s1->y == maxy) {
|
||||
s1->y--;
|
||||
}
|
||||
if (s2->y == maxy) {
|
||||
s2->y--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -226,13 +226,13 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
VITA_GXM_RenderData *data;
|
||||
|
||||
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
|
||||
if (!renderer) {
|
||||
if (renderer == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data = (VITA_GXM_RenderData *) SDL_calloc(1, sizeof(VITA_GXM_RenderData));
|
||||
if (!data) {
|
||||
if (data == NULL) {
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
return NULL;
|
||||
@@ -280,8 +280,7 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
sceSysmoduleLoadModule( SCE_SYSMODULE_RAZOR_CAPTURE );
|
||||
#endif
|
||||
|
||||
if (gxm_init(renderer) != 0)
|
||||
{
|
||||
if (gxm_init(renderer) != 0) {
|
||||
SDL_free(data);
|
||||
SDL_free(renderer);
|
||||
return NULL;
|
||||
@@ -308,7 +307,7 @@ 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) {
|
||||
if (vita_texture == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -647,8 +646,7 @@ VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
static void
|
||||
VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode)
|
||||
{
|
||||
if (blendMode != data->currentBlendMode)
|
||||
{
|
||||
if (blendMode != data->currentBlendMode) {
|
||||
fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend;
|
||||
|
||||
switch (blendMode)
|
||||
@@ -709,8 +707,7 @@ VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const
|
||||
cmd->data.draw.first = (size_t)vertex;
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
for (int i = 0; i < count; i++) {
|
||||
vertex[i].x = points[i].x;
|
||||
vertex[i].y = points[i].y;
|
||||
vertex[i].color = color;
|
||||
@@ -733,8 +730,7 @@ VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const S
|
||||
cmd->data.draw.first = (size_t)vertex;
|
||||
cmd->data.draw.count = (count-1) * 2;
|
||||
|
||||
for (int i = 0; i < count - 1; i++)
|
||||
{
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
vertex[i*2].x = points[i].x;
|
||||
vertex[i*2].y = points[i].y;
|
||||
vertex[i*2].color = color;
|
||||
@@ -768,7 +764,7 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu
|
||||
data,
|
||||
count * sizeof(texture_vertex));
|
||||
|
||||
if (!vertices) {
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -808,7 +804,7 @@ VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Textu
|
||||
data,
|
||||
count * sizeof(color_vertex));
|
||||
|
||||
if (!vertices) {
|
||||
if (vertices == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1146,7 +1142,7 @@ VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
|
||||
}
|
||||
|
||||
temp_pixels = SDL_malloc(buflen);
|
||||
if (!temp_pixels) {
|
||||
if (temp_pixels == NULL) {
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
@@ -1234,14 +1230,17 @@ 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 == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(vita_texture == NULL)
|
||||
if (vita_texture == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(vita_texture->tex == NULL)
|
||||
if (vita_texture->tex == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
sceGxmFinish(data->gxm_context);
|
||||
|
||||
@@ -1257,8 +1256,9 @@ VITA_GXM_DestroyRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata;
|
||||
if (data) {
|
||||
if (!data->initialized)
|
||||
if (!data->initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
gxm_finish(renderer);
|
||||
|
||||
|
||||
@@ -38,14 +38,17 @@ vita_mem_alloc(unsigned int type, unsigned int size, unsigned int alignment, uns
|
||||
|
||||
*uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL);
|
||||
|
||||
if (*uid < 0)
|
||||
if (*uid < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sceGxmMapMemory(mem, size, attribs) < 0)
|
||||
if (sceGxmMapMemory(mem, size, attribs) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
@@ -54,8 +57,9 @@ void
|
||||
vita_mem_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
@@ -82,8 +86,7 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
}
|
||||
|
||||
ret = sceKernelGetMemBlockBase(data->texturePoolUID, &mem);
|
||||
if ( ret < 0)
|
||||
{
|
||||
if ( ret < 0) {
|
||||
return NULL;
|
||||
}
|
||||
data->texturePool = sceClibMspaceCreate(mem, poolsize);
|
||||
@@ -92,8 +95,7 @@ vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size)
|
||||
return NULL;
|
||||
}
|
||||
ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE);
|
||||
if (ret < 0)
|
||||
{
|
||||
if (ret < 0) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -103,8 +105,7 @@ 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 != NULL) {
|
||||
sceClibMspaceFree(data->texturePool, ptr);
|
||||
}
|
||||
}
|
||||
@@ -113,12 +114,12 @@ void
|
||||
vita_gpu_mem_destroy(VITA_GXM_RenderData *data)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (data->texturePool != NULL)
|
||||
{
|
||||
if (data->texturePool != NULL) {
|
||||
sceClibMspaceDestroy(data->texturePool);
|
||||
data->texturePool = NULL;
|
||||
if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapMemory(mem);
|
||||
sceKernelFreeMemBlock(data->texturePoolUID);
|
||||
}
|
||||
@@ -132,10 +133,12 @@ vita_mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_of
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0)
|
||||
}
|
||||
if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
@@ -144,8 +147,9 @@ void
|
||||
vita_mem_vertex_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapVertexUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
@@ -158,10 +162,12 @@ vita_mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_
|
||||
size = ALIGN(size, 4096);
|
||||
*uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL);
|
||||
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(*uid, &mem) < 0) {
|
||||
return NULL;
|
||||
if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0)
|
||||
}
|
||||
if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mem;
|
||||
}
|
||||
@@ -170,8 +176,9 @@ void
|
||||
vita_mem_fragment_usse_free(SceUID uid)
|
||||
{
|
||||
void *mem = NULL;
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0)
|
||||
if (sceKernelGetMemBlockBase(uid, &mem) < 0) {
|
||||
return;
|
||||
}
|
||||
sceGxmUnmapFragmentUsseMemory(mem);
|
||||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h)
|
||||
void
|
||||
set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max)
|
||||
{
|
||||
if(data->drawing) {
|
||||
if (data->drawing) {
|
||||
// clear the stencil buffer to 0
|
||||
sceGxmSetFrontStencilFunc(
|
||||
data->gxm_context,
|
||||
@@ -748,8 +748,7 @@ gxm_init(SDL_Renderer *renderer)
|
||||
&data->linearIndicesUid
|
||||
);
|
||||
|
||||
for (i = 0; i <= UINT16_MAX; ++i)
|
||||
{
|
||||
for (i = 0; i <= UINT16_MAX; ++i) {
|
||||
data->linearIndices[i] = i;
|
||||
}
|
||||
|
||||
@@ -927,8 +926,7 @@ void gxm_finish(SDL_Renderer *renderer)
|
||||
// clean up display queue
|
||||
vita_mem_free(data->depthBufferUid);
|
||||
|
||||
for (size_t i = 0; i < VITA_GXM_BUFFERS; i++)
|
||||
{
|
||||
for (size_t i = 0; i < VITA_GXM_BUFFERS; i++) {
|
||||
// clear the buffer then deallocate
|
||||
SDL_memset(data->displayBufferData[i], 0, VITA_GXM_SCREEN_HEIGHT * VITA_GXM_SCREEN_STRIDE * 4);
|
||||
vita_mem_free(data->displayBufferUid[i]);
|
||||
@@ -1048,8 +1046,9 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2;
|
||||
}
|
||||
|
||||
if (!texture)
|
||||
if (texture == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*return_w = w;
|
||||
*return_h = h;
|
||||
@@ -1062,7 +1061,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
);
|
||||
|
||||
/* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */
|
||||
if (!texture_data) {
|
||||
if (texture_data == NULL) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n");
|
||||
texture_data = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
|
||||
@@ -1076,7 +1075,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
||||
texture->cdram = 1;
|
||||
}
|
||||
|
||||
if (!texture_data) {
|
||||
if (texture_data == NULL) {
|
||||
SDL_free(texture);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1209,8 +1208,7 @@ void gxm_minimal_term_for_common_dialog(void)
|
||||
|
||||
void gxm_init_for_common_dialog(void)
|
||||
{
|
||||
for (int i = 0; i < VITA_GXM_BUFFERS; i += 1)
|
||||
{
|
||||
for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) {
|
||||
buffer_for_common_dialog[i].displayData.wait_vblank = SDL_TRUE;
|
||||
buffer_for_common_dialog[i].displayData.address = vita_mem_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
||||
@@ -1258,8 +1256,7 @@ void gxm_swap_for_common_dialog(void)
|
||||
void gxm_term_for_common_dialog(void)
|
||||
{
|
||||
sceGxmDisplayQueueFinish();
|
||||
for (int i = 0; i < VITA_GXM_BUFFERS; i += 1)
|
||||
{
|
||||
for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) {
|
||||
vita_mem_free(buffer_for_common_dialog[i].uid);
|
||||
sceGxmSyncObjectDestroy(buffer_for_common_dialog[i].sync);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user