This has been megasquashed because it was a month-long mess of fixes
and reworks.
In summary:
* objects no-longer draw by hooking a DRAW event. In stead they
inherit from gui2::top_level_drawable, and implement its interface.
* the game display now renders to an offscreen buffer. This is used
to implement hardware scrolling, and to redraw after halos, floating
labels etc. move.
* halos, floating labels, tooltips, and a few more things are now
drawn on top of the game display, rather than as part of it. This
allows them to be updated independently without reading pixels
from the screen.
* surface restorers have been removed. Reading pixels from the screen
should now be unnecessary excepting two cases: (a) screenshots,
(b) background blur. Blur is cached, and screenshots are occasional.
* GUI2 widgets no longer keep track of dirty state. They are redrawn
as necessary. Most places which previously set dirty state now queue
a redraw in their part of the screen in stead.
* A consequence is that active translucency is enabled across all UI
elements, and the game display can (and does) continue to animate
while menus and dialogs are showing.
* performance is drastically increased for basically everything, most
notably map scrolling, floating text, and halos.
* CPU usage is drastically decreased. With animations disabled it is
essentially zero while nothing is moving.
* GPU usage is also minimal. The display is only flipped if something
is drawn.
Contains primitive drawing functions, such as fill, points, line, etc,
and also texture drawing functions blit, flipped, tiled.
This removes specialty drawing code from several places, most notably
CVideo and gui/core/canvas.
Functions to draw to the screen should now go in draw.cpp.
Places where usage is clear have been converted to the new calls.
Places that need extra work to convert are still using get_image(),
as are places that will be clobbered as part of general rendering
system upgrades anyway.
Draws now immediately apply to the render target, in stead of
accumulating on the drawing surface. This means textures can start
to be used for drawing in stead of surfaces, and both systems
should be able to be used interchangably for now.
Some things have been broken, including but probably not limited to:
* background blur
* the occasional direct SDL_FillRect call
* floating labels
* map screenshots
Some things will be broken if textures are used for drawing:
* widget restore images
* other screenshots
* clipping areas
However, this is the first step towards proper high-dpi hardware-
accelerated rendering.
This additionally:
* Makes all copyright notices identical aside from the starting year for Wesnoth-specific source files. Files not included: mariadbpp, lua, spirit po, xbrz, and bcrypt (crypt_blowfish).
* Removes all attribution from the files, since the vast majority of them are outdated or seemingly just outright incorrect. For example, I would guess that Dave is no longer the sole author of the majority of Wesnoth's current code.
There's really no reason to have this anymore. It was (AFAIK) introduced years ago
as a performance-saving measure, then was moved to Advanced Preferences in 1.13 since
modern PCs mostly have no issues.
* Removed create_neutral_surface in favor of a surface ctor that takes w/h dimensions.
* Removed make_neutral_surface in favor of a surface::make_neutral function. Most usecases of this were
to make a copy of a surface anyway, so I added a new surface::clone function
* Moved the pixel format validation and conversion to the surface class. Now *all* surfaces should be
guaranteed to be in the 'neutral' format. Any new surface that is created (with clone() or the dimension
ctor will be in that format, and any time a raw SDL_Surface* ptr is assigned, it is also converted. This
applies both to the ctor and assignment operators.
* Removed create_compatible_surface. All surfaces should be compatible in the first place.
* Removed surface::assign was in favor of simple assignment operators. The existing assignment operators
already just called assign().
* Removed surface::null in favor of the implicit SDL_Surface* conversion operator for consistency. We were
already using null and implicit pointer bool conversion, so I decided to go with the latter. I was going
to add an operator bool(), but it was ambiguous in surface-to-surface comparisons.
A few catch blocks modify something in their exceptions, so those are kept non-const.
(cherry-picked from commit 2bf4d68c87b69256266b7745a9e3453693794e35)
In particular, this enables C4100, the warning for unreferenced function
parameters.
I also fixed some /W4 warnings.
(cherry-picked from commit d4c9db9e3529434bf29a4ed237bc64e67f868f45)
The loss of new_haloes in commit 80d42597b8eb701e3cef40c7890fcb0bc402450e also meant that a halo
was scheduled for the next halo_impl::render() run only when the previous
halo was unrendered, i.e. in the next frame. Thus, when the unit halo was
recreated when the unit was moving (a temporary fake unit, and together
with it, the corresponding halo, is created every time the unit steps into
a new hex), the new halo didn't show up for one frame.
Fixed by adding every new halo into invalidated_haloes immediately.
New haloes were sometimes added to both new_haloes and invalidated_haloes,
and were therefore rendered twice in the same frame. As a result, the halo
added itself to its unrender buffer, and therefore remained on screen even
after unrendering.
Eliminating the entire new_haloes set fixes the issue. Fixes#2187.
I had added a unrender() call to halo_impl::effect::set_location() in an
attempt to fix haloes from showing in the top-left corner when a Mage of
Light is being moved. It had turned out to be unnecessary in the end,
but I had retained the call because I thought it was the right thing to do.
However, it turned out that removing that call is all it takes to fix bug
#1563.
Thanks to @newfrenchy83 for bringing the fix to my attention.
This only includes cases where this can be done without triggering warnings about narrowing conversion.
Also includes cleanups of sdl/rect.hpp includes.
This commit still doesn't fix all of them. I decided to leave alone
cases where variables with the same name are assigned in multiple
conditions of the same if...else if...else statement, and cases where a
scope logging macro is used multiple times in the same scope. In any
case, this commit greatly reduces the warning count on MSVC2015 and makes
new warnings much easier to spot.
This constitutes drop-in replacements for:
* boost::shared_ptr
* boost::scoped_ptr
* boost::weak_ptr
* boost::enable_shared_from_this
* boost::static_pointer_cast
* boost::dynamic_pointer_cast
This excludes boost::intrusive_ptr, except for stray includes. Refactoring that is more complicated.