Commit Graph

571 Commits

Author SHA1 Message Date
Bastien Bouclet
3376597abd OPENGL: Use premultiplied alpha for color-keyed cursors
This fixes colour fringing on keyed cursors when using filtering.

Fixes Trac#10594.
2018-08-26 21:08:40 +02:00
Eugene Sandulenko
23aa8a5d13 DINGUX: Fix initSize() method signature 2018-08-18 14:05:02 +02:00
Matthew Stewart
a5a45fdae1 SDL: Clip mouse range in convertVirtualToWindow 2018-07-08 22:30:31 +01:00
Matthew Stewart
a382a6dd30 SDL: Clip mouse range in convertWindowToVirtual
When the graphics scale was 2x or higher, it was possible for the mouse
to pass the size of the screen specified by "initSize".
2018-07-08 22:30:31 +01:00
Cameron Cawley
d93fe85994 BACKENDS: Fix compilation with SDL 1.2 2018-07-08 22:20:28 +01:00
Thierry Crozat
89f1b1c96e GUI: Add Stretch Mode selection in Options dialog 2018-07-08 16:54:51 +01:00
Thierry Crozat
812ce59ee4 SDL: Implement stretch mode API
Four modes are supported:
 - Use original size with no scaling
 - Scale by an integral amount as much as possible but not bigger
   than the window.
 - Scale to fit the window while respecting the aspect ratio. There
   may be black bars on the left and right, or on the top and bottom,
   but not both. This is the default, and the old behaviour.
 - Scale and stretch to fit the window. In this mode the aspecy ratio
   is not respected and there is no black bars.
The mode is controled by the "scaling_mode" value (between 0 and 3) in
the config file.

Also add Crtl-Alt-s hotkey to cycle through scaling modes
2018-07-08 16:54:51 +01:00
Thierry Crozat
8526c2c31a OSYSTEM: Add Stretch Mode API 2018-07-08 16:54:51 +01:00
Adrian Frühwirth
cee4d6b853 JANITORIAL: Fix trailing whitespace 2018-05-24 15:30:55 +02:00
Eugene Sandulenko
d6b5e3f611 BAKCENDS: Mark methods as override 2018-03-28 11:58:35 +02:00
rsn8887
9af2b5ca3a PSP2: fix touch sometimes not directly under finger 2018-03-20 03:14:11 -05:00
rsn8887
68274d1cc6 PSP2: Improve direct touch accuracy 2018-01-27 19:02:59 -06:00
rsn8887
3978a82650 SURFACESDL: Remove erroneous override declarations 2018-01-17 19:06:12 -06:00
rsn8887
6f2a8bdbca PSP2: remove code duplication in psp2 graphicsmanager 2018-01-17 18:52:48 -06:00
Tarek Soliman
f285e384da GRAPHICS: Fix rounding error when using non-integral scaling
When a non-integral scaling was being used, x and/or y cursor position would be
one less than what it should be.

Fixes Trac#10401

Thanks snover!
2018-01-12 22:43:00 -06:00
Bastien Bouclet
ae634388e9 SDL: Enable the startup fullscreen hack for X11 only
It causes problems on AmigaOS and Linux/SDL2/Vivante
2017-12-10 15:23:16 +01:00
Colin Snover
a5bc89102e ALL: Remove obsolete register keyword
The register keyword was deprecated from the C++11 standard,
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4193.html#809>,
and removed from the C++17 standard,
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4340>, so
cannot exist in a well-formed C++17 program.

It has never done anything in GCC
<https://gcc.gnu.org/ml/gcc/2010-05/msg00113.html>
and because of the way it is specified in the standard, it is “as
meaningful as whitespace”
<http://www.drdobbs.com/keywords-that-arent-or-comments-by-anoth/184403859>.

The one remaining use of the register keyword is in the DS backend,
where it is used to create a local register variable using the
non-standard GCC Extended Asm feature.

Closes gh-1079.
2017-12-03 20:27:42 -06:00
Colin Snover
20b2c1b7e1 SDL: Fix memory corruption when switching to/from 32-bit cursors
When a 32-bit cursor has the same size as an 8- or 16-bit cursor,
the mouse surfaces were not being regenerated even though the
32-bit cursors have a different memory requirement. This lead to
memory corruption as an inappropriate surface would be used for
the other type of cursor.

The shoe-horned 32-bit cursor support is clearly showing its
scrappy nature here and probably ought to be revisited in the
future if the SurfaceSdl graphics manager sticks around.

Fixes Trac#10349, Trac#10350, Trac#10351.
2017-12-03 12:33:05 -06:00
rsn8887
c78fa86860 PSP2: fix clipping and display quality for odd resolutions (Phantasmagoria) 2017-12-02 13:00:22 -06:00
rsn8887
d73437c293 PSP2: fix odd resolutions on PSP2, fixes Phantasmagoria 2017-12-02 11:53:23 -06:00
Colin Snover
5c855a0a5a BACKENDS: Fix shake position getting stuck
If a game is doing a screen shake (for example, DOTT when the
stereo is on), and the user does an RTL, the screen shake offset
may get stuck if the engine does not reset it on shutdown. To
avoid this in all cases, just always reset the screen shake
whenever the graphics manager is told to switch to a new graphics
mode.
2017-12-01 19:43:12 -06:00
Bastien Bouclet
779b97ee3f SDL: Don't use the window size hint for fullscreen
Prevents the opengl backend from changing mode when entering fullscreen
for games with a window size hint.

