Commit Graph

47 Commits

Author SHA1 Message Date
Jacques Lucke
ed29ab303c Blenloader: extract blenloader core library for use in blendthumb
We recently started using blenloader code in blendthumb to avoid having to
reimplement some parts of .blend file parsing. While this works, it has the side
effect that on Windows referencing blenloader code increased the binary size of
blendthumb from < 1MB to ~75 MB. That happens because this dependency drags
along lots of other code which effectively is unused, but the compiler is unable
to remove it.

There didn't seem to be a simple solution to make msvc optimize the unused code
away. This patch solves the issue by extracting the shared code into a separate
`blenloader_core` module which does not depend on the rest of Blender (except
blenlib). Therefore, using this new module in blendthumb does not drag along all
the other dependencies, bring its file size back down.

In the future, more code may be moved from blenloader to blenloader_core, but
for now I extracted these two headers:
* `BLO_core_bhead.hh`: Various `BHead` types and related parsing functions.
* `BLO_core_blend_header.hh`: Parsing of the header at the beginning of .blend
  files.

Pull Request: https://projects.blender.org/blender/blender/pulls/138371
2025-05-07 04:51:50 +02:00
Campbell Barton
43af16a4c1 Cleanup: spelling in comments, correct comment block formatting
Also use doxygen comments more consistently.
2025-05-01 11:44:33 +10:00
Jacques Lucke
6a90382390 Core: support buffers larger than 2GB in .blend files
This is implements option 1 of #129309. It contains a few changes:
* Split `BHead8` into `SmallBHead8` and `LargeBHead8`. The latter is the new one
  and uses `int64_t` for array sizes instead of just `int`. That applies to to
  buffer size in bytes (`len`) and the array size (`nr`).
* The first .blend file header (the first few bytes of the file) are updated
  according to #129309.
* Support reading files with that use `BHead4`, `SmallBHead8` and `LargeBHead8`.
* New option in the preferences that controls whether new files are written with
  the older `SmallBHead8` or the new `LargeBHead8`. The new file format is
  disabled by default. Potential unofficial 32 bit builds (#67184) always write
  `BHead4`, but can read all types (in theory anyway, can't test it).

Note that there are other places in Blender that don't fully support arrays this
large. E.g. I noticed that the spreadsheet currently can't scroll all the way
down.

The experimental option can be removed once we are in the 5.0 branch, at which
point only 4.5 will be able to open the files saved with 5.0.

Co-authored-by: Bastien Montagne <bastien@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/129751
2025-04-29 10:55:26 +02:00
Jonas Holzman
27117e0ffc Fix: macOS: Wrong QuickLook aspect ratio for screenshot previews of blend files
This patch fixes a visual issue where the QuickLook previews/thumbnails
of blend file (introduced in PR #107072) would have a distorted square
aspect ratio instead of their original aspect ratio. Fixed by using the
original image aspect ratio scaled to honor the QLFileThumbnailRequest's
maximumSize as per the official documentation[1].

[1]: https://developer.apple.com/documentation/quicklookthumbnailing/qlthumbnailreply/init(contextsize:currentcontextdrawing:)?language=objc

Pull Request: https://projects.blender.org/blender/blender/pulls/135691
2025-03-11 16:09:42 +01:00
Campbell Barton
b85fc32cae Cleanup: spelling & repeated words in comments
Address warnings from check_spelling.py
2025-03-06 10:33:21 +11:00
Ankit Meel
13c3d95f52 Xcode/thumbnailer: rebuild error due to rpath
Fix duplicate rpath error on rebuild by using CMake target
property.

Pull Request: https://projects.blender.org/blender/blender/pulls/134527
2025-02-14 10:46:48 +01:00
Brecht Van Lommel
9da1778f1a Cleanup: Various clang-tidy warnings in blendthumb
Pull Request: https://projects.blender.org/blender/blender/pulls/133734
2025-01-31 17:03:17 +01:00
Campbell Barton
c86d3b429e Cleanup: spelling in comments 2025-01-30 14:18:40 +11:00
Campbell Barton
1fdb91c766 License Headers: quiet "check_licenses" warnings 2025-01-29 17:22:51 +11:00
Ankit Meel
b858319dd3 macOS/QuickLook: support rich thumbnail in Finder
Support thumbnail that shows the file contents instead
of the default blend file icon for all files in Finder.
Some files may still have the usual blender icon as thumbnail
depending on their contents.

blender-thumbnailer process is kept alive by the system
in the background and is invoked by QuickLook when needed.

The checkbox to disable the extension is present in
the Settings app.

It will NOT be an interactive "Preview" that allows richer
interactions like Panning viewport, or rotating 3D objects.
2025-01-23 17:00:19 +01:00
Hans Goudey
c8efea42e1 Cleanup: Remove unnecessary braces for container default constructors
These containers (Set, Vector, Map, Span), etc. have default constructors,
making the braces unnecessary for default initialization. Better to depend
on that consistently rather than having braces in some places and not others.
2024-03-07 09:30:23 -05:00
Campbell Barton
375c217ea0 Cleanup: apply clang-tidy modernize-deprecated-headers 2024-01-08 11:32:49 +11:00
Hans Goudey
09063a3632 Cleanup: Remove some indirect includes in common headers
The idea is to avoid mistakenly depending on indirect includes,
and avoid compile time overhead from unnecessary header parsing.

Pull Request: https://projects.blender.org/blender/blender/pulls/116664
2024-01-06 01:47:39 +01:00
Hans Goudey
d6cfd7d1f4 Cleanup: Remove unnecessary keywords from C++ headers
- Remove unnecessary `struct`
- Use `using` instead of `typedef`
- Remove `void` from `(void)` as function arguments
2024-01-04 15:07:48 -05:00
Campbell Barton
d31c61edee Cleanup: spelling in comments 2023-10-27 12:13:48 +11: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
Aras Pranckevicius
acbd952abf Cleanup: fewer iostreams related includes from BLI/BKE headers
Including <iostream> or similar headers is quite expensive, since it
also pulls in things like <locale> and so on. In many BLI headers,
iostreams are only used to implement some sort of "debug print",
or an operator<< for ostream.

Change some of the commonly used places to instead include <iosfwd>,
which is the standard way of forward-declaring iostreams related
classes, and move the actual debug-print / operator<< implementations
into .cc files.

This is not done for templated classes though (it would be possible
to provide explicit operator<< instantiations somewhere in the
source file, but that would lead to hard-to-figure-out linker error
whenever someone would add a different template type). There, where
possible, I changed from full <iostream> include to only the needed
<ostream> part.

For Span<T>, I just removed print_as_lines since it's not used by
anything. It could be moved into a .cc file using a similar approach
as above if needed.

Doing full blender build changes include counts this way:
- <iostream> 1986 -> 978
- <sstream> 2880 -> 925

It does not affect the total build time much though, mostly because
towards the end of it there's just several CPU cores finishing
compiling OpenVDB related source files.

Pull Request: https://projects.blender.org/blender/blender/pulls/111046
2023-08-16 09:51:37 +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
Campbell Barton
fd0977284b Cleanup: simplify typedefs
Also remove unused `buffer_struct`.
2023-07-30 16:14:09 +10:00
Sergey Sharybin
c1bc70b711 Cleanup: Add a copyright notice to files and use SPDX format
A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.

This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.

Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.

Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:

    https://reuse.software/faq/
2023-05-31 16:19:06 +02:00
Sergey Sharybin
a12a8a71bb Remove "All Rights Reserved" from Blender Foundation copyright code
The goal is to solve confusion of the "All rights reserved" for licensing
code under an open-source license.

The phrase "All rights reserved" comes from a historical convention that
required this phrase for the copyright protection to apply. This convention
is no longer relevant.

However, even though the phrase has no meaning in establishing the copyright
it has not lost meaning in terms of licensing.

This change makes it so code under the Blender Foundation copyright does
not use "all rights reserved". This is also how the GPL license itself
states how to apply it to the source code:

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software ...

This change does not change copyright notice in cases when the copyright
is dual (BF and an author), or just an author of the code. It also does
mot change copyright which is inherited from NaN Holding BV as it needs
some further investigation about what is the proper way to handle it.
2023-03-30 10:51:59 +02:00
Sergey Sharybin
d32d787f5f Clang-Format: Allow empty functions to be single-line
For example

```
OIIOOutputDriver::~OIIOOutputDriver()
{
}
```

becomes

```
OIIOOutputDriver::~OIIOOutputDriver() {}
```

Saves quite some vertical space, which is especially handy for
constructors.

Pull Request: https://projects.blender.org/blender/blender/pulls/105594
2023-03-29 16:50:54 +02:00
Hans Goudey
2652029f3b Cleanup: Clang tidy
Addressed almost all warnings except for replacing defines
with enums and variable assignment in if statements.
2022-12-29 12:01:32 -05:00
Jacques Lucke
2654c523c1 Cleanup: use nullptr in C++ 2022-11-19 11:51:42 +01:00
Campbell Barton
3961d3493b Cleanup: use 'u' prefixed integer types for brevity in C code
This also simplifies using function style casts when moving to C++.
2022-09-26 11:33:22 +10:00
Campbell Barton
21d77a417e Cleanup: replace C-style casts with functional casts for numeric types
Some changes missed from f68cfd6bb0.
2022-09-25 22:31:31 +10:00
Campbell Barton
f68cfd6bb0 Cleanup: replace C-style casts with functional casts for numeric types 2022-09-25 20:17:08 +10:00
Campbell Barton
c7b247a118 Cleanup: replace static_casts with functional casts for numeric types 2022-09-25 18:31:10 +10:00
Campbell Barton
891949cbb4 Cleanup: use 'u' prefixed integer types for brevity & cast style
To use function style cast '(unsigned char)x' can't be replaced by
'unsigned char(x)'.
2022-09-25 18:26:27 +10:00
Harley Acheson
ff27b68f41 Fix T101295: Allow Large Windows Thumbnails
Allow our Windows Thumbnail Handler to supply thumbnails up to the
maximum 256x256 size.

Differential Revision: https://developer.blender.org/D16051

Reviewed by Ray Molenkamp
2022-09-23 14:49:36 -07:00
Campbell Barton
266a125b11 Cleanup: use sizeof() for better readability 2022-08-12 12:21:47 +10:00
Campbell Barton
c8e8f107bf Fix T99711: Eternal loop reading blend file thumbnail
Account for negative BHead length (already handled by blend file loading).
2022-07-15 14:53:38 +10:00
Ray Molenkamp
b1329d7eaa Fix T99705: fix integer overflow in thumbnail extractor
It was smart enough to check if the buffer had the right
size but neglected to cast to a 64 bit value so it
overflowed.

Differential Revision: https://developer.blender.org/D15457
Reviewed By: brecht
2022-07-14 12:18:35 -06:00
Campbell Barton
c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00
Campbell Barton
2545119112 Cleanup: move public doc-strings into headers for 'blendthumb'
Ref T92709
2021-12-08 17:12:37 +11:00
Campbell Barton
b280699078 Cleanup: use elem macros 2021-10-20 11:16:43 +11:00
Campbell Barton
ef9269bd62 Thumbnails: refactor extraction to use one code-path for all platforms
Thumbnail extraction now shares code between Linux/Windows,
allowing thumbnails from Zstd compressed blend files to be extracted.

The main logic is placed in blendthumb_extract.cc and is built as static
library. For windows there is DLL which is registered during blender
install and which then reads and generates thumbnails.

For other platforms there is blender-thumbnailer executable file which
takes blend file as an input and generates PNG file. As a result
Python script blender-thumbnailer.py is no longer needed.

The thumbnail extractor shares the same code-path as Blenders file
reading, so there is no need to duplicate any file reading logic.
This means reading compressed blend files is supported (broken since
the recent move Zstd compression - D5799).

This resolves T63736.

Contributors:

- @alausic original patch.
- @LazyDodo windows fixes/support.
- @campbellbarton general fixes/update.
- @lukasstockner97 Zstd support.

Reviewed By: sybren, mont29, LazyDodo, campbellbarton

Ref D6408
2021-10-20 10:31:30 +11:00
Campbell Barton
4485dc483c Cleanup: use C-style comments, nullptr for C++
Minor changes extracted from D6408
2021-10-01 10:45:09 +10:00
luzpaz
a4a9d14ba7 UI: Fix Typos in Comments and Docs
Approximately 91 spelling corrections, almost all in comments.

Differential Revision: https://developer.blender.org/D10288

Reviewed by Harley Acheson
2021-02-05 19:08:14 -08:00
Dalai Felinto
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
Campbell Barton
1aebcdbb3a Cleanup: spelling, clang-format 2020-03-12 12:34:54 +11:00
Ray Molenkamp
e1698e3750 Windows: Clean-up warning while building blendthumb
Casting a 64 bit pointer to a 32 bit DWORD gave 2 warnings.
Solved by storing the actual DWORD in the registry table.

Would have preferred to use a union, but C++ doesn't let you
initialize anything other than the first field, and C99 style
initializers are not supported until C++20, so this solution
will have to do until then.
2020-03-11 09:27:35 -06:00
Campbell Barton
3d2b0c9b40 Cleanup: expand tabs 2019-09-10 00:04:02 +10:00
Campbell Barton
1b0dd5a215 Cleanup: style, spelling 2019-09-07 21:28:05 +10:00
Ray Molenkamp
6726e98fe2 Cleanup: clang-format 2019-08-30 13:33:49 -06:00
Ray Molenkamp
6c16c2c233 MSVC: Fix BlendThumb debug build.
Spotted by @deadpin on chat
2019-08-30 13:27:56 -06:00
Ray Molenkamp
66ec72045f Windows: Move building of blendthumb into the blender codebase.
Previously this was done in the deps builder due to the fact we needed
both 32 and 64 bit versions of this dll and CMAKE does not support that
in a single build folder. Now that 32 bit support has been dropped, this
can be safely moved into the codebase.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5633
2019-08-30 08:40:08 -06:00