1#pragma once
2
3#include "container/seadBuffer.h"
4#include "container/seadSafeArray.h"
5#include "gfx/seadColor.h"
6#include "heap/seadDisposer.h"
7#include "prim/seadNamable.h"
8#include "prim/seadSafeString.h"
9#include "time/seadTickTime.h"
10
11namespace sead
12{
13class ProcessMeter;
14
15class ProcessMeterBarBase : public IDisposer, public INamable
16{
17public:
18 struct Section
19 {
20 TickTime time;
21 TickSpan span;
22 Color4f color;
23 s32 parent;
24 };
25
26 ProcessMeterBarBase(Section* sections, s32 num_sections, const SafeString& name,
27 const Color4f& color);
28 ~ProcessMeterBarBase() override;
29
30 void measureBegin();
31 void measureBegin(const TickTime& start_time);
32 void measureBegin(const Color4f& color);
33 void measureBegin(const TickTime& start_time, const Color4f& color);
34
35 void measureEnd();
36 void measureEnd(const TickTime& end_time);
37
38 const Section* getLastFirstBegin() const;
39 TickSpan getLastTotalSpan() const;
40
41 void onEndFrame();
42
43 ProcessMeter* getParentProcessMeter() const { return mParent; }
44 void setParentProcessMeter(ProcessMeter* parent);
45
46 void setColor(const Color4f& color) { mColor = color; }
47
48protected:
49 void measureBeginImpl_(const TickTime& start_time, Color4f color);
50 void measureEndImpl_(const TickTime& end_time);
51
52 void addSection_(const TickTime& time, Color4f color, s32 parent);
53 Section* getCurSection_(s32 idx);
54 void endSection_(s32 idx, const TickTime& time);
55
56 void* _30 = nullptr;
57 void* _38 = nullptr;
58 ProcessMeter* mParent = nullptr;
59 Color4f mColor;
60 SafeArray<Buffer<Section>, 2> mSectionList;
61 SafeArray<TickTime, 2> mTicks;
62 SafeArray<s32, 2> _88;
63 s32 mActiveBufferIdx = 0;
64 s32 mTopSection = -1;
65 s32 mOverNum = 0;
66 bool mEnabled = false;
67};
68
69template <s32 N>
70class MultiProcessMeterBar : public ProcessMeterBarBase
71{
72public:
73 MultiProcessMeterBar(const SafeString& name = SafeString::cEmptyString,
74 const Color4f& color = Color4f::cRed)
75 : ProcessMeterBarBase(mSections, N, name, color)
76 {
77 }
78
79private:
80 Section mSections[2 * N];
81};
82} // namespace sead
83