TuttleOFX
1
|
00001 #ifndef _TUTTLE_PLUGIN_TEXT_PROCESS_HPP_ 00002 #define _TUTTLE_PLUGIN_TEXT_PROCESS_HPP_ 00003 00004 #include <tuttle/plugin/ImageGilProcessor.hpp> 00005 00006 #include <terry/freetype/freegil.hpp> 00007 #include <boost/gil/typedefs.hpp> 00008 00009 #include <boost/ptr_container/ptr_vector.hpp> 00010 #include <boost/scoped_ptr.hpp> 00011 00012 namespace tuttle { 00013 namespace plugin { 00014 namespace text { 00015 00016 /** 00017 * @brief Text process 00018 * 00019 */ 00020 template<class View, class Functor> 00021 class TextProcess : public ImageGilProcessor<View> 00022 { 00023 public: 00024 typedef typename View::value_type Pixel; 00025 typedef terry::rgb8_pixel_t text_pixel_t; 00026 struct glyph_t 00027 { 00028 char ch; 00029 FT_Face face; 00030 }; 00031 00032 /** 00033 * to be used with boost::ptr_container 00034 */ 00035 struct make_glyph 00036 { 00037 FT_Face _face; 00038 00039 make_glyph( FT_Face face ) : _face( face ) {} 00040 00041 glyph_t* operator()( char ch ) 00042 { 00043 glyph_t* u = new glyph_t(); 00044 00045 u->ch = ch; 00046 u->face = _face; 00047 return u; 00048 } 00049 00050 }; 00051 00052 protected: 00053 00054 OFX::Clip* _clipSrc; ///< Source image clip 00055 boost::scoped_ptr<OFX::Image> _src; 00056 OfxRectI _srcPixelRod; 00057 View _srcView; ///< @brief source clip (filters have only one input) 00058 00059 TextPlugin& _plugin; ///< Rendering plugin 00060 std::vector<FT_Glyph_Metrics> _metrics; 00061 std::vector<int> _kerning; 00062 boost::ptr_vector<glyph_t> _glyphs; 00063 View _dstViewForGlyphs; 00064 boost::gil::point2<int> _textCorner; 00065 boost::gil::point2<int> _textSize; 00066 Pixel _foregroundColor; 00067 TextProcessParams _params; 00068 std::string _text; 00069 00070 public: 00071 TextProcess( TextPlugin& instance ); 00072 00073 void setup( const OFX::RenderArguments& args ); 00074 00075 void multiThreadProcessImages( const OfxRectI& procWindowRoW ); 00076 }; 00077 00078 } 00079 } 00080 } 00081 00082 #include "TextProcess.tcc" 00083 00084 #endif