Commit Graph

136 Commits

Author SHA1 Message Date
666ed1b51c Image: Make fill method also fill the mipmaps 2025-09-23 14:55:04 +02:00
638c6a5659 Fix Image format RGB565 conversion 2025-08-03 16:28:13 +02:00
a32b59622f Fix Image nearest and cubic resizing bias 2025-07-30 23:54:12 +08:00
e35c80b61c Image: Fix is_invisible detection for RGBAH and RGBAF 2025-06-23 18:21:04 +02:00
f6f1df7d73 Add 64-bit versions of core power of 2 functions 2025-06-01 23:11:12 -07:00
63dff62948 Merge pull request #100673 from RandomShaper/res_duplicate
Overhaul resource duplication
2025-05-27 09:39:25 -05:00
2a03b459b9 Overhaul Resource::duplicate()
Thanks to a refactor, `Resource::duplicate_for_local_scene()` and `Resource::duplicate()` are now both users of the same, parametrized, implementation.

`Resource::duplicate()` now honors deepness in a more consistent and predictable fashion. `Resource::duplicate_deep()` is added (instead of just adding a parameter to the former, for compatibility needs).

The behavior after this change is as follows:
  - Deep (`deep=true`, formerly `subresources=true`):
    - Previously, only resources found as direct property values of the one to copy would be, recursively, duplicated.
    - Now, in addition, arrays and dictionaries are walked so the copy is truly deep, and only local subresources found across are copied.
    - Previously, subresources would be duplicated as many times as being referenced throughout the main resource.
    - Now, each subresource is only duplicated once and from that point, a referenced to that single copy is used. That's the enhanced behavior that `duplicate_for_local_scene()` already featured.
    - The behavior with respect to packed arrays is still duplication.
    - Formerly, arrays and dictionaries were recursive duplicated, with resources ignored.
    - Now, arrays and dictionaries are recursive duplicated, with resources duplicated.
    - When doing it through `duplicate_deep()`, there's a` deep_subresources_mode` parameter, with various possibilites to control if no resources are duplicated (so arrays, etc. are, but keeping referencing the originals), if only the internal ones are (resources with no non-local path, the default), or if all of them are. The default is to copy every subresource, just like `duplicate(true)`.
  - Not deep (`deep=false`, formerly `subresources=false`): <a name="resource-shallow"></a>
    - Previously, the first level of resources found as direct property values would be duplicated unconditionally. Packed arrays, arrays and dictionaries were non-recursively duplicated.
    - Now, no subresource found at any level in any form will be duplicated, but the original reference kept instead. Packed arrays, arrays and dictionaries are referenced, not duplicated at all.
    - Now, resources found as values of always-duplicate properties are duplicated, recursively or not matching what was requested for the root call.

This commit also changes what's the virtual method to override to customize the duplication (now it's the protected `_duplicate()` instead of the public `duplicate()`).
2025-05-26 10:05:25 +02:00
0f9986470a Image: Fix detecting color channels 2025-05-16 12:47:57 +02:00
579feb387c Core: Add [[nodiscard]] to string-like classes 2025-05-06 12:23:41 -05:00
237597b01f BasisU: Use KTX2 format and add import options to configure encoder 2025-05-03 01:45:38 +08:00
5af4bef46f Inline static variables (part 1) 2025-04-29 18:10:44 +02:00
ad40939b6f Core: Replace C math headers with C++ equivalents
- Minor restructuring to ensure `math_funcs.h` is the central point for math functions
2025-04-16 15:49:02 -05:00
94282d88f9 Core: Use Math namespace for constants 2025-04-10 16:29:30 -05:00
889410dcda Add String::replace_char(s) methods for performance and convenience 2025-04-10 13:08:45 +02:00
4f4031a675 Replace size() == 0 with is_empty(). 2025-04-02 19:18:43 +08:00
647b99c6d0 Image: Fix typo at _set_color_at_ofs with FORMAT_RGB565 2025-03-29 17:51:31 +01:00
dd47d9173e Image: Improve is_invisible function 2025-03-28 22:42:37 +01:00
e3063f5675 Merge pull request #104590 from bruvzg/tex_decomp_load
Load decompressable texture format if no supported one is found.
2025-03-28 17:30:28 +01:00
649fa630a7 Image: Remove references to defunct FORMAT_CUSTOM 2025-03-26 21:37:26 +01:00
b384de9013 Load decompressable texture format is no supported one found. 2025-03-25 09:46:19 +02:00
f09ee0171a Style: Begin integrating simple .clangd fixes 2025-03-22 13:24:35 -05:00
10f6c01b9c Remove ABS in favor of Math::abs 2025-03-19 13:52:40 +01:00
69b281295c Add DDS image load and save functionality
Save and load DDS from Image class.

