Render: Allow empty cliprect.

This fixes an issue where an empty cliprect is treated the same as a NULL
cliprect, causing the render backends to disable clipping.

Also adds a new API, SDL_RenderIsClipEnabled(render) that allows you to
differentiate between:
 - SDL_RenderSetClipRect(render, NULL)
 - SDL_Rect r = {0,0,0,0}; SDL_RenderSetClipRect(render, &r);

Fixes https://bugzilla.libsdl.org/show_bug.cgi?id=2504
This commit is contained in:
Jørgen P. Tjernø
2014-04-19 13:15:41 -07:00
parent a9b8c776dc
commit 4d68f8c53e
11 changed files with 43 additions and 18 deletions

View File

@@ -347,11 +347,9 @@ SW_UpdateClipRect(SDL_Renderer * renderer)
{
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
SDL_Surface *surface = data->surface;
const SDL_Rect *rect = &renderer->clip_rect;
if (surface) {
if (!SDL_RectEmpty(rect)) {
SDL_SetClipRect(surface, rect);
if (renderer->clipping_enabled) {
SDL_SetClipRect(surface, &renderer->clip_rect);
} else {
SDL_SetClipRect(surface, NULL);
}