mirror of https://github.com/libsdl-org/SDL
Make sure logical presentation is complete before destroying the logical render target
Fixes "testautomation --filter render_testLogicalSize"
This commit is contained in:
parent
619f65af0c
commit
00fc50557e
|
@ -2263,6 +2263,60 @@ int SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void SDL_RenderLogicalBorders(SDL_Renderer *renderer)
|
||||
{
|
||||
const SDL_FRect *dst = &renderer->logical_dst_rect;
|
||||
|
||||
if (dst->x > 0.0f || dst->y > 0.0f) {
|
||||
SDL_BlendMode saved_blend_mode = renderer->blendMode;
|
||||
SDL_Color saved_color = renderer->color;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
|
||||
if (dst->x > 0.0f) {
|
||||
SDL_FRect rect;
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
rect.w = dst->x;
|
||||
rect.h = (float)renderer->view->pixel_h;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.x = dst->x + dst->w;
|
||||
rect.w = (float)renderer->view->pixel_w - rect.x;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
if (dst->y > 0.0f) {
|
||||
SDL_FRect rect;
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
rect.w = (float)renderer->view->pixel_w;
|
||||
rect.h = dst->y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.y = dst->y + dst->h;
|
||||
rect.h = (float)renderer->view->pixel_h - rect.y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, saved_blend_mode);
|
||||
SDL_SetRenderDrawColor(renderer, saved_color.r, saved_color.g, saved_color.b, saved_color.a);
|
||||
}
|
||||
}
|
||||
|
||||
static void SDL_RenderLogicalPresentation(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_assert(renderer->target == NULL);
|
||||
SDL_SetRenderViewport(renderer, NULL);
|
||||
SDL_SetRenderClipRect(renderer, NULL);
|
||||
SDL_SetRenderScale(renderer, 1.0f, 1.0f);
|
||||
SDL_RenderLogicalBorders(renderer);
|
||||
SDL_RenderTexture(renderer, renderer->logical_target, &renderer->logical_src_rect, &renderer->logical_dst_rect);
|
||||
}
|
||||
|
||||
int SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y)
|
||||
{
|
||||
SDL_RenderViewState *view;
|
||||
|
@ -3927,50 +3981,6 @@ static void SDL_SimulateRenderVSync(SDL_Renderer *renderer)
|
|||
}
|
||||
}
|
||||
|
||||
static void SDL_RenderLogicalBorders(SDL_Renderer *renderer)
|
||||
{
|
||||
const SDL_FRect *dst = &renderer->logical_dst_rect;
|
||||
|
||||
if (dst->x > 0.0f || dst->y > 0.0f) {
|
||||
SDL_BlendMode saved_blend_mode = renderer->blendMode;
|
||||
SDL_Color saved_color = renderer->color;
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE);
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
|
||||
if (dst->x > 0.0f) {
|
||||
SDL_FRect rect;
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
rect.w = dst->x;
|
||||
rect.h = (float)renderer->view->pixel_h;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.x = dst->x + dst->w;
|
||||
rect.w = (float)renderer->view->pixel_w - rect.x;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
if (dst->y > 0.0f) {
|
||||
SDL_FRect rect;
|
||||
|
||||
rect.x = 0.0f;
|
||||
rect.y = 0.0f;
|
||||
rect.w = (float)renderer->view->pixel_w;
|
||||
rect.h = dst->y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
rect.y = dst->y + dst->h;
|
||||
rect.h = (float)renderer->view->pixel_h - rect.y;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
SDL_SetRenderDrawBlendMode(renderer, saved_blend_mode);
|
||||
SDL_SetRenderDrawColor(renderer, saved_color.r, saved_color.g, saved_color.b, saved_color.a);
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_RenderPresent(SDL_Renderer *renderer)
|
||||
{
|
||||
SDL_bool presented = SDL_TRUE;
|
||||
|
@ -3979,11 +3989,7 @@ int SDL_RenderPresent(SDL_Renderer *renderer)
|
|||
|
||||
if (renderer->logical_target) {
|
||||
SDL_SetRenderTargetInternal(renderer, NULL);
|
||||
SDL_SetRenderViewport(renderer, NULL);
|
||||
SDL_SetRenderClipRect(renderer, NULL);
|
||||
SDL_SetRenderScale(renderer, 1.0f, 1.0f);
|
||||
SDL_RenderLogicalBorders(renderer);
|
||||
SDL_RenderTexture(renderer, renderer->logical_target, &renderer->logical_src_rect, &renderer->logical_dst_rect);
|
||||
SDL_RenderLogicalPresentation(renderer);
|
||||
}
|
||||
|
||||
FlushRenderCommands(renderer); /* time to send everything to the GPU! */
|
||||
|
@ -4021,6 +4027,12 @@ static int SDL_DestroyTextureInternal(SDL_Texture *texture, SDL_bool is_destroyi
|
|||
} else {
|
||||
if (texture == renderer->target) {
|
||||
SDL_SetRenderTargetInternal(renderer, NULL); /* implies command queue flush */
|
||||
|
||||
if (texture == renderer->logical_target) {
|
||||
/* Complete any logical presentation */
|
||||
SDL_RenderLogicalPresentation(renderer);
|
||||
FlushRenderCommands(renderer);
|
||||
}
|
||||
} else {
|
||||
FlushRenderCommandsIfTextureNeeded(texture);
|
||||
}
|
||||
|
|
|
@ -845,7 +845,6 @@ static int render_testLogicalSize(void *arg)
|
|||
rect.w = (float)viewport.w / factor;
|
||||
rect.h = (float)viewport.h / factor;
|
||||
CHECK_FUNC(SDL_RenderFillRect, (renderer, &rect))
|
||||
(void)SDL_RenderPresent(renderer);
|
||||
CHECK_FUNC(SDL_SetRenderLogicalPresentation, (renderer, 0, 0,
|
||||
SDL_LOGICAL_PRESENTATION_DISABLED,
|
||||
SDL_SCALEMODE_NEAREST))
|
||||
|
@ -869,7 +868,6 @@ static int render_testLogicalSize(void *arg)
|
|||
CHECK_FUNC(SDL_SetRenderDrawColor, (renderer, 0, 255, 0, SDL_ALPHA_OPAQUE))
|
||||
CHECK_FUNC(SDL_RenderFillRect, (renderer, NULL))
|
||||
CHECK_FUNC(SDL_SetRenderViewport, (renderer, NULL))
|
||||
(void)SDL_RenderPresent(renderer);
|
||||
CHECK_FUNC(SDL_SetRenderLogicalPresentation, (renderer, 0, 0,
|
||||
SDL_LOGICAL_PRESENTATION_DISABLED,
|
||||
SDL_SCALEMODE_NEAREST))
|
||||
|
@ -902,7 +900,6 @@ static int render_testLogicalSize(void *arg)
|
|||
SDL_SCALEMODE_LINEAR))
|
||||
CHECK_FUNC(SDL_SetRenderDrawColor, (renderer, 0, 255, 0, SDL_ALPHA_OPAQUE))
|
||||
CHECK_FUNC(SDL_RenderFillRect, (renderer, NULL))
|
||||
(void)SDL_RenderPresent(renderer);
|
||||
CHECK_FUNC(SDL_SetRenderLogicalPresentation, (renderer, 0, 0,
|
||||
SDL_LOGICAL_PRESENTATION_DISABLED,
|
||||
SDL_SCALEMODE_NEAREST))
|
||||
|
|
Loading…
Reference in New Issue