Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-core / trunk / src / synfig / target_tile.cpp
index 7a411bb..f02b71b 100644 (file)
@@ -2,10 +2,11 @@
 /*!    \file target_tile.cpp
 **     \brief Template File
 **
-**     $Id: target_tile.cpp,v 1.2 2005/01/12 06:46:45 darco Exp $
+**     $Id$
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 2008 Chris Moore
 **
 **     This package is free software; you can redistribute it and/or
 **     modify it under the terms of the GNU General Public License as
@@ -47,12 +48,19 @@ using namespace etl;
 using namespace synfig;
 
 /* === M A C R O S ========================================================= */
-const unsigned int     DEF_TILE_WIDTH = 64;
-const unsigned int     DEF_TILE_HEIGHT= 64;
+const unsigned int     DEF_TILE_WIDTH = TILE_SIZE / 2;
+const unsigned int     DEF_TILE_HEIGHT= TILE_SIZE / 2;
+
+// note that if this isn't defined then the rendering is incorrect for
+// the straight blend method since the optimize_layers() function in
+// canvas.cpp which makes the straight blend method work correctly
+// isn't called.  ie. leave this defined.  to see the problem, draw a
+// small circle over a solid background.  set circle to amount 0.99
+// and blend method 'straight'.  the background should vanish but doesn't
+#define SYNFIG_OPTIMIZE_LAYER_TREE
 
-#define SYNFIG_OPTIMIZE_LAYER_TREE     1
 #ifdef _DEBUG
-#define SYNFIG_DISPLAY_EFFICIENCY      1
+// #define SYNFIG_DISPLAY_EFFICIENCY
 #endif
 
 /* === G L O B A L S ======================================================= */
@@ -276,14 +284,15 @@ synfig::Target_Tile::render_frame_(Context context,ProgressCallback *cb)
                                add_tile_time+=timer();
                        }
                        tile_timer.reset();
+                       signal_progress()();
                }
        }
        if(cb && !cb->amount_complete(total_tiles,total_tiles))
                return false;
 
-#if SYNFIG_DISPLAY_EFFICIENCY==1
+#ifdef SYNFIG_DISPLAY_EFFICIENCY
        synfig::info(">>>>>> Render Time: %fsec, Find Tile Time: %fsec, Add Tile Time: %fsec, Total Time: %fsec",work_time,find_tile_time,add_tile_time,total_time());
-       synfig::info(">>>>>> FRAME EFICIENCY: %f%%",(100.0f*work_time/total_time()));
+       synfig::info(">>>>>> FRAME EFFICIENCY: %f%%",(100.0f*work_time/total_time()));
 #endif
 #undef total_tiles
        return true;
@@ -307,7 +316,7 @@ synfig::Target_Tile::render(ProgressCallback *cb)
        curr_frame_=0;
        init();
        if( !init() ){
-               if(cb) cb->error(_("Target initialisation failure"));
+               if(cb) cb->error(_("Target initialization failure"));
                return false;
        }
 
@@ -354,21 +363,29 @@ synfig::Target_Tile::render(ProgressCallback *cb)
 
                        Context context;
 
-                       #ifdef SYNFIG_OPTIMIZE_LAYER_TREE
-                       Canvas::Handle op_canvas(Canvas::create());
-                       optimize_layers(canvas->get_context(), op_canvas);
-                       context=op_canvas->get_context();
-                       #else
+#ifdef SYNFIG_OPTIMIZE_LAYER_TREE
+                       Canvas::Handle op_canvas;
+                       if (!getenv("SYNFIG_DISABLE_OPTIMIZE_LAYER_TREE"))
+                       {
+                               op_canvas = Canvas::create();
+                               op_canvas->set_file_name(canvas->get_file_name());
+                               optimize_layers(canvas->get_time(), canvas->get_context(), op_canvas);
+                               context=op_canvas->get_context();
+                       }
+                       else
+                               context=canvas->get_context();
+#else
                        context=canvas->get_context();
-                       #endif
+#endif
 
 /*
                        #ifdef SYNFIG_OPTIMIZE_LAYER_TREE
                        Context context;
                        Canvas::Handle op_canvas(Canvas::create());
+                       op_canvas->set_file_name(canvas->get_file_name());
                        // Set the time that we wish to render
                        canvas->set_time(t);
-                       optimize_layers(canvas->get_context(), op_canvas);
+                       optimize_layers(canvas->get_time(), canvas->get_context(), op_canvas);
                        context=op_canvas->get_context();
                        #else
                        Context context;
@@ -399,13 +416,20 @@ synfig::Target_Tile::render(ProgressCallback *cb)
 
                        Context context;
 
-                       #ifdef SYNFIG_OPTIMIZE_LAYER_TREE
-                       Canvas::Handle op_canvas(Canvas::create());
-                       optimize_layers(canvas->get_context(), op_canvas);
-                       context=op_canvas->get_context();
-                       #else
+#ifdef SYNFIG_OPTIMIZE_LAYER_TREE
+                       Canvas::Handle op_canvas;
+                       if (!getenv("SYNFIG_DISABLE_OPTIMIZE_LAYER_TREE"))
+                       {
+                               op_canvas = Canvas::create();
+                               op_canvas->set_file_name(canvas->get_file_name());
+                               optimize_layers(canvas->get_time(), canvas->get_context(), op_canvas);
+                               context=op_canvas->get_context();
+                       }
+                       else
+                               context=canvas->get_context();
+#else
                        context=canvas->get_context();
-                       #endif
+#endif
 
                        if(!render_frame_(context, cb))
                                return false;