Commit Graph

2127 Commits

Author SHA1 Message Date
Brecht Van Lommel
46d32d8966 Merge branch 'blender-v4.0-release' into main 2023-10-10 15:36:39 +02:00
Brecht Van Lommel
478e1ab6d3 Fix build error on Windows after BLI_read changes
Don't use posix-only ssize_t in platform independent code.

Pull Request: https://projects.blender.org/blender/blender/pulls/113493
2023-10-10 15:36:15 +02:00
Campbell Barton
57fc3d48b8 Merge branch 'blender-v4.0-release' 2023-10-10 22:49:58 +11:00
Campbell Barton
8d80d611e9 Use BLI_read instead of read to avoid issues with large files
Follow up to fix for #113473, similar issues exist elsewhere.
2023-10-10 22:47:35 +11:00
Campbell Barton
4afd8ef9a4 Cleanup: add BLI_mmap_get_length, remove duplicate file size access
Remove unnecessary calls to BLI_file_descriptor_size when using
BLI_mmap_open since this stores the file size too.

While accessing the size twice isn't so bad, the additional check
that the file size isn't an error value is unnecessarily verbose.
2023-10-10 15:43:13 +11:00
Campbell Barton
ae6b1ead4c Fix failure to check the error value for file-size access
Accessing the file size returns -1 on error, for file packing this
was passed directly to an allocation which would wrap around to
SIZE_T_MAX and fail to allocate. In other cases zero was treated
as an error value but -1 wasn't.

Add checks for the error return value, also warn that packing files over
2gb isn't supported.
2023-10-10 14:56:30 +11:00
Campbell Barton
cb51cc7ce8 Fix OpenEXR leak, failure to close a file when BLI_mmap_open fails 2023-10-10 14:16:04 +11:00
Campbell Barton
e38ff7c06d Cleanup: use C++ comments for disabled code 2023-09-25 17:06:04 +10:00
Brecht Van Lommel
70ac1e5df1 Fix #112645: switching view transform unnecessarily resets look
AgX and Filmic have different looks in the configuration, but the looks
share the same UI name and purpose. So we can switch to the
corresponding look when switching view transforms.

Thanks to Yiming Wu for helping track down the problem.

Pull Request: https://projects.blender.org/blender/blender/pulls/112686
2023-09-22 12:05:55 +02:00
Campbell Barton
5fbcb4c27e Cleanup: remove spaces from commented arguments
Also use local enums for `MA_BM_*` in versioning code.
2023-09-22 12:21:18 +10:00
Campbell Barton
e3b77cf08a ImBuf: calculate the JPEG DPI with double precision
These were calculated as floats then converted to doubles,
loosing precision unnecessarily.
2023-09-20 12:12:49 +10:00
Campbell Barton
bdbf1871ec ImBuf: don't include null bytes for jpeg meta-data markers
JPEG strings aren't null terminated, there is no need to include the
null byte. For reference ImageMagick doesn't do this.
2023-09-20 12:12:40 +10:00
Campbell Barton
a0aed358fa BLI_string: assert the len argument to BLI_strdupn is valid
Ensure the string isn't null terminated before len, if this happens
it's likely an error calculating the length argument. Since the length
is passed to memcpy it could result in reading outside `str` bounds.

There was one case where the string was duplicated then grew by 1 byte
afterwards. Replace this with an allocation since it's an uncommon
operation, not especially useful to support.
2023-09-20 12:11:34 +10:00
Campbell Barton
085b094f18 Cleanup: use const arguments & variables 2023-09-19 11:09:20 +10:00
Julian Eisel
3589533908 Thumbnails: Always use cached thumbnails for offline files
bd9f94e917 made it so the file browser doesn't bring files online for
the purpuse of creating their thumbnail, because that can take a while.
Instead it uses a previously cached thumbnail if available. This should
be the behavior for all cases thumbnails are requested, it's not only
the file browser that does this.

