Move file compression enum out of FileWrite.

This commit is contained in:
Bartosz Taudul 2024-05-31 19:24:32 +02:00
parent 07c6e12dbf
commit 9dea830f98
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
6 changed files with 26 additions and 26 deletions

View File

@ -50,7 +50,7 @@ int main( int argc, char** argv )
}
#endif
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
tracy::FileCompression clev = tracy::FileCompression::Fast;
if( argc != 3 ) Usage();

View File

@ -381,7 +381,7 @@ int main(int argc, char **argv) {
}
#endif
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
tracy::FileCompression clev = tracy::FileCompression::Fast;
if (argc != 3)
Usage();

View File

@ -551,7 +551,7 @@ bool View::Draw()
ImGui::PopFont();
ImGui::Separator();
static FileWrite::Compression comp = FileWrite::Compression::Fast;
static FileCompression comp = FileCompression::Fast;
static int zlvl = 6;
ImGui::TextUnformatted( ICON_FA_FILE_ZIPPER " Trace compression" );
ImGui::SameLine();
@ -560,7 +560,7 @@ bool View::Draw()
int idx = 0;
while( CompressionName[idx] )
{
if( ImGui::RadioButton( CompressionName[idx], (int)comp == idx ) ) comp = (FileWrite::Compression)idx;
if( ImGui::RadioButton( CompressionName[idx], (int)comp == idx ) ) comp = (FileCompression)idx;
ImGui::SameLine();
TextDisabledUnformatted( CompressionDesc[idx] );
idx++;
@ -572,7 +572,7 @@ bool View::Draw()
ImGui::Indent();
if( ImGui::SliderInt( "##zstd", &zlvl, 1, 22, "%d", ImGuiSliderFlags_AlwaysClamp ) )
{
comp = FileWrite::Compression::Zstd;
comp = FileCompression::Zstd;
}
ImGui::Unindent();
@ -1340,7 +1340,7 @@ void View::DrawSourceTooltip( const char* filename, uint32_t srcline, int before
ImGui::PopStyleVar();
}
bool View::Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict )
bool View::Save( const char* fn, FileCompression comp, int zlevel, bool buildDict )
{
std::unique_ptr<FileWrite> f( FileWrite::Open( fn, comp, zlevel ) );
if( !f ) return false;

View File

@ -367,7 +367,7 @@ private:
void CalcZoneTimeDataImpl( const V& children, const ContextSwitch* ctx, unordered_flat_map<int16_t, ZoneTimeData>& data, int64_t& ztime );
void SetPlaybackFrame( uint32_t idx );
bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict );
bool Save( const char* fn, FileCompression comp, int zlevel, bool buildDict );
void Attention( bool& alreadyDone );
void UpdateTitle();

View File

@ -20,18 +20,18 @@
namespace tracy
{
class FileWrite
enum class FileCompression
{
public:
enum class Compression
{
Fast,
Slow,
Extreme,
Zstd
};
};
static FileWrite* Open( const char* fn, Compression comp = Compression::Fast, int level = 1 )
class FileWrite
{
public:
static FileWrite* Open( const char* fn, FileCompression comp = FileCompression::Fast, int level = 1 )
{
auto f = fopen( fn, "wb" );
return f ? new FileWrite( f, comp, level ) : nullptr;
@ -67,7 +67,7 @@ public:
std::pair<size_t, size_t> GetCompressionStatistics() const { return std::make_pair( m_srcBytes, m_dstBytes ); }
private:
FileWrite( FILE* f, Compression comp, int level )
FileWrite( FILE* f, FileCompression comp, int level )
: m_stream( nullptr )
, m_streamHC( nullptr )
, m_streamZstd( nullptr )
@ -80,17 +80,17 @@ private:
{
switch( comp )
{
case Compression::Fast:
case FileCompression::Fast:
m_stream = LZ4_createStream();
break;
case Compression::Slow:
case FileCompression::Slow:
m_streamHC = LZ4_createStreamHC();
break;
case Compression::Extreme:
case FileCompression::Extreme:
m_streamHC = LZ4_createStreamHC();
LZ4_resetStreamHC( m_streamHC, LZ4HC_CLEVEL_MAX );
break;
case Compression::Zstd:
case FileCompression::Zstd:
m_streamZstd = ZSTD_createCStream();
ZSTD_CCtx_setParameter( m_streamZstd, ZSTD_c_compressionLevel, level );
ZSTD_CCtx_setParameter( m_streamZstd, ZSTD_c_contentSizeFlag, 0 );
@ -100,7 +100,7 @@ private:
break;
}
if( comp == Compression::Zstd )
if( comp == FileCompression::Zstd )
{
fwrite( ZstdHeader, 1, sizeof( ZstdHeader ), m_file );
}

View File

@ -50,7 +50,7 @@ int main( int argc, char** argv )
}
#endif
tracy::FileWrite::Compression clev = tracy::FileWrite::Compression::Fast;
tracy::FileCompression clev = tracy::FileCompression::Fast;
uint32_t events = tracy::EventType::All;
int zstdLevel = 1;
bool buildDict = false;
@ -64,13 +64,13 @@ int main( int argc, char** argv )
switch( c )
{
case 'h':
clev = tracy::FileWrite::Compression::Slow;
clev = tracy::FileCompression::Slow;
break;
case 'e':
clev = tracy::FileWrite::Compression::Extreme;
clev = tracy::FileCompression::Extreme;
break;
case 'z':
clev = tracy::FileWrite::Compression::Zstd;
clev = tracy::FileCompression::Zstd;
zstdLevel = atoi( optarg );
if( zstdLevel > ZSTD_maxCLevel() || zstdLevel < ZSTD_minCLevel() )
{