150 Commits

Author SHA1 Message Date
Charles Dang
12d4a11959 Halo: simplify effect::set_location 2024-09-23 10:01:47 -04:00
Charles Dang
09e7ed97e8 Further deploy display::get_location_rect 2024-09-23 09:55:53 -04:00
Charles Dang
647f7949cb Prefer get_location over get_location_[x|y] when possible 2024-09-02 13:44:31 -04:00
shijie.chen
d88ddec6f1
Remove unnecessary header files (#8531)
Co-authored-by: shijie.chen <shijie.chen@goland.cn>
2024-03-12 00:07:48 -04:00
pentarctagon
970163813d 2024 copyright update 2024-01-20 22:22:23 -06:00
Pentarctagon
c44cc2742e Copyright update.. 2023-04-29 10:48:11 -05:00
Tommy
073b468dde Remove halo TODOs as done or out of scope 2022-07-31 16:47:26 +12:00
Tommy
b8d4f49858 Minor refactor to pass draw regions in display::expose() 2022-07-29 16:52:44 +12:00
Tommy
3835f9580b Fix some poor indentation, and tidy some TODOs 2022-07-22 15:07:59 +12:00
Tommy
ba24612f73 Remove trailing newlines from multiline log messages 2022-07-20 15:20:57 +12:00
Tommy
1c25ebdfa2 Remove std::endl from log lines, now that it's added automatically 2022-07-20 15:20:57 +12:00
Tommy
06254e5581 Mega draw manager implementation
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.
2022-07-13 13:34:01 +12:00
Pentarctagon
3874fe5f0d Remove <iostream> from a lot of places. 2022-07-06 20:11:11 -05:00
Tommy
0481a63f56 Replace sdl::rects_overlap with new rect::overlaps 2022-07-02 12:30:58 +12:00
Tommy
64ccf9231c Correctly scale orbs, crowns, etc. 2022-06-11 05:56:07 +12:00
Tommy
c1fa2bed0b Move clip and render target setters from CVideo to draw.
CVideo::set_clip -> draw::set_clip
CVideo::set_render_target -> draw::set_render_target
etc.
2022-06-11 05:56:06 +12:00
Tommy
f183978071 Some small rendering fixes.
* halo background draw fixed
* tiled images clip correctly
* new interface/setter for reducing clipping area.
2022-06-01 00:35:53 +12:00
Tommy
96bc7d6046 Consolidate drawing functions in new "draw" namespace.
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.
2022-05-31 21:17:33 +12:00
Tommy
3bc0defdce image: deprecate get_image for new explicit get_surface and get_texture.
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.
2022-05-31 21:17:33 +12:00
Tommy
f808039fb3 sdl::texture: cache texture width and height for easy access. 2022-05-31 21:17:33 +12:00
Tommy
062a4de231 Remove reverse image cache and image::reverse_image.
Flipping can be done as part of basic texture blitting.
2022-05-31 21:17:33 +12:00
Tommy
e2d059daae sdl/texture: remove null() in favour of an explicit bool conversion.
It was not used anywhere anyway.
2022-05-31 21:17:33 +12:00
Tommy
19f3037731 Use new CVideo clipping interface. 2022-05-08 11:23:22 +12:00
Tommy
01cf583fa9 Fix halo background rendering. 2022-05-08 11:22:55 +12:00
Tommy
12260a731d Buggy but forward-compatible halo rendering. 2022-05-08 11:21:14 +12:00
Tommy
eb60753664 Overhaul drawing to use CVideo API in stead of blitting to a surface.
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.
2022-05-08 11:17:42 +12:00
Pentarctagon
340023921d
2022 copyright update. 2022-03-06 19:07:13 -06:00
Pentarctagon
57ce449af8
Re-add attribution to copyright notices.
These are mostly useless and outdated/wrong, but apparently it's probably illegal to remove them.
2021-07-27 20:21:38 -05:00
Pentarctagon
ba75e1af50
Copyright update.
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.
2021-07-26 11:38:03 -05:00
Charles Dang
8587a14cde Removed preference to disable halos
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.
2019-10-19 18:44:04 +11:00
Charles Dang
ee35f6ac9a Cleaned up various surface-related backend things
* 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.
2019-07-22 15:39:00 +11:00
Martin Hrubý (hrubymar10)
674fda85b7 Migrate links to https if available - Fwd c18537edc0678f40a209797d72dfaba3e5e88545
(cherry-picked from commit bc4d22dc72e79c3d6a3364ac896e473afd298246)
2018-10-07 03:23:36 +00:00
Charles Dang
d9fb6c0bf5 Catch all exceptions (where possible) as const references
A few catch blocks modify something in their exceptions, so those are kept non-const.

(cherry-picked from commit 2bf4d68c87b69256266b7745a9e3453693794e35)
2018-10-07 03:20:58 +00:00
Jyrki Vesterinen
ca150a9129 Visual Studio: increased warning level to /W4 even for release builds
In particular, this enables C4100, the warning for unreferenced function
parameters.

I also fixed some /W4 warnings.

(cherry-picked from commit d4c9db9e3529434bf29a4ed237bc64e67f868f45)
2018-10-07 03:18:09 +00:00
Gregory A Lundberg
b5f76eff79
Bump copyright to 2018 2018-01-19 00:02:20 -06:00
Jyrki Vesterinen
b710af1716 Fix #2285: GCC-dev compiler warnings 2017-12-09 18:30:49 +02:00
Jyrki Vesterinen
efa91bd9e8 Fix #2275: Unit halo flickers when unit moves
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.
2017-12-05 20:29:42 +02:00
lundberg
e8cd3df79a Fix MSVC variable hides variable warning 2017-11-17 11:34:55 -06:00
Jyrki Vesterinen
80d42597b8 Remove new_haloes
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.
2017-11-12 19:21:01 +02:00
Jyrki Vesterinen
8a7aa49718 Fix #1563: graphical glitch when two halos touch
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.
2017-09-11 20:07:39 +03:00
Charles Dang
4479682469 Convert uses of create_rect to aggregate initialization when possible
This only includes cases where this can be done without triggering warnings about narrowing conversion.
Also includes cleanups of sdl/rect.hpp includes.
2017-05-17 21:16:57 +11:00
Charles Dang
e4f03fe459 Moved all preferences source files into a single folder 2017-05-04 11:04:19 +11:00
Charles Dang
e1a579da51 Deployed std::map::emplace en-masse 2017-04-09 15:40:13 +11:00
Celtic Minstrel
b4dc11ce36 Belated 2017 copyright update 2017-03-19 10:05:38 -04:00
Jyrki Vesterinen
3dfd421191 Address some cppcheck suggestions
I addressed the suggestions in files which I know well enough to feel
highly comfortable to edit them.

Thanks to @matthiaskrgr for the cppcheck run.
2017-03-18 12:28:41 +02:00
Charles Dang
e22c8967ee Cleaned up global.hpp includes 2016-12-17 15:21:04 +11:00
Charles Dang
bf86912371 CVideo: removed update_rect functions
These have been functionally useless, since none of their code was ever executed. Since this hasn't caused
any problems this far, I'm removing them.
2016-12-07 00:41:11 +11:00
Jyrki Vesterinen
af733360a8 Fix a bunch of MSVC2015 compiler warnings about hiding declarations
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.
2016-10-06 00:11:56 +03:00
Charles Dang
05092ba2f6 Refactor most boost pointer related stuff to use their stdlib counterparts
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.
2016-07-25 09:28:42 +11:00
Charles Dang
dd88d4906e Appropriately handle std::stoi exceptions 2016-07-19 01:38:24 +11:00