Fixes #10335. Closes gh-1074.
2017-11-29 16:49:32 -06:00
Colin Snover
c278677d07 SDL: Store fake mouse warp event in virtual coordinates
Normally, notifyMousePosition converts real mouse events into the
virtual coordinate system, but events only get sent through
notifyMousePosition if they are real events from SDL since that
method also decides if the real mouse is inside the content area or
not. As such, these fake events need to be pre-converted to virtual
coordinates or else the wrong values are sent through to the engine
when a scaler or AR correction is in use.
2017-11-27 20:39:21 -06:00
Colin Snover
9bbf7f3f36 SDL: Don't pass null pointers to SDL_DestroyTexture/SDL_DestroyRenderer
SDL does not like this and will raise an assertion when built with
internal SDL assertions turned on. With internal assertions turned
off, it will still call SDL_SetError any time a null pointer is
passed, though it will not raise an assertion or crash.
2017-11-15 11:36:14 -06:00
Bastien Bouclet
1dbe3ad18e SDL: Fix assertion when using 4bpp cursors with a key color
Myst ME uses such cursors.
2017-11-11 13:26:22 +01:00
Thierry Crozat
1d1f898c01 SDL: Preserve mouse position when switching between OpenGL and SurfaceSDL backends
Since those GraphcisManager initialize the cursor position to (0,0) when
created the cursor was jumping to the top left corner and then moving
back to its initial position as soon as the mouse was moved. Now it
stays at its initial position.

There are still some issues with it when changing between OpenGL and
SurfaceSDL at the same time as toggling fullscreen. But it is not worse
than before.
2017-11-11 00:15:13 +00:00
Thierry Crozat
b93fefebe8 SDL: Fix display artefacts with transparent OSD message
If we do not update the area below the message, it is just blitted on top
of itself again and again and gets progressively less transparent. It also
causes artefacts when the mouse pass below the OSD message.
2017-11-11 00:11:50 +00:00
Patrik Dahlstrom
bf85ad820c SDL: fix various OSD message artifacts
On the OpenPandora handheld, the OSD message would not render unless you
moved the cursor in the area where it was supposed to show.
Additionally, the OSD message was not transparent like in v1.8.
This commit fixes both these issues.
2017-11-10 19:56:28 +00:00
Colin Snover
8e8ec3900c SDL: Get correct default graphics mode ID when queried
Fixes Trac#10312.
2017-11-07 21:34:42 -06:00
Tarek Soliman
2fea095fc7 SDL: Fix SDL1 cursor position when using a touchscreen
I noticed that in Maemo the cursor was offset after the SDL refactoring
in de2bbe3b97

In Maemo when entering fullscreen, ScummVM receives a SDL_VIDEORESIZE
event with the native touchscreen resolution rather than the current
window size. This causes a call to notifyResize.

Before that refactoring, notifyResize did nothing (in SDL1).
Now it calls handleResize but doesn't actually set a new video mode.
This messes up the coordinate mapping, causing an overcorrection for
the cursor position.
2017-10-19 17:51:01 -05:00
Colin Snover
752f4e4f04 SDL: Fix missing scaled cursors in SDL 2.0.4 on Windows
This may be a problem with SDL 2.0.4 generally, not just on
Windows, but it doesn't really matter much since it can't be
broken on *any* platform.
2017-10-17 18:41:34 -05:00
Colin Snover
4307156e1c SDL: Fix 32bpp cursor scaling in SDL1
The SDL1 loop is not very optimal. Unfortunately all our existing
scalers only work in 16bpp and I don't have time to fix that right
now, so this is fine.
2017-10-16 00:27:34 -05:00
Colin Snover
4466738885 SDL: Fix scaled 32bpp cursor rendering 2017-10-15 21:38:58 -05:00
Colin Snover
ef44cc55ee DINGUX: Really constify getFeatureState 2017-10-15 16:54:24 -05:00
Colin Snover
7aef79c421 DINGUX: Fix missing const on hasFeature/getFeatureState implementation 2017-10-15 16:41:04 -05:00
Colin Snover
1f8eeb5920 DINGUX: Replace usage of old SurfaceSdlGraphicsManager APIs 2017-10-15 16:32:58 -05:00
Colin Snover
4263a78aa0 GPH: Replace usage of old SurfaceSdlGraphicsManager APIs 2017-10-15 16:18:10 -05:00
Colin Snover
2ef10faa1e PSP2: Replace usage of old SurfaceSdlGraphicsManager APIs 2017-10-15 16:00:00 -05:00
Colin Snover
e308605b2f OPENPANDORA: Remove duplicated loadGFXMode code 2017-10-15 15:52:11 -05:00
Colin Snover
bda253b1ac BACKENDS: Constify PaletteManager::grabPalette implementations 2017-10-15 13:47:19 -05:00
Colin Snover
4757c24c68 BACKENDS: Fix up graphics manager ports with const & override where appropriate 2017-10-15 13:24:21 -05:00
Colin Snover
f6ab0e5c10 SDL: Allow window size to be reset whenever launcher is visible
This ensures the window gets resized properly when a user changes
the scaler options in the GUI. Simply unlocking the window size on
a call to setGraphicsMode is not good enough, because the scaler
mode can be changed by games during mode switches, and we don't
want to reset the window size in that case.
2017-10-15 13:24:21 -05:00
Colin Snover
8b112f57a9 SDL: Support 32bpp cursor rendering
32bpp cursor scaling is not available, but this should be fine as
many of the software scalers are not designed to work with >16bpp
data in any case.

This change also includes some minor cleanup of unnecessary #ifdefs
around code that works equally well with or without USE_RGB_COLOR,
to simplify the implementation.
2017-10-15 13:24:21 -05:00
Colin Snover
d1b77d4b68 BACKENDS: Fix missing mouse events when system cursor cannot be moved
Normally with SDL, a mouse motion event will be sent after the
system mouse cursor has been moved by a call to
SDL_WarpMouseInWindow, but if the system cursor cannot be moved
(e.g. because the window does not have mouse focus), games still
need to receive these mouse events so they can successfully update
the mouse position internally. Otherwise, games continue to think
the mouse is still in the original position and will continue to
try to perform whatever action is associated with that mouse
position.

Refs Trac#9689.
2017-10-15 13:24:21 -05:00
Colin Snover
cd538ffffa BACKENDS: Do not send mouse events to games occurring outside the game draw rect 2017-10-15 13:24:21 -05:00
Colin Snover
319ab07fe0 SDL: Minor code cleanup to declare variables at point of first use 2017-10-15 13:24:20 -05:00
Colin Snover
5d8cf6ba42 BACKENDS: Fix GraphicsManager handling of empty cursors
The SDL graphics manager was just ignoring calls from CursorMan to
set the cursor to a blank cursor, which meant engines that did not
immediately send a cursor to CursorMan at startup would still show
the launcher's cursor (usually with a broken palette).

The OpenGL graphics manager would try to generate and draw an
invalid cursor surface when receiving an empty cursor.
2017-10-15 13:24:20 -05:00
Colin Snover
da0a8db704 BACKENDS: Also hide mouse cursor outside game area when an engine has hidden the cursor
The only reason we show the system cursor outside the game area is
to show users where their mouse is when the window is resized and
the mouse is outside the game area. If the game cannot be
interacted with, then the mouse also does not need to be shown in
the black areas.
2017-10-15 13:24:20 -05:00
Colin Snover
de2bbe3b97 BACKENDS: Refactor OpenGL & SDL graphics backends
This patch refactors the OpenGL and SDL graphics backends,
primarily to unify window scaling and mouse handling, and to
fix coordinate mapping between the ScummVM window and the
virtual game screen when they have different aspect ratios.

Unified code for these two backends has been moved to a new
header-only WindowedGraphicsManager class, so named because it
contains code for managing graphics managers that interact with
a windowing system and render virtual screens within a larger
physical content window.

The biggest behavioral change here is with the coordinate
system mapping:

Previously, mouse offsets were converted by mapping the whole
space within the window as input to the virtual game screen
without maintaining aspect ratio. This was done to prevent
'stickiness' when the mouse cursor was within the window but
outside of the virtual game screen, but it caused noticeable
distortion of mouse movement speed on the axis with blank
space.

Instead of introducing mouse speed distortion to prevent
stickiness, this patch changes coordinate transformation to
show the system cursor when the mouse moves outside of the virtual
game screen when mouse grab is off, or by holding the mouse inside
the virtual game screen (instead of the entire window) when mouse
grab is on.

This patch also improves some other properties of the
GraphicsManager/PaletteManager interfaces:

* Nullipotent operations (getWidth, getHeight, etc.) of the
  PaletteManager/GraphicsManager interfaces are now const
* Methods marked `virtual` but not inherited by any subclass have
  been de-virtualized
* Extra unnecessary calculations of hardware height in
  SurfaceSdlGraphicsManager have been removed
* Methods have been renamed where appropriate for clarity
  (setWindowSize -> handleResize, etc.)
* C++11 support improved with `override` specifier added on
  overridden virtual methods in subclasses (primarily to avoid
  myself accidentally creating new methods in the subclasses
  by changing types/names during refactoring)

Additional refactoring can and should be done at some point to
continue to deduplicate code between the OpenGL and SDL backends.
Since the primary goal here was to improve the coordinate mapping,
full refactoring of these backends was not completed here.
2017-10-15 13:24:20 -05:00
Colin Snover
969dd565a1 SDL: Allow window resize with non-OpenGL SDL2 backend
The GUI is not redrawn when the window size changes, but that is
not as important as being able to resize the games themselves.
2017-10-15 13:24:20 -05:00