Hi!
As well as I can't code as frequent as last past days I would annotate here
the discoveries I'm doing for the rest of things pending to implement.

Maybe you already know that many of the Synfig's layers provide a system to
render based on a math formula. They use a common function called:

Color get_color(Point &p)const;

where Point &p is a floating 2D point (x,y) coordinates in user space. This
function is called by the type of layers that needs to read the color
context at a certain position to give the deformed version of the context
(for example the Twirl layer). Given a point in 2D space, the layer asks
its context for the color it has and then it provides as well another color
for that position, based on a math formulation. This way, calling get_color
for a layer it for all the pixels is possible to render the entire canvas.
These method is only used by layers that deform the context and it is not
used by primitive layers (the one that provide the render result by
themselves (Circle, Rectangle, etc.)).

So well, it seems that Cairo provide a way to generate raster images based
on a callback function:

http://www.cairographics.org/manual/cairo-Raster-Sources.html

"The raster source provides the ability to supply arbitrary pixel data
whilst rendering. The pixels are queried at the time of rasterisation by
means of user callback functions, allowing for the ultimate flexibility.
For example, in handling compressed image sources, you may keep a MRU cache
of decompressed images and decompress sources on the fly and discard old
ones to conserve memory.

For the raster source to be effective, you must at least specify the
acquire and release callbacks which are used to retrieve the pixel data for
the region of interest and demark when it can be freed afterwards. Other
callbacks are provided for when the pattern is copied temporarily during
rasterisation, or more permanently as a snapshot in order to keep the pixel
data available for printing."

So it looks very promising to replace the current render system for those
layers (that does a very time cost subpixel sampling to achieve good
results) if we integrate that get_color with the raster sources API we can
have advantage of the further Cairo facilities to clip, and matrix
operations, etc.

I'm exited!

Cheers
2012/8/15 Carlos López González <genet...@gmail.com>

> Don't go yet! there's more!
> Radial gradients achieved with similar results than linear ones.
> Cheers!
>
> 2012/8/15 Carlos López González <genet...@gmail.com>
>
>> So I'm here again to make some clarifications:
>> The speed up of 6 times is due to that I wrote special code to avoid to
>> render the context of the gradient if it is full opaque. In that case it
>> ignores the background of the gradient and the result is that only one
>> layer is rendered.
>> There are the summary of the speed up:
>> One single gradient without any context.
>> Normal gradient: Reduction time: 61% (or 2.56 times faster)
>> Normal gradient loop: Reduction time: 65% (or 2.85 times faster)
>> Normal gradient zigzag: Reduction time: 57% (or 2.32 times faster)
>> Normal gradient loop+zigzag: Reduction time: 65% (or 2.32 times faster)
>>
>> I've made a test with three gradients with alpha stacked on a solid color
>> and the results are:
>> Software: render time: 0.337 seconds
>> Cairo: render time: 0.082 seconds
>> What gives a performance of reduction time of 76% or 4.16 times faster.
>> Isn't great?
>> Attached are the two gradients. Notice the difference of the file sizes...
>> Cheers!
>>
>>
>> 2012/8/15 Carlos López González <genet...@gmail.com>
>>
>>>
>>>
>>> 2012/8/15 <jco...@gmail.com>
>>>
>>> Congratulation!
>>>>
>>>> Will this implementation help speed up the UI response?
>>>>
>>>
>>> I hope so! and it is possible that using gl backend it would achieve
>>> more speed.
>>>
>>>
>>>>
>>>>
>>>> Hope Carlos has his another long vacation soon :)
>>>>
>>>> Cheers
>>>> Yu
>>>>
>>>> -- Sent from my HP Veer
>>>>
>>>> ------------------------------
>>>> On Aug 15, 2012 7:02 PM, Carlos López González <genet...@gmail.com>
>>>> wrote:
>>>>
>>>> Hi!
>>>> So this is my last vacations day :(
>>>> I've started the port of linear gradients to Cairo with excellent
>>>> results.
>>>>
>>>> Initially Cairo decreases Software render time a 83%. It means that
>>>> Cairo is about six times faster than Software!
>>>>
>>>> There are some aliasing problems when two colors stack together. There
>>>> is where Synfig's software wins, thanks to its float subsampling system.
>>>> Still there are some bugs with loop and zigzag parameters but they can
>>>> be solved.
>>>> Attached are some examples
>>>>
>>>> Cheers!
>>>>
>>>> 2012/8/14 Carlos López González <genet...@gmail.com>
>>>>
>>>>> Oh, well, it was *me* who misunderstood the meaning.... ^__^'''
>>>>> I believed that he wanted vacations to me from coding! LOL
>>>>> Cheers!
>>>>>
>>>>> 2012/8/14 Timothée Giet <anim...@gmail.com>
>>>>>
>>>>>> 2012/8/14 Zelgadis <ksee.zelga...@gmail.com>
>>>>>>
>>>>>>> 2012/8/14 Zelgadis <ksee.zelga...@gmail.com>:
>>>>>>> > P.S. People, wouldn't it be great if Carlos had opportunity to be
>>>>>>> on
>>>>>>> > vacations forever? ^___^
>>>>>>>
>>>>>>> P.P.S. Don't get me wrong - I mean that Carlos is very productive
>>>>>>> when
>>>>>>> he is on vacations. ^__^
>>>>>>>
>>>>>>> I think everebody understood it this way ;)
>>>>>> Big congrats again to him for his Big work :)
>>>>>>
>>>>>> Tim
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Live Security Virtual Conference
>>>>>> Exclusive live event will cover all the ways today's security and
>>>>>> threat landscape has changed and how IT managers can respond.
>>>>>> Discussions
>>>>>> will include endpoint security, mobile security and the latest in
>>>>>> malware
>>>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>>>>> _______________________________________________
>>>>>> Synfig-devl mailing list
>>>>>> Synfig-devl@lists.sourceforge.net
>>>>>> https://lists.sourceforge.net/lists/listinfo/synfig-devl
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Carlos
>>>>> http://synfig.org
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Carlos
>>>> http://synfig.org
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Live Security Virtual Conference
>>>> Exclusive live event will cover all the ways today's security and
>>>> threat landscape has changed and how IT managers can respond.
>>>> Discussions
>>>> will include endpoint security, mobile security and the latest in
>>>> malware
>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>>> _______________________________________________
>>>> Synfig-devl mailing list
>>>> Synfig-devl@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/synfig-devl
>>>>
>>>>
>>>
>>>
>>> --
>>> Carlos
>>> http://synfig.org
>>>
>>>
>>
>>
>> --
>> Carlos
>> http://synfig.org
>>
>>
>
>
> --
> Carlos
> http://synfig.org
>
>


-- 
Carlos
http://synfig.org
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to