Commit graph

27 commits

Author SHA1 Message Date
Hermet Park
55c0849746 loaders: explicit variable scope to improve portability
issue: https://github.com/godotengine/godot/pull/105093
2025-05-24 01:37:24 +09:00
Hermet Park
52cf31a79d renderer: make the file io configurable
certain systems, may not support file I/O operations.
ThorVG should provide users with an option to configure
builds according to their requirements.

This ensures that file I/O calls are avoided,
preventing potential crashes.

Please use the meson '-Dfile=true/false' option for this.

Please note that "THORVG_FILE_IO_SUPPORT" might be expected
for your thorvg manual build.

issue: https://github.com/thorvg/thorvg/issues/3008
2024-12-02 12:03:15 +09:00
Hermet Park
3490f9b9ce png, gl_engine: fixed an wrong png colorspace.
issue: https://github.com/thorvg/thorvg/pull/2880
2024-10-22 00:41:42 +09:00
Hermet Park
c64ed2ec03 loaders: enhance decoding efficiency
enhance decoding efficiency by determining the desired canvas format
during image loading. This allows loaders to preemptively decode
the image in the specified format, to not convert the format again.
2024-04-06 12:08:21 +09:00
Hermet Park
c4e6b03b84 loaders: decode the image with premultiplied alpha.
basically, the renderer requires images with premultiplied alpha.
2024-04-06 12:08:21 +09:00
Hermet Park
38c625d070 renderer: enhanced shared surface handling with mutex implementation
Introduced a dedicated mutex for each surface instance
to ensure safe sharing between the loader, renderer, and engine.

This enhancement allows for secure modification and access to bitmap data,
addressing potential concurrency issues.

Multiple Picture instances can now safely share a single loader instance,
optimizing performance.

