Author: Nikita Kitaev <nikita...@gmail.com>
Date:   Mon Mar 21 16:32:56 2011 -0700

Render preview using cairo

---

 synfig-studio/src/gui/preview.cpp |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/synfig-studio/src/gui/preview.cpp 
b/synfig-studio/src/gui/preview.cpp
index d681d3e..ca61117 100644
--- a/synfig-studio/src/gui/preview.cpp
+++ b/synfig-studio/src/gui/preview.cpp
@@ -35,6 +35,7 @@
 #include "audiocontainer.h"
 #include <gtkmm/stock.h>
 #include <gtkmm/separator.h>
+#include <gdkmm/general.h>
 
 #include <synfig/target_scanline.h>
 #include <synfig/surface.h>
@@ -551,8 +552,7 @@ bool studio::Widget_Preview::redraw(GdkEventExpose */*heh*/)
        //synfig::info("Now to draw to the window...");
        //copy to window
        Glib::RefPtr<Gdk::Window>       wind = draw_area.get_window();
-       Glib::RefPtr<Gdk::Drawable> surf = 
Glib::RefPtr<Gdk::Drawable>::cast_static(wind);
-       Glib::RefPtr<Gdk::GC>           gc = Gdk::GC::create(wind);
+       Cairo::RefPtr<Cairo::Context> cr = wind->create_cairo_context();
 
        {
                Gdk::Rectangle 
r(0,0,draw_area.get_width(),draw_area.get_height());
@@ -560,9 +560,7 @@ bool studio::Widget_Preview::redraw(GdkEventExpose */*heh*/)
        }
 
        if(!wind) synfig::warning("The destination window is broken...");
-       if(!surf) synfig::warning("The destination is not drawable...");
 
-       if(surf)
        {
                /* Options for drawing...
                        1) store with alpha, then clear and render with alpha 
every frame
@@ -575,15 +573,14 @@ bool studio::Widget_Preview::redraw(GdkEventExpose 
*/*heh*/)
                */
                //px->composite(const Glib::RefPtr<Gdk::Pixbuf>& dest, int 
dest_x, int dest_y, int dest_width, int dest_height, double offset_x, double 
offset_y, double scale_x, double scale_y, InterpType interp_type, int 
overall_alpha) const
 
-               surf->draw_pixbuf(
-                       gc, //GC
-                       pxnew, //pixbuf
-                       0, 0,   // Source X and Y
-                       0, 0,   // Dest X and Y
-                       -1,-1,  // Width and Height
-                       Gdk::RGB_DITHER_NONE, // RgbDither
-                       0, 0 // Dither offset X and Y
-               );
+        cr->save();
+        Gdk::Cairo::set_source_pixbuf(
+            cr, //cairo context
+            pxnew, //pixbuf
+            0, 0 //coordinates to place upper left corner of pixbuf
+            );
+        cr->paint();
+        cr->restore();
 
                if(timedisp >= 0)
                {
@@ -593,9 +590,16 @@ bool studio::Widget_Preview::redraw(GdkEventExpose 
*/*heh*/)
                                                                                
                                                                        
App::get_time_format()));
                        //synfig::info("Time for preview draw is: %s for time 
%g", timecode.c_str(), adj_time_scrub.get_value());
 
-                       gc->set_rgb_fg_color(Gdk::Color("#FF0000"));
+            cr->save();
+
                        layout->set_text(timecode);
-                       surf->draw_layout(gc,4,4,layout);
+
+            cr->set_source_rgb(1,0,0);
+            cr->move_to(4,4);
+            layout->show_in_cairo_context(cr);
+            cr->stroke();
+
+            cr->restore();
                }
        }
 


------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to