Allow adding timeline items to TimelineController.

TimelineItem class is basically an expansion of the previous VisData
structure. After the transition process is finished the VisData map will be
removed, as it will no longer have any function.
This commit is contained in:
Bartosz Taudul 2022-09-03 16:41:17 +02:00
parent 449dff0eca
commit 8034fce416
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -1,8 +1,11 @@
#ifndef __TRACYTIMELINECONTROLLER_HPP__ #ifndef __TRACYTIMELINECONTROLLER_HPP__
#define __TRACYTIMELINECONTROLLER_HPP__ #define __TRACYTIMELINECONTROLLER_HPP__
#include <vector>
#include "../public/common/TracyForceInline.hpp" #include "../public/common/TracyForceInline.hpp"
#include "tracy_robin_hood.h" #include "tracy_robin_hood.h"
#include "TracyTimelineItem.hpp"
namespace tracy namespace tracy
{ {
@ -24,6 +27,14 @@ public:
void FirstFrameExpired(); void FirstFrameExpired();
void End( float offset ); void End( float offset );
template<class T, class U>
void AddItem( U* data )
{
auto it = m_itemMap.find( data );
if( it == m_itemMap.end() ) it = m_itemMap.emplace( data, std::make_unique<T>( m_view, m_worker, data ) ).first;
m_items.emplace_back( it->second.get() );
}
float GetHeight() const { return m_height; } float GetHeight() const { return m_height; }
const unordered_flat_map<const void*, VisData>& GetVisData() const { return m_visData; } const unordered_flat_map<const void*, VisData>& GetVisData() const { return m_visData; }
@ -41,6 +52,9 @@ public:
} }
private: private:
std::vector<TimelineItem*> m_items;
unordered_flat_map<const void*, std::unique_ptr<TimelineItem>> m_itemMap;
unordered_flat_map<const void*, VisData> m_visData; unordered_flat_map<const void*, VisData> m_visData;
float m_height; float m_height;