This change builds upon the previous Loader Cache improvements:
ff6ea4b6c4
2024-01-02 20:34:12 +09:00
Hermet Park
60282f51f8 renderer/loader: code refactoring.
Removed internal unique_ptr usage for a more compact size.
2024-01-02 20:34:12 +09:00
Jinny You
92288c8291 updated copyright date (#1866) 2024-01-02 20:34:12 +09:00
Hermet Park
49d26691e5 common: Revise internal loader interfaces.
We are introducing the FontLoader, which slightly differs
from the ImageLoader in terms of features. To adequately
support both, we have separated the loader functionalities
into FontLoader and ImageLoader. This allows us to optimally
adapt the LoadModule for each case.
2024-01-02 20:34:11 +09:00
Hermet Park
f64ee28079 Loaders: Introduced a loader cache.
The loader cache is applied to conserve memory.

If the input data is already present in loaders,
the loader cache will promptly return the active loader.

This results in a lot of memory savings for the duplicated resources.

binary diff: -400 bytes
2024-01-02 20:34:10 +09:00
Hermet Park
1fbdf7bbb6 renderer, loader: minor code refactoring.
- sync with its file name
- remove unnecessary section comments
- compact binary size (-300)
- private Task::run() methods from the loaders
2024-01-02 20:34:10 +09:00
Hermet Park
43f0ba403c loaders/png: fixed data conversion warnings on Windows
../src/loaders/external_png/tvgPngLoader.cpp(110): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
../src/loaders/external_png/tvgPngLoader.cpp(111): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
../src/loaders/external_png/tvgPngLoader.cpp(112): warning C4244: '=': conversion from 'float' to 'uint32_t', possible loss of data
2023-12-26 18:06:58 +09:00
Hermet Park
da6216f9bf sw_engine: specify buffer size so that we can clearly access the buffer data.
Also, it introduces the 'pixel_t' type to ensure that anonymous pixel data
follows the system's decision.
2023-05-08 10:55:03 +09:00
Hermet Park
527b1af926 common sw_engine: applied colorspace format size.
Now backend engines know which channel size is required for
compositions.

@Issue: https://github.com/thorvg/thorvg/issues/976
2023-05-08 10:55:03 +09:00
Hermet Park
e9b12aa9f7 engine/loaders: Migrate alpha premultiplying to the engine side.
It's not efficient to handle alpha premultiplying in every loader.
The backend engine should be responsible for it.
Now, we can remove duplicate code.
2023-04-29 12:37:09 +09:00
Hermet Park
c710af2560 loaders: Remove the color space conversion on the loader side.
Now, the job is completely delegated to the backend engine.
2023-04-28 15:27:53 +09:00
Hermet Park
cf4484c1ad engine/loaders: develop the ColorSpace feature infrastructure
Replace the existing fragile usage of the colorspace data type
with a new and robust concrete ColorSpace type.
2023-04-28 15:27:53 +09:00
JunsuChoi
507b11829c loader: Support ABGR colorspace
Since the color space is set at the time of specifying the target buffer of the canvas,
there is no way to know the color space when the picture is loaded.
So, check the color space applied to SwCanvas at the time of reload()
and change the color space.

There is an issue of BGR color space support for each loader.
The external_jpg loader resets the TJPF color space and calls read() to get a new buffer.
In the case of external_png, we need to change the color value directly
because it have to start over from begin_read_*.

This solution can affect performance as much as it access again image buffer
that have already been `read()` done. However, this only happens once.
2023-02-08 17:54:33 -08:00
Hermet Park
9b3c34c3b1 updated copyright. 2023-01-14 13:48:11 +09:00
Michal Maciola
b033cfabbd loader png external: fix potential memory leak if read fails 2022-02-07 23:53:51 +09:00
Hermet Park
f0141e63de updated copyright date. 2022-01-12 14:08:48 +09:00
Hermet Park
36da47af80 png_loaders: fix the wrong premultiplying operations.
It should not modify the alpha channel value while premultiplying
that turned out with the wrong visual result.

@Issue: https://github.com/Samsung/thorvg/issues/655
2021-12-13 23:46:15 -08:00
Hermet Park
4cdf648e14 sw_engine image: support non-premultiplied alpha images.
Previously, translucent png images are not displayed properly
due to alpha channels premultiplication.

This patch implements that missing part to support it properly
by introducing the Surface data between canvas engine & rasterizer

@Issue: https://github.com/Samsung/thorvg/issues/655
2021-12-02 17:10:12 +09:00
Hermet Park
3b2e1f4291 Revert "loaders: Consider colorspaces (#838)"
This reverts commit cd5116b053.

Ah this breaks the Stress example due to Picture::duplicate() is not available...

Need to consider and come back again.
2021-11-01 16:53:25 +09:00
Michal Maciola
cd5116b053
loaders: Consider colorspaces (#838)
* common: added colorSpace() function

This patch introduces colorSpace() function for SW and GL engine.

* infra: change LoadModule:read() into LoadModule:read(uint32_t colorspace)

This patch changes LoadModule:read() into LoadModule:read(uint32_t colorspace)

* picture: implement passing colorspace into loader

This patch implements passing colorspace into loaders.
Loader->read is now called on the first update.

* external_jpg_loader: support colorspaces

* external_png_loader: support colorspaces
2021-11-01 16:10:22 +09:00
projectitis
dad6c71b6c
all: fix warnings on MSVC
* Explicit casts to suppress warnings
* Fixed compiler warnings
2021-10-09 11:33:45 +09:00
Hermet Park
ff20974632 loaders: prepare for static jpg/png loaders.
This patch has 2 purposes,

1. revise the loaders infrastructure to support both static/external linking loaders.
2. add a template for static jpg/png loaders after external jpg/png.

Our default loaders prefer static linking, external loaders are only available
when dependent libraries on the build system are found.

You might wonder why we have the external loaders together,
they might be faster than static loaders since the popular libraries are likely to be well maintained,
fine-grained optimized.

Thus in this patch, meson tries to apply the external loaders first
then see if the dependencies were found or not,
if it's failed, it turns to the default static loaders.

Next this patch, we need the contribution for actual static jpg/png loaders implementation.

@Issue: https://github.com/Samsung/thorvg/issues/594
2021-10-05 19:22:51 +09:00