Save/load frame images.

This commit is contained in:
Bartosz Taudul 2019-06-06 23:08:19 +02:00
parent 6ae4afa0f4
commit 6b2741ccdb
3 changed files with 69 additions and 3 deletions

View File

@ -7,7 +7,7 @@ namespace Version
{
enum { Major = 0 };
enum { Minor = 4 };
enum { Patch = 8 };
enum { Patch = 9 };
}
}

View File

@ -379,7 +379,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
uint64_t fsz;
f.Read( &fsz, sizeof( fsz ) );
ptr->frames.reserve_exact( fsz, m_slab );
if( fileVer >= FileVersion( 0, 4, 2 ) )
if( fileVer >= FileVersion( 0, 4, 9 ) )
{
int64_t refTime = 0;
if( ptr->continuous )
@ -388,6 +388,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
{
ptr->frames[j].start = ReadTimeOffset( f, refTime );
ptr->frames[j].end = -1;
f.Read( &ptr->frames[j].frameImage, sizeof( int32_t ) );
}
}
else
@ -396,6 +397,29 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
{
ptr->frames[j].start = ReadTimeOffset( f, refTime );
ptr->frames[j].end = ReadTimeOffset( f, refTime );
f.Read( &ptr->frames[j].frameImage, sizeof( int32_t ) );
}
}
}
else if( fileVer >= FileVersion( 0, 4, 2 ) )
{
int64_t refTime = 0;
if( ptr->continuous )
{
for( uint64_t j=0; j<fsz; j++ )
{
ptr->frames[j].start = ReadTimeOffset( f, refTime );
ptr->frames[j].end = -1;
ptr->frames[j].frameImage = -1;
}
}
else
{
for( uint64_t j=0; j<fsz; j++ )
{
ptr->frames[j].start = ReadTimeOffset( f, refTime );
ptr->frames[j].end = ReadTimeOffset( f, refTime );
ptr->frames[j].frameImage = -1;
}
}
}
@ -407,11 +431,17 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
{
f.Read( &ptr->frames[j].start, sizeof( int64_t ) );
ptr->frames[j].end = -1;
ptr->frames[j].frameImage = -1;
}
}
else
{
f.Read( ptr->frames.data(), sizeof( FrameEvent ) * fsz );
for( uint64_t j=0; j<fsz; j++ )
{
f.Read( &ptr->frames[j].start, sizeof( int64_t ) );
f.Read( &ptr->frames[j].end, sizeof( int64_t ) );
ptr->frames[j].frameImage = -1;
}
}
}
m_data.frames.Data()[i] = ptr;
@ -431,6 +461,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
{
f.Read( &ptr->frames[i].start, sizeof( int64_t ) );
ptr->frames[i].end = -1;
ptr->frames[i].frameImage = -1;
}
m_data.frames.Data().push_back( ptr );
m_data.framesBase = ptr;
@ -1198,6 +1229,29 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
}
}
if( fileVer >= FileVersion( 0, 4, 9 ) )
{
if( eventMask & EventType::FrameImages )
{
f.Read( sz );
m_data.frameImage.reserve_exact( sz, m_slab );
for( uint64_t i=0; i<sz; i++ )
{
auto fi = m_slab.Alloc<FrameImage>();
f.Read2( fi->w, fi->h );
const auto sz = fi->w * fi->h * 4;
auto ptr = (char*)m_slab.AllocBig( sz );
f.Read( ptr, sz );
fi->ptr = ptr;
m_data.frameImage[i] = fi;
}
}
else
{
// Implement skip, if more data is added after frame image section
}
}
finishLoading:
s_loadProgress.total.store( 0, std::memory_order_relaxed );
m_loadTime = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now() - loadStart ).count();
@ -4024,6 +4078,7 @@ void Worker::Write( FileWrite& f )
for( auto& fe : fd->frames )
{
WriteTimeOffset( f, refTime, fe.start );
f.Write( &fe.frameImage, sizeof( fe.frameImage ) );
}
}
else
@ -4032,6 +4087,7 @@ void Worker::Write( FileWrite& f )
{
WriteTimeOffset( f, refTime, fe.start );
WriteTimeOffset( f, refTime, fe.end );
f.Write( &fe.frameImage, sizeof( fe.frameImage ) );
}
}
}
@ -4254,6 +4310,15 @@ void Worker::Write( FileWrite& f )
f.Write( &frame.second->size, sizeof( frame.second->size ) );
f.Write( frame.second->data, sizeof( CallstackFrame ) * frame.second->size );
}
sz = m_data.frameImage.size();
f.Write( &sz, sizeof( sz ) );
for( auto& fi : m_data.frameImage )
{
f.Write( &fi->w, sizeof( fi->w ) );
f.Write( &fi->h, sizeof( fi->h ) );
f.Write( fi->ptr, fi->w * fi->h * 4 );
}
}
void Worker::WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t& refTime )

View File

@ -34,6 +34,7 @@ namespace EventType
Messages = 1 << 1,
Plots = 1 << 2,
Memory = 1 << 3,
FrameImages = 1 << 4,
None = 0,
All = std::numeric_limits<uint32_t>::max()