Browse Source

use HAVE_* macros for dependencies

pull/114/head
nillerusr 2 years ago
parent
commit
c909de8faf
  1. 33
      common/imageutils.cpp
  2. 3
      engine/audio/private/voice_record_openal.cpp
  3. 2
      engine/downloadthread.cpp
  4. 4
      engine/sv_log.cpp
  5. 6
      engine/sys_getmodes.cpp
  6. 8
      game/client/vgui_fpspanel.cpp
  7. 8
      launcher/android/main.cpp
  8. 37
      vgui2/vgui_surfacelib/linuxfont.cpp

33
common/imageutils.cpp

@ -93,6 +93,8 @@ extern void longjmp( jmp_buf, int ) __attribute__((noreturn)); @@ -93,6 +93,8 @@ extern void longjmp( jmp_buf, int ) __attribute__((noreturn));
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
#if HAVE_JPEG
struct ValveJpegErrorHandler_t
{
// The default manager
@ -129,12 +131,12 @@ static void ValveJpegErrorHandler( j_common_ptr cinfo ) @@ -129,12 +131,12 @@ static void ValveJpegErrorHandler( j_common_ptr cinfo )
// Bail
longjmp( pError->m_ErrorContext, 1 );
}
#endif
// convert the JPEG file given to a TGA file at the given output path.
ConversionErrorType ImgUtl_ConvertJPEGToTGA( const char *jpegpath, const char *tgaPath, bool bRequirePowerOfTwo )
{
#if !defined( _X360 )
#if !defined( _X360 ) && HAVE_JPEG
//
// !FIXME! This really probably should use ImgUtl_ReadJPEGAsRGBA, to avoid duplicated code.
@ -485,7 +487,7 @@ unsigned char * ImgUtl_ReadTGAAsRGBA(const char *tgaPath, int &width, int &heigh @@ -485,7 +487,7 @@ unsigned char * ImgUtl_ReadTGAAsRGBA(const char *tgaPath, int &width, int &heigh
unsigned char *ImgUtl_ReadJPEGAsRGBA( const char *jpegPath, int &width, int &height, ConversionErrorType &errcode )
{
#if !defined( _X360 )
#if !defined( _X360 ) && HAVE_JPEG
struct jpeg_decompress_struct jpegInfo;
struct ValveJpegErrorHandler_t jerr;
JSAMPROW row_pointer[1];
@ -636,6 +638,7 @@ unsigned char *ImgUtl_ReadJPEGAsRGBA( const char *jpegPath, int &width, int &hei @@ -636,6 +638,7 @@ unsigned char *ImgUtl_ReadJPEGAsRGBA( const char *jpegPath, int &width, int &hei
#endif
}
#if HAVE_PNG
static void ReadPNGData( png_structp png_ptr, png_bytep outBytes, png_size_t byteCountToRead )
{
@ -654,11 +657,11 @@ static void ReadPNGData( png_structp png_ptr, png_bytep outBytes, png_size_t byt @@ -654,11 +657,11 @@ static void ReadPNGData( png_structp png_ptr, png_bytep outBytes, png_size_t byt
// Read the bytes
pBuf->Get( outBytes, byteCountToRead );
}
#endif
unsigned char *ImgUtl_ReadPNGAsRGBA( const char *pngPath, int &width, int &height, ConversionErrorType &errcode )
{
#if !defined( _X360 )
#if !defined( _X360 ) && HAVE_PNG
// Just load the whole file into a memory buffer
CUtlBuffer bufFileContents;
@ -679,7 +682,7 @@ unsigned char *ImgUtl_ReadPNGAsRGBA( const char *pngPath, int &width, int &heigh @@ -679,7 +682,7 @@ unsigned char *ImgUtl_ReadPNGAsRGBA( const char *pngPath, int &width, int &heigh
unsigned char *ImgUtl_ReadPNGAsRGBAFromBuffer( CUtlBuffer &buffer, int &width, int &height, ConversionErrorType &errcode )
{
#if !defined( _X360 )
#if !defined( _X360 ) && HAVE_PNG
png_const_bytep pngData = (png_const_bytep)buffer.Base();
if (png_sig_cmp( pngData, 0, 8))
@ -1844,6 +1847,7 @@ static void FlushPNGData( png_structp png_ptr ) @@ -1844,6 +1847,7 @@ static void FlushPNGData( png_structp png_ptr )
// We're writing to a memory buffer, it's a NOP
}
#if HAVE_PNG
ConversionErrorType ImgUtl_WriteRGBAAsPNGToBuffer( const unsigned char *pRGBAData, int nWidth, int nHeight, CUtlBuffer &bufOutData, int nStride )
{
#if !defined( _X360 )
@ -1927,11 +1931,13 @@ fail: @@ -1927,11 +1931,13 @@ fail:
return CE_SOURCE_FILE_FORMAT_NOT_SUPPORTED;
#endif
}
#endif
//-----------------------------------------------------------------------------
// Purpose: Initialize destination --- called by jpeg_start_compress
// before any data is actually written.
//-----------------------------------------------------------------------------
#if HAVE_JPEG
METHODDEF(void) init_destination (j_compress_ptr cinfo)
{
JPEGDestinationManager_t *dest = ( JPEGDestinationManager_t *) cinfo->dest;
@ -2012,12 +2018,14 @@ GLOBAL(void) jpeg_UtlBuffer_dest (j_compress_ptr cinfo, CUtlBuffer *pBuffer ) @@ -2012,12 +2018,14 @@ GLOBAL(void) jpeg_UtlBuffer_dest (j_compress_ptr cinfo, CUtlBuffer *pBuffer )
dest->pub.term_destination = term_destination;
dest->pBuffer = pBuffer;
}
#endif
//-----------------------------------------------------------------------------
// Purpose: Write three channel RGB data to a JPEG file
//-----------------------------------------------------------------------------
bool ImgUtl_WriteRGBToJPEG( unsigned char *pSrcBuf, unsigned int nSrcWidth, unsigned int nSrcHeight, const char *lpszFilename )
{
#if HAVE_JPEG
CUtlBuffer dstBuf;
JSAMPROW row_pointer[1]; // pointer to JSAMPLE row[s]
@ -2069,11 +2077,14 @@ bool ImgUtl_WriteRGBToJPEG( unsigned char *pSrcBuf, unsigned int nSrcWidth, unsi @@ -2069,11 +2077,14 @@ bool ImgUtl_WriteRGBToJPEG( unsigned char *pSrcBuf, unsigned int nSrcWidth, unsi
jpeg_destroy_compress(&cinfo);
return CE_SUCCESS;
#else
return CE_SOURCE_FILE_FORMAT_NOT_SUPPORTED;
#endif
}
ConversionErrorType ImgUtl_WriteRGBAAsJPEGToBuffer( const unsigned char *pRGBAData, int nWidth, int nHeight, CUtlBuffer &bufOutData, int nStride )
{
#if !defined( _X360 )
#if !defined( _X360 ) && HAVE_JPEG
JSAMPROW row_pointer[1]; // pointer to JSAMPLE row[s]
int row_stride; // physical row width in image buffer
@ -2214,6 +2225,7 @@ ConversionErrorType ImgUtl_SaveBitmapToBuffer( CUtlBuffer &fileData, const Bitma @@ -2214,6 +2225,7 @@ ConversionErrorType ImgUtl_SaveBitmapToBuffer( CUtlBuffer &fileData, const Bitma
ConversionErrorType ImgUtl_LoadPNGBitmapFromBuffer( CUtlBuffer &fileData, Bitmap_t &bitmap )
{
#if HAVE_PNG
bitmap.Clear();
ConversionErrorType nErrorCode;
int width, height;
@ -2226,10 +2238,14 @@ ConversionErrorType ImgUtl_LoadPNGBitmapFromBuffer( CUtlBuffer &fileData, Bitmap @@ -2226,10 +2238,14 @@ ConversionErrorType ImgUtl_LoadPNGBitmapFromBuffer( CUtlBuffer &fileData, Bitmap
// Install the buffer into the bitmap, and transfer ownership
bitmap.SetBuffer( width, height, IMAGE_FORMAT_RGBA8888, buffer, true, width*4 );
return CE_SUCCESS;
#else
return CE_SOURCE_FILE_FORMAT_NOT_SUPPORTED;
#endif
}
ConversionErrorType ImgUtl_SavePNGBitmapToBuffer( CUtlBuffer &fileData, const Bitmap_t &bitmap )
{
#if HAVE_PNG
if ( !bitmap.IsValid() )
{
Assert( bitmap.IsValid() );
@ -2252,6 +2268,9 @@ ConversionErrorType ImgUtl_SavePNGBitmapToBuffer( CUtlBuffer &fileData, const Bi @@ -2252,6 +2268,9 @@ ConversionErrorType ImgUtl_SavePNGBitmapToBuffer( CUtlBuffer &fileData, const Bi
bitmap.Stride()
);
return result;
#else
return CE_SOURCE_FILE_FORMAT_NOT_SUPPORTED;
#endif
}
ConversionErrorType ImgUtl_ResizeBitmap( Bitmap_t &destBitmap, int nWidth, int nHeight, const Bitmap_t *pImgSource )

3
engine/audio/private/voice_record_openal.cpp

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
//=============================================================================//
// This module implements the voice record and compression functions
#if HAVE_OPENAL
//#include "audio_pch.h"
//#include "voice.h"
#include "tier0/platform.h"
@ -207,3 +208,5 @@ IVoiceRecord* CreateVoiceRecord_OpenAL(int sampleRate) @@ -207,3 +208,5 @@ IVoiceRecord* CreateVoiceRecord_OpenAL(int sampleRate)
}
}
#endif
#endif

2
engine/downloadthread.cpp

@ -522,7 +522,7 @@ DWORD __stdcall DownloadThread( void *voidPtr ) @@ -522,7 +522,7 @@ DWORD __stdcall DownloadThread( void *voidPtr )
}
#elif defined( POSIX )
#elif defined( POSIX ) && HAVE_CURL
#include "curl/curl.h"

4
engine/sv_log.cpp

@ -713,6 +713,7 @@ static bool CreateTempFilename( TempFilename_t &info, const char *filenameBase, @@ -713,6 +713,7 @@ static bool CreateTempFilename( TempFilename_t &info, const char *filenameBase,
// Gzip Filename to Filename.gz.
static bool gzip_file_compress( const CUtlString &Filename )
{
#if HAVE_ZLIB
bool bRet = false;
// Try to find a unique temp filename.
@ -758,6 +759,9 @@ static bool gzip_file_compress( const CUtlString &Filename ) @@ -758,6 +759,9 @@ static bool gzip_file_compress( const CUtlString &Filename )
}
return bRet;
#else
return false;
#endif
}
static void FixupInvalidPathChars( char *filename )

6
engine/sys_getmodes.cpp

@ -1932,7 +1932,9 @@ static void VID_ProcessMovieFrame( const MovieInfo_t& info, bool jpeg, const cha @@ -1932,7 +1932,9 @@ static void VID_ProcessMovieFrame( const MovieInfo_t& info, bool jpeg, const cha
bool bSuccess = false;
if ( jpeg )
{
#if HAVE_JPEG
bSuccess = videomode->TakeSnapshotJPEGToBuffer( outBuf, info.jpeg_quality );
#endif
}
else
{
@ -2001,6 +2003,7 @@ void CVideoMode_Common::WriteMovieFrame( const MovieInfo_t& info ) @@ -2001,6 +2003,7 @@ void CVideoMode_Common::WriteMovieFrame( const MovieInfo_t& info )
delete[] hp;
}
#if HAVE_JPEG
//-----------------------------------------------------------------------------
// Purpose: Expanded data destination object for CUtlBuffer output
//-----------------------------------------------------------------------------
@ -2099,10 +2102,11 @@ GLOBAL(void) jpeg_UtlBuffer_dest (j_compress_ptr cinfo, CUtlBuffer *pBuffer ) @@ -2099,10 +2102,11 @@ GLOBAL(void) jpeg_UtlBuffer_dest (j_compress_ptr cinfo, CUtlBuffer *pBuffer )
dest->pub.term_destination = term_destination;
dest->pBuffer = pBuffer;
}
#endif
bool CVideoMode_Common::TakeSnapshotJPEGToBuffer( CUtlBuffer& buf, int quality )
{
#if !defined( _X360 )
#if !defined( _X360 ) && HAVE_JPEG
if ( g_LostVideoMemory )
return false;

8
game/client/vgui_fpspanel.cpp

@ -310,7 +310,13 @@ void CFPSPanel::Paint() @@ -310,7 +310,13 @@ void CFPSPanel::Paint()
vel = player->GetLocalVelocity();
}
g_pMatSystemSurface->DrawColoredText( m_hFont, x, 2 + i * ( vgui::surface()->GetFontTall( m_hFont ) + 2 ),
if( nShowPosMode > 1 )
g_pMatSystemSurface->DrawColoredText( m_hFont, x, 2 + i * ( vgui::surface()->GetFontTall( m_hFont ) + 2 ),
255, 255, 255, 255,
"vel: %.2f %.2f %.2f",
vel.x, vel.y, vel.z );
else
g_pMatSystemSurface->DrawColoredText( m_hFont, x, 2 + i * ( vgui::surface()->GetFontTall( m_hFont ) + 2 ),
255, 255, 255, 255,
"vel: %.2f",
vel.Length() );

8
launcher/android/main.cpp

@ -31,18 +31,18 @@ int iLastArgs = 0; @@ -31,18 +31,18 @@ int iLastArgs = 0;
DLL_EXPORT int LauncherMain( int argc, char **argv ); // from launcher.cpp
extern void InitCrashHandler();
JNIEXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over)
DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over)
{
Msg( "Java_com_valvesoftware_ValveActivity2_setenv %s=%s", jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL) );
return setenv( jenv->GetStringUTFChars(env, NULL), jenv->GetStringUTFChars(value, NULL), over );
}
JNIEXPORT void Java_com_valvesoftware_ValveActivity2_nativeOnActivityResult()
DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_nativeOnActivityResult()
{
Msg( "Java_com_valvesoftware_ValveActivity_nativeOnActivityResult" );
}
JNIEXPORT void Java_com_valvesoftware_ValveActivity2_setArgs(JNIEnv *env, jclass *clazz, jstring str)
DLL_EXPORT void Java_com_valvesoftware_ValveActivity2_setArgs(JNIEnv *env, jclass *clazz, jstring str)
{
strncpy( java_args, env->GetStringUTFChars(str, NULL), sizeof java_args );
}
@ -77,7 +77,7 @@ void SetLauncherArgs() @@ -77,7 +77,7 @@ void SetLauncherArgs()
#undef D
}
JNIEXPORT int LauncherMainAndroid( int argc, char **argv )
DLL_EXPORT int LauncherMainAndroid( int argc, char **argv )
{
SDL_version ver;
SDL_GetVersion( &ver );

37
vgui2/vgui_surfacelib/linuxfont.cpp

@ -96,7 +96,7 @@ void CLinuxFont::CreateFontList() @@ -96,7 +96,7 @@ void CLinuxFont::CreateFontList()
if ( m_FriendlyNameCache.Count() > 0 )
return;
#ifndef ANDROID
#if HAVE_FC
if(!FcInit())
return;
FcConfig *config;
@ -169,7 +169,7 @@ void CLinuxFont::CreateFontList() @@ -169,7 +169,7 @@ void CLinuxFont::CreateFontList()
#endif
}
#ifndef ANDROID
#if HAVE_FC
static FcPattern* FontMatch(const char* type, ...)
{
FcValue fcvalue;
@ -405,19 +405,40 @@ bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int d @@ -405,19 +405,40 @@ bool CLinuxFont::CreateFromMemory(const char *windowsFontName, void *data, int d
return true;
}
#ifdef ANDROID
char *FindFontAndroid(const char *winFontName, bool bBold, int italic)
#if !HAVE_FC
char *TryFindFont(const char *winFontName, bool bBold, int italic)
{
static char fontFile[MAX_PATH];
const char *fontName;
const char *fontName, *fontNamePost;
#ifdef ANDROID
if( strcmp( winFontName, "Courier New") == 0 )
fontName = "LiberationMono-Regular.ttf";
else
fontName = "DroidSansFallback.ttf"; // for chinese/japanese/korean
snprintf( fontFile, sizeof fontFile, "%s/files/%s", getenv("APP_DATA_PATH"), fontName);
#else
// "platform/resource/linux_fonts/";
if( strcmp( winFontName, "Courier New") == 0 )
fontName = "liberationmono";
if( bBold )
{
if( italic )
fontNamePost = "boldoblique";
else
fontNamePost = "bold";
}
else if( italic )
fontNamePost = "oblique";
else
fontNamePost = "regular";
snprintf(fontFile, sizeof fontFile, "platform/resource/linux_fonts/%s-%s.ttf", fontName, fontNamePost);
#endif
return fontFile;
#if 0 // Old detect
@ -480,9 +501,9 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags ) @@ -480,9 +501,9 @@ char *CLinuxFont::GetFontFileName( const char *windowsFontName, int flags )
const int italic = ( flags & vgui::ISurface::FONTFLAG_ITALIC ) ? FC_SLANT_ITALIC : FC_SLANT_ROMAN;
#ifdef ANDROID
char *filename = FindFontAndroid( windowsFontName, bBold, italic );
Msg("Android font: %s\n", filename);
#if !HAVE_FC
char *filename = TryFindFont( windowsFontName, bBold, italic );
Msg("Found font: %s\n", filename);
if( !filename ) return NULL;
return strdup( filename );
#else

Loading…
Cancel
Save