mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-27 19:01:52 +00:00
SDL API renaming: SDL_surface.h
Fixes https://github.com/libsdl-org/SDL/issues/6884
This commit is contained in:
@@ -1348,7 +1348,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
|
||||
|
||||
/* See what the best texture format is */
|
||||
fmt = surface->format;
|
||||
if (fmt->Amask || SDL_HasColorKey(surface)) {
|
||||
if (fmt->Amask || SDL_SurfaceHasColorKey(surface)) {
|
||||
needAlpha = SDL_TRUE;
|
||||
} else {
|
||||
needAlpha = SDL_FALSE;
|
||||
@@ -1365,7 +1365,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
|
||||
|
||||
/* Try to have the best pixel format for the texture */
|
||||
/* No alpha, but a colorkey => promote to alpha */
|
||||
if (!fmt->Amask && SDL_HasColorKey(surface)) {
|
||||
if (!fmt->Amask && SDL_SurfaceHasColorKey(surface)) {
|
||||
if (fmt->format == SDL_PIXELFORMAT_RGB888) {
|
||||
for (i = 0; i < (int)renderer->info.num_texture_formats; ++i) {
|
||||
if (renderer->info.texture_formats[i] == SDL_PIXELFORMAT_ARGB8888) {
|
||||
@@ -1410,7 +1410,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
|
||||
}
|
||||
|
||||
if (format == surface->format->format) {
|
||||
if (surface->format->Amask && SDL_HasColorKey(surface)) {
|
||||
if (surface->format->Amask && SDL_SurfaceHasColorKey(surface)) {
|
||||
/* Surface and Renderer formats are identicals.
|
||||
* Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */
|
||||
direct_update = SDL_FALSE;
|
||||
@@ -1445,7 +1445,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
|
||||
SDL_DestroyPixelFormat(dst_fmt);
|
||||
if (temp) {
|
||||
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
|
||||
SDL_FreeSurface(temp);
|
||||
SDL_DestroySurface(temp);
|
||||
} else {
|
||||
SDL_DestroyTexture(texture);
|
||||
return NULL;
|
||||
@@ -1462,7 +1462,7 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
|
||||
SDL_GetSurfaceAlphaMod(surface, &a);
|
||||
SDL_SetTextureAlphaMod(texture, a);
|
||||
|
||||
if (SDL_HasColorKey(surface)) {
|
||||
if (SDL_SurfaceHasColorKey(surface)) {
|
||||
/* We converted to a texture with alpha format */
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
} else {
|
||||
@@ -2136,7 +2136,7 @@ void SDL_UnlockTexture(SDL_Texture *texture)
|
||||
renderer->UnlockTexture(renderer, texture);
|
||||
}
|
||||
|
||||
SDL_FreeSurface(texture->locked_surface);
|
||||
SDL_DestroySurface(texture->locked_surface);
|
||||
texture->locked_surface = NULL;
|
||||
}
|
||||
|
||||
@@ -4261,7 +4261,7 @@ void SDL_DestroyTexture(SDL_Texture *texture)
|
||||
|
||||
renderer->DestroyTexture(renderer, texture);
|
||||
|
||||
SDL_FreeSurface(texture->locked_surface);
|
||||
SDL_DestroySurface(texture->locked_surface);
|
||||
texture->locked_surface = NULL;
|
||||
|
||||
SDL_free(texture);
|
||||
|
||||
@@ -342,7 +342,7 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
|
||||
/* Make sure we're set up to display in the desired format */
|
||||
if (target_format != swdata->target_format && swdata->display) {
|
||||
SDL_FreeSurface(swdata->display);
|
||||
SDL_DestroySurface(swdata->display);
|
||||
swdata->display = NULL;
|
||||
}
|
||||
|
||||
@@ -394,8 +394,8 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
|
||||
{
|
||||
if (swdata) {
|
||||
SDL_SIMDFree(swdata->pixels);
|
||||
SDL_FreeSurface(swdata->stretch);
|
||||
SDL_FreeSurface(swdata->display);
|
||||
SDL_DestroySurface(swdata->stretch);
|
||||
SDL_DestroySurface(swdata->display);
|
||||
SDL_free(swdata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
} else {
|
||||
SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE);
|
||||
retval = SDL_PrivateUpperBlitScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode);
|
||||
SDL_FreeSurface(src_clone);
|
||||
SDL_DestroySurface(src_clone);
|
||||
src_clone = src_scaled;
|
||||
src_scaled = NULL;
|
||||
}
|
||||
@@ -488,14 +488,14 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD);
|
||||
/* Renderer scaling, if needed */
|
||||
retval = Blit_to_Screen(src_rotated_rgb, NULL, surface, &tmp_rect, scale_x, scale_y, texture->scaleMode);
|
||||
SDL_FreeSurface(src_rotated_rgb);
|
||||
SDL_DestroySurface(src_rotated_rgb);
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_FreeSurface(mask_rotated);
|
||||
SDL_DestroySurface(mask_rotated);
|
||||
}
|
||||
if (src_rotated != NULL) {
|
||||
SDL_FreeSurface(src_rotated);
|
||||
SDL_DestroySurface(src_rotated);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -504,10 +504,10 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
if (mask != NULL) {
|
||||
SDL_FreeSurface(mask);
|
||||
SDL_DestroySurface(mask);
|
||||
}
|
||||
if (src_clone != NULL) {
|
||||
SDL_FreeSurface(src_clone);
|
||||
SDL_DestroySurface(src_clone);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -645,9 +645,9 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate)
|
||||
clip_rect.w = cliprect->w;
|
||||
clip_rect.h = cliprect->h;
|
||||
SDL_IntersectRect(viewport, &clip_rect, &clip_rect);
|
||||
SDL_SetClipRect(surface, &clip_rect);
|
||||
SDL_SetSurfaceClipRect(surface, &clip_rect);
|
||||
} else {
|
||||
SDL_SetClipRect(surface, drawstate->viewport);
|
||||
SDL_SetSurfaceClipRect(surface, drawstate->viewport);
|
||||
}
|
||||
drawstate->surface_cliprect_dirty = SDL_FALSE;
|
||||
}
|
||||
@@ -694,8 +694,8 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
const Uint8 b = cmd->data.color.b;
|
||||
const Uint8 a = cmd->data.color.a;
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetClipRect(surface, NULL);
|
||||
SDL_FillRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
SDL_SetSurfaceClipRect(surface, NULL);
|
||||
SDL_FillSurfaceRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
@@ -777,7 +777,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
SDL_FillSurfaceRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
@@ -839,7 +839,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
||||
SDL_SetSurfaceBlendMode(tmp, blendmode);
|
||||
|
||||
SDL_BlitSurface(tmp, NULL, surface, dstrect);
|
||||
SDL_FreeSurface(tmp);
|
||||
SDL_DestroySurface(tmp);
|
||||
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
|
||||
}
|
||||
} else {
|
||||
@@ -980,7 +980,7 @@ static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||
{
|
||||
SDL_Surface *surface = (SDL_Surface *)texture->driverdata;
|
||||
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_DestroySurface(surface);
|
||||
}
|
||||
|
||||
static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
||||
|
||||
@@ -80,8 +80,8 @@ to a situation where the program can segfault.
|
||||
static Uint32 get_colorkey(SDL_Surface *src)
|
||||
{
|
||||
Uint32 key = 0;
|
||||
if (SDL_HasColorKey(src)) {
|
||||
SDL_GetColorKey(src, &key);
|
||||
if (SDL_SurfaceHasColorKey(src)) {
|
||||
SDL_GetSurfaceColorKey(src, &key);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
@@ -504,8 +504,8 @@ SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_HasColorKey(src)) {
|
||||
if (SDL_GetColorKey(src, &colorkey) == 0) {
|
||||
if (SDL_SurfaceHasColorKey(src)) {
|
||||
if (SDL_GetSurfaceColorKey(src, &colorkey) == 0) {
|
||||
colorKeyAvailable = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
@@ -549,8 +549,8 @@ SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int
|
||||
|
||||
if (colorKeyAvailable == SDL_TRUE) {
|
||||
/* If available, the colorkey will be used to discard the pixels that are outside of the rotated area. */
|
||||
SDL_SetColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
SDL_FillRect(rz_dst, NULL, colorkey);
|
||||
SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);
|
||||
} else if (blendmode == SDL_BLENDMODE_NONE) {
|
||||
blendmode = SDL_BLENDMODE_BLEND;
|
||||
} else if (blendmode == SDL_BLENDMODE_MOD || blendmode == SDL_BLENDMODE_MUL) {
|
||||
@@ -558,12 +558,12 @@ SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, int flipx, int
|
||||
* that the pixels outside the rotated area don't affect the destination surface.
|
||||
*/
|
||||
colorkey = SDL_MapRGBA(rz_dst->format, 255, 255, 255, 0);
|
||||
SDL_FillRect(rz_dst, NULL, colorkey);
|
||||
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);
|
||||
/* Setting a white colorkey for the destination surface makes the final blit discard
|
||||
* all pixels outside of the rotated area. This doesn't interfere with anything because
|
||||
* white pixels are already a no-op and the MOD blend mode does not interact with alpha.
|
||||
*/
|
||||
SDL_SetColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
SDL_SetSurfaceColorKey(rz_dst, SDL_TRUE, colorkey);
|
||||
}
|
||||
|
||||
SDL_SetSurfaceBlendMode(rz_dst, blendmode);
|
||||
|
||||
@@ -257,7 +257,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
{
|
||||
/* Clip triangle with surface clip rect */
|
||||
SDL_Rect rect;
|
||||
SDL_GetClipRect(dst, &rect);
|
||||
SDL_GetSurfaceClipRect(dst, &rect);
|
||||
SDL_IntersectRect(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
if (blend == SDL_BLENDMODE_MOD) {
|
||||
Uint32 c = SDL_MapRGBA(tmp->format, 255, 255, 255, 255);
|
||||
SDL_FillRect(tmp, NULL, c);
|
||||
SDL_FillSurfaceRect(tmp, NULL, c);
|
||||
}
|
||||
|
||||
SDL_SetSurfaceBlendMode(tmp, blend);
|
||||
@@ -417,7 +417,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
||||
|
||||
if (tmp) {
|
||||
SDL_BlitSurface(tmp, NULL, dst, &dstrect);
|
||||
SDL_FreeSurface(tmp);
|
||||
SDL_DestroySurface(tmp);
|
||||
}
|
||||
|
||||
end:
|
||||
@@ -553,7 +553,7 @@ int SDL_SW_BlitTriangle(
|
||||
{
|
||||
/* Clip triangle with surface clip rect */
|
||||
SDL_Rect rect;
|
||||
SDL_GetClipRect(dst, &rect);
|
||||
SDL_GetSurfaceClipRect(dst, &rect);
|
||||
SDL_IntersectRect(&dstrect, &rect, &dstrect);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user