mirror of
https://github.com/wolfpld/tracy.git
synced 2026-08-25 04:28:22 +00:00
Save/load view state.
This commit is contained in:
@@ -3,11 +3,15 @@
|
||||
|
||||
#include "TracyStorage.hpp"
|
||||
#include "TracyUserData.hpp"
|
||||
#include "TracyViewData.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
constexpr auto FileDescription = "description";
|
||||
constexpr auto FileTimeline = "timeline";
|
||||
|
||||
enum : uint32_t { VersionTimeline = 0 };
|
||||
|
||||
UserData::UserData()
|
||||
: m_preserveState( false )
|
||||
@@ -53,6 +57,34 @@ bool UserData::SetDescription( const char* description )
|
||||
return true;
|
||||
}
|
||||
|
||||
void UserData::LoadState( ViewData& data )
|
||||
{
|
||||
assert( Valid() );
|
||||
FILE* f = OpenFile( FileTimeline, false );
|
||||
if( !f ) return;
|
||||
uint32_t ver;
|
||||
fread( &ver, 1, sizeof( ver ), f );
|
||||
if( ver == VersionTimeline )
|
||||
{
|
||||
fread( &data.zvStart, 1, sizeof( data.zvStart ), f );
|
||||
fread( &data.zvEnd, 1, sizeof( data.zvEnd ), f );
|
||||
}
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
void UserData::SaveState( const ViewData& data )
|
||||
{
|
||||
if( !m_preserveState ) return;
|
||||
assert( Valid() );
|
||||
FILE* f = OpenFile( FileTimeline, true );
|
||||
if( !f ) return;
|
||||
uint32_t ver = VersionTimeline;
|
||||
fwrite( &ver, 1, sizeof( ver ), f );
|
||||
fwrite( &data.zvStart, 1, sizeof( data.zvStart ), f );
|
||||
fwrite( &data.zvEnd, 1, sizeof( data.zvEnd ), f );
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
void UserData::StateShouldBePreserved()
|
||||
{
|
||||
m_preserveState = true;
|
||||
|
||||
Reference in New Issue
Block a user