Hi!
finally I broke the bug that was stopping me to continue the progress.
Some layers renders by using the slow approaching of use the render
function that creates the rendered surface by (sub)sampling the context
color at different vector positions.
This is done using the get_color from the context and so from the layers.
Each layer must define a get_color for that to provide the method to the
render function to work.
When implementing this behavior on Cairo I need to do the same with the
Cairo layers. I do it by coding a get_cairocolor function
I did all the code work for the intermediate classes and layers: Composite,
Bitmap and Context but I didn't implement any get_cairocolor function for
any layer that really produces content.
That was the reason why all the render test of that kind of layers (Twirl
is one of them) produced a transparent result.
Finally I've realized that and so I've made the first migration for
get_cairocolor for the Linear Gradient layer (not pushed yet).
My surprise is that the render result is awful. :)
I've found that I the specialized subsampling functions I made for surfaces
that have its components already premultipled is incomplete. I mix values
between 0 and 1 with values between 0 and 255.
It is needed to pass one parameter to those functions to scale up and down
properly the calculated result.
I've not coded it yet but the good news is that I know where the problems
comes.
Time to have dinner and sleep.
Cheers!
2012/10/15 Carlos López González <genet...@gmail.com>
> Hi!
> Finally, after some days of researching I found why the code I wrote
> worked in the snippet of code and not in the render system. It needed
> a reset of the matrix transformations before the mask was applied.
>
> After that, the door to adapt the blend methods that are supported in
> Cairo has been completed as you can see in the latest commits.
>
> Also I've added code to support those blend methods that haven't got
> any possible similar or equal operator in Cairo. This default code is
> terribly slow but I've not found any way to perform the correct
> operation. It needs two color conversions, a clamp operation and one
> alpha premultiplication and one alpha demultiplication. And everything
> for each layer that is composited so it would be (is) terribly slow. I
> also would like to add one extra parameter in the future for those
> blend methods not fully accomplished to be possible to use the default
> blend method for the correctness of the render result in case that
> someone would like to use Cairo render for a production render. It
> would be a kind of "legacy blend methods option" (true or false,
> defaults to false) to allow the user specify to use the legacy one or
> the approximated one.
>
> Formerly all the blend methods are finished although some of them
> doesn't produce the exact render result when the destination surface
> is not a solid color. In those cases the blended overlapping area has
> more opacity than it should have.
>
> Regarding to the layers, only rectangle is capable of use the new
> blending methods so the rest has to be gradually migrate to use the
> new functions.
>
> There still some layers missing from add support for Cairo render but
> it is a question of time to port all them.
>
> My working rate is very slow lately so please be patient.
>
> I still open to anyone that want to contribute with the missing areas
> to code. Specially I would need help when dealing with the direct to
> screen drawing and the usage of the cairo_gl surface. There is so few
> documentation and examples in that area and any help is welcome.
>
> Cheers!
>
> 2012/10/5 Carlos López González <genet...@gmail.com>:
> > Thanks guys!
> >
> > I'm having troubles with BRIGHTEN mode. Although Cairo has a LIGHTEN
> > operator (that does a ver similar operation) it doesn't remove the
> > source part that is not onto the destination so I need to do an extra
> > operation.
> > Doing the tests in a separated snippet of code it is fair simple to
> > make the blended result to be only on top of the destination surface.
> > I should only to use the destination surface as additional mask
> > surface before doing the paint operation. It works fine in the snippet
> > of code but I'm failing to do the same on the render.
> > I suspect that the optimize_canvas function is doing evil things with
> > the layers, including some extra paste canvas layers inside or
> > changing the blending method.
> > So I'm going to add a debug function that would recursive list the
> > layers and its blending methods into a txt file just before the render
> > starts, to check why when doing the masking operation on the synfig
> > code, doesn't work as in the snippet of code.
> >
> > I could have moved to try other blend mode instead of insist with
> > BRIGHTEN but at the end I would have the same mask problems regardless
> > the operator used (it happens the same even with if I use OVER (aka
> > COMPOSITE) instead of LIGHTEN)
> >
> > Cheers!
> >
> > 2012/10/3 Joshua Bell <joshbe...@gmail.com>:
> >> Agreed. You're a legend, Carlos.
> >>
> >> "Timothée Giet" <anim...@gmail.com> wrote:
> >>
> >>>Great!
> >>>
> >>>Carlos, you rock :)
> >>>
> >>>2012/10/3 Carlos López González <genet...@gmail.com>
> >>>
> >>>> Hi!
> >>>> This morning I came out with another simper solution for the STRAIGHT
> >>>> method!
> >>>> It is very exciting!
> >>>> The code I previously figured out was this:
> >>>>
> >>>> /////////////////////////////////////// OLD CODE
> >>>> cairo_save(cr);
> >>>>
> >>>> // This part would retrieve the current passed surface and copy it on
> >>>> destimage
> >>>> cairo_surface_t* dest=cairo_get_target(cr);
> >>>> cairo_surface_flush(dest);
> >>>> cairo_surface_t* destimage=cairo_surface_map_to_image(dest, NULL);
> >>>>
> >>>> // Then using destimage width and height create newdest
> >>>> int w=cairo_image_surface_get_width(destimage);
> >>>> int h=cairo_image_surface_get_height(destimage);
> >>>> cairo_surface_t*
> >>>newdest=cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
> >>>> w, h);
> >>>>
> >>>> // Now I paint destimage to newdest with a 1.0 -alpha mask
> >>>> cairo_t* destcr=cairo_create(newdest);
> >>>> cairo_set_source_surface(destcr, destimage, 0, 0);
> >>>> cairo_paint_with_alpha(destcr, 1.0-alpha);
> >>>> cairo_destroy(destcr);
> >>>>
> >>>> // Here I rewrite the newdest to destimage
> >>>> destcr=cairo_create(destimage);
> >>>> cairo_set_source_surface(destcr, newdest, 0, 0);
> >>>> cairo_set_operator(destcr, CAIRO_OPERATOR_SOURCE);
> >>>> cairo_paint(destcr);
> >>>> cairo_destroy(destcr);
> >>>>
> >>>> // and update the cr target (dest)
> >>>> cairo_surface_unmap_image(dest, destimage);
> >>>> cairo_surface_mark_dirty(dest);
> >>>>
> >>>> // destroy and restore
> >>>> cairo_surface_destroy(newdest);
> >>>> cairo_restore(cr);
> >>>>
> >>>> // Finally I paint with he ADD operator using alpha for the current
> >>>> cairo_t commands
> >>>> cairo_set_operator(cr, CAIRO_OPERATOR_ADD);
> >>>> cairo_paint_with_alpha(cr, alpha);
> >>>>
> >>>> ////////////////////////////// OLD CODE - end
> >>>>
> >>>> And I asked my self: Is there other way to fade out a given surface?
> >>>> The solution I did was: extract image, paint with 1.0-alpha, paint
> >>>> back and extract back.
> >>>>
> >>>> I think that I can directly paint on the given surface without need
> >>>to
> >>>> map and unmap. Also I've found a way to fade out a surface in a
> >>>single
> >>>> operation:
> >>>>
> >>>> // //////////////////////////////////// NEW CODE
> >>>> // First save the context status
> >>>> cairo_save(cr);
> >>>>
> >>>> // Second paint with the DEST_IN operator.
> >>>> // It would achieve the following result:
> >>>> // aR=aA*aB
> >>>> // xR=xB
> >>>> // which is exactly to fade out the destination surface
> >>>> // by the alpha of the source (1.0-alpha in this case)
> >>>> cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0-alpha);
> >>>> cairo_set_operator(cr, CAIRO_OPERATOR_DEST_IN);
> >>>> cairo_paint(cr);
> >>>>
> >>>> // Then restore the cairo context
> >>>> cairo_restore(cr);
> >>>>
> >>>> // Then paint using the ADD operator and the alpha value
> >>>> cairo_set_operator(cr, CAIRO_OPERATOR_ADD);
> >>>> cairo_paint_with_alpha(cr, alpha);
> >>>> // //////////////////////////////////// NEW CODE end
> >>>>
> >>>> I cannot test it right now, but I'm very excited on I have found a
> >>>way
> >>>> to perform the desired blending operation with atomic Cairo
> >>>> instructions!!
> >>>>
> >>>> Cheers!
> >>>>
> >>>> 2012/10/2 Carlos López González <genet...@gmail.com>:
> >>>> > Thanks Konstantin. Your backing helps a lot.
> >>>> >
> >>>> > I've finally figured out how to emulate the STRAIGHT blend method
> >>>> > operation in Cairo.
> >>>> > It is an important milestone because I'm confident on being able to
> >>>> > emulate the Synfig's
> >>>> > blend methods that aren't directly supported by Cairo just using a
> >>>> > combination of Cairo's operators.
> >>>> > This means that the performance when blending can have the full
> >>>> > benefit of use Cairo native API.
> >>>> > It is possible that some of the Synfig's blend methods gets
> >>>difficult
> >>>> > to emulate or impossible but
> >>>> > I hope they would be the less used.
> >>>> >
> >>>> > Cheers!
> >>>> >
> >>>> > 2012/9/29 Konstantin Dmitriev <ksee.zelga...@gmail.com>:
> >>>> >> 2012/9/29 Carlos López González <genet...@gmail.com>:
> >>>> >>> Hi!
> >>>> >>> I've added Cairo support for Shade and Bevel layers.
> >>>> >>> Again the results are very similar but slightly slower. These
> >>>kind of
> >>>> layers
> >>>> >>> that manipulate pixels directly doesn't seem to improve much
> >>>using
> >>>> Cairo
> >>>> >>> colors. In fact they loose time doing some unwanted operations
> >>>(due
> >>>> >>> premultiplied and due to need to convert alpha to a 0-1 range)
> >>>that
> >>>> doesn't
> >>>> >>> compensate the supposed speed increase for handling unsigned char
> >>>in
> >>>> memory.
> >>>> >>>
> >>>> >>> I've seen that there are room for some improvements in the Paste
> >>>Canvas
> >>>> >>> layer because in Cairo I didn't clip the Paste Canvas's canvas's
> >>>> context
> >>>> >>> because I didn't understand what was doing the Software. Now that
> >>>I
> >>>> know
> >>>> >>> more about Cairo and that I understand what does Paste Canvas do,
> >>>I
> >>>> could
> >>>> >>> try to use clip in Cairo render and so the things should improve
> >>>the
> >>>> speed
> >>>> >>> for all the encapsulated layers that have defined boundaries.
> >>>> >>
> >>>> >> Hi, Carlos!
> >>>> >> It's awesom to see such a progress.
> >>>> >> >From some moment this week I've got a strong feeling that the
> >>>> >> finished cairo implementation is somewhere near, on the horizon.
> >>>That
> >>>> >> is awesome. Of course, there's still a lot of work, I understand.
> >>>But
> >>>> >> it will be such a significant step even if we will not gain
> >>>desired
> >>>> >> speed increase!
> >>>> >> Please keep your hard work!
> >>>> >> Thank you!
> >>>> >> K.
> >>>> >>
> >>>> >>
> >>>> >>
> >>>> >> --
> >>>> >> http://morevnaproject.org/
> >>>> >>
> >>>> >>
> >>>>
>
> >>>------------------------------------------------------------------------------
> >>>> >> How fast is your code?
> >>>> >> 3 out of 4 devs don\\\'t know how their code performs in
> >>>production.
> >>>> >> Find out how slow your code is with AppDynamics Lite.
> >>>> >> http://ad.doubleclick.net/clk;262219672;13503038;z?
> >>>> >> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
> >>>> >> _______________________________________________
> >>>> >> 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
> >>>>
> >>>>
> >>>>
>
> >>>------------------------------------------------------------------------------
> >>>> Don't let slow site performance ruin your business. Deploy New Relic
> >>>APM
> >>>> Deploy New Relic app performance management and know exactly
> >>>> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> >>>> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> >>>> http://p.sf.net/sfu/newrelic-dev2dev
> >>>> _______________________________________________
> >>>> Synfig-devl mailing list
> >>>> Synfig-devl@lists.sourceforge.net
> >>>> https://lists.sourceforge.net/lists/listinfo/synfig-devl
> >>>>
> >>>
> >>>
> >>>------------------------------------------------------------------------
> >>>
>
> >>>------------------------------------------------------------------------------
> >>>Don't let slow site performance ruin your business. Deploy New Relic
> >>>APM
> >>>Deploy New Relic app performance management and know exactly
> >>>what is happening inside your Ruby, Python, PHP, Java, and .NET app
> >>>Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> >>>http://p.sf.net/sfu/newrelic-dev2dev
> >>>
> >>>------------------------------------------------------------------------
> >>>
> >>>_______________________________________________
> >>>Synfig-devl mailing list
> >>>Synfig-devl@lists.sourceforge.net
> >>>https://lists.sourceforge.net/lists/listinfo/synfig-devl
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> Don't let slow site performance ruin your business. Deploy New Relic APM
> >> Deploy New Relic app performance management and know exactly
> >> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> >> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> >> http://p.sf.net/sfu/newrelic-dev2dev
> >> _______________________________________________
> >> 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
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl