Author: Carlos Lopez <genet...@gmail.com>
Date:   Mon Aug 20 20:14:03 2012 +0200

Stretch layer: add support for Cairo render.

---

 synfig-core/src/modules/lyr_std/stretch.cpp |   31 +++++++++++++++++++++++++++
 synfig-core/src/modules/lyr_std/stretch.h   |    1 +
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/synfig-core/src/modules/lyr_std/stretch.cpp 
b/synfig-core/src/modules/lyr_std/stretch.cpp
index ea3e138..bb5b237 100644
--- a/synfig-core/src/modules/lyr_std/stretch.cpp
+++ b/synfig-core/src/modules/lyr_std/stretch.cpp
@@ -182,6 +182,37 @@ Layer_Stretch::accelerated_render(Context context,Surface 
*surface,int quality,
        return context.accelerated_render(surface,quality,desc,cb);
 }
 
+//////
+bool
+Layer_Stretch::accelerated_cairorender(Context context,cairo_surface_t 
*surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
+{
+       if (amount[0] == 0 || amount[1] == 0)
+       {
+               cairo_t* cr=cairo_create(surface);
+               cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
+               cairo_fill(cr);
+               return true;
+       }
+       
+       RendDesc desc(renddesc);
+       desc.clear_flags();
+    // Adjust the top_left and bottom_right points
+       // for our zoom amount
+       Point npos;
+       npos[0]=(desc.get_tl()[0]-center[0])/amount[0]+center[0];
+       npos[1]=(desc.get_tl()[1]-center[1])/amount[1]+center[1];
+       desc.set_tl(npos);
+       npos[0]=(desc.get_br()[0]-center[0])/amount[0]+center[0];
+       npos[1]=(desc.get_br()[1]-center[1])/amount[1]+center[1];
+       desc.set_br(npos);
+       
+       // Render the scene
+       return context.accelerated_cairorender(surface,quality,desc,cb);
+}
+
+/////
+
+
 Rect
 Layer_Stretch::get_full_bounding_rect(Context context)const
 {
diff --git a/synfig-core/src/modules/lyr_std/stretch.h 
b/synfig-core/src/modules/lyr_std/stretch.h
index 10054c4..03904c6 100644
--- a/synfig-core/src/modules/lyr_std/stretch.h
+++ b/synfig-core/src/modules/lyr_std/stretch.h
@@ -61,6 +61,7 @@ public:
        virtual Color get_color(Context context, const Point &pos)const;
 
        virtual bool accelerated_render(Context context,Surface *surface,int 
quality, const RendDesc &renddesc, ProgressCallback *cb)const;
+       virtual bool accelerated_cairorender(Context context,cairo_surface_t 
*surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
        synfig::Layer::Handle hit_check(synfig::Context context, const 
synfig::Point &point)const;
 
        virtual Vocab get_param_vocab()const;


------------------------------------------------------------------------------
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