File indexing completed on 2026-10-08 09:32:13
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 <TCollection_AsciiString.hxx>
0022 #include <NCollection_IndexedDataMap.hxx>
0023
0024 class Graphic3d_CView;
0025
0026
0027 class Graphic3d_FrameStats : public Standard_Transient
0028 {
0029 DEFINE_STANDARD_RTTIEXT(Graphic3d_FrameStats, Standard_Transient)
0030 public:
0031
0032 Standard_EXPORT Graphic3d_FrameStats();
0033
0034
0035 Standard_EXPORT ~Graphic3d_FrameStats() override;
0036
0037
0038 double UpdateInterval() const { return myUpdateInterval; }
0039
0040
0041 void SetUpdateInterval(double theInterval) { myUpdateInterval = theInterval; }
0042
0043
0044 bool IsLongLineFormat() const { return myIsLongLineFormat; }
0045
0046
0047 void SetLongLineFormat(bool theValue) { myIsLongLineFormat = theValue; }
0048
0049
0050 Standard_EXPORT virtual void FrameStart(const occ::handle<Graphic3d_CView>& theView,
0051 bool theIsImmediateOnly);
0052
0053
0054 Standard_EXPORT virtual void FrameEnd(const occ::handle<Graphic3d_CView>& theView,
0055 bool theIsImmediateOnly);
0056
0057 public:
0058
0059 Standard_EXPORT virtual TCollection_AsciiString FormatStats(
0060 Graphic3d_RenderingParams::PerfCounters theFlags) const;
0061
0062
0063 Standard_EXPORT virtual void FormatStats(
0064 NCollection_IndexedDataMap<TCollection_AsciiString, TCollection_AsciiString>& theDict,
0065 Graphic3d_RenderingParams::PerfCounters theFlags) const;
0066
0067
0068 double FrameDuration() const { return myFrameDuration; }
0069
0070
0071
0072
0073 double FrameRate() const { return LastDataFrame().FrameRate(); }
0074
0075
0076
0077
0078
0079
0080
0081
0082 double FrameRateCpu() const { return LastDataFrame().FrameRateCpu(); }
0083
0084
0085
0086 size_t CounterValue(Graphic3d_FrameStatsCounter theCounter) const
0087 {
0088 return LastDataFrame()[theCounter];
0089 }
0090
0091
0092
0093 double TimerValue(Graphic3d_FrameStatsTimer theTimer) const { return LastDataFrame()[theTimer]; }
0094
0095
0096 bool HasCulledLayers() const
0097 {
0098 return LastDataFrame()[Graphic3d_FrameStatsCounter_NbLayersNotCulled]
0099 != LastDataFrame()[Graphic3d_FrameStatsCounter_NbLayers];
0100 }
0101
0102
0103 bool HasCulledStructs() const
0104 {
0105 return LastDataFrame()[Graphic3d_FrameStatsCounter_NbStructsNotCulled]
0106 != LastDataFrame()[Graphic3d_FrameStatsCounter_NbStructs];
0107 }
0108
0109
0110
0111 const Graphic3d_FrameStatsData& LastDataFrame() const
0112 {
0113 return myCounters.Value(myLastFrameIndex);
0114 }
0115
0116
0117 int LastDataFrameIndex() const { return myLastFrameIndex; }
0118
0119
0120 const NCollection_Array1<Graphic3d_FrameStatsData>& DataFrames() const { return myCounters; }
0121
0122
0123 NCollection_Array1<Graphic3d_FrameStatsData>& ChangeDataFrames() { return myCounters; }
0124
0125 public:
0126
0127
0128 size_t& ChangeCounter(Graphic3d_FrameStatsCounter theCounter)
0129 {
0130 return ActiveDataFrame()[theCounter];
0131 }
0132
0133
0134
0135 double& ChangeTimer(Graphic3d_FrameStatsTimer theTimer) { return ActiveDataFrame()[theTimer]; }
0136
0137
0138
0139 Graphic3d_FrameStatsDataTmp& ActiveDataFrame() { return myCountersTmp; }
0140
0141 protected:
0142
0143 virtual void updateStatistics(const occ::handle<Graphic3d_CView>& theView,
0144 bool theIsImmediateOnly) = 0;
0145
0146 protected:
0147 OSD_Timer myFpsTimer;
0148 double myFrameStartTime;
0149 double myFrameDuration;
0150 double myUpdateInterval;
0151
0152 size_t myFpsFrameCount;
0153 NCollection_Array1<Graphic3d_FrameStatsData> myCounters;
0154 Graphic3d_FrameStatsDataTmp myCountersTmp;
0155 Graphic3d_FrameStatsData myCountersMax;
0156 int myLastFrameIndex;
0157 bool myIsLongLineFormat;
0158
0159 };
0160
0161 #endif