Author: Carlos Lopez <genet...@gmail.com> Date: Sat Jul 14 13:20:55 2012 +0200
Versions of the set_render_method member for Layer_Bitmap and Import --- synfig-core/src/modules/lyr_std/import.cpp | 13 +++++++++++ synfig-core/src/modules/lyr_std/import.h | 3 ++ synfig-core/src/synfig/layer_bitmap.cpp | 32 ++++++++++++++++++++++++++- synfig-core/src/synfig/layer_bitmap.h | 7 ++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/synfig-core/src/modules/lyr_std/import.cpp b/synfig-core/src/modules/lyr_std/import.cpp index b8e0541..1ad7aae 100644 --- a/synfig-core/src/modules/lyr_std/import.cpp +++ b/synfig-core/src/modules/lyr_std/import.cpp @@ -247,3 +247,16 @@ Import::set_time(Context context, Time time, const Point &pos)const context.set_time(time,pos); } + +void +Import::set_render_method(Context context, RenderMethod x) +{ + if(get_method() != x) // if the method is different + { + Layer_Bitmap::set_render_method(context, x); // set the method (and pass to the other layers) + importer=0; // invalidate the importer + set_param("filename", filename); // this will update the importer to the new type + } + else + context.set_render_method(x); // pass it down. +} diff --git a/synfig-core/src/modules/lyr_std/import.h b/synfig-core/src/modules/lyr_std/import.h index 2452319..50cbd6a 100644 --- a/synfig-core/src/modules/lyr_std/import.h +++ b/synfig-core/src/modules/lyr_std/import.h @@ -31,6 +31,7 @@ #include <synfig/color.h> #include <synfig/vector.h> #include <synfig/importer.h> +#include <synfig/target.h> /* === M A C R O S ========================================================= */ @@ -65,6 +66,8 @@ public: virtual void set_time(synfig::Context context, synfig::Time time)const; virtual void set_time(synfig::Context context, synfig::Time time, const synfig::Point &point)const; + + virtual void set_render_method(synfig::Context context, synfig::RenderMethod x); }; /* === E N D =============================================================== */ diff --git a/synfig-core/src/synfig/layer_bitmap.cpp b/synfig-core/src/synfig/layer_bitmap.cpp index c5d51dc..6e3405b 100644 --- a/synfig-core/src/synfig/layer_bitmap.cpp +++ b/synfig-core/src/synfig/layer_bitmap.cpp @@ -62,6 +62,7 @@ using namespace etl; synfig::Layer_Bitmap::Layer_Bitmap(): Layer_Composite (1.0,Color::BLEND_COMPOSITE), + method (SOFTWARE), tl (-0.5,0.5), br (0.5,-0.5), c (1), @@ -108,7 +109,17 @@ synfig::Layer_Bitmap::get_param(const String & param)const { ValueBase ret1(ValueBase::TYPE_INTEGER); ret1=int(width); - ValueBase ret2(surface.get_w()); + ValueBase ret2(ValueBase::TYPE_INTEGER); + switch (method) + { + case SOFTWARE: + ret2=int(surface.get_w()); + break; + case CAIRO: + default: + ret2=int(cairosurface.get_w()); + break; + } ret1.set_static(get_param_static(param)); ret2.set_static(get_param_static(param)); if (trimmed) return ret1; @@ -118,7 +129,17 @@ synfig::Layer_Bitmap::get_param(const String & param)const { ValueBase ret1(ValueBase::TYPE_INTEGER); ret1=int(height); - ValueBase ret2(surface.get_h()); + ValueBase ret2(ValueBase::TYPE_INTEGER); + switch (method) + { + case SOFTWARE: + ret2=int(surface.get_h()); + break; + case CAIRO: + default: + ret2=int(cairosurface.get_h()); + break; + } ret1.set_static(get_param_static(param)); ret2.set_static(get_param_static(param)); if (trimmed) return ret1; @@ -179,6 +200,13 @@ Layer_Bitmap::hit_check(synfig::Context context, const synfig::Point &pos)const return context.hit_check(pos); } +void +synfig::Layer_Bitmap::set_render_method(Context context, RenderMethod x) +{ + set_method(x); + context.set_render_method(x); +} + inline const Color& synfig::Layer_Bitmap::filter(Color& x)const diff --git a/synfig-core/src/synfig/layer_bitmap.h b/synfig-core/src/synfig/layer_bitmap.h index 1b907b3..581dbfc 100644 --- a/synfig-core/src/synfig/layer_bitmap.h +++ b/synfig-core/src/synfig/layer_bitmap.h @@ -29,6 +29,7 @@ #include "layer_composite.h" #include "surface.h" +#include "target.h" // for RenderMethod /* === M A C R O S ========================================================= */ @@ -45,6 +46,7 @@ class Layer_Bitmap : public Layer_Composite, public Layer_NoDeform { const Color& filter(Color& c)const; const CairoColor& filter(CairoColor& c)const; + RenderMethod method; public: typedef etl::handle<Layer_Bitmap> Handle; @@ -75,6 +77,11 @@ public: virtual bool accelerated_cairorender(Context context,cairo_surface_t *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const; virtual synfig::Layer::Handle hit_check(synfig::Context context, const synfig::Point &point)const; + + virtual void set_render_method(Context context, RenderMethod x); + void set_method(RenderMethod x) { method=x;} + RenderMethod get_method()const { return method;} + }; // END of class Layer_Bitmap }; // END of namespace synfig ------------------------------------------------------------------------------ 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