File indexing completed on 2025-01-18 10:03:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_FrameStats_HeaderFile
0015 #define _Graphic3d_FrameStats_HeaderFile
0016
0017 #include <Graphic3d_FrameStatsData.hxx>
0018 #include <Graphic3d_RenderingParams.hxx>
0019 #include <Standard_Type.hxx>
0020 #include <Standard_Transient.hxx>
0021 #include <TColStd_IndexedDataMapOfStringString.hxx>
0022
0023 class Graphic3d_CView;
0024
0025
0026 class Graphic3d_FrameStats : public Standard_Transient
0027 {
0028 DEFINE_STANDARD_RTTIEXT(Graphic3d_FrameStats, Standard_Transient)
0029 public:
0030
0031
0032 Standard_EXPORT Graphic3d_FrameStats();
0033
0034
0035 Standard_EXPORT virtual ~Graphic3d_FrameStats();
0036
0037
0038 Standard_Real UpdateInterval() const { return myUpdateInterval; }
0039
0040
0041 void SetUpdateInterval (Standard_Real theInterval) { myUpdateInterval = theInterval; }
0042
0043
0044 Standard_Boolean IsLongLineFormat() const { return myIsLongLineFormat; }
0045
0046
0047 void SetLongLineFormat (Standard_Boolean theValue) { myIsLongLineFormat = theValue; }
0048
0049
0050 Standard_EXPORT virtual void FrameStart (const Handle(Graphic3d_CView)& theView,
0051 bool theIsImmediateOnly);
0052
0053
0054 Standard_EXPORT virtual void FrameEnd (const Handle(Graphic3d_CView)& theView,
0055 bool theIsImmediateOnly);
0056
0057 public:
0058
0059
0060 Standard_EXPORT virtual TCollection_AsciiString FormatStats (Graphic3d_RenderingParams::PerfCounters theFlags) const;
0061
0062
0063 Standard_EXPORT virtual void FormatStats (TColStd_IndexedDataMapOfStringString& theDict,
0064 Graphic3d_RenderingParams::PerfCounters theFlags) const;
0065
0066
0067 Standard_Real FrameDuration() const { return myFrameDuration; }
0068
0069
0070
0071
0072 Standard_Real FrameRate() const { return LastDataFrame().FrameRate(); }
0073
0074
0075
0076
0077
0078
0079
0080 Standard_Real FrameRateCpu() const { return LastDataFrame().FrameRateCpu(); }
0081
0082
0083
0084 Standard_Size CounterValue (Graphic3d_FrameStatsCounter theCounter) const { return LastDataFrame()[theCounter]; }
0085
0086
0087
0088 Standard_Real TimerValue (Graphic3d_FrameStatsTimer theTimer) const { return LastDataFrame()[theTimer]; }
0089
0090
0091 Standard_Boolean HasCulledLayers() const { return LastDataFrame()[Graphic3d_FrameStatsCounter_NbLayersNotCulled] != LastDataFrame()[Graphic3d_FrameStatsCounter_NbLayers]; }
0092
0093
0094 Standard_Boolean HasCulledStructs() const { return LastDataFrame()[Graphic3d_FrameStatsCounter_NbStructsNotCulled] != LastDataFrame()[Graphic3d_FrameStatsCounter_NbStructs]; }
0095
0096
0097
0098 const Graphic3d_FrameStatsData& LastDataFrame() const { return myCounters.Value (myLastFrameIndex); }
0099
0100
0101 Standard_Integer LastDataFrameIndex() const { return myLastFrameIndex; }
0102
0103
0104 const NCollection_Array1<Graphic3d_FrameStatsData>& DataFrames() const { return myCounters; }
0105
0106
0107 NCollection_Array1<Graphic3d_FrameStatsData>& ChangeDataFrames() { return myCounters; }
0108
0109 public:
0110
0111
0112 Standard_Size& ChangeCounter (Graphic3d_FrameStatsCounter theCounter) { return ActiveDataFrame()[theCounter]; }
0113
0114
0115 Standard_Real& ChangeTimer (Graphic3d_FrameStatsTimer theTimer) { return ActiveDataFrame()[theTimer]; }
0116
0117
0118 Graphic3d_FrameStatsDataTmp& ActiveDataFrame() { return myCountersTmp; }
0119
0120 protected:
0121
0122
0123 virtual void updateStatistics (const Handle(Graphic3d_CView)& theView,
0124 bool theIsImmediateOnly) = 0;
0125
0126 protected:
0127
0128 OSD_Timer myFpsTimer;
0129 Standard_Real myFrameStartTime;
0130 Standard_Real myFrameDuration;
0131 Standard_Real myUpdateInterval;
0132 Standard_Size myFpsFrameCount;
0133 NCollection_Array1<Graphic3d_FrameStatsData> myCounters;
0134 Graphic3d_FrameStatsDataTmp myCountersTmp;
0135 Graphic3d_FrameStatsData myCountersMax;
0136 Standard_Integer myLastFrameIndex;
0137 Standard_Boolean myIsLongLineFormat;
0138
0139 };
0140
0141 #endif