X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Ftarget_tile.cpp;h=f02b71bc7620adf2039cd0eb51477f0a2bb53de1;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=f245ed4934e3356a82a00d4582902390479ad2be;hpb=49b7555d9c8ae6590a56b5dcc82f34ee8b025e34;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/target_tile.cpp b/synfig-core/trunk/src/synfig/target_tile.cpp index f245ed4..f02b71b 100644 --- a/synfig-core/trunk/src/synfig/target_tile.cpp +++ b/synfig-core/trunk/src/synfig/target_tile.cpp @@ -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 ======================================================= */ @@ -92,11 +100,11 @@ Target_Tile::next_frame(Time& time) frame_end=desc.get_frame_end(); time_start=desc.get_time_start(); time_end=desc.get_time_end(); - + // Calculate the number of frames total_frames=frame_end-frame_start; if(total_frames<=0)total_frames=1; - + //RendDesc rend_desc=desc; //rend_desc.set_gamma(1); @@ -124,7 +132,7 @@ Target_Tile::next_tile(int& x, int& y) // Add the last tiles (which will be clipped) if(rend_desc().get_w()%tile_w_!=0)tw++; if(rend_desc().get_h()%tile_h_!=0)th++; - + x=(curr_tile_%tw)*tile_h_; y=(curr_tile_/tw)*tile_w_; @@ -148,13 +156,13 @@ synfig::Target_Tile::render_frame_(Context context,ProgressCallback *cb) etl::clock::value_type find_tile_time(0); etl::clock::value_type add_tile_time(0); total_time.reset(); - + // If the quality is set to zero, then we // use the parametric scanline-renderer. if(get_quality()==0) { Surface surface; - + RendDesc tile_desc; int x,y,w,h; int i; @@ -200,7 +208,7 @@ synfig::Target_Tile::render_frame_(Context context,ProgressCallback *cb) if(get_remove_alpha()) for(int i=0;iamount_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,11 +316,11 @@ 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; } - + // If the description's end frame is equal to // the start frame, then it is assumed that we // are rendering only one frame. Correct it. @@ -322,53 +331,61 @@ synfig::Target_Tile::render(ProgressCallback *cb) frame_end=desc.get_frame_end(); time_start=desc.get_time_start(); time_end=desc.get_time_end(); - + // Calculate the number of frames total_frames=frame_end-frame_start; - - - + + + try { // Grab the time i=next_frame(t); - + //synfig::info("1time_set_to %s",t.get_string().c_str()); - + if(i>=1) { do { curr_tile_=0; - + // If we have a callback, and it returns // false, go ahead and bail. (maybe a use cancel) if(cb && !cb->amount_complete(total_frames-(i-1),total_frames)) return false; - + if(!start_frame(cb)) return false; // Set the time that we wish to render //if(!get_avoid_time_sync() || canvas->get_time()!=t) canvas->set_time(t); - + 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; @@ -377,7 +394,7 @@ synfig::Target_Tile::render(ProgressCallback *cb) context=canvas->get_context(); #endif */ - + if(!render_frame_(context,0)) return false; end_frame(); @@ -387,7 +404,7 @@ synfig::Target_Tile::render(ProgressCallback *cb) else { curr_tile_=0; - + if(!start_frame(cb)) return false; @@ -398,20 +415,27 @@ synfig::Target_Tile::render(ProgressCallback *cb) //synfig::info("2time_set_to %s",t.get_string().c_str()); 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; end_frame(); } - + } catch(String str) {