The ColorStop offset < 0 and > 1 should be treated as 0 and 1 respectively.
The offset value < than the previous offset value should be replaced
by the previous value - without this change segfault occurred.
Validating the APIs parameters values is the user responsibility.
The loader was ready to handle the gradient stroke, but there was no API to support
it when the loader was introduced. We've had this API for a while already, so
its call has been added.
We are doing enough calculations in the parser if the unit is user space.
This causes the cx,cy coordinates of radial gradient to be calculated incorrectly.
So remove it.
Calculation of objectBoundingBox case in linear gradient is incorrect code.
This causes the x,y coordinates of the linear gradient to be calculated incorrectly.
So remove it.
For now the bounding box of all the shapes was established and if it was larger
than the viewBox of the SVG, the clipping layer was added. The bounds api
returns the rectangle that encloses the shapes before any transformations.
So comparing it with the viewBox doesn't make sense. The comparison is removed
and the clipping layer is always added.
1.
Modify that attribute information used for use type
looks like it was used for g type.
2.
Fix clippath node looking like setting "none"
(clippath's display = false is intentional)
If no viewBox attribute is given, the height and width attributes are used
to establish the viewBox size. However, this information was not available
inside the scene builder, even though it was needed.
not only clippath but alpha compositions might also have any valid color.
Set it default and let it override values while appending shapes if it's necessary.
Current loader could return invalid shapes -default, from _appendShape()-
by a certain interpretation result,
Though it's a wrong or exception case, we can prevent worse case by avoiding it.
If the boundary of scene created through the scenebuilder is larger than the viewbox,
scene(SVG's root) should be clipped to the size of the viewbox.
So, if scene need a clip, add a parent root and add clippath composition to that root.
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.
* 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.
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>
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.
When there is a matrix of linear gradient, the applied formula is this.
= T(x - cx, y - cy) x g->transform x T(cx, cy)
This patch has modified this formula to work properly.
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.
remove unnecessary condition.
implementation won't be included multiple times not like headers.
Thus this condition is unnecessary.
Change-Id: Id37e675c40ce7213a06c950da8e5ca17ff7245c9