In fact it makes sense to move this into the normal function to "manage"
thumbnails (that is, load and if necessary (re)create cached
thumbnails) since there are no currently known use-cases for
different behavior.

Also, seems like the previous solution didn't work when loading ID
previews from offline .blend files. For that we need to use the path to
the .blend file to check the offline status, not the full path to the ID.

Found while working on #109234 (Use UI preview system for async loading of
file/asset previews).

Pull Request: https://projects.blender.org/blender/blender/pulls/112101
2023-09-08 16:41:44 +02:00
Julian Eisel
1b2e29e692 Cleanup: Clarify path variable name in thumbnail create function
"filepath" was misleading since this path could also point into a .blend
file. Further, the convention was to use "filepath" for such files, and
"file_path" for when only an actual file path was expected. This is
highly confusing and non-obvious. Plus a (newer?) function broke with
the convention.

Just be explicit about the type of path, even if a bit verbose. It's
good to always have the reminder that this may be more than just a file
path when passing it around.
2023-09-06 18:46:29 +02:00
Julian Eisel
a24fa35120 Cleanup: Avoid redundant/confusing variable in thubnail create function
This confused me plenty of times. If there are two local variables I
assume they contain different things. In fact these two were equal
throughout the function.
2023-09-06 17:41:44 +02:00
Julian Eisel
1ee584c137 Cleanup: Add comments to thumbnail creation function
The function is quite confusing, this should clarify things a bit.
2023-09-06 16:58:07 +02:00
Julian Eisel
6659579abc Cleanup: Move variable declarations close to usage in thumbnail function
This function is rather big and it's not clear what state variables are
in without a bunch of scrolling around. Plus, having the declarations
close to the function calls that set them makes it more clear that these
functions use the variables as output parameters. So this change should
help understanding the function flow.
2023-09-06 16:56:30 +02:00
Julian Eisel
ba03948dd2 Cleanup: Move BKE preview image code to separate file
Previously, BKE level preview image code was in `BKE_icons.h` and `icons.hh`.
While these types are related, I always found this quite hard to navigate since
preview image stuff was just in the middle of icon functions. Plus, people
don't expect preview image functions in icon files, the relationship is not
obvious.

Instead, use focused files that make it easy to quickly navigate them
and see what they are dealing with.

Pull Request: https://projects.blender.org/blender/blender/pulls/111709
2023-09-04 18:02:16 +02:00
Hans Goudey
3db523ab3e Cleanup: Move BLO headers to C++
Except for BLO_readfile.h, which is still included by C files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111610
2023-08-28 15:01:05 +02:00
Campbell Barton
f66fa32ada Cleanup: spelling in comments 2023-08-23 13:30:55 +10:00
Campbell Barton
5a8cb665e0 Cleanup: various non-functional C++ changes 2023-08-19 23:52:47 +10:00
Sergey Sharybin
d0dcfb8159 Color management: Tweak compatible look check
Change compatible look check so that if the view contains
explicitly configured looks the non-explicit looks are not
added to the list.

In practice this means that if there are looks "Low Contrast"
and "AgX - Low Contrast" only the latter one is considered to
be compatible with the "AgX" view.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/111229
2023-08-17 15:40:34 +02:00
Sergey Sharybin
77f6c83bd5 Fix compilation error after recent commits to color management
Individually patches were fine, but they got some conflict
when both are applied.

Pull Request: https://projects.blender.org/blender/blender/pulls/111228
2023-08-17 14:47:49 +02:00
Sergey Sharybin
16c44700e9 Color management: Validate look is compatible with view on load
While currently the only way to reproduce the issue is to modify
the default OCIO configuration, change the view (which does yet
validate look on change) and save-reload, it seems to be a good
thing to validate anyway, to be more future-proof.

Pull Request: https://projects.blender.org/blender/blender/pulls/111209
2023-08-17 14:38:52 +02:00
Sergey Sharybin
241fac09dd Color management: Validate Look on View Transform changes
If the new view transform does not support the currently configured
look reset look to the default None, similar to the color management
verification on .blend file open.

Currently it is not a problem as all views support the same set of
looks. But with an upcoming addition of AgX it will no longer be
true.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/111185
2023-08-17 14:38:07 +02:00
Sybren A. Stüvel
0e2875ede9 Prevent crash when color management is turned off
Prevent a segmentation fault when the viewport is set to 'Material Preview'
mode, drawing textures, and Blender built with `WITH_OPENCOLORIO=OFF`.

Most `IMB_colormanagement_...` functions assume that the `colorspace`
pointer can be `nullptr`, but the internal function
`colormanage_ensure_srgb_scene_linear_info()` does not, causing a crash.

Since this check can be done in multiple places, I picked one that seems
consistent with the rest of the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/111144
2023-08-17 10:21:09 +02:00
Campbell Barton
e955c94ed3 License Headers: Set copyright to "Blender Authors", add AUTHORS
Listing the "Blender Foundation" as copyright holder implied the Blender
Foundation holds copyright to files which may include work from many
developers.

While keeping copyright on headers makes sense for isolated libraries,
Blender's own code may be refactored or moved between files in a way
that makes the per file copyright holders less meaningful.

Copyright references to the "Blender Foundation" have been replaced with
"Blender Authors", with the exception of `./extern/` since these this
contains libraries which are more isolated, any changed to license
headers there can be handled on a case-by-case basis.

Some directories in `./intern/` have also been excluded:

- `./intern/cycles/` it's own `AUTHORS` file is planned.
- `./intern/opensubdiv/`.

An "AUTHORS" file has been added, using the chromium projects authors
file as a template.

Design task: #110784

Ref !110783.
2023-08-16 00:20:26 +10:00
Jacques Lucke
cc4d5c432c RNA: move headers to C++
Also see #103343.

Pull Request: https://projects.blender.org/blender/blender/pulls/111022
2023-08-10 22:40:27 +02:00
Aras Pranckevicius
d973355b3a Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).

However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.

This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.

Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
  to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).

Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.

Pull Request #110944
2023-08-10 14:51:40 +03:00
Sergey Sharybin
ba81908a2d Color management: Improve no-op color space detection
Make it so transform between color spaces which is a no-op does not
peroform any calculations.

This was initially found when working on #110941, but the issue can
be replicated easily by renaming "Linear" to "Linear Rec.709" and
adding alias as "Linear".

Doing so would result in a failure of the compositor_matte_test.
The reason for that is due to the image data-block still referring
to the "Linear" color space, the name-based comparison not detecting
that "Linear" and "Linear Rec.709" are the same spaces, and that the
cryptomatte requires bit-perfect floating point values.

Pull Request: https://projects.blender.org/blender/blender/pulls/110959
2023-08-09 16:24:49 +02:00
Jason Fielder
2367ed2ef2 macOS: Enable support for EDR rendering
Add a High Dynamic Range option in the Color Management > Display panel.
This enables display of extended color ranges above 1.0 for the 3D
viewport, image editor and render previews.

This requires a monitor that can display HDR colors, and a view
transform designed for HDR output. The Standard view transform works,
but Filmic does not as it was designed to bring values into the 0..1
range for SDR displays.

This patch is limited to allowing the display to visualize extended
colors, but does not include future looking work to better integrate HDR
into the full workflow.

It is implemented by rendering to high bit-depth texture formats for
the user interface, and uncapping the color range in color management.

Authored by Apple: Michael Parkin-White

Pull Request: https://projects.blender.org/blender/blender/pulls/105662
2023-08-09 14:25:15 +02:00
Campbell Barton
bff7962c80 Cleanup: remove redundant struct/void in C++, function style casts 2023-08-09 13:37:37 +10:00
Brecht Van Lommel
803b541307 Fix OpenImageIO thread pool not following -t command line option
We do this for the OpenEXR thread pool as well. Needed until OIIO fully
switches over to TBB.

