Commit graph

247 commits

Author SHA1 Message Date
Kp 7effca68f0 Use RAII_SDL_Surface to track SDL-only main canvas surface
The Rebirth main screen grd_curscreen borrows the memory allocated by
SDL_CreateRGBSurface to store its data.  Store the pointer to that
surface inside grd_curscreen and make grd_curscreen responsible for
freeing the surface.
2022-11-06 18:18:57 +00:00
Kp fc4157f56f Fix MacOS clang build of similar/2d/font.cpp
clang-14 on OSX, but not clang-14 on x86_64-pc-linux-gnu, fails
class template argument deduction when given:

```
	char *c1 = initializer();
	const char *c2 = c1 + 1;
	std::span{c1, c2};
```

clang correctly refuses to match this to `std::span(pointer, pointer)`,
but fails to find the constructor `std::span(iterator, sentinel)`.

Work around this by changing the type of the sentinel from
`const uint8_t *` to `color_palette_index *` (an alias of `uint8_t *`).

Reported-by: Kreeblah <https://github.com/dxx-rebirth/dxx-rebirth/issues/664>
2022-10-02 19:51:36 +00:00
Kp 97f0c5a6d0 Pass std::span to decode_data 2022-09-24 17:47:52 +00:00
Kp 9faa3d912d Pass std::span to pcx_encode_line 2022-09-24 17:47:52 +00:00
Kp 8f1055ca6b Use std::span for poison helper functions 2022-09-24 17:47:51 +00:00
Kp e80c6fb05f Rename font underline to draw_full_width_as_fg_color
This started out as underline, but one of the special drawing modes uses
it to draw an underline-width block across the entire vertical height of
the character.
2022-07-02 18:10:45 +00:00
Kp bdeca5687e Remove unused copy_diminish_palette
Fixes: f413017317 ("Delegate bald_guy_load PCX to SDL image")
2022-07-02 18:10:45 +00:00
Kp 5eaa53d220 Fix SDL-only build 2021-11-01 03:37:20 +00:00
Kp 961aae074a Remove unused ogl_ubitmapm_cs argument scale
Every caller passes `F1_0`.  Remove the argument, and propagate its
results through the function.
2021-11-01 03:37:18 +00:00
Kp 855697bf5d Make font scaling constructors explicit 2021-09-19 10:53:48 +00:00
Kp 3c37552e5b Use enum class bm_mode for grs_bitmap::type 2021-09-12 16:20:52 +00:00
Kp 21241471c6 Return string width/height from gr_get_string_size
Use structured bindings to capture the values on return, so that they
can be declared as `const` if they are immutable after initial
computation.
2021-09-12 16:20:52 +00:00
Kp 0750046bc1 Move retrieval of font average width out of gr_get_string_size
Most callers do not need it, and it is only vaguely related to the
purpose of measuring a particular string.  For those callers that need
it, lift it out.
2021-09-12 16:20:52 +00:00
Kp 6a1f5937a2 Change ogl_font_choose_size to return width/height 2021-09-04 12:17:14 +00:00
Kp 4c681c40fd Factor out the slider font smoothing hack
Move the test from the innermost loop to one layer farther out, since it
was conditional on two specific passes of the innermost loop.
2021-09-04 12:17:14 +00:00
Kp 6172b69329 Convert more font.cpp sites to use xrange 2021-09-04 12:17:14 +00:00
Kp c99b67e359 Switch callers to unchecked_partial_range(range) where possible
Use unchecked_partial_range(range) instead of
unchecked_partial_range(iterator), since the range form can preserve the
underlying index_type.
2021-09-04 12:17:14 +00:00
Kp 1354099b0d Move Computed_colors into gr_find_closest_color
- Inline add_computed_color into gr_find_closest_color, and then only
  one function will need access to Computed_colors.
- Allow the recent-choice bubble-up logic to apply to all elements
- If all entries are in use, always overwrite the last element in
  Computed_colors instead of picking one randomly.
2021-09-04 12:17:14 +00:00
Kp ae3dc7f934 Simplify computed color reset
gr_find_closest_color did not need it.  Remove it.  For the others,
resetting the count is sufficient.  There is no need to reset the
individual elements.
2021-09-04 12:17:14 +00:00
Kp 347b8d9f77 Factor out palette color search code 2021-09-04 12:17:14 +00:00
Kp fb3c2a4808 Narrow grs_canvas fg/bg color fields 2021-09-04 12:17:14 +00:00
Kp 35c7684200 Cache text color change control code
This generates the same code in an optimized build, but makes the intent
clearer.
2021-09-04 12:17:14 +00:00
Kp f9ed412ba6 Move use of SQUARE into a helper
Give the compiler discretion over whether to inline the multiplications.
2021-08-26 03:13:45 +00:00
Kp 172c183d83 Reduce scope of font rendering variables 2021-08-26 03:13:45 +00:00
Kp 517919a473 Remove unused return value of gr_internal_color_string, ogl_internal_string 2021-08-26 03:13:45 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Kp a7cbf60922 Return error code from PHYSFSRWOPS_openRead*
This improves error reporting for movies.
2021-07-25 23:00:56 +00:00
Kp ee07a45712 Simplify MALLOC invocations
Remove overload for C array decay, and fix up the call sites that
required it.
2021-06-28 03:37:48 +00:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp 081024eb8f Fix build for screenshot=legacy opengl=0
Reported-by: dimag0g <https://github.com/dxx-rebirth/dxx-rebirth/pull/568>
2021-02-06 17:53:53 +00:00
Kp c0601edde3 Move GammaLevel to CCfg 2020-12-27 22:03:09 +00:00
Kp aaf4629c05 Fix potential canvas.cv_font / cv_font inconsistency in gr_ustring
A prior conversion changed the actual rendering to use the argument
cv_font, but still picked which render function to use based on the
flags for the active font.  Switch to use only the supplied font.
2020-12-27 22:03:09 +00:00
Kp c1d6150015 Pass grs_font& to gr_set_curfont 2020-12-27 22:03:09 +00:00
Kp 2ded2b2d0c Make kmatrix background optional
Previously, if the background failed to load, the kmatrix window was
immediately aborted.  Change the logic so that a failure to load uses a
blank black background, but still shows the kmatrix window.
2020-12-26 21:17:29 +00:00
Kp fc63029833 Move more symbols into namespaces 2020-12-26 21:17:29 +00:00
Kp 017c4ce933 Restore buffering on PCX loads
Commit 3114874713 delegated PCX loading to
SDL_image, and as an incidental change, switched to using an unbuffered
PHYSFS file.  On Linux, this has no perceptible difference in
performance.  On Windows, the unbuffered accesses cause enough of a
performance problem for users to notice and report an issue.  Add a new
helper to create an SDL_RWops around a buffered file, and use that for
PCX loading.

Fixes: 3114874713 ("Delegate PCX loading to SDL_image")
Reported-by: Q3BFG10K <https://github.com/dxx-rebirth/dxx-rebirth/issues/549>
Reported-by: aybe <https://github.com/dxx-rebirth/dxx-rebirth/issues/555>
Analyzed-by: arbruijn <https://github.com/dxx-rebirth/dxx-rebirth/issues/555#issuecomment-735442076>
2020-11-30 05:12:00 +00:00
Kp 6285878c4c Add color_palette_index type alias, to note palette-related uint8_t 2020-07-16 02:31:04 +00:00
Kp 80f8bbabd1 Add constexpr to compile-time switches in font templates 2020-07-16 02:31:04 +00:00
Kp 8cc7be4986 Use std::bitset to track used colors
This reduces memory usage over using std::array<bool> for the same
number of bits.
2020-07-16 02:31:04 +00:00
Kp 316a4740a6 Move words_bigendian into if constexpr
`words_bigendian` is `constexpr`, so move the tests on it behind `if
constexpr` to encourage the compiler to prune unreachable paths.
2020-07-05 23:34:33 +00:00
Kp 6e4b63e098 Use C++17 std::size instead of custom lengthof
lengthof was added to provide the size of C arrays.  C++17 std::size is
now available, and can serve the same purpose.  Remove the custom
lengthof.

The generated code is the same in both cases, other than the change in
line numbers caused by removal of the #include directives.
2020-07-05 23:34:32 +00:00
Kp 7a790f6068 Inline gr_set_fontcolor
It is a trivial function.
2020-07-05 23:34:32 +00:00
Kp f413017317 Delegate bald_guy_load PCX to SDL image 2020-05-17 23:35:26 +00:00
Kp 83a9b32dc7 Simplify bald_guy_load
Close the file sooner.  Use std::transform with a reverse_iterator to
decode and transpose the blob.
2020-05-17 23:35:26 +00:00
Kp 3114874713 Delegate PCX loading to SDL_image
This adds a new dependency, but most systems likely already have
SDL_image installed.  Use of SDL_image can be disabled, but this is
discouraged, because various in-game interfaces assume the use of the
original background.

The old implementation automatically corrected for filename case.  The
new implementation expects that the supplied filename can be passed to
PYHSFS_openRead as-is.  All known uses in-game have been corrected to
satisfy this requirement.  If the new stricter match requirement becomes
a problem, a variant of PHYSFSRWOPS_openRead that adjusts filename case
could be created for use here.

- Update install instructions
- Update ebuild
- Update Arch PKGBUILD
2020-05-17 23:35:26 +00:00
Kp db7b4b3f88 Refer to <memory> directly, not through "compiler-make_unique.h" 2020-05-02 21:18:43 +00:00
Kp cc38cdf4b8 Qualify uses of std::make_unique 2020-05-02 21:18:42 +00:00
Kp 8839f538e0 Refer to <array> directly, not through "compiler-array.h" 2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
Kp b4d974e5b2 Remove register; it has no effect, and will be deprecated in C++17 2020-05-02 21:18:42 +00:00