Applied patch from IL'dar AKHmetgaleev aka AkhIL to allow different qualities of...
[synfig.git] / synfig-studio / trunk / src / gtkmm / workarea.cpp
index 8f73604..8924d12 100644 (file)
@@ -171,8 +171,10 @@ public:
                set_clipping(true);
                if(low_res)
                {
-                       set_tile_w(workarea->tile_w/2);
-                       set_tile_h(workarea->tile_h/2);
+
+                       int div = 1 << workarea->get_lowrespixel();
+                       set_tile_w(workarea->tile_w/div);
+                       set_tile_h(workarea->tile_h/div);
                }
                else
                {
@@ -192,8 +194,10 @@ public:
        {
                assert(workarea);
                newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN);
-               if(low_res)
-                       newdesc->set_wh(w/2,h/2);
+               if(low_res) {
+                       int div = 1 << workarea->get_lowrespixel();
+                       newdesc->set_wh(w/div,h/div);
+               }
                else
                        newdesc->set_wh(w,h);
 
@@ -345,9 +349,11 @@ public:
                if(low_res)
                {
                        // We need to scale up
+
+                       int div = 1 << workarea->get_lowrespixel();
                        pixbuf=pixbuf->scale_simple(
-                               surface.get_w()*2,
-                               surface.get_h()*2,
+                               surface.get_w()*div,
+                               surface.get_h()*div,
                                Gdk::INTERP_NEAREST
                        );
                }
@@ -630,14 +636,14 @@ WorkArea::WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interfac
        canvas(canvas_interface->get_canvas()),
        scrollx_adjustment(0,-4,4,0.01,0.1),
        scrolly_adjustment(0,-4,4,0.01,0.1),
-       w(128),
-       h(128),
+       w(TILE_SIZE),
+       h(TILE_SIZE),
        last_event_time(0),
        progresscallback(0),
        dragging(DRAG_NONE),
        show_grid(false),
-       tile_w(128),
-       tile_h(128),
+       tile_w(TILE_SIZE),
+       tile_h(TILE_SIZE),
        timecode_width(0),
        timecode_height(0)
 {
@@ -649,6 +655,7 @@ WorkArea::WorkArea(etl::loose_handle<synfigapp::CanvasInterface> canvas_interfac
        render_idle_func_id=0;
        zoom=prev_zoom=1.0;
        quality=10;
+       lowrespixel=1;
        rendering=false;
        canceled_=false;
        low_resolution=true;
@@ -892,6 +899,8 @@ WorkArea::load_meta_data()
 
                if(!tmp.empty())
                        gx=stratof(tmp);
+               else
+                       synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
 
                if(iter==data.end())
                        tmp.clear();
@@ -900,11 +909,11 @@ WorkArea::load_meta_data()
 
                if(!tmp.empty())
                        gy=stratof(tmp);
+               else
+                       synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
 
                set_grid_size(Vector(gx,gy));
        }
-       else
-               synfig::error("WorkArea::load_meta_data(): Unable to parse data for \"grid_size\", which was \"%s\"",data.c_str());
 
        data=canvas->get_meta_data("grid_show");
        if(data.size() && (data=="1" || data[0]=='t' || data[0]=='T'))
@@ -1976,7 +1985,9 @@ WorkArea::next_unrendered_tile(int refreshes)const
                x(focus_point[0]/pw+drawing_area->get_width()/2-w/2),
                y(focus_point[1]/ph+drawing_area->get_height()/2-h/2);
 
-       const int width_in_tiles(w/tile_w+(w%tile_w?1:0));
+
+       int div = 1 << lowrespixel;
+       const int width_in_tiles(w/tile_w+((low_resolution?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
        const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
 
        int
@@ -2142,6 +2153,17 @@ WorkArea::set_quality(int x)
        queue_render_preview();
 }
 
+void
+WorkArea::set_lowrespixel(int x)
+{
+       if(x==lowrespixel)
+               return;
+       lowrespixel=x;
+       queue_render_preview();
+}
+
+
+
 
 namespace studio
 {
@@ -2239,7 +2261,8 @@ studio::WorkArea::async_update_preview()
        handle<Target> target;
 
        // if we have lots of pixels to render and the tile renderer isn't disabled, use it
-       if(w*h>(low_resolution?480*270:480*270/2) &&
+       int div = 1 << lowrespixel;
+       if(w*h>(low_resolution?480*270:480*270/div) &&
           !getenv("SYNFIG_DISABLE_TILE_RENDER"))
        {
                // do a tile render