-
Notifications
You must be signed in to change notification settings - Fork 0
For review: TVG Loader #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master-7
Are you sure you want to change the base?
Conversation
6955f0f to
e6fd9a3
Compare
tvgTvgHelper.h is a base file used for .tvg saver/loader module.
1c86fc0 to
c50b982
Compare
inc/thorvg.h
Outdated
| }; | ||
|
|
||
| enum class TVG_EXPORT LoaderResult { InvalidType, Success, SizeCorruption, MemoryCorruption, LogicalCorruption }; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't you use the Result enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefere a special enum type with InvalidType before Success to compare if (return > Success) return;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved enum from thorvg.h
| * | ||
| * @BETA_API | ||
| */ | ||
| Result paint(std::unique_ptr<Paint> paint) noexcept; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fun of such an api...
if a user needs a scene, he can use Scene::gen()
and we have an api to set a composition
src/lib/tvgLoaderMgr.h
Outdated
| #include "tvgLoader.h" | ||
|
|
||
| enum class FileType { Svg = 0, Raw, Png, Unknown }; | ||
| enum class FileType { Svg = 0, Tvg, Raw, Png, Unknown }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a tiny thing, but please add this before Unknown, not in the middle
src/loaders/tvg/tvgTvgLoadParser.cpp
Outdated
| { | ||
| case TVG_FILL_RADIAL_GRADIENT_INDICATOR : | ||
| { // radial gradient | ||
| if (block.lenght != 12) return LoaderResult::SizeCorruption; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not use 12/8/4 and so on... if something changes it'll be horrible to find which of these vlues should be changes as well
src/loaders/tvg/tvgTvgLoadParser.cpp
Outdated
| _read_tvg_float(&x1, block.data); | ||
| _read_tvg_float(&y1, block.data + 4); | ||
| _read_tvg_float(&x2, block.data + 8); | ||
| _read_tvg_float(&y2, block.data + 12); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
up
src/loaders/tvg/tvgTvgLoadParser.cpp
Outdated
| * Returns true on success and moves pointer to next position or false if corrupted. | ||
| * Details: see tvgParseShape() in tvgShapeImpl.h | ||
| */ | ||
| LoaderResult tvg_read_paint(tvg_block base_block, Paint **paint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change the naming convention?
src/loaders/tvg/tvgTvgLoader.cpp
Outdated
| #include "tvgTvgLoader.h" | ||
| #include "tvgTvgLoadParser.h" | ||
|
|
||
| TvgLoader::TvgLoader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's not recommended to use an empty constr
src/loaders/tvg/tvgTvgLoader.cpp
Outdated
| if (this->buffer) | ||
| { | ||
| free(this->buffer); | ||
| this->buffer = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullptr?
src/loaders/tvg/tvgTvgLoadParser.cpp
Outdated
|
|
||
| #include <stdio.h> | ||
| #include <string.h> | ||
| #include <map> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need this?
src/loaders/tvg/tvgTvgLoadParser.cpp
Outdated
| if (result > LoaderResult::Success) return false; | ||
| if (result == LoaderResult::Success) { | ||
| if (scene->push(unique_ptr<Paint>(paint)) != Result::Success) { | ||
| return LoaderResult::MemoryCorruption; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does not compile -> no conversion rules
Tvg loader module introduction
Introduced sync loading possibility
c50b982 to
fe03b8e
Compare
For review: TVG Loader moduler