Pull Request: https://projects.blender.org/blender/blender/pulls/110501
2023-08-07 18:19:33 +02:00
Campbell Barton
adf58a77ff Cleanup: use LISTBASE_FOREACH & LISTBASE_FOREACH_BACKWARD macros 2023-08-04 08:51:13 +10:00
Campbell Barton
f7be60eff0 Cleanup: format 2023-08-04 08:46:18 +10:00
Campbell Barton
7afd938dde Cleanup: various non-functional C++ changes 2023-08-04 08:45:57 +10:00
Campbell Barton
de391cf811 Cleanup: use nullptr instead of zero 2023-08-03 19:17:43 +10:00
Sergey Sharybin
0a964cf0e1 Color management: Improve non-color managed versioning
Support configurations where there is no dedicated None display
and try to use Raw view of the default display.

This allows to preserve compatibility with old files and the new
upcoming AgX configuration.

Ref #110685

Pull Request: https://projects.blender.org/blender/blender/pulls/110581
2023-08-01 14:58:19 +02:00
Campbell Barton
52acf6a6ec Cleanup: correct file names in comments after C -> C++ renaming
Use back-tick quotes to differentiate these from plain text.
2023-07-31 13:02:30 +10:00
Campbell Barton
fd0977284b Cleanup: simplify typedefs
Also remove unused `buffer_struct`.
2023-07-30 16:14:09 +10:00
Campbell Barton
ed01e16aa6 Cleanup: quiet uninitialized warnings 2023-07-29 13:47:57 +10:00
Ray molenkamp
4ea2baf4ae CMake: revert last weeks modernizations
The cleanup of blenkernel last weeks , caused the house of cards to
collapse on  top of bf_gpu's shader_builder, which is off by default
but used on a daily basis by the rendering team.

Given the fixes forward in #110394 ran into a ODR violation in OSL that
was hiding there for years, I don't see another way forward without
impeding the rendering teams productivity for "quite a while" as there
is no guarantee the OSL issue would be the end of it.

the only way forward appears to be back.

this reverts :

19422044ed
a670b53abe
0f541db97c
be516e8c81
3e88a2f44c
4e64b772f5
9547e7a317
07fe6c5a57

The problematic commit was 07fe6c5a57
as blenkernel links most of blender, it's a bit of a link order issue
magnet. Given all these commits stack, it's near impossible to revert
just that one without spending a significant amount of time resolving
merge conflicts. 99% of that work was automated, so easier to just
revert all of them, and re-do the work, than it is to deal with the
merge conflicts.

Pull Request: https://projects.blender.org/blender/blender/pulls/110438
2023-07-25 16:43:21 +02:00
Campbell Barton
50edca5306 Cleanup: minor readability changes to escape_uri_string
- A `_size` suffixed argument was modified to be come the length,
  store in a variable with a `_len` suffix to avoid confusion.
- The enum type for masking characters read like a number
  (used Set suffix), add `e` prefix to make it clear it's an enum.
2023-07-24 12:44:46 +10:00
Campbell Barton
a82836b6c2 Cleanup: replace typdef with 'using'
Apply modernize-use-using with edits (as it strips out useful info).
2023-07-24 11:04:19 +10:00
Campbell Barton
b8ea968929 Cleanup: simplify struct & enum declarations for C++ 2023-07-24 10:13:31 +10:00
Campbell Barton
302887c619 Cleanup: use boolean literals in source/
Apply clang-tidy modernize-use-bool-literals to source/.
2023-07-22 11:43:01 +10:00
Campbell Barton
81ee130063 Cleanup: use C++ system headers
Apply clang-tidy modernize-deprecated-headers to source/
2023-07-22 11:27:25 +10:00
Campbell Barton
08f4f1f41e Cleanup: spelling in comments, capitalize tags 2023-07-20 09:42:00 +10:00