/*! \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
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;
#define SYNFIG_OPTIMIZE_LAYER_TREE 1
#ifdef _DEBUG
-#define SYNFIG_DISPLAY_EFFICIENCY 1
+// #define SYNFIG_DISPLAY_EFFICIENCY 1
#endif
/* === G L O B A L S ======================================================= */
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);
// 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_;
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;
if(get_remove_alpha())
for(int i=0;i<surface.get_w()*surface.get_h();i++)
surface[0][i]=Color::blend(surface[0][i],desc.get_bg_color(),1.0f);
-
+
// Add the tile to the target
if(!add_tile(surface,x,y))
{
else // If quality is set otherwise, then we use the accelerated renderer
{
Surface surface;
-
+
RendDesc tile_desc;
int x,y,w,h;
int i;
tile_desc=rend_desc;
tile_desc.set_subwindow(x,y,w,h);
-
+
etl::clock timer2;
timer2.reset();
-
+
if(!context.accelerated_render(&surface,get_quality(),tile_desc,&super))
{
// For some reason, the accelerated renderer failed.
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
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;
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.
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);
+ 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();
#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;
context=canvas->get_context();
#endif
*/
-
+
if(!render_frame_(context,0))
return false;
end_frame();
else
{
curr_tile_=0;
-
+
if(!start_frame(cb))
return false;
//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);
+ 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();
#endif
-
+
if(!render_frame_(context, cb))
return false;
end_frame();
}
-
+
}
catch(String str)
{