Commit graph

293 commits

Author SHA1 Message Date
Hermet Park
abc9e89517 common log: notify opacity composition usage log.
replaced [XXX] log prefix with XXX:
2020-12-15 14:29:52 +09:00
JunsuChoi
54816339ed svg_loader XmlParser: Print unsupported elements, attribute with log option
* Using printf is temporary. We are planning a proper way to print the log.
When parsing a Svg file, Loader print unsupported elements and attributes.
2020-12-15 14:07:38 +09:00
Hermet Park
932cc65543 loaders: fix memory leak.
While looking for image loader, it occured memory leaks.
Fixed it properly.

@Issues: 178
2020-12-10 11:57:38 +09:00
Hermet Park
1ed611386d
common sw_engine: code refactoring & stabilizing.
Apply tvg Array instead of std::vector

Also Fixed to compList in update() to passed by reference, not copying.
Also Fixed Composition Target memory leak

Here is the binary size result:

[libthorvg.so] 1785376 >> 1607416
[text] 121255 >> 118277
[data] 7792 >> 7736
[dec] 129119 >> 126085
2020-12-09 19:56:59 +09:00
Hermet Park
d13cd37094 fix typo 2020-12-09 15:29:22 +09:00
Hermet Park
d4515d2732 common array: Introduce Array function to common.
This Array is promoted from SvgVector to use it widely in tvg.
It's similar with std::vector, we can use it instead of it.

Also, svg_loader replaced with it subsequently.
2020-12-09 15:29:22 +09:00
Hermet Park
1e78d1f845
picture: replace size parameter to float.
Considering smooth-resizing on sub-pixeling.
2020-12-08 12:27:13 +09:00
JunsuChoi
6889f0ad1f
common Picture : Introduce Picture's size setter, getter APIs
* common Picture : Introduce Picture's size setter, getter APIs

If picture or file loaded by picture has an explicit Size(width, height),
it is transformed to fit the size.
2020-12-04 15:03:25 +09:00
JunsuChoi
d3020b7bbe svg_loader Loader,XmlParser: String that has not been parsed returns false
Existing parser functions always return true.
Parser function's return value was not being properly used.
So, add a return to check whether it is parsed or not.
2020-12-03 18:39:47 +09:00
JunsuChoi
e00f948705
raw_loader Loader: Introduce Raw image loader
Add RawLoader class that loads and display raw images,
and adds a Rasterizer for image data.
Image data can be loaded via picture.
Loaded image supports Composition, Transformation and Alpha blending.

New API
Result load(uint32_t* data, uint32_t width, uint32_t height, bool isCopy) noexcept;
2020-11-23 18:12:36 +09:00
Hermet Park
9872cf066d
common taskScheduler: thread sync optmization
replaced future/promise with mutex since they use a lot of memory allocation number.

plus, binary size is reduced from 2094896 -> 1746864
2020-11-09 14:36:22 +09:00
Hermet Park
1b8188ee67
sw_engine shape: performance optimization.
we introduced shared memory pool for avoiding reallocate memory
while it process the stroke outlines, It experimentally increase
the outline data if we use the allocated memory for multiples shape strokes,
we don't need to alloc/free memory during the process.

This shared outline memory is allocated for threads count
so that we don't interrupt memory access during the tasks.

@Issues: 75
2020-11-04 16:28:47 +09:00
JunsuChoi
dc822174e8 svg_loader: Fixed a typo
lenght ->length
2020-11-02 14:16:13 +09:00
JunsuChoi
d4e9450ec1 common lib/loaders: Fix missing space for coding convention
Correct missing or incorrect spaces according to coding convention.
2020-11-02 14:15:05 +09:00
JunsuChoi
1bf123ff46 svg_loader SvgLoader: Fix wrong indentation
indent 3 -> 4
2020-11-02 14:14:36 +09:00
JunsuChoi
6cf2d89571 svg_loader SvgLoader: Prevent memory overflow for tagName
When copying tagName, if length of referenced string is longer
than general case, it is not used as tagName.
2020-10-30 17:06:06 +09:00
Hermet Park
389b028be4 svg_loader XmlParser: just renamed file name to simplify.
XmlParser without "Simple" is enough to address itself.
2020-10-15 20:44:53 +09:00
JunsuChoi
77ccbcc6fe
tvgSvgLoader: Add points copy of missing polygon/polyline
When using <use> node, do atrribute copy.
At that time, when target(url) is polygon or polyline,
points array is not copied, causing a problem in output.
So, add missing array copy.
2020-10-13 13:45:40 +09:00
JunsuChoi
098c94819c tvgSvgLoader: Fix wrong bracket 2020-10-13 13:43:54 +09:00
JunsuChoi
e73cf7db60 tvgSvgLoader: Add "clip-path" attribute
Below node types support clip-path.
<circle>
<ellipse>
<g>
<path>
<polygon>
<polyline>
<rect>
2020-10-13 13:43:54 +09:00
JunsuChoi
ea0ce1f496 SvgLoader: Implement ClipPath style
Supports case of using style attribute for defined <clipPath>.
In SVG, <clipPath> can be used as a "clipPath" attribute or a style "clip-path".
This patch only supports "clip-path" of style is declared.
The remaining features will be added later.

[Example SVG case]

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve">
 <defs>
      <clipPath id="clipPath">
          <rect x="15" y="15" width="40" height="40" fill="#F00" />
          <circle cx="20" cy="20" r="10" fill="#F00" />
      </clipPath>
  </defs>

  <circle cx="25" cy="25" r="20"
          style="fill: #0000ff; clip-path: url(#clipPath); " />
</svg>
2020-10-13 13:43:54 +09:00
Hermet Park
6365d02a96 optimization: cut off file dependencies.
we should avoid code insertion during file dependencies,
such as #include "xxx.h" which has implementations.

This could increase binary size, we can avoid it as possible.

Current patch improves binary size like this:

From: file(2059008) = text(120360) data(8096) bss(80) dec(128536)
To  : file(1921832) = text(118429) data(7872) bss(56) dec(126357)

More additional patches will come in to optmize binary size.
2020-09-23 20:57:30 +09:00
JunsuChoi
855397be36 SvgLoader: Fix wrong display when dasharray size is 1
If dash array size is 1, it means that dash and gap size are the same.
2020-09-15 12:21:02 +09:00
JunsuChoi
1280548cf1 SvgLoader: Fix missing doc.gradients update
When both <defs> and <svg> gradients are declared,
the update of gradient declared in <svg> is omitted.
Therefore, this patch fixes any missing gradient updates.
2020-09-11 11:11:13 +09:00
JunsuChoi
68ce2dc7d8 SvgLoader: Supports case when only rx or ry is declared
In relation to the declaration of rx and ry attribute of rect, the following three cases occur.
rx="10" (or ry="10"
rx="10" ry = "0" (or rx="0" ry = "10")
rx="10" ry = "10"
To cover these case, we check the rx and ry declarations.
2020-09-10 10:31:31 +09:00
Hermet Park
3e63263646 svg_loader: refactoring code.
merge loader class with task to simplfy code.
2020-09-08 10:43:38 +09:00
JunsuChoi
801896cf8f SvgLoader: Add Mask, ClipPath nodees as dummy.
Mask and clippath TAG are not supported yet.
If this TAG is used, the Child TAG declared with this TAG may cause problems.
To prevent that, declare them as Unknown types until they are supported. (display=none)
2020-09-04 19:47:22 +09:00
JunsuChoi
bd36738011 SvgLoader: Support DashArray attribute for stroke
It supports stroke-dasharray, one of the stroke properties of svg.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-dasharray
2020-09-04 16:45:31 +09:00
JunsuChoi
497c1ef131 SvgLoader: Fix memory leak for loader's gradient
Release the memory that was not released.
2020-09-04 16:03:46 +09:00
JunsuChoi
c27a952f44 SvgLoader: Add null check
Since the pointer actually used inside the if condition is loader->def,
add a null check for this.
2020-09-04 16:03:07 +09:00
Hermet Park
b40016c81d svg_loader: prevent dangling node in exception case.
We prefer the independent unit function behavior.
2020-09-04 11:49:08 +09:00
JunsuChoi
3018fe29cd SvgLoader: Remove unnecessary declaration
This declaration is no longer needed,
removing unnecessary actions.(69e8b54be2)
2020-09-04 11:45:45 +09:00
JunsuChoi
23fa5bba23 SvgLoader: Do not delete the cloned node
Reverted incorrectly modified code in 3b9bb51321.

The newly created node becomes a child of the parent parameter
and is deleted together when parsing ends.
2020-09-04 11:45:45 +09:00
JunsuChoi
7807814acb SvgLoader: Fix pointing to wrong parent
If defs type is open empty style, it is not included in stack.
2020-09-04 11:45:45 +09:00
JunsuChoi
c15103e033 SvgLoader: Prevent underflow when stack.cnt is 0
If graphic node is directly located in the <svg>(root) node,
it may cause underflow because stack.cnt is 0.
2020-09-02 18:23:04 +09:00
JunsuChoi
7aff026276 SvgLoader: Defs type nodes are not saved in loader's node list.
If there is an empty (unused) <defs /> inside the svg file, this can cause problems.
<defs> node is managed separately in loader->def.
So it doesn't have to be added to loader's list.
2020-09-02 18:23:04 +09:00
Hermet Park
6f962151b4 svg_loader: fix vector memory leaks.
vector is designed for c++ syntaxes,
it works properly when c++ memory allocator is applied,

Here svg_loader uses c style structures which allocated using malloc()/calloc().
That brings the memory broken of stl vectors.

So, we replaced it with our customized SvgVector to easily fix it.
2020-09-02 12:56:18 +09:00
Hermet Park
09fce05105 svg_loader: code refactoring
revise code for simple & better readibility.
2020-09-01 17:51:00 +09:00
Hermet Park
2ef3d05db9 svg_loader: applied asynchronous threads tasks for optimal performance.
Change-Id: I6575a6a6302c0ae52d1256a5f79f4c080002a4aa
2020-08-25 16:08:33 +09:00
Hermet Park
04c6295974 code refactoring
remove unnecessary condition.
implementation won't be included multiple times not like headers.

Thus this condition is unnecessary.

Change-Id: Id37e675c40ce7213a06c950da8e5ca17ff7245c9
2020-08-20 16:16:46 +09:00
Hermet Park
70b4703707 remove print/cout logs.
we need a comprehensive logging interface for this.

right now, leave as "LOG:" to replace later.

Change-Id: I25321223cd48ec13a1de5e4140cfea75a2f42866
2020-08-18 20:35:13 +09:00
Hermet Park
7ab71c52d0 picture svg: introduce load() with memory data input source.
picture now affords the memory data as input source so that
user can pass svg data memory directly.

Change-Id: I246c09b682a2d60e53ad556ce0c90337142ee4f1
2020-08-14 19:41:04 +09:00
Hermet Park
709548701a loader svg: code refactoring.
renamed svg loader path.

Change-Id: I0219721540ea981d15d17b9571c1ee9b37651fb8
2020-08-14 18:47:50 +09:00
Renamed from src/loaders/svg_loader/tvgSvgLoader.cpp (Browse further)