Initialise a couple of values before using them.
[synfig.git] / synfig-core / trunk / src / synfig / target_scanline.cpp
index 23b86b3..49cff08 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 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
@@ -46,7 +47,7 @@ using namespace synfig;
 
 /* === M A C R O S ========================================================= */
 
-#define SYNFIG_OPTIMIZE_LAYER_TREE 1
+#define SYNFIG_OPTIMIZE_LAYER_TREE
 
 #define PIXEL_RENDERING_LIMIT 1500000
 
@@ -171,13 +172,20 @@ synfig::Target_Scanline::render(ProgressCallback *cb)
 
                Context context;
 
-               #ifdef SYNFIG_OPTIMIZE_LAYER_TREE
-               Canvas::Handle op_canvas(Canvas::create());
-               optimize_layers(canvas->get_time(), 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 the quality is set to zero, then we
                // use the parametric scanline-renderer.
@@ -305,13 +313,20 @@ synfig::Target_Scanline::render(ProgressCallback *cb)
                        canvas->set_time(t);
                Context context;
 
-               #ifdef SYNFIG_OPTIMIZE_LAYER_TREE
-               Canvas::Handle op_canvas(Canvas::create());
-               optimize_layers(canvas->get_time(), 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 the quality is set to zero, then we
                // use the parametric scanline-renderer.