Skip to content

Conversation

@mmaciola
Copy link
Owner

For review: TVG Loader moduler

@mmaciola mmaciola requested a review from mgrudzinska May 21, 2021 12:58
@mmaciola mmaciola force-pushed the master-7-loader-1-2-async branch 4 times, most recently from 6955f0f to e6fd9a3 Compare May 24, 2021 09:54
tvgTvgHelper.h is a base file used for .tvg saver/loader module.
@mmaciola mmaciola force-pushed the master-7-loader-1-2-async branch 2 times, most recently from 1c86fc0 to c50b982 Compare May 24, 2021 12:57
inc/thorvg.h Outdated
};

enum class TVG_EXPORT LoaderResult { InvalidType, Success, SizeCorruption, MemoryCorruption, LogicalCorruption };

Copy link
Collaborator

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?

Copy link
Owner Author

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;

Copy link
Owner Author

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;
Copy link
Collaborator

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

#include "tvgLoader.h"

enum class FileType { Svg = 0, Raw, Png, Unknown };
enum class FileType { Svg = 0, Tvg, Raw, Png, Unknown };
Copy link
Collaborator

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

{
case TVG_FILL_RADIAL_GRADIENT_INDICATOR :
{ // radial gradient
if (block.lenght != 12) return LoaderResult::SizeCorruption;
Copy link
Collaborator

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

_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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up

* 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)
Copy link
Collaborator

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?

#include "tvgTvgLoader.h"
#include "tvgTvgLoadParser.h"

TvgLoader::TvgLoader()
Copy link
Collaborator

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

if (this->buffer)
{
free(this->buffer);
this->buffer = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullptr?


#include <stdio.h>
#include <string.h>
#include <map>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this?

if (result > LoaderResult::Success) return false;
if (result == LoaderResult::Success) {
if (scene->push(unique_ptr<Paint>(paint)) != Result::Success) {
return LoaderResult::MemoryCorruption;
Copy link
Collaborator

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

mmaciola added 3 commits May 24, 2021 16:46
Tvg loader module introduction
Introduced sync loading possibility
@mmaciola mmaciola force-pushed the master-7-loader-1-2-async branch from c50b982 to fe03b8e Compare May 24, 2021 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants