00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CULLBINMANAGER_H
00016 #define CULLBINMANAGER_H
00017
00018 #include "pandabase.h"
00019 #include "cullBin.h"
00020 #include "cullBinEnums.h"
00021 #include "pointerTo.h"
00022 #include "pvector.h"
00023 #include "pmap.h"
00024 #include "vector_int.h"
00025 #include "pStatCollector.h"
00026
00027 class CullResult;
00028 class GraphicsStateGuardianBase;
00029
00030
00031
00032
00033
00034
00035 class EXPCL_PANDA_PGRAPH CullBinManager : public CullBinEnums {
00036 protected:
00037 CullBinManager();
00038 ~CullBinManager();
00039
00040 PUBLISHED:
00041 typedef CullBin::BinType BinType;
00042
00043 int add_bin(const string &name, BinType type, int sort);
00044 void remove_bin(int bin_index);
00045
00046 INLINE int get_num_bins() const;
00047 INLINE int get_bin(int n) const;
00048 MAKE_SEQ(get_bins, get_num_bins, get_bin);
00049 int find_bin(const string &name) const;
00050
00051 INLINE string get_bin_name(int bin_index) const;
00052
00053 INLINE BinType get_bin_type(int bin_index) const;
00054 INLINE BinType get_bin_type(const string &name) const;
00055 INLINE void set_bin_type(int bin_index, BinType type);
00056 INLINE void set_bin_type(const string &name, BinType type);
00057
00058 INLINE int get_bin_sort(int bin_index) const;
00059 INLINE int get_bin_sort(const string &name) const;
00060 INLINE void set_bin_sort(int bin_index, int sort);
00061 INLINE void set_bin_sort(const string &name, int sort);
00062
00063 INLINE bool get_bin_active(int bin_index) const;
00064 INLINE bool get_bin_active(const string &name) const;
00065 INLINE void set_bin_active(int bin_index, bool active);
00066 INLINE void set_bin_active(const string &name, bool active);
00067
00068 void write(ostream &out) const;
00069
00070 static CullBinManager *get_global_ptr();
00071
00072 public:
00073
00074 PT(CullBin) make_new_bin(int bin_index, GraphicsStateGuardianBase *gsg,
00075 const PStatCollector &draw_region_pcollector);
00076
00077
00078
00079
00080 typedef CullBin *BinConstructor(const string &name,
00081 GraphicsStateGuardianBase *gsg,
00082 const PStatCollector &draw_region_pcollector);
00083
00084 void register_bin_type(BinType type, BinConstructor *constructor);
00085
00086 private:
00087 void do_sort_bins();
00088 void setup_initial_bins();
00089 static BinType parse_bin_type(const string &bin_type);
00090
00091 class EXPCL_PANDA_PGRAPH BinDefinition {
00092 public:
00093 bool _in_use;
00094 string _name;
00095 BinType _type;
00096 int _sort;
00097 bool _active;
00098 };
00099 typedef pvector<BinDefinition> BinDefinitions;
00100 BinDefinitions _bin_definitions;
00101
00102 class SortBins {
00103 public:
00104 INLINE SortBins(CullBinManager *manager);
00105 INLINE bool operator () (int a, int b) const;
00106 CullBinManager *_manager;
00107 };
00108
00109 typedef pmap<string, int> BinsByName;
00110 BinsByName _bins_by_name;
00111
00112 typedef vector_int SortedBins;
00113 SortedBins _sorted_bins;
00114 bool _bins_are_sorted;
00115 bool _unused_bin_index;
00116
00117 typedef pmap<BinType, BinConstructor *> BinConstructors;
00118 BinConstructors _bin_constructors;
00119
00120 static CullBinManager *_global_ptr;
00121 friend class SortBins;
00122 };
00123
00124 EXPCL_PANDA_PGRAPH ostream &
00125 operator << (ostream &out, CullBinManager::BinType bin_type);
00126
00127 #include "cullBinManager.I"
00128
00129 #endif