Skip to content

Commit

Permalink
New class Preview Target Cairo
Browse files Browse the repository at this point in the history
  • Loading branch information
genete committed Mar 4, 2013
1 parent 370a2cd commit 24429fb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
43 changes: 43 additions & 0 deletions synfig-studio/src/gui/preview.cpp
Expand Up @@ -40,6 +40,7 @@
#include <gdkmm/general.h>

#include <synfig/target_scanline.h>
#include <synfig/target_cairo.h>
#include <synfig/surface.h>

#include <algorithm>
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions synfig-studio/src/gui/preview.h
Expand Up @@ -68,6 +68,7 @@ class Preview : public sigc::trackable, public etl::shared_object
{
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;
Expand All @@ -91,6 +92,7 @@ class Preview : public sigc::trackable, public etl::shared_object

//expose the frame information etc.
class Preview_Target;
class Preview_Target_Cairo;
void frame_finish(const Preview_Target *);

sigc::signal0<void> sig_changed;
Expand Down Expand Up @@ -155,6 +157,7 @@ class Preview : public sigc::trackable, public etl::shared_object

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();}

Expand Down

0 comments on commit 24429fb

Please sign in to comment.