From 78432386722217ddba2ba0597a96ad5d81e069ca Mon Sep 17 00:00:00 2001 From: dooglus Date: Thu, 31 Jan 2008 14:12:58 +0000 Subject: [PATCH] Change the tile size from 128 to 120 and allow all the factors of 120 to be used as the pixel size for low-resolution editing. git-svn-id: http://svn.voria.com/code@1534 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-core/trunk/src/synfig/target_tile.h | 2 +- synfig-studio/trunk/src/gtkmm/app.cpp | 42 ++++++++++++++++------- synfig-studio/trunk/src/gtkmm/canvasview.cpp | 17 +++++---- synfig-studio/trunk/src/gtkmm/canvasview.h | 2 +- synfig-studio/trunk/src/gtkmm/renderer_canvas.cpp | 2 +- synfig-studio/trunk/src/gtkmm/workarea.cpp | 28 +++++++-------- synfig-studio/trunk/src/gtkmm/workarea.h | 6 ++-- 7 files changed, 61 insertions(+), 38 deletions(-) diff --git a/synfig-core/trunk/src/synfig/target_tile.h b/synfig-core/trunk/src/synfig/target_tile.h index 8f5bf54..7ba4ad7 100644 --- a/synfig-core/trunk/src/synfig/target_tile.h +++ b/synfig-core/trunk/src/synfig/target_tile.h @@ -31,7 +31,7 @@ /* === M A C R O S ========================================================= */ -#define TILE_SIZE 128 +#define TILE_SIZE 120 /* === T Y P E D E F S ===================================================== */ diff --git a/synfig-studio/trunk/src/gtkmm/app.cpp b/synfig-studio/trunk/src/gtkmm/app.cpp index 8195891..6c185a4 100644 --- a/synfig-studio/trunk/src/gtkmm/app.cpp +++ b/synfig-studio/trunk/src/gtkmm/app.cpp @@ -639,12 +639,21 @@ 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("lowres-pixel-2", _("Set Low-Res pixel size to 2")); + DEFINE_ACTION("lowres-pixel-3", _("Set Low-Res pixel size to 3")); + DEFINE_ACTION("lowres-pixel-4", _("Set Low-Res pixel size to 4")); + DEFINE_ACTION("lowres-pixel-5", _("Set Low-Res pixel size to 5")); + DEFINE_ACTION("lowres-pixel-6", _("Set Low-Res pixel size to 6")); + DEFINE_ACTION("lowres-pixel-8", _("Set Low-Res pixel size to 8")); + DEFINE_ACTION("lowres-pixel-10", _("Set Low-Res pixel size to 10")); + DEFINE_ACTION("lowres-pixel-12", _("Set Low-Res pixel size to 12")); + DEFINE_ACTION("lowres-pixel-15", _("Set Low-Res pixel size to 15")); + DEFINE_ACTION("lowres-pixel-20", _("Set Low-Res pixel size to 20")); + DEFINE_ACTION("lowres-pixel-24", _("Set Low-Res pixel size to 24")); + DEFINE_ACTION("lowres-pixel-30", _("Set Low-Res pixel size to 30")); + DEFINE_ACTION("lowres-pixel-40", _("Set Low-Res pixel size to 40")); + DEFINE_ACTION("lowres-pixel-60", _("Set Low-Res pixel size to 60")); + DEFINE_ACTION("lowres-pixel-120", _("Set Low-Res pixel size to 120")); DEFINE_ACTION("play", _("Play")); // DEFINE_ACTION("pause", _("Pause")); DEFINE_ACTION("stop", _("Stop")); @@ -777,12 +786,21 @@ init_ui_manager() " " " " " " -" " -" " -" " -" " -" " -" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " " " " " " " diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.cpp b/synfig-studio/trunk/src/gtkmm/canvasview.cpp index e9fe579..eb9795b 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasview.cpp @@ -1290,21 +1290,26 @@ CanvasView::init_menus() } } + // prime factors of 120 are 2, 2, 2, 3, 5 + int pixel_size_array[] = {2,3,4,5,6,8,10,12,15,20,24,30,40,60,120}; + list pixel_sizes(pixel_size_array, pixel_size_array + sizeof(pixel_size_array) / sizeof(int)); + // Low-Res Quality Menu { int i; - for(i=1;i<=6;i++) + for(list::iterator iter = pixel_sizes.begin(); iter != pixel_sizes.end(); iter++) { - Glib::RefPtr 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 + i = *iter; + Glib::RefPtr action(Gtk::RadioAction::create(low_res_pixel_size_group,strprintf("lowres-pixel-%d",i), + strprintf(_("Set Low-Res pixel size to %d"),i))); + if(i==2) // default pixel size { action->set_active(); - work_area->set_lowrespixel(i); + work_area->set_low_res_pixel_size(i); } action_group->add( action, sigc::bind( - sigc::mem_fun(*work_area, &studio::WorkArea::set_lowrespixel), + sigc::mem_fun(*work_area, &studio::WorkArea::set_low_res_pixel_size), i ) ); diff --git a/synfig-studio/trunk/src/gtkmm/canvasview.h b/synfig-studio/trunk/src/gtkmm/canvasview.h index aa3cb16..57799b1 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasview.h +++ b/synfig-studio/trunk/src/gtkmm/canvasview.h @@ -320,7 +320,7 @@ private: Glib::RefPtr duck_mask_angle; Gtk::RadioButtonGroup quality_group; - Gtk::RadioButtonGroup lowrespixel_group; + Gtk::RadioButtonGroup low_res_pixel_size_group; Glib::RefPtr action_group; diff --git a/synfig-studio/trunk/src/gtkmm/renderer_canvas.cpp b/synfig-studio/trunk/src/gtkmm/renderer_canvas.cpp index 81d922d..ee80f32 100644 --- a/synfig-studio/trunk/src/gtkmm/renderer_canvas.cpp +++ b/synfig-studio/trunk/src/gtkmm/renderer_canvas.cpp @@ -152,7 +152,7 @@ Renderer_Canvas::render_vfunc( } else { - int div = 1 << get_work_area()->get_lowrespixel(); + int div = get_work_area()->get_low_res_pixel_size(); 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)); diff --git a/synfig-studio/trunk/src/gtkmm/workarea.cpp b/synfig-studio/trunk/src/gtkmm/workarea.cpp index 5cd526d..1b61346 100644 --- a/synfig-studio/trunk/src/gtkmm/workarea.cpp +++ b/synfig-studio/trunk/src/gtkmm/workarea.cpp @@ -171,7 +171,7 @@ public: set_clipping(true); if(low_res) { - int div = 1 << workarea->get_lowrespixel(); + int div = workarea->get_low_res_pixel_size(); set_tile_w(workarea->tile_w/div); set_tile_h(workarea->tile_h/div); } @@ -194,7 +194,7 @@ public: assert(workarea); newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN); if(low_res) { - int div = 1 << workarea->get_lowrespixel(); + int div = workarea->get_low_res_pixel_size(); newdesc->set_wh(w/div,h/div); } else @@ -309,7 +309,7 @@ public: int h(get_tile_h()); int x(surface.get_w()*surface.get_h()); //if(low_res) { - // int div = 1 << workarea->get_lowrespixel(); + // int div = workarea->get_low_res_pixel_size(); // w/=div,h/=div; //} Color dark(0.6,0.6,0.6); @@ -351,7 +351,7 @@ public: if(low_res) { // We need to scale up - int div = 1 << workarea->get_lowrespixel(); + int div = workarea->get_low_res_pixel_size(); pixbuf=pixbuf->scale_simple( surface.get_w()*div, surface.get_h()*div, @@ -476,7 +476,7 @@ public: newdesc->set_flags(RendDesc::PX_ASPECT|RendDesc::IM_SPAN); if(low_res) { - int div = 1 << workarea->get_lowrespixel(); + int div = workarea->get_low_res_pixel_size(); newdesc->set_wh(w/div,h/div); } else @@ -555,7 +555,7 @@ public: //int h(surface.get_h()); int x(surface.get_w()*surface.get_h()); //if(low_res) { - // int div = 1 << workarea->get_lowrespixel(); + // int div = workarea->get_low_res_pixel_size(); // w/=div,h/=div; //} Color dark(0.6,0.6,0.6); @@ -564,7 +564,7 @@ public: int th=workarea->tile_h; if(low_res) { - int div = 1 << workarea->get_lowrespixel(); + int div = workarea->get_low_res_pixel_size(); tw/=div; th/=div; } @@ -597,7 +597,7 @@ public: if(low_res) { // We need to scale up - int div = 1 << workarea->get_lowrespixel(); + int div = workarea->get_low_res_pixel_size(); pixbuf=pixbuf->scale_simple( surface.get_w()*div, surface.get_h()*div, @@ -664,7 +664,7 @@ WorkArea::WorkArea(etl::loose_handle canvas_interfac render_idle_func_id=0; zoom=prev_zoom=1.0; quality=10; - lowrespixel=1; + low_res_pixel_size=2; rendering=false; canceled_=false; low_resolution=true; @@ -1994,7 +1994,7 @@ 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); - int div = 1 << lowrespixel; + int div = low_res_pixel_size; 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)); @@ -2162,11 +2162,11 @@ WorkArea::set_quality(int x) } void -WorkArea::set_lowrespixel(int x) +WorkArea::set_low_res_pixel_size(int x) { - if(x==lowrespixel) + if(x==low_res_pixel_size) return; - lowrespixel=x; + low_res_pixel_size=x; queue_render_preview(); } @@ -2267,7 +2267,7 @@ studio::WorkArea::async_update_preview() // if we have lots of pixels to render and the tile renderer isn't disabled, use it int div; - div = low_resolution ? (1 << lowrespixel) : 1; + div = low_resolution ? low_res_pixel_size : 1; if (w*h > 240*div*135*div && !getenv("SYNFIG_DISABLE_TILE_RENDER")) { // do a tile render diff --git a/synfig-studio/trunk/src/gtkmm/workarea.h b/synfig-studio/trunk/src/gtkmm/workarea.h index f9ade43..ca4f7cc 100644 --- a/synfig-studio/trunk/src/gtkmm/workarea.h +++ b/synfig-studio/trunk/src/gtkmm/workarea.h @@ -227,7 +227,7 @@ private: bool canceled_; int quality; - int lowrespixel; + int low_res_pixel_size; bool dirty_trap_enabled; @@ -407,10 +407,10 @@ public: void popup_menu(); int get_quality()const { return quality; } - int get_lowrespixel()const { return lowrespixel; } + int get_low_res_pixel_size()const { return low_res_pixel_size; } void set_quality(int x); - void set_lowrespixel(int x); + void set_low_res_pixel_size(int x); int get_w()const { return w; } -- 2.7.4