Gnash  0.8.10
PathParser.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018 
00019 #ifndef GNASH_PATH_PARSER_H
00020 #define GNASH_PATH_PARSER_H
00021 
00022 #include "Geometry.h"
00023 #include <vector>
00024 #include <deque>
00025 #include "SWFCxForm.h"
00026 
00027 namespace gnash
00028 {
00029 
00032 struct UnivocalPath
00033 {
00034   enum fill_type
00035   {
00036     FILL_RIGHT,
00037     FILL_LEFT
00038   };
00039   
00040   UnivocalPath() : _path(NULL), _fill_type(FILL_LEFT) {}
00041 
00042   UnivocalPath(const Path* path, fill_type filltype)
00043     : _path(path),
00044       _fill_type(filltype)
00045   {
00046   }
00047   
00048   const point& startPoint() const;
00049   const point& endPoint() const;
00050 
00051   const Path* _path;
00052   fill_type   _fill_type;
00053 };
00054 
00057 //
00060 class PathParser : boost::noncopyable
00061 {
00062 public:
00065   PathParser(const std::vector<Path>& paths, size_t num_styles);
00066 
00067   virtual ~PathParser() { }
00068 
00073   void run(const SWFCxForm& cx, const SWFMatrix& mat);
00074 
00077   virtual void prepareFill(int fill_style, const SWFCxForm& cx) = 0;
00078   
00082   virtual void terminateFill(int fill_style) = 0;
00083   
00088   virtual void fillShape()
00089   {
00090   }
00091   
00095   virtual void moveTo(const point& p) = 0;
00096   
00098   virtual void curveTo(const Edge& curve) = 0;
00099 
00101   virtual void lineTo(const point& p) = 0;
00102 
00103 private:
00104   std::deque<UnivocalPath>::iterator emitConnecting(std::deque<UnivocalPath>& paths);
00105     
00106   void append(const UnivocalPath& append_path);
00107   
00108   void start_shapes(int fill_style, const SWFCxForm& cx);
00109 
00110   void end_shapes(int fill_style);
00111 
00112   void reset_shape(const UnivocalPath& append_path);
00113   
00114   bool closed_shape();
00115 
00116   void line_to(const Edge& curve);
00117 
00118   const std::vector<Path>& _paths;
00119   const size_t             _num_styles;
00120   point       _shape_origin;
00121   point       _cur_endpoint;
00122 };
00123 
00124 }
00125 
00126 #endif // __PATH_PARSER_H