Fixed build after cherry-pick of 5750bcb174 from SDL3

This commit is contained in:
Sam Lantinga 2022-11-30 13:05:57 -08:00
parent b8d85c6939
commit 6926d046c0
2 changed files with 101 additions and 290 deletions

View file

@ -673,27 +673,23 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
while (cmd) {
switch (cmd->command) {
case SDL_RENDERCMD_SETDRAWCOLOR:
{
case SDL_RENDERCMD_SETDRAWCOLOR: {
break; /* Not used in this backend. */
}
case SDL_RENDERCMD_SETVIEWPORT:
{
case SDL_RENDERCMD_SETVIEWPORT: {
drawstate.viewport = &cmd->data.viewport.rect;
drawstate.surface_cliprect_dirty = SDL_TRUE;
break;
}
case SDL_RENDERCMD_SETCLIPRECT:
{
case SDL_RENDERCMD_SETCLIPRECT: {
drawstate.cliprect = cmd->data.cliprect.enabled ? &cmd->data.cliprect.rect : NULL;
drawstate.surface_cliprect_dirty = SDL_TRUE;
break;
}
case SDL_RENDERCMD_CLEAR:
{
case SDL_RENDERCMD_CLEAR: {
const Uint8 r = cmd->data.color.r;
const Uint8 g = cmd->data.color.g;
const Uint8 b = cmd->data.color.b;
@ -705,8 +701,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
break;
}
case SDL_RENDERCMD_DRAW_POINTS:
{
case SDL_RENDERCMD_DRAW_POINTS: {
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
const Uint8 b = cmd->data.draw.b;
@ -869,162 +864,6 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
}
case SDL_RENDERCMD_GEOMETRY: {
int i;
for (i = 0; i < count; i++) {
verts[i].x += drawstate.viewport->x;
verts[i].y += drawstate.viewport->y;
}
}
if (blend == SDL_BLENDMODE_NONE) {
SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
} else {
SDL_BlendPoints(surface, verts, count, blend, r, g, b, a);
}
break;
}
case SDL_RENDERCMD_DRAW_LINES:
{
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
const Uint8 b = cmd->data.draw.b;
const Uint8 a = cmd->data.draw.a;
const int count = (int)cmd->data.draw.count;
SDL_Point *verts = (SDL_Point *)(((Uint8 *)vertices) + cmd->data.draw.first);
const SDL_BlendMode blend = cmd->data.draw.blend;
SetDrawState(surface, &drawstate);
/* Apply viewport */
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
int i;
for (i = 0; i < count; i++) {
verts[i].x += drawstate.viewport->x;
verts[i].y += drawstate.viewport->y;
}
}
if (blend == SDL_BLENDMODE_NONE) {
SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
} else {
SDL_BlendLines(surface, verts, count, blend, r, g, b, a);
}
break;
}
case SDL_RENDERCMD_FILL_RECTS:
{
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
const Uint8 b = cmd->data.draw.b;
const Uint8 a = cmd->data.draw.a;
const int count = (int)cmd->data.draw.count;
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
const SDL_BlendMode blend = cmd->data.draw.blend;
SetDrawState(surface, &drawstate);
/* Apply viewport */
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
int i;
for (i = 0; i < count; i++) {
verts[i].x += drawstate.viewport->x;
verts[i].y += drawstate.viewport->y;
}
}
if (blend == SDL_BLENDMODE_NONE) {
SDL_FillRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
} else {
SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a);
}
break;
}
case SDL_RENDERCMD_COPY:
{
SDL_Rect *verts = (SDL_Rect *)(((Uint8 *)vertices) + cmd->data.draw.first);
const SDL_Rect *srcrect = verts;
SDL_Rect *dstrect = verts + 1;
SDL_Texture *texture = cmd->data.draw.texture;
SDL_Surface *src = (SDL_Surface *)texture->driverdata;
SetDrawState(surface, &drawstate);
PrepTextureForCopy(cmd);
/* Apply viewport */
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
dstrect->x += drawstate.viewport->x;
dstrect->y += drawstate.viewport->y;
}
if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
SDL_BlitSurface(src, srcrect, surface, dstrect);
} else {
/* If scaling is ever done, permanently disable RLE (which doesn't support scaling)
* to avoid potentially frequent RLE encoding/decoding.
*/
SDL_SetSurfaceRLE(surface, 0);
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
SDL_Surface *tmp = SDL_CreateRGBSurfaceWithFormat(dstrect->w, dstrect->h, src->format->format);
/* Scale to an intermediate surface, then blit */
if (tmp) {
SDL_Rect r;
SDL_BlendMode blendmode;
Uint8 alphaMod, rMod, gMod, bMod;
SDL_GetSurfaceBlendMode(src, &blendmode);
SDL_GetSurfaceAlphaMod(src, &alphaMod);
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
r.x = 0;
r.y = 0;
r.w = dstrect->w;
r.h = dstrect->h;
SDL_SetSurfaceBlendMode(src, SDL_BLENDMODE_NONE);
SDL_SetSurfaceColorMod(src, 255, 255, 255);
SDL_SetSurfaceAlphaMod(src, 255);
SDL_PrivateUpperBlitScaled(src, srcrect, tmp, &r, texture->scaleMode);
SDL_SetSurfaceColorMod(tmp, rMod, gMod, bMod);
SDL_SetSurfaceAlphaMod(tmp, alphaMod);
SDL_SetSurfaceBlendMode(tmp, blendmode);
SDL_BlitSurface(tmp, NULL, surface, dstrect);
SDL_FreeSurface(tmp);
/* No need to set back r/g/b/a/blendmode to 'src' since it's done in PrepTextureForCopy() */
}
} else {
SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode);
}
}
break;
}
case SDL_RENDERCMD_COPY_EX:
{
CopyExData *copydata = (CopyExData *)(((Uint8 *)vertices) + cmd->data.draw.first);
SetDrawState(surface, &drawstate);
PrepTextureForCopy(cmd);
/* Apply viewport */
if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) {
copydata->dstrect.x += drawstate.viewport->x;
copydata->dstrect.y += drawstate.viewport->y;
}
SW_RenderCopyEx(renderer, surface, cmd->data.draw.texture, &copydata->srcrect,
&copydata->dstrect, copydata->angle, &copydata->center, copydata->flip,
copydata->scale_x, copydata->scale_y);
break;
}
case SDL_RENDERCMD_GEOMETRY:
{
int i;
SDL_Rect *verts = (SDL_Rect *) (((Uint8 *) vertices) + cmd->data.draw.first);
const int count = (int) cmd->data.draw.count;

View file

@ -68,34 +68,6 @@ typedef struct SDL_EGL_VideoData
EGLBoolean(EGLAPIENTRY *eglDestroyContext) (EGLDisplay dpy, EGLContext ctx);
EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
EGLint const* attrib_list);
EGLDisplay(EGLAPIENTRY *eglGetDisplay)(NativeDisplayType display);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay)(EGLenum platform,
void *native_display,
const EGLAttrib *attrib_list);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplayEXT)(EGLenum platform,
void *native_display,
const EGLint *attrib_list);
EGLBoolean(EGLAPIENTRY *eglInitialize)(EGLDisplay dpy, EGLint *major,
EGLint *minor);
EGLBoolean(EGLAPIENTRY *eglTerminate)(EGLDisplay dpy);
void *(EGLAPIENTRY *eglGetProcAddress)(const char *procName);
EGLBoolean(EGLAPIENTRY *eglChooseConfig)(EGLDisplay dpy,
const EGLint *attrib_list,
EGLConfig *configs,
EGLint config_size, EGLint *num_config);
EGLContext(EGLAPIENTRY *eglCreateContext)(EGLDisplay dpy,
EGLConfig config,
EGLContext share_list,
const EGLint *attrib_list);
EGLBoolean(EGLAPIENTRY *eglDestroyContext)(EGLDisplay dpy, EGLContext ctx);
EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
EGLint const* attrib_list);