Commit graph

350 commits

Author SHA1 Message Date
Matthew Jimenez
1e99ce9d43 GRAPHICS: Use constexpr for palette constants 2025-02-26 11:11:43 +02:00
Le Philousophe
859a8e06ad GRAPHICS: Also enable NEON codepath if compiler builds with NEON enabled
This will allow to build with NEON on platforms using an old compiler
but with NEON enabled for all translation units.
2025-02-01 18:06:56 +01:00
Le Philousophe
a28e064dfe AGS: Add missing stub when Freetype is not available 2024-10-31 08:59:33 +01:00
Walter Agazzi
3b52b26652 AGS: Common: when calculating TTF font's extent just use FT_Face->bbox
This apparently already stores precalculated maximal glyphs extents.
Testing this side-by-side with the previous solution shows that these bbox values are mostly matching the
results of loading and measuring each glyph.
They are 100% matching in the "bad" fonts which I've been adding this calculation for. For some "good"
fonts they sometimes have 1 pixel less offset, but are not less than the extent given by (0, height).

And obviously this is faster than loading and calculating glyphs.
From upstream d96da7e7a7cbdf1d5b101921c5fb83fe0040169d
2024-10-30 18:07:42 +02:00
Walter Agazzi
f2b5bb80a1 AGS: Common: when calculating TTF's extents, use first 128 glyphs
This fixes loading very big fonts, which may take literally seconds to calculate if we process each glyph.

This load mode is primarily purposed for backwards compatibility, as with new games authors may
fix / replace the font if they have issues.
Because of that, it's not a good thing to pessimize loading times for games that don't require this autofix.

From upstream b058b35ec82f19a4f2b70d952eede9589e626083
2024-10-30 18:07:42 +02:00
Walter Agazzi
6efd1cc41e AGS: Common: calculate real TTF glyphs extent, fix fonts cut from the top
This is an attempt to fix certain fonts getting "cut off" from the top when
being drawn on a limited size texture or bitmap.

The reason for such behavior is that fonts may include glyphs which
topmost extent is higher than the reported "ascender".
In this case the engine simply does not know that glyphs may be drawn
higher, and the prepared texture is not accommodated for that.

How we fix this:
1. Following a caller's instruction (a new flag ALFONT_FLG_PRECALC_MAX_CBOX),
alfont preloads all glyphs one by one and records the maximal extents of their "control boxes".
These values are saved and returned on demand.
2. Our FontMetrics struct has a new VExtent field, that keeps these values (converted to top-down
 Y axis) for the reference.
3. get_font_surface_height() now returns a surface height calculated from these extent values.
4. CalcFontGraphicalVExtent() now uses the extent values when telling how the text will be
graphically positioned, relative to the requested "text position".

From upstream ec362d744f7e7c0630d68a92219f2129fec7ab3d
2024-10-30 18:07:42 +02:00
Walter Agazzi
34fd9c07d5 AGS: Fix missing function type 2024-10-30 18:07:42 +02:00
Walter Agazzi
cd093dbf79 AGS: Allegro: Allegro: added utf8 validation to unicode functions
From upstream 0e89c1e03a5114afb416c7020a9a2d8d9308e7e1 and
a6fef605bf0cf1b04d8ff2a9f94070b479ba2a2a
2024-10-30 18:07:42 +02:00
Le Philousophe
f001fa7bbc AGS: Add target specifiers for Clang
This allows to enable back SIMD support when compiling with it
2024-09-05 07:24:29 +03:00
Le Philousophe
3da80ddaeb AGS: Use target pragmas instead of compiler flag to prevent ODR problems
This is the same as in PR#5581
2024-09-05 07:24:29 +03:00
antoniou79
65977961b2 AGS: Support for FreeType 2.13.3 changes to FT_Outline struct
FreeType 2.13.3 changed a few types of the struct members for FT_Outline struct to unsigned

This is the relevant commit from the FreeType source (github):
2a7bb4596f
2024-08-15 10:51:58 +03:00
Hubert Maier
72acbbd8f8 JANITORIAL: Fix occured typo in ahhint.cpp 2024-07-15 20:50:41 +03:00
Hubert Maier
17d99844db JANITORIAL: Fix occured typo in ftmemory.h 2024-07-15 20:50:41 +03:00
Hubert Maier
030d65566e JANITORIAL: Fix seperate typo in surface_sse2.cpp 2024-07-15 20:50:41 +03:00
Hubert Maier
c5c6db4c11 JANITORIAL: Fix many typos in surface_neon.cpp 2024-07-15 20:50:41 +03:00
Hubert Maier
ef77941154 JANITORIAL: Fix seperate typo in surface_avx2.cpp 2024-07-15 20:50:41 +03:00
Le Philousophe
49f0f141d5 AGS: Use a namespace alias to keep std namespace as in original code 2024-07-08 21:37:28 +02:00
Paul Gilbert
c2a476411c AGS: Move std namespace into common/std/ 2024-07-07 15:28:31 -07:00
Cameron Cawley
ff530edcb1 GRAPHICS: Deprecate ManagedSurface methods that implicitly copy pixel data 2024-07-02 13:31:18 +01:00
Cameron Cawley
1357bfe672 COMMON: Avoid including engine headers in common code for DebugChannelDef 2024-06-20 20:15:57 +01:00
Walter Agazzi
117cb3efba AGS: Add sanity check for 8bpp games
Prevents assertion in Snow Problem/The Crimson Diamond
2024-05-13 20:10:50 +02:00
Kaloyan Chehlarski
fe5c2068aa AGS: Fix 2bpp tinted blitting with AVX2 optimizations
Tinted blitting was completely broken on the 2bpp AVX2
path, due to the code ignoring the boundary in the
middle of the wide registers. This change fixes the vertical
striping produced by the original code, and removes some
unnecessary operations that were being performed for
every group of pixels.
2024-05-06 21:52:03 +02:00
Matthew Jimenez
5219c99400 GRAPHICS: Move PaletteManager definition to a separate header 2024-03-12 12:24:00 +02:00
Cameron Cawley
5f04021a5c
AGS: Use emmintrin.h for SSE2 intrinsics 2024-01-09 10:12:45 +02:00
Kaloyan Chehlarski
283bfd228d AGS: Fix ASAN crashes in SIMD blit paths
All optimized blitting paths exhibit similar overreading
behavior, due to the flawed design of (almost) always
loading a full 128/256-bit line, and discarding overread
pixels afterwards. This commit patches up the code so the
overreads never happen, albeit at the cost of a few
memcpys at the end of every line of pixels.
2023-12-02 16:43:09 +01:00
Kaloyan Chehlarski
56377af2ae AGS: Fix tinting in SSE path, 4bpp
The code for tinting in the SSE path was incorrect, and
produced blue tinting in multiple games (bugtracker #14634)
2023-12-01 23:03:07 +02:00
Kaloyan Chehlarski
6c21737f50 AGS: Properly pre-flip surface when blitting
Fixed an error in the arguments when pre-flipping a
blit prior to blitting.
2023-11-23 01:07:15 +02:00
Kaloyan Chehlarski
6208f8807e AGS: Properly pre-scale surface before blit
Fixed two different errors that were causing scaled blitting
to read out of bounds.
2023-11-23 00:44:19 +02:00
Kaloyan Chehlarski
1acc57e15c AGS: Fix 4bpp->2bpp conversion in AVX2 path
This fixes the broken text outlines in Maniac Mansion Deluxe
2023-11-19 18:49:32 +02:00
Kaloyan Chehlarski
ee38b13fd3 AGS: Disable optimized blit stretching and flipping
The CPU extension optimized paths do not work properly
when scaling or flipping the image. Fixing this needs a lot
of work, so for now we pre-stretch and pre-flip as a
workaround.
2023-11-19 00:01:58 +01:00
Kaloyan Chehlarski
e10081f29b AGS: Re-add include guard for NEON path cpp file
This was mistakenly removed previously, but it seems that
without it the iOS backend breaks.
2023-10-16 13:23:04 +03:00
Kaloyan Chehlarski
33a1b1738b AGS: Don't skip drawing last line in optimized blit paths
Fixed an oversight in the code which would result in scaled
blits skipping the last line.
2023-10-16 13:23:04 +03:00
Kaloyan Chehlarski
5b29081355 AGS: Apply clipping fix to 2bpp optimized blitting
The issue that produced crashes when blitting beyond the
bottom-right edge of the screen was previously fixed,
but only for cases involving a 4bpp surface. The fix has
now been extended to the 2bpp functions as well.
2023-10-14 14:27:55 +03:00
Kaloyan Chehlarski
18a34cb7af AGS: Fix AVX2 scaled blitting
Scaled blitting in the AVX2 path would immediately crash
ScummVM, due to a couple of incorrect increments inside
a for-loop; this has now been fixed.
2023-10-14 14:27:54 +03:00
Kaloyan Chehlarski
d6d65273c0 AGS: Allow usage of AVX2 optimized blit path
The previous design of the optimized paths used the same
name for the dummy class used to access BITMAP's private
members. On machines that support AVX2 this meant that
the SSE2 path would shadow the AVX2 one, and make it
inaccessible unless the configure script specifically
disabled SSE2 extensions.
The dummy class has now been split into three, one
for each of the optimization paths; those dummy classes
now contain all of the internal functions to avoid potential
name clashes; and finally, all the internal functions have
been marked as static.
2023-10-14 14:27:54 +03:00
Kaloyan Chehlarski
5214d921c4 AGS: Fix edge case in Allegro optimized blit clipping
This fixes a (literal) edge case that was introduced in the last
attempt at fixing the clipping issues that would crash
ScummVM when a sprite is drawn at the bottom right of
the screen. In particular, the specific Y value that would
result in only one row of the sprite being off screen no
longer produces a crash.
2023-10-14 14:27:54 +03:00
Kaloyan Chehlarski
b902f61b3f AGS: Fix AVX2 blitting
The AVX2 path was previously completely broken, as all
blitting produced an alternating pattern of 4 correctly
blitted colors, followed by 4 black pixels. The intrinsics used
in the pixel drawing code have been changed so this is no
longer the case.
2023-10-12 12:42:28 +03:00
Kaloyan Chehlarski
1c34e1c614 AGS: Fix for surface blitting-related crashes
This is a second attempt at fixing the crashes that pop up
when attempting to blit past the bottom-right corner of a
surface. The previous commit caused a bunch of surfaces
to not blit their last row, and introduced more drawing
errors in scrolling scenes. Also, made sure the size check in
AVX2 code is 8 bytes everywhere, as this was also likely to
cause issues.
2023-10-07 23:32:11 +03:00
Kaloyan Chehlarski
8fc73a36a6 Revert "AGS: Fix blitting-related crash"
This reverts commit e2720d39f3.
The changes were based on a wrong assumption on where
the issue actually lies, and introduced a new problem:
some surfaces' bottom rows were getting entirely skipped.
2023-10-07 23:32:11 +03:00
Kaloyan Chehlarski
d542838664 Revert "AGS: Fix clipping issue in blitting code"
This reverts commit 90beb8887e.
The changes were based on a wrong assumption on
where the issue lies, and also introduced even buggier
behavior in scrolling scenes.
2023-10-07 23:32:10 +03:00
Kaloyan Chehlarski
7f84df864d AGS: Fix incorrect format check in generic blitting code
This fixes a bunch of errors in 5 Days a Stranger (and all other
games with 16-bit surfaces), including leaked memory and
incorrectly displayed text.
2023-10-07 23:32:10 +03:00
Kaloyan Chehlarski
e2720d39f3 AGS: Fix blitting-related crash
Fixed an off-by-one error in the non-scaling blit code, which
would result in an attempt to draw to one row beyond the
bounds of the dest surface (affects only the optimized paths).
2023-10-07 14:45:31 +03:00
Kaloyan Chehlarski
90beb8887e AGS: Fix clipping issue in blitting code
Fixed a clipping issue that would crash ScummVM when
attempting to blit to a surface with a negative dest x
(affecting both the optimized and non-optimized paths).
2023-10-07 14:45:22 +03:00
Eugene Sandulenko
94755eb838
BUILD: MACOS: Fix building with NEON enabled 2023-09-03 22:47:00 +02:00
Walter Agazzi
7279c8a540 AGS: Freetype: Trim include paths 2023-09-03 22:27:43 +02:00
Walter Agazzi
85db570098 AGS: Freetype: Remove unused variable 2023-09-03 22:27:43 +02:00
Walter Agazzi
4a33374939 AGS: Freetype: Use scummvm logging in autohint debug functions
These two functions are not actually used, but still nice to have
2023-09-03 22:27:43 +02:00
Walter Agazzi
ccf816a83a AGS: Freetype: Use scummvm debug logging 2023-09-03 22:27:43 +02:00
Walter Agazzi
c08d7492c4 AGS: Freetype: Remove unneeded debugging directives 2023-09-03 22:27:43 +02:00
Walter Agazzi
1d7b009638 AGS: Freetype: Remove newline from warnings 2023-09-03 22:27:43 +02:00