Commit Graph

506 Commits (25f6851ca184346297c1d953e9e649311a0dc083)

Author SHA1 Message Date
Patric Stout 25f6851ca1 Codechange: switch all video drivers to std::chrono for keeping time
On all OSes we tested the std::chrono::steady_clock is of a high
enough resolution to do millisecond measurements, which is all we
need.

By accident, this fixes a Win32 driver bug, where we would never
hit our targets, as the resolution of the clock was too low to
do accurate millisecond measurements with (it was ~16ms resolution
instead).
4 years ago
Patric Stout 8e0d48a0f6
Fix: [SDL2] simplify what to redraw to prevent tearing (#8685)
When there are a lot of rects to redraw, of which one of the last
ones is almost the full screen, visual tearing happens over the
vertical axis. This is most visible when scrolling the map.

This can be prevented by using less rects. To simplify the situation,
and as solutions like OpenGL need this anyway, keep a single rect
that shows the biggest size that updates everything correctly.

Although this means it needs a bit more time redrawing where it
is strictly seen not needed, it also means less commands have
to be executed in the backend. In the end, this is a trade-off,
and from experiments it seems the approach of this commit gives
a better result.
4 years ago
Patric Stout 6de188d025
Fix 52317bb7: [SDL2] ensure we don't try to blit out of bounds (#8684)
During resizing, there can still be dirty-rects ready to blit based
on the old dimensions. X11 with shared memory enabled crashes if
you try to do this. So, instead, if we resize, reset the dirty-rects.

This is fine, as moments later we mark the whole (new) screen as
dirty anyway.
4 years ago
milek7 751f595bb6 Fix: VkMapping declarations violated C++ ODR rule. 4 years ago
Michael Lutz 8d780e0607 Add: [OSX] Automatic zoom level suggestion for Cocoa video driver. 4 years ago
Michael Lutz f175e38666 Add: [Win32] Automatic zoom level suggestion for Win32 video driver.
The zoom level suggestion is based on the DPI scaling set in Windows.
We use 150% scaling as the threshold for 2X zoom and 300% scaling
as the threshold for 4X zoom.
4 years ago
Michael Lutz 22f5aeab07 Feature: Automatic UI and font zoom levels when supported by the OS. 4 years ago
Michael Lutz f5555a6d26 Fix 9c872192: [OSX] Clear mouse button emulation flag. 4 years ago
Michael Lutz e5c3253642 Add: [OSX] Setting to disable HiDPI graphics rendering. 4 years ago
Michael Lutz 0fc763bc55 Change: [OSX] Render screen in full native resolution on HiDPI displays. 4 years ago
Michael Lutz 8906e9e0fd Codechange: Consistently use screen size and not driver resolution for determining window sizes. 4 years ago
Michael Lutz acca56b6a5 Cleanup: [OSX] Improve some comments. 4 years ago
Michael Lutz c78e559e88 Codechange: [OSX] Remove unused 'app active' flag. 4 years ago
Michael Lutz 9c8721922b Fix: [OSX] An emulated right mouse down event has to be followed by right mouse up. 4 years ago
Michael Lutz 649ff5f9f9 Codechange: [OSX] Use relative mouse handling during scrolling. 4 years ago
Michael Lutz 43326d11d8 Change: [OSX] Use a layer-backed view to speed up drawing. 4 years ago
Michael Lutz 2a8c3a2cf6 Codechange: [OSX] Align backing buffer pitch for a tiny bit performance. 4 years ago
Michael Lutz 94b76ce9a4 Cleanup: [OSX] Move event loop into video driver file. 4 years ago
Michael Lutz 23389e9491 Remove: [OSX] Startup splash screen.
It wasn't displayed anyway as it was never copied to the bundle.
4 years ago
Michael Lutz 063b90b97d Codechange: [OSX] Move key event handling to our view. 4 years ago
Michael Lutz f4bd54fedd Codechange: [OSX] Move mouse event handling to our NSView. 4 years ago
Michael Lutz bd42fc94cc Codechange: [OSX] Move some things from video driver to our NSView. 4 years ago
Michael Lutz 965ce12947 Codechange: [OSX] Use newer mouse tracking API. 4 years ago
Michael Lutz 42af13c141 Codechange: [OSX] Split drawing into its own subview.
This allows the drawing backend code to be independent
of any event or command handling.
4 years ago
Michael Lutz 60f30036f1 Codechange: [OSX] Drain autoreleased objects in each game loop cycle. 4 years ago
Michael Lutz 8aaf4ea098 Codechange: [OSX] Split Window and back buffer creation in Cocoa video driver. 4 years ago
Michael Lutz 0eff7de659 Cleanup: [OSX] Doxygen comment style in video driver. 4 years ago
Michael Lutz 8ced72ab10 Codechange: [OSX] Inline some functions that are used in only one place. 4 years ago
Michael Lutz 13134f9d64 Codechange: [OSX] Replace #define with modern code. 4 years ago
Michael Lutz 88f6c7a9f3 Codechange: [OSX] Fold remaining Cocoa video subdriver into the main driver. 4 years ago
Michael Lutz e6bea3961f Change: [OSX] Replace screen resolution list with suggested window sizes.
We never change the real screen resolution on OSX. As such, offering a list
of resolutions is pointless. Instead of that, offer the user a list of
commonly used window sizes up to the current screen size.
4 years ago
Michael Lutz 4db7837d06 Codechange: [OSX] There is only one subdriver left, remove virtual dispatch. 4 years ago
Patric Stout 52317bb7df Change: [SDL2] Remove unneeded delay of redrawing the screen
In testing, I could find no reason why this statement is here.

The comment is rather unclear (it states what it does, but not
why it would be needed).

This line of code was introduced with f4f40448, which gives no
further insight on why it would be needed to have it here.

As such, let's remove it and see if anyone else reports any
problems with it. If so, this commit can be reverted and a more
clear comment should be added what this line of code is dealing
with (the WHY, not the WHAT).
4 years ago
Patric Stout 2e1535389a Codechange: [SDL2] Don't use globals if we can do with locals 4 years ago
Patric Stout 2bbef6b5cf Codechange: [SDL2] Name paint function Paint(), like other drivers do
This reduces confusion when reading different drivers.
4 years ago
Patric Stout 569ce6c7b4 Fix 30e69c51: palette was not marked dirty when creating a new
This means the code depended that the caller did this for us
before MakePalette() is executed, which is neither a
requirement nor a promise the code makes.
4 years ago
Patric Stout 2c9084d48c
Fix #8029: [SDL2] disable draw-thread on wayland SDL video driver (#8648)
When the wayland SDL video driver is used, an EGL context is
created in the main thread. It is not allowed to update this
context from another thread, which is exactly what our draw-thread
is trying.

The other solution would be to move all of SDL into the
draw-thread, but that would introduce a whole scala of different
problems.

The wayland SDL backend is significantly faster than the
X11 SDL backend, but there is a performance hit nevertheless.
4 years ago
SamuXarick a4035af337
Codechange: Apply coding style (#8640)
* Fix: Missing or needed spaces

* Codechange: Remove space

* Codechange: Remove space

* Codechange: More missing spaces

* Codechange: Missing spaces

* Codechange: Remove space

* Codechange: Remove space
4 years ago
Patric Stout 0e54c32452 Codechange: [SDL2] Use MakeDirty() to force a redraw
The original code is "strictly correct", but just reads really
weird, and we use MakeDirty() in several other places instead too.
4 years ago
Patric Stout 30e69c518b Codechange: [SDL2] Rework how palette is updated
It now follows more what the Win32 driver does, and has far less
exceptions and special casing.

MakePalette creates the Palette and prepares surface.
UpdatePalette updates the Palette.
CheckPaletteAnim checks if UpdatePalette needs to be called and
  marks the whole screen dirty so DrawSurfaceToScreen will do a
  full redraw.
4 years ago
Patric Stout eb80fefd1d Fix: [SDL2] Display why SDL_CreateWindow() failed in case it does
All SDL_NNN errors print SDL_GetError, except for this one place.
4 years ago
Patric Stout 19345908cb Codechange: [SDL2] Split away CreateMainWindow from CreateMainSurface
This makes the code a bit more readable, as both intentions are
more clear, and there is less nesting in the main function.
4 years ago
Patric Stout 8c37e5c526 Codechange: [SDL2] reworked the different surfaces to make it more readable 4 years ago
Patric Stout 8de325f256 Codechange: [SDL2] Only prepare "caption" if you are going to us it 4 years ago
Patric Stout e41ec5b42e Codechange: [SDL2] Minor code cleanup to remove silly variable 4 years ago
Patric Stout 678031f9b3 Codechange: [SDL2] Only set _cur_palette, never _local_palette 4 years ago
Patric Stout f31b65825f Codechange: [SDL2] Move FindStartupDisplay to its own function 4 years ago
Patric Stout 6916fc76bd Codechange: [SDL2] reworked FindResolutions to be more like the rest
There was no default resolution fallback, and the code was different
from the win32 driver. It is now named the same and much more
similar.
4 years ago
Patric Stout a52d716c88 Codechange: [SDL2] remove include-protection
This is already done by CMake: if SDL2 is not detected, this file
is not included.
4 years ago
Patric Stout 1eceee915e Codechange: [SDL2/Win32] Be consistent how 0bpp blitters are not allowed
Sometimes it returned an usererror(), sometimes Start() failed.
Now it always fails on Start(), so nothing else has to check again
what blitter is used.

AfterBlitterChange() can never change to a 0bpp, so it is sufficient
to guard this with an assert().
4 years ago