1 // rendererAST.h 2 // this file is part of Context Free 3 // --------------------- 4 // Copyright (C) 2013-2014 John Horigan - john@glyphic.com 5 // 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 // 20 // John Horigan can be contacted at john@glyphic.com or at 21 // John Horigan, 1209 Villa St., Mountain View, CA 94041-1123, USA 22 // 23 // 24 25 #ifndef INCLUDE_RENDERERAST_H 26 #define INCLUDE_RENDERERAST_H 27 28 #include "cfdg.h" 29 #include "CmdInfo.h" 30 #include <array> 31 #include <cstddef> 32 33 class RendererAST : public Renderer { 34 public: 35 // AST interface 36 ~RendererAST(); 37 std::array<StackType, 8192> mCFstack; 38 const StackType* mLogicalStackTop; 39 std::size_t mStackSize; 40 void initStack(const StackRule* p); 41 void unwindStack(std::size_t oldsize, const std::vector<AST::ASTparameter>& params); stackItem(int offset)42 const StackType* stackItem(int offset) const { 43 return (offset < 0) ? (mLogicalStackTop + offset) : (mCFstack.data() + offset); 44 } 45 46 Rand64 mCurrentSeed; 47 bool mRandUsed; 48 49 double mMaxNatural; 50 bool mImpure; 51 52 double mCurrentTime; 53 double mCurrentFrame; 54 55 agg::point_d mLastPoint; 56 bool mStop; 57 bool mClosed; 58 bool mWantMoveTo; 59 bool mWantCommand; 60 bool mOpsOnly; 61 unsigned mIndex; 62 unsigned mNextIndex; 63 AST::cpath_ptr mCurrentPath; 64 AST::InfoCache::iterator mCurrentCommand; 65 66 void init(); 67 static bool isNatural(RendererAST* r, double n); 68 static void ColorConflict(RendererAST* r, const yy::location& w); 69 virtual void processPathCommand(const Shape& s, const AST::CommandInfo* attr) = 0; 70 virtual void processShape(Shape& s) = 0; 71 virtual void processPrimShape(Shape& s, const AST::ASTrule* attr = nullptr) = 0; 72 virtual void processSubpath(const Shape& s, bool tr, int) = 0; 73 74 protected: 75 RendererAST(int w, int h); 76 virtual void colorConflict(const yy::location& w) = 0; 77 }; 78 79 #endif // INCLUDE_RENDERERAST_H 80