Co-authored-by: BlueCube3310 <53150244+BlueCube3310@users.noreply.github.com>
2025-03-14 19:31:43 -07:00
271067eb2b Fix certain channel masks for Texture previewer 2025-01-15 18:40:53 +01:00
c7a9d64eaf Add color channel filter to editor texture previews 2025-01-11 23:27:48 +00:00
3c304ab7cc Merge pull request #96076 from AThousandShips/improve_null_check_core_drivers
[Core,Drivers] Improve use of `Ref.is_null/valid`
2024-12-23 11:14:58 -06:00
be86ce3103 Apply iwyu suggestion in core. 2024-12-19 00:43:47 +08:00
335077a03f Image: More cleanup and reduced code duplication. 2024-12-12 11:52:59 +01:00
88ffe07de9 Betsy: Add BC3 and BC5 support 2024-11-27 12:27:05 +01:00
3b6705a641 Support uid:// in more places 2024-11-16 21:43:18 +01:00
0dabcd9941 Resource UID fixes and improvements 2024-11-14 16:37:54 +01:00
80a9c0d569 Clean up Image 2024-11-01 21:32:16 +01:00
ec650a2f09 [Core,Drivers] Improve use of Ref.is_null/valid
Use `is_null` over `!is_valid` and vice versa.
2024-11-01 16:50:11 +01:00
38f9769bc6 [Core] Improve error messages with vformat 2024-10-30 15:55:51 +01:00
95fd45d9a5 Betsy: Implement BC4 compression 2024-09-22 10:16:37 +02:00
a6d84bc0ce Merge pull request #97059 from Gaktan/fix_weird_msvc_compilation_error
Fix weird MSVC compilation error
2024-09-16 13:36:06 +02:00
453f32ae0a Fix weird MSVC compilation error
For some reason, MSVC doesn't appreciate uint8 math with enum constants
2024-09-15 23:13:24 +02:00
606eedb0c9 Betsy: Add caching and BC1 compression support 2024-09-11 23:48:29 +02:00
194bdde947 Cleanup of raw nullptr checks with Ref
Using `is_valid/null` over checks with `nullptr` or `ERR_FAIL_NULL` etc.
2024-08-31 15:01:09 +02:00
76c8211653 Image: Add a method for detecting signed values 2024-08-27 09:23:17 +02:00
4b8946102b Merge pull request #91535 from BlueCube3310/betsy-bc6h
Add Betsy to speed up BC6 compression
2024-08-21 06:38:03 +02:00
f4037d6f6c Merge pull request #92496 from clayjohn/HDR-2D-sRGB
Ensure MovieWriter output is in gamma space when using HDR 2D
2024-08-19 12:08:40 +02:00
394ea653aa Add Betsy to speed up BC6 compression 2024-08-18 11:14:05 +02:00
eb684cccdc Merge pull request #92291 from BlueCube3310/image-convert-optimized
Optimize image conversion for half and float formats.
2024-08-16 10:33:32 +02:00
0ed45629fd Support 64-bit image sizes for VRAM compression 2024-07-21 21:06:14 +02:00
0445ccf428 Fix Image CowData crash when baking large lightmaps
This switches to 64-bit integers in select locations of the Image
class, so that image resolutions of 16384×16384 (used by
lightmap texture arrays) can be used properly. Values that are larger
should also work.

VRAM compression is also supported, although most VRAM-compressed
formats are limited to individual slices of 16384×16384. WebP
is limited to 16383×16383 due to format limitations.
2024-07-19 16:04:30 +02:00
e651421905 [TextServer, GDExtension] Fix building text servers as GDExtension, expose new/changed low-level methods to GDExtension API. 2024-06-12 19:30:19 +03:00
3b9d074fd7 Ensure MovieWriter output is in gamma space when using HDR 2D 2024-05-28 15:30:13 -07:00
d260a2ba74 Optimize half and float image conversion 2024-05-24 11:01:20 +02:00
28a18cf1b8 Merge pull request #88763 from BlueCube3310/image-is-compressed-static
Image: Add static `is_format_compressed` function.
2024-05-02 14:01:18 +02:00