X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftags%2Fstable%2Fsrc%2Fsynfig%2Ftarget.cpp;fp=synfig-core%2Ftags%2Fstable%2Fsrc%2Fsynfig%2Ftarget.cpp;h=a6c75a940c2364c676cb565f0f6c185c0206015e;hb=d3408370fc3297609b3aa8d4ff7edf1f238df251;hp=0000000000000000000000000000000000000000;hpb=9f067badc4463e2ad6363dfe9b8c4fc28b0ec503;p=synfig.git diff --git a/synfig-core/tags/stable/src/synfig/target.cpp b/synfig-core/tags/stable/src/synfig/target.cpp new file mode 100644 index 0000000..a6c75a9 --- /dev/null +++ b/synfig-core/tags/stable/src/synfig/target.cpp @@ -0,0 +1,113 @@ +/* === S Y N F I G ========================================================= */ +/*! \file target.cpp +** \brief Target Class Implementation +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#define SYNFIG_NO_ANGLE + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "target.h" +#include "string.h" +#include "canvas.h" +#include "target_null.h" +#include "target_null_tile.h" + +using namespace synfig; +using namespace etl; +using namespace std; + +synfig::Target::Book* synfig::Target::book_; +synfig::Target::ExtBook* synfig::Target::ext_book_; + +static synfig::Gamma* default_gamma_; + +/* === P R O C E D U R E S ================================================= */ + +bool +Target::subsys_init() +{ + book_=new synfig::Target::Book(); + ext_book_=new synfig::Target::ExtBook(); + + default_gamma_=new synfig::Gamma(1.0/2.2); + //default_gamma_->set_black_level(0.05); // Default to 5% black level. + + book()["null"]=std::pair(Target_Null::create,"null"); + ext_book()["null"]="null"; + book()["null-tile"]=std::pair(Target_Null_Tile::create,"null-tile"); + ext_book()["null-tile"]="null-tile"; + + return true; +} + +bool +Target::subsys_stop() +{ + delete book_; + delete ext_book_; + delete default_gamma_; + return true; +} + +Target::Book& +Target::book() +{ + return *book_; +} + +Target::ExtBook& +Target::ext_book() +{ + return *ext_book_; +} + + +/* === M E T H O D S ======================================================= */ + +Target::Target(): + quality_(4), + gamma_(*default_gamma_), + remove_alpha(false), + avoid_time_sync_(false) +{ +} + +void +synfig::Target::set_canvas(Canvas::Handle c) +{ + canvas=c; + RendDesc desc=canvas->rend_desc(); + set_rend_desc(&desc); +} + + +Target::Handle +Target::create(const String &name, const String &filename) +{ + if(!book().count(name)) + return handle(); + + return Target::Handle(book()[name].first(filename.c_str())); +}