Author: Carlos Lopez <[email protected]>
Date:   Sat Sep 29 09:08:57 2012 +0200

LumaKey: Add support for Cairo render

---

 synfig-core/src/modules/mod_filter/lumakey.cpp |   39 ++++++++++++++++++++++++
 synfig-core/src/modules/mod_filter/lumakey.h   |   19 +++++++----
 2 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/synfig-core/src/modules/mod_filter/lumakey.cpp 
b/synfig-core/src/modules/mod_filter/lumakey.cpp
index f468c2a..c331698 100644
--- a/synfig-core/src/modules/mod_filter/lumakey.cpp
+++ b/synfig-core/src/modules/mod_filter/lumakey.cpp
@@ -160,6 +160,45 @@ LumaKey::accelerated_render(Context context,Surface 
*surface,int quality, const
        return true;
 }
 
+////
+bool
+LumaKey::accelerated_cairorender(Context context,cairo_surface_t *surface,int 
quality, const RendDesc &renddesc, ProgressCallback *cb)const
+{
+       SuperCallback supercb(cb,0,9500,10000);
+       
+       if(!context.accelerated_cairorender(surface,quality,renddesc,&supercb))
+               return false;
+
+       int x,y;
+       
+       CairoSurface cairosurface(surface);
+       if(!cairosurface.map_cairo_image())
+       {
+               synfig::info("map cairo image failed");
+               return false;
+       }
+       CairoSurface::pen pen(cairosurface.begin());
+       
+       for(y=0;y<renddesc.get_h();y++,pen.inc_y(),pen.dec_x(x))
+               for(x=0;x<renddesc.get_w();x++,pen.inc_x())
+               {
+                       Color tmp(Color(pen.get_value().demult_alpha()));
+                       tmp.set_a(tmp.get_y()*tmp.get_a());
+                       tmp.set_y(1);
+                       
pen.put_value(CairoColor(tmp.clamped()).premult_alpha());
+               }
+       
+       cairosurface.unmap_cairo_image();
+       // Mark our progress as finished
+       if(cb && !cb->amount_complete(10000,10000))
+               return false;
+       
+       return true;
+}
+
+////
+
+
 Rect
 LumaKey::get_bounding_rect(Context context)const
 {
diff --git a/synfig-core/src/modules/mod_filter/lumakey.h 
b/synfig-core/src/modules/mod_filter/lumakey.h
index cb008d5..4c3ca92 100644
--- a/synfig-core/src/modules/mod_filter/lumakey.h
+++ b/synfig-core/src/modules/mod_filter/lumakey.h
@@ -40,7 +40,11 @@
 
 /* === C L A S S E S & S T R U C T S ======================================= */
 
-class LumaKey : public synfig::Layer_Composite, public synfig::Layer_NoDeform
+using namespace synfig;
+using namespace std;
+using namespace etl;
+
+class LumaKey : public Layer_Composite, public Layer_NoDeform
 {
        SYNFIG_LAYER_MODULE_EXT
 private:
@@ -48,18 +52,19 @@ private:
 public:
        LumaKey();
 
-       virtual bool set_param(const synfig::String & param, const 
synfig::ValueBase &value);
+       virtual bool set_param(const String & param, const ValueBase &value);
 
-       virtual synfig::ValueBase get_param(const synfig::String & param)const;
+       virtual ValueBase get_param(const String & param)const;
 
-       virtual synfig::Color get_color(synfig::Context context, const 
synfig::Point &pos)const;
+       virtual Color get_color(Context context, const Point &pos)const;
 
        virtual Vocab get_param_vocab()const;
 
-       synfig::Layer::Handle hit_check(synfig::Context context, const 
synfig::Point &point)const;
-       virtual synfig::Rect get_bounding_rect(synfig::Context context)const;
+       Layer::Handle hit_check(Context context, const Point &point)const;
+       virtual Rect get_bounding_rect(Context context)const;
 
-       virtual bool accelerated_render(synfig::Context context,synfig::Surface 
*surface,int quality, const synfig::RendDesc &renddesc, 
synfig::ProgressCallback *cb)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;
        virtual bool reads_context()const { return true; }
 }; // END of class LumaKey
 


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to