Blame synfig-core/src/synfig/target_tile.h

Carlos Lopez a09598
/* === S Y N F I G ========================================================= */
Carlos Lopez a09598
/*!	\file target_tile.h
Carlos Lopez a09598
**	\brief Template Header
Carlos Lopez a09598
**
Carlos Lopez a09598
**	$Id$
Carlos Lopez a09598
**
Carlos Lopez a09598
**	\legal
Carlos Lopez a09598
**	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
Carlos Lopez a09598
**	Copyright (c) 2008 Chris Moore
Carlos Lopez e83454
**	Copyright (c) 2012-2013 Carlos Lรณpez
Carlos Lopez a09598
**
Carlos Lopez a09598
**	This package is free software; you can redistribute it and/or
Carlos Lopez a09598
**	modify it under the terms of the GNU General Public License as
Carlos Lopez a09598
**	published by the Free Software Foundation; either version 2 of
Carlos Lopez a09598
**	the License, or (at your option) any later version.
Carlos Lopez a09598
**
Carlos Lopez a09598
**	This package is distributed in the hope that it will be useful,
Carlos Lopez a09598
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
Carlos Lopez a09598
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Carlos Lopez a09598
**	General Public License for more details.
Carlos Lopez a09598
**	\endlegal
Carlos Lopez a09598
*/
Carlos Lopez a09598
/* ========================================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
/* === S T A R T =========================================================== */
Carlos Lopez a09598
Carlos Lopez a09598
#ifndef __SYNFIG_TARGET_TILE_H
Carlos Lopez a09598
#define __SYNFIG_TARGET_TILE_H
Carlos Lopez a09598
Carlos Lopez a09598
/* === H E A D E R S ======================================================= */
Carlos Lopez a09598
Carlos Lopez a09598
#include "target.h"
Carlos Lopez a09598
Carlos Lopez a09598
/* === M A C R O S ========================================================= */
Carlos Lopez a09598
4590f7
#define TILE_SIZE 64
Carlos Lopez a09598
Carlos Lopez a09598
/* === T Y P E D E F S ===================================================== */
Carlos Lopez a09598
Carlos Lopez a09598
/* === C L A S S E S & S T R U C T S ======================================= */
Carlos Lopez a09598
Carlos Lopez a09598
namespace synfig {
Carlos Lopez a09598
5e2754
namespace rendering { class SurfaceResource; }
371bd9
Carlos Lopez a09598
/*!	\class Target_Tile
Carlos Lopez a09598
**	\brief Render-target
Carlos Lopez a09598
**	\todo writeme
Carlos Lopez a09598
*/
Carlos Lopez a09598
class Target_Tile : public Target
Carlos Lopez a09598
{
Carlos Lopez b2ebf2
	//! Number of threads
Carlos Lopez a09598
	int threads_;
Carlos Lopez b2ebf2
	//! Tile width in pixels
Carlos Lopez a09598
	int tile_w_;
Carlos Lopez b2ebf2
	//! Tile height in pixles
Carlos Lopez a09598
	int tile_h_;
Carlos Lopez b2ebf2
	//! The current tile being rendered
Carlos Lopez a09598
	int curr_tile_;
Carlos Lopez b2ebf2
	//! Determines if the tiles should be clipped to the redener description
Carlos Lopez b2ebf2
	//! or not
Carlos Lopez a09598
	bool clipping_;
874534
4590f7
	String engine_;
4590f7
874534
	struct TileGroup;
371bd9
a4bbdd
	bool call_renderer(
a4bbdd
		const etl::handle<rendering::surfaceresource> &surface,</rendering::surfaceresource>
a4bbdd
		Canvas &canvas,
a4bbdd
		const ContextParams &context_params,
a4bbdd
		const RendDesc &renddesc );
371bd9
Carlos Lopez a09598
public:
Carlos Lopez a09598
	typedef etl::handle<target_tile> Handle;</target_tile>
Carlos Lopez a09598
	typedef etl::loose_handle<target_tile> LooseHandle;</target_tile>
Carlos Lopez a09598
	typedef etl::handle<const target_tile=""> ConstHandle;</const>
Carlos Lopez a09598
Carlos Lopez a09598
	Target_Tile();
Carlos Lopez a09598
Carlos Lopez a09598
	//! Renders the canvas to the target
Carlos Lopez a09598
	virtual bool render(ProgressCallback *cb=NULL);
Carlos Lopez a09598
a4bbdd
	virtual bool async_render_tile(
a4bbdd
		etl::handle<canvas> canvas,</canvas>
a4bbdd
		ContextParams context_params,
a4bbdd
		RectInt rect,
a4bbdd
		RendDesc tile_desc,
a4bbdd
		ProgressCallback *cb);
4590f7
	virtual bool wait_render_tiles(ProgressCallback *cb=NULL);
4590f7
Carlos Lopez a09598
	//! Determines which tile needs to be rendered next.
Carlos Lopez a09598
	/*!	Most cases will not have to redefine this function.
Carlos Lopez a09598
	**	The default should be adequate in nearly all situations.
Carlos Lopez a09598
	**	\returns The number of tiles left to go plus one.
Carlos Lopez a09598
	**		This means that whenever this function returns zero,
Carlos Lopez a09598
	**		there are no more tiles to render and that any value
9f38ba
	**		in \a rect should be disregarded. */
9f38ba
	virtual int next_tile(RectInt& rect);
Carlos Lopez 4fdecc
	
Carlos Lopez b2ebf2
	//! Returns the number of peniding frames to render. If it is zero it
Carlos Lopez b2ebf2
	//! stops rendering frames.
Carlos Lopez a09598
	virtual int next_frame(Time& time);
Carlos Lopez a09598
Carlos Lopez a09598
	//! Adds the tile at \a x , \a y contained in \a surface
Carlos Lopez a09598
	virtual bool add_tile(const synfig::Surface &surface, int x, int y)=0;
Carlos Lopez a09598
Carlos Lopez a09598
	//! Marks the start of a frame
Carlos Lopez a09598
	/*! \return \c true on success, \c false upon an error.
Carlos Lopez a09598
	**	\see end_frame(), start_scanline()
Carlos Lopez a09598
	*/
Carlos Lopez a09598
	virtual bool start_frame(ProgressCallback *cb=NULL)=0;
Carlos Lopez a09598
Carlos Lopez a09598
	//! Marks the end of a frame
Carlos Lopez a09598
	/*! \see start_frame() */
Carlos Lopez a09598
	virtual void end_frame()=0;
Carlos Lopez b2ebf2
	//!Sets the number of threads
Carlos Lopez a09598
	void set_threads(int x) { threads_=x; }
Carlos Lopez b2ebf2
	//!Gets the number of threads
Carlos Lopez a09598
	int get_threads()const { return threads_; }
luz.paz 99f3ef
	//!Sets the tile width
Carlos Lopez a09598
	void set_tile_w(int w) { tile_w_=w; }
luz.paz 99f3ef
	//!Gets the tile width
Carlos Lopez a09598
	int get_tile_w()const { return tile_w_; }
Carlos Lopez b2ebf2
	//!Sets the tile height
Carlos Lopez a09598
	void set_tile_h(int h) { tile_h_=h; }
Carlos Lopez b2ebf2
	//!Gets the tile height
Carlos Lopez a09598
	int get_tile_h()const { return tile_h_; }
Carlos Lopez b2ebf2
	//! Gets clipping
Carlos Lopez a09598
	bool get_clipping()const { return clipping_; }
Carlos Lopez b2ebf2
	//! Sets clipping
Carlos Lopez a09598
	void set_clipping(bool x) { clipping_=x; }
4590f7
	//! Gets engine
4590f7
	const String& get_engine()const { return engine_; }
4590f7
	//! Sets engine
4590f7
	void set_engine(const String &x) { engine_=x; }
Carlos Lopez a09598
Carlos Lopez a09598
private:
Carlos Lopez b2ebf2
	//! Renders the context to the surface
a4bbdd
	bool render_frame_(etl::handle<canvas> canvas, ContextParams context_params, ProgressCallback *cb);</canvas>
Carlos Lopez a09598
Carlos Lopez a09598
}; // END of class Target_Tile
Carlos Lopez a09598
Carlos Lopez a09598
}; // END of namespace synfig
Carlos Lopez a09598
Carlos Lopez a09598
/* === E N D =============================================================== */
Carlos Lopez a09598
Carlos Lopez a09598
#endif