Author: Carlos Lopez <genet...@gmail.com> Date: Mon Mar 4 17:14:23 2013 +0100
New class Preview Target Cairo --- synfig-studio/src/gui/preview.cpp | 43 +++++++++++++++++++++++++++++++++++++ synfig-studio/src/gui/preview.h | 3 ++ 2 files changed, 46 insertions(+), 0 deletions(-) diff --git a/synfig-studio/src/gui/preview.cpp b/synfig-studio/src/gui/preview.cpp index fe48f69..f641757 100644 --- a/synfig-studio/src/gui/preview.cpp +++ b/synfig-studio/src/gui/preview.cpp @@ -40,6 +40,7 @@ #include <gdkmm/general.h> #include <synfig/target_scanline.h> +#include <synfig/target_cairo.h> #include <synfig/surface.h> #include <algorithm> @@ -76,6 +77,48 @@ using namespace studio; /* === E N T R Y P O I N T ================================================= */ +class studio::Preview::Preview_Target_Cairo : public Target_Cairo +{ + Preview *prev; +public: + Preview_Target_Cairo(Preview *prev_): prev(prev_) + { + } + + virtual bool set_rend_desc(RendDesc *r) + { + return Target_Cairo::set_rend_desc(r); + } + + virtual bool obtain_surface(cairo_surface_t*& surface) + { + int w=desc.get_w(), h=desc.get_h(); + surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + return true; + } + + bool put_surface(cairo_surface_t *surf, synfig::ProgressCallback *cb) + { + if(!prev) + return false; + gamma_filter(surf); + if(cairo_surface_status(surf)) + { + if(cb) cb->error(_("Cairo Surface bad status")); + return false; + } + FlipbookElem fe; + Preview pr = *prev; + float time = get_canvas()->get_time(); + fe.t = time; + fe.surface=cairo_surface_reference(surf); + prev->push_back(fe); + + cairo_surface_destroy(surf); + return true; + } +}; + class studio::Preview::Preview_Target : public Target_Scanline { Surface surface; diff --git a/synfig-studio/src/gui/preview.h b/synfig-studio/src/gui/preview.h index f885d4f..6484b5a 100644 --- a/synfig-studio/src/gui/preview.h +++ b/synfig-studio/src/gui/preview.h @@ -68,6 +68,7 @@ public: { float t; Glib::RefPtr<Gdk::Pixbuf> buf; //at whatever resolution they are rendered at (resized at run time) + cairo_surface_t* surface; }; etl::handle<studio::AsyncRenderer> renderer; @@ -91,6 +92,7 @@ private: //expose the frame information etc. class Preview_Target; + class Preview_Target_Cairo; void frame_finish(const Preview_Target *); sigc::signal0<void> sig_changed; @@ -155,6 +157,7 @@ public: FlipBook::const_iterator begin() const {return frames.begin();} FlipBook::const_iterator end() const {return frames.end();} + void push_back(FlipbookElem fe) { frames.push_back(fe); } void clear() {frames.clear();} ------------------------------------------------------------------------------ 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_d2d_feb _______________________________________________ Synfig-devl mailing list Synfig-devl@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synfig-devl