Commit Graph

122 Commits

Author SHA1 Message Date
Ryan C. Gordon
fb5fd67ccb Fixed all known static analysis bugs, with checker-279 on macOS. 2016-11-24 21:41:09 -05:00
Sam Lantinga
8e2634eb13 Fixed divide by zero if setting integer scale without setting logical width and height 2016-10-14 00:51:57 -07:00
Sam Lantinga
27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Eric Wing
bb3cb4f42a overscan (feature for SDL_RenderSetLogicalSize): Fix to ignore overscan hint when using the Direct3D 9 backend.
D39 does not support negative viewport values which the current implementation relies on.
D3D11 does support negative viewport values so that will continue working.
Refer to Bug 2799.
2016-04-04 19:25:24 -07:00
Sam Lantinga
9c48365524 Fixed bug 3029 - software renderer cuts off edges when rotate-blitting with a multiple of 90 degrees
Adam M.

When doing a rotated texture copy with the software renderer, where the angle is a multiple of 90 degrees, one or two edges of the image get cut off. This is because of the following line in sw_rotate.c:
    if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) {
which is effectively saying:
    if (dx >= 0 && dx < src->w-1 && dy >= 0 && dy < src->h-1) {

As a result, it doesn't process pixels in the right column or bottom row of the source image (except when they're accessed as part of the bilinear filtering for nearby pixels). This causes it to look like the edges are cut off, and it's especially obvious with an exact multiple of 90 degrees.
2016-10-07 18:00:30 -07:00
Sam Lantinga
c8cfccc2f1 Fixed bug 3116 - renderer->hidden in SDL_RenderCopy(Ex)
Daniel

Seems like check of the visibility of renderer (renderer->hidden) is missing in SDL_RenderCopyEx.

In SDL_RenderCopy it should be done much earlier (after checking support for RenderCopyEx, line 1750).
2016-10-01 14:31:00 -07:00
Sam Lantinga
67901f537c Fixed bug 3174 - SDL_SetRenderTarget clip rect
Marcel Bakker

In SDL_SetRenderTarget(),
i think the intended behavior was to clear the clip rect when a new target is set.
2016-10-01 13:29:30 -07:00
Philipp Wiesemann
0a1999dfd2 Fixed compile warnings about type conversion.
Found by buildbot.
2016-01-16 21:25:10 +01:00
Ethan Lee
167cf14c1f SDL_RenderSetIntegerScale 2016-01-05 16:39:18 -05:00
Eric Wing
d77a55738b merged SDL 2.0.4 rc2 2015-06-21 04:04:14 -07:00
Sam Lantinga
b7ede6cc47 Fixed bug 1550 - SDL_RenderCopy/CopyEx in software should optionally render 8bit alpha
Adam M.

There are three problems in the code that I see.
1. SW_RenderCopyEx enables a color key on surface_scaled even if the source surface didn't have a color key.
2. SW_RenderCopyEx doesn't copy blend mode, color mod, or alpha mod from src to surface_scaled.
3. When SDL_BlitScaled(src, srcrect, surface_scaled, &tmp_rect) is called, it blends the src pixels into surface_scaled instead of overwriting them (if src has blending, etc. enabled).

I've attached a patch that 1) fixes the three problems that I mentioned, 2) adds the requested performance improvement of using the regular blit function if no rotation or flipping is needed, 3) avoids cloning the source surface if no stretching is required, and simplifies the rotation code slightly.
2015-06-19 23:20:43 -07:00
Eric Wing
27fab8f4bb merged SDL 2.0.4rc1+ 2015-06-17 20:03:08 -07:00
Sam Lantinga
6a3ad8a998 Fixed bug 2367 - Bad mouse motion coordinates with two windows where one has changed logical size
Andreas Ragnerstam

I have two windows where one has a renderer where the logical size has been changed with SDL_RenderSetLogicalSize. When I get SDL_MOUSEMOTION events belonging to the non-scaled window these will have been scaled with the factor of the scaled window, which is not expected.

Adding some printf debugging to SDL_RendererEventWatch of SDL_render.c, where (event->type == SDL_MOUSEMOTION), I found that for every mouse motion SDL_RendererEventWatch is called twice and the event->motion.x and event.motion.y are set twice for the event, once for each renderer where only the last one set will be saved to the event struct. This will work fine if both renderers have the same scale, but otherwise the motion coordinates will be scaled for the renderer belonging to another window than the mouse was moved in.

I guess one solution would be to check that window == renderer->window for SDL_MOUSEMOTION events, similar to what is done for when SDL_WINDOWEVENT events.

I get the same error on both X11 and Windows.
The same problem also exists for SDL_MOUSEBUTTONDOWN and SDL_MOUSEBUTTONUP events.
2015-05-28 12:18:05 -07:00
Sam Lantinga
42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
David Ludwig
9e9ef5ad31 Fixed bug 3202 - Fix renderer visibility on a window maximized directly from the minimized state
Many thanks to id.zeta for details on the bug, and for the fix!
2015-12-27 17:55:45 -05:00
Philipp Wiesemann
0856a7ef34 Changed an error return value from 0 to NULL for consistency. 2015-08-21 23:50:37 +02:00
Philipp Wiesemann
0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00
Ryan C. Gordon
d5a578531b Drop out of SDL_UpdateTexture() early if the rectangle is zero pixels.
Hopefully makes static analysis happy about a zero-byte malloc elsewhere.
2015-05-26 16:42:36 -04:00
Sam Lantinga
2c4a6ea0a2 Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Eric Wing
313881175d Adds support to control the scaling policy/mode of SDL_RenderSetLogicalSize for both letterbox (current behavior) and a new overscan mode (expand to fill the entire screen, even if some parts draw off the screen).
The expected use case is for games that are designed with multiple aspect ratios already in mind and leave optional margins on the edges of the game which won't hurt if they are cut off.

An example use case is a game is designed for wide-screen/16:9, but then wants to deploy on an iPad which is 4:3. Normally, SDL will letterbox, which will shrink things and result in wasted space. But the designer already thought about 4:3 and designed the edges of the game so they could be cut off without any functional loss. So rather than wasting space with letterboxing, "overscan" mode will zoom the rendering to fill up the entire screen. Parts on the edges will be drawn offscreen, but since the game was already designed with this in mind, it is fine. The end result is the iPad (4:3) experience is much better since it feels like a game designed for that screen aspect ratio.

This patch introduces a new SDL_hint: SDL_HINT_RENDER_LOGICAL_SIZE_MODE.
Valid values are "letterbox" or "0" for letterboxing and "overscan" or "1" for overscan.
The default mode is letterbox to preserve existing behavior.

// Example usage:
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, "overscan");
SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
2014-12-03 04:41:26 -08:00
Philipp Wiesemann
9c398852e6 Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Ryan C. Gordon
b72938c861 Windows: Always set the system timer resolution to 1ms by default.
An existing hint lets apps that don't need the timer resolution changed avoid
this, to save battery, etc, but this fixes several problems in timing, audio
callbacks not firing fast enough, etc.

Fixes Bugzilla #2944.
2015-04-20 12:22:44 -04:00