Applied patch from IL'dar AKHmetgaleev aka AkhIL to allow different qualities of...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 31 Jan 2008 14:11:15 +0000 (14:11 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Thu, 31 Jan 2008 14:11:15 +0000 (14:11 +0000)
git-svn-id: http://svn.voria.com/code@1529 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/canvasview.h
synfig-studio/trunk/src/gtkmm/renderer_canvas.cpp
synfig-studio/trunk/src/gtkmm/workarea.cpp
synfig-studio/trunk/src/gtkmm/workarea.h

index 75a7953..8195891 100644 (file)
@@ -569,6 +569,7 @@ init_ui_manager()
        menus_action_group->add( Gtk::Action::create("menu-layer", _("_Layer")) );
        menus_action_group->add( Gtk::Action::create("menu-duck-mask", _("Show/Hide Ducks")) );
        menus_action_group->add( Gtk::Action::create("menu-preview-quality", _("Preview Quality")) );
+       menus_action_group->add( Gtk::Action::create("menu-lowres-pixel", _("Low-Res Pixel Size")) );
        menus_action_group->add( Gtk::Action::create("menu-layer-new", _("New Layer")) );
        menus_action_group->add( Gtk::Action::create("menu-keyframe", _("Keyframe")) );
        menus_action_group->add( Gtk::Action::create("menu-group", _("Group")) );
@@ -638,6 +639,12 @@ init_ui_manager()
        DEFINE_ACTION("quality-08", _("Use Quality Level 8"));
        DEFINE_ACTION("quality-09", _("Use Quality Level 9"));
        DEFINE_ACTION("quality-10", _("Use Quality Level 10"));
+       DEFINE_ACTION("lowres-pixel-01", _("Set Low-Res pixel size to 2^1"));
+       DEFINE_ACTION("lowres-pixel-02", _("Set Low-Res pixel size to 2^2"));
+       DEFINE_ACTION("lowres-pixel-03", _("Set Low-Res pixel size to 2^3"));
+       DEFINE_ACTION("lowres-pixel-04", _("Set Low-Res pixel size to 2^4"));
+       DEFINE_ACTION("lowres-pixel-05", _("Set Low-Res pixel size to 2^5"));
+       DEFINE_ACTION("lowres-pixel-06", _("Set Low-Res pixel size to 2^6"));
        DEFINE_ACTION("play", _("Play"));
        // DEFINE_ACTION("pause", _("Pause"));
        DEFINE_ACTION("stop", _("Stop"));
@@ -769,6 +776,14 @@ init_ui_manager()
 "                      <menuitem action='quality-09' />"
 "                      <menuitem action='quality-10' />"
 "              </menu>"
+"              <menu action='menu-lowres-pixel'>"
+"                      <menuitem action='lowres-pixel-01' />"
+"                      <menuitem action='lowres-pixel-02' />"
+"                      <menuitem action='lowres-pixel-03' />"
+"                      <menuitem action='lowres-pixel-04' />"
+"                      <menuitem action='lowres-pixel-05' />"
+"                      <menuitem action='lowres-pixel-06' />"
+"              </menu>"
 "              <separator name='bleh08'/>"
 "              <menuitem action='play'/>"
 //"            <menuitem action='pause'/>"
index 71ad5ba..fd9a212 100644 (file)
@@ -1290,6 +1290,28 @@ CanvasView::init_menus()
                }
        }
 
+       // Low-Res Quality Menu
+       {
+               int i;
+               for(i=1;i<=6;i++)
+               {
+                       Glib::RefPtr<Gtk::RadioAction> action(Gtk::RadioAction::create(quality_group,strprintf("lowres-pixel-%02d",i),
+                                                                                                                                                  strprintf(_("Set Low-Res pixel size to 2^%d"),i)));
+                       if(i==1)                        // default quality
+                       {
+                               action->set_active();
+                               work_area->set_lowrespixel(i);
+                       }
+                       action_group->add( action,
+                               sigc::bind(
+                                       sigc::mem_fun(*work_area, &studio::WorkArea::set_lowrespixel),
+                                       i
+                               )
+                       );
+               }
+       }
+
+
        action_group->add( Gtk::Action::create("play", Gtk::Stock::MEDIA_PLAY),
                sigc::mem_fun(*this, &studio::CanvasView::play)
        );
index 812958d..aa3cb16 100644 (file)
@@ -320,6 +320,7 @@ private:
        Glib::RefPtr<Gtk::ToggleAction> duck_mask_angle;
 
        Gtk::RadioButtonGroup quality_group;
+       Gtk::RadioButtonGroup lowrespixel_group;
 
        Glib::RefPtr<Gtk::ActionGroup> action_group;
 
index 9115bff..1a137fb 100644 (file)
@@ -152,7 +152,9 @@ Renderer_Canvas::render_vfunc(
                }
                else
                {
-                       const int width_in_tiles(w/tile_w+(((get_work_area()->get_low_resolution_flag())?((w/2)%(tile_w/2)):(w%tile_w))?1:0));
+
+                       int div = 1 << get_work_area()->get_lowrespixel();
+                       const int width_in_tiles(w/tile_w+(((get_work_area()->get_low_resolution_flag())?((w/div)%(tile_w/div)):(w%tile_w))?1:0));
                        const int height_in_tiles(h/tile_h+(h%tile_h?1:0));
 
                        int u(0),v(0),tx,ty;
index 9b77c6c..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
                        );
                }
@@ -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;
@@ -1978,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+((low_resolution?((w/2)%(tile_w/2)):(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
@@ -2144,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
 {
@@ -2241,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
index 8769789..f9ade43 100644 (file)
@@ -227,6 +227,7 @@ private:
        bool canceled_;
 
        int quality;
+       int lowrespixel;
 
        bool dirty_trap_enabled;
 
@@ -406,8 +407,10 @@ public:
        void popup_menu();
 
        int get_quality()const { return quality; }
+       int get_lowrespixel()const { return lowrespixel; }
 
        void set_quality(int x);
+       void set_lowrespixel(int x);
 
 
        int get_w()const { return w; }