Remove std prefix from uint types
std::uint* -> uint*
This commit is contained in:
+1
-1
@@ -148,7 +148,7 @@ void ActorFrame::AddChild( Actor *pActor )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ASSERT( pActor != nullptr );
|
ASSERT( pActor != nullptr );
|
||||||
ASSERT( reinterpret_cast<std::uintptr_t>(pActor) != static_cast<std::uintptr_t>(0xC0000005) );
|
ASSERT( reinterpret_cast<uintptr_t>(pActor) != static_cast<uintptr_t>(0xC0000005) );
|
||||||
m_SubActors.push_back( pActor );
|
m_SubActors.push_back( pActor );
|
||||||
|
|
||||||
pActor->SetParent( this );
|
pActor->SetParent( this );
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ActorFrameTexture::ActorFrameTexture()
|
|||||||
m_bAlphaBuffer = false;
|
m_bAlphaBuffer = false;
|
||||||
m_bFloat = false;
|
m_bFloat = false;
|
||||||
m_bPreserveTexture = false;
|
m_bPreserveTexture = false;
|
||||||
static std::uint64_t i = 0;
|
static uint64_t i = 0;
|
||||||
++i;
|
++i;
|
||||||
m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i );
|
m_sTextureName = ssprintf( ConvertI64FormatString("ActorFrameTexture %lli"), i );
|
||||||
|
|
||||||
|
|||||||
@@ -248,16 +248,16 @@ void ActorMultiVertex::DrawPrimitives()
|
|||||||
|
|
||||||
for( size_t i=0; i < TS.vertices.size(); i++ )
|
for( size_t i=0; i < TS.vertices.size(); i++ )
|
||||||
{
|
{
|
||||||
// RageVColor uses a std::uint8_t for each channel. 0-255.
|
// RageVColor uses a uint8_t for each channel. 0-255.
|
||||||
// RageColor uses a float. 0-1.
|
// RageColor uses a float. 0-1.
|
||||||
// So each channel of the RageVColor needs to be converted to a float,
|
// So each channel of the RageVColor needs to be converted to a float,
|
||||||
// multiplied by the channel from the RageColor, then the result
|
// multiplied by the channel from the RageColor, then the result
|
||||||
// converted to std::uint8_t. If implicit conversion is allowed to happen,
|
// converted to uint8_t. If implicit conversion is allowed to happen,
|
||||||
// sometimes the compiler decides to turn the RageColor into a std::uint8_t,
|
// sometimes the compiler decides to turn the RageColor into a uint8_t,
|
||||||
// which makes any value other than 1 into 0. Thus, the explicit
|
// which makes any value other than 1 into 0. Thus, the explicit
|
||||||
// conversions. -Kyz
|
// conversions. -Kyz
|
||||||
#define MULT_COLOR_ELEMENTS(color_a, color_b) \
|
#define MULT_COLOR_ELEMENTS(color_a, color_b) \
|
||||||
color_a= static_cast<std::uint8_t>(static_cast<float>(color_a) * color_b);
|
color_a= static_cast<uint8_t>(static_cast<float>(color_a) * color_b);
|
||||||
// RageVColor * RageColor
|
// RageVColor * RageColor
|
||||||
MULT_COLOR_ELEMENTS(TS.vertices[i].c.b, m_pTempState->diffuse[0].b);
|
MULT_COLOR_ELEMENTS(TS.vertices[i].c.b, m_pTempState->diffuse[0].b);
|
||||||
MULT_COLOR_ELEMENTS(TS.vertices[i].c.r, m_pTempState->diffuse[0].r);
|
MULT_COLOR_ELEMENTS(TS.vertices[i].c.r, m_pTempState->diffuse[0].r);
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ bool CryptManager::VerifyFileWithFile( RString sPath, RString sSignatureFile )
|
|||||||
|
|
||||||
void CryptManager::GetRandomBytes( void *pData, int iBytes )
|
void CryptManager::GetRandomBytes( void *pData, int iBytes )
|
||||||
{
|
{
|
||||||
std::uint8_t *pBuf = (std::uint8_t *) pData;
|
uint8_t *pBuf = (uint8_t *) pData;
|
||||||
while( iBytes-- )
|
while( iBytes-- )
|
||||||
*pBuf++ = (std::uint8_t) RandomInt( 256 );
|
*pBuf++ = (uint8_t) RandomInt( 256 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -467,7 +467,7 @@ RString CryptManager::GetPublicKeyFileName()
|
|||||||
/* Generate a version 4 random UUID. */
|
/* Generate a version 4 random UUID. */
|
||||||
RString CryptManager::GenerateRandomUUID()
|
RString CryptManager::GenerateRandomUUID()
|
||||||
{
|
{
|
||||||
std::uint32_t buf[4];
|
uint32_t buf[4];
|
||||||
CryptManager::GetRandomBytes( buf, sizeof(buf) );
|
CryptManager::GetRandomBytes( buf, sizeof(buf) );
|
||||||
|
|
||||||
buf[1] &= 0xFFFF0FFF;
|
buf[1] &= 0xFFFF0FFF;
|
||||||
|
|||||||
+2
-2
@@ -189,8 +189,8 @@ void ImageCache::ReadFromDisk()
|
|||||||
|
|
||||||
struct ImageTexture: public RageTexture
|
struct ImageTexture: public RageTexture
|
||||||
{
|
{
|
||||||
std::uintptr_t m_uTexHandle;
|
uintptr_t m_uTexHandle;
|
||||||
std::uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay
|
uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay
|
||||||
/* This is a reference to a pointer in g_ImagePathToImage. */
|
/* This is a reference to a pointer in g_ImagePathToImage. */
|
||||||
RageSurface *&m_pImage;
|
RageSurface *&m_pImage;
|
||||||
int m_iWidth, m_iHeight;
|
int m_iWidth, m_iHeight;
|
||||||
|
|||||||
+2
-2
@@ -422,8 +422,8 @@ LuaThreadVariable::LuaThreadVariable( lua_State *L )
|
|||||||
|
|
||||||
RString LuaThreadVariable::GetCurrentThreadIDString()
|
RString LuaThreadVariable::GetCurrentThreadIDString()
|
||||||
{
|
{
|
||||||
std::uint64_t iID = RageThread::GetCurrentThreadID();
|
uint64_t iID = RageThread::GetCurrentThreadID();
|
||||||
return ssprintf( "%08x%08x", std::uint32_t(iID >> 32), std::uint32_t(iID) );
|
return ssprintf( "%08x%08x", uint32_t(iID >> 32), uint32_t(iID) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LuaThreadVariable::PushThreadTable( lua_State *L, bool bCreate )
|
bool LuaThreadVariable::PushThreadTable( lua_State *L, bool bCreate )
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
struct msTriangle
|
struct msTriangle
|
||||||
{
|
{
|
||||||
std::uint16_t nVertexIndices[3];
|
uint16_t nVertexIndices[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -870,7 +870,7 @@ void NoteField::DrawPrimitives()
|
|||||||
|
|
||||||
// Create an oscillating / pulsing glow effect.
|
// Create an oscillating / pulsing glow effect.
|
||||||
// Converts a counter to radians and uses the cosine for a cyclic appearance.
|
// Converts a counter to radians and uses the cosine for a cyclic appearance.
|
||||||
static std::uint_fast16_t iGlowCounter;
|
static uint_fast16_t iGlowCounter;
|
||||||
static constexpr float fCyclical = 2.0f * 3.14159265f / 360.0f;
|
static constexpr float fCyclical = 2.0f * 3.14159265f / 360.0f;
|
||||||
iGlowCounter = (iGlowCounter + 1) % 360;
|
iGlowCounter = (iGlowCounter + 1) % 360;
|
||||||
float phase = iGlowCounter * fCyclical;
|
float phase = iGlowCounter * fCyclical;
|
||||||
|
|||||||
+1
-1
@@ -1258,7 +1258,7 @@ ProfileLoadResult Profile::LoadStatsFromDir(RString dir, bool require_signature)
|
|||||||
if(compressed)
|
if(compressed)
|
||||||
{
|
{
|
||||||
RString sError;
|
RString sError;
|
||||||
std::uint32_t iCRC32;
|
uint32_t iCRC32;
|
||||||
RageFileObjInflate *pInflate = GunzipFile(pFile.release(), sError, &iCRC32);
|
RageFileObjInflate *pInflate = GunzipFile(pFile.release(), sError, &iCRC32);
|
||||||
if(pInflate == nullptr)
|
if(pInflate == nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,12 +15,12 @@ public:
|
|||||||
/* only called by RageTextureManager::InvalidateTextures */
|
/* only called by RageTextureManager::InvalidateTextures */
|
||||||
virtual void Invalidate() { m_uTexHandle = 0; /* don't Destroy() */}
|
virtual void Invalidate() { m_uTexHandle = 0; /* don't Destroy() */}
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
virtual std::uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay
|
virtual uintptr_t GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Create(); // called by constructor and Reload
|
void Create(); // called by constructor and Reload
|
||||||
void Destroy();
|
void Destroy();
|
||||||
std::uintptr_t m_uTexHandle; // treat as unsigned in OpenGL, IDirect3DTexture9* for D3D
|
uintptr_t m_uTexHandle; // treat as unsigned in OpenGL, IDirect3DTexture9* for D3D
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -656,7 +656,7 @@ RageSurface *RageDisplay::CreateSurfaceFromPixfmt( RagePixelFormat pixfmt,
|
|||||||
RageSurface *surf = CreateSurfaceFrom(
|
RageSurface *surf = CreateSurfaceFrom(
|
||||||
width, height, tpf->bpp,
|
width, height, tpf->bpp,
|
||||||
tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3],
|
tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3],
|
||||||
(std::uint8_t *) pixels, pitch );
|
(uint8_t *) pixels, pitch );
|
||||||
|
|
||||||
return surf;
|
return surf;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -203,7 +203,7 @@ struct RageTextureLock
|
|||||||
|
|
||||||
/* Given a surface with a format and no pixel data, lock the texture into the
|
/* Given a surface with a format and no pixel data, lock the texture into the
|
||||||
* surface. The data is write-only. */
|
* surface. The data is write-only. */
|
||||||
virtual void Lock( std::uintptr_t iTexHandle, RageSurface *pSurface ) = 0;
|
virtual void Lock( uintptr_t iTexHandle, RageSurface *pSurface ) = 0;
|
||||||
|
|
||||||
/* Unlock and update the texture. If bChanged is false, the texture update
|
/* Unlock and update the texture. If bChanged is false, the texture update
|
||||||
* may be omitted. */
|
* may be omitted. */
|
||||||
@@ -259,23 +259,23 @@ public:
|
|||||||
|
|
||||||
/* return 0 if failed or internal texture resource handle
|
/* return 0 if failed or internal texture resource handle
|
||||||
* (unsigned in OpenGL, texture pointer in D3D) */
|
* (unsigned in OpenGL, texture pointer in D3D) */
|
||||||
virtual std::uintptr_t CreateTexture(
|
virtual uintptr_t CreateTexture(
|
||||||
RagePixelFormat pixfmt, // format of img and of texture in video mem
|
RagePixelFormat pixfmt, // format of img and of texture in video mem
|
||||||
RageSurface* img, // must be in pixfmt
|
RageSurface* img, // must be in pixfmt
|
||||||
bool bGenerateMipMaps
|
bool bGenerateMipMaps
|
||||||
) = 0;
|
) = 0;
|
||||||
virtual void UpdateTexture(
|
virtual void UpdateTexture(
|
||||||
std::uintptr_t iTexHandle,
|
uintptr_t iTexHandle,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
int xoffset, int yoffset, int width, int height
|
int xoffset, int yoffset, int width, int height
|
||||||
) = 0;
|
) = 0;
|
||||||
virtual void DeleteTexture( std::uintptr_t iTexHandle ) = 0;
|
virtual void DeleteTexture( uintptr_t iTexHandle ) = 0;
|
||||||
/* Return an object to lock pixels for streaming. If not supported, returns nullptr.
|
/* Return an object to lock pixels for streaming. If not supported, returns nullptr.
|
||||||
* Delete the object normally. */
|
* Delete the object normally. */
|
||||||
virtual RageTextureLock *CreateTextureLock() { return nullptr; }
|
virtual RageTextureLock *CreateTextureLock() { return nullptr; }
|
||||||
virtual void ClearAllTextures() = 0;
|
virtual void ClearAllTextures() = 0;
|
||||||
virtual int GetNumTextureUnits() = 0;
|
virtual int GetNumTextureUnits() = 0;
|
||||||
virtual void SetTexture( TextureUnit, std::uintptr_t /* iTexture */ ) = 0;
|
virtual void SetTexture( TextureUnit, uintptr_t /* iTexture */ ) = 0;
|
||||||
virtual void SetTextureMode( TextureUnit, TextureMode ) = 0;
|
virtual void SetTextureMode( TextureUnit, TextureMode ) = 0;
|
||||||
virtual void SetTextureWrapping( TextureUnit, bool ) = 0;
|
virtual void SetTextureWrapping( TextureUnit, bool ) = 0;
|
||||||
virtual int GetMaxTextureSize() const = 0;
|
virtual int GetMaxTextureSize() const = 0;
|
||||||
@@ -291,9 +291,9 @@ public:
|
|||||||
* DeleteTexture. (UpdateTexture is not permitted.) Returns 0 if render-to-
|
* DeleteTexture. (UpdateTexture is not permitted.) Returns 0 if render-to-
|
||||||
* texture is unsupported.
|
* texture is unsupported.
|
||||||
*/
|
*/
|
||||||
virtual std::uintptr_t CreateRenderTarget( const RenderTargetParam &, int & /* iTextureWidthOut */, int & /* iTextureHeightOut */ ) { return 0; }
|
virtual uintptr_t CreateRenderTarget( const RenderTargetParam &, int & /* iTextureWidthOut */, int & /* iTextureHeightOut */ ) { return 0; }
|
||||||
|
|
||||||
virtual std::uintptr_t GetRenderTarget() { return 0; }
|
virtual uintptr_t GetRenderTarget() { return 0; }
|
||||||
|
|
||||||
/* Set the render target, or 0 to resume rendering to the framebuffer. An active render
|
/* Set the render target, or 0 to resume rendering to the framebuffer. An active render
|
||||||
* target may not be used as a texture. If bPreserveTexture is true, the contents
|
* target may not be used as a texture. If bPreserveTexture is true, the contents
|
||||||
@@ -301,7 +301,7 @@ public:
|
|||||||
* bPreserveTexture is true the first time a render target is used, behave as if
|
* bPreserveTexture is true the first time a render target is used, behave as if
|
||||||
* bPreserveTexture was false.
|
* bPreserveTexture was false.
|
||||||
*/
|
*/
|
||||||
virtual void SetRenderTarget( std::uintptr_t /* iHandle */, bool /* bPreserveTexture */ = true ) { }
|
virtual void SetRenderTarget( uintptr_t /* iHandle */, bool /* bPreserveTexture */ = true ) { }
|
||||||
|
|
||||||
virtual bool IsZTestEnabled() const = 0;
|
virtual bool IsZTestEnabled() const = 0;
|
||||||
virtual bool IsZWriteEnabled() const = 0;
|
virtual bool IsZWriteEnabled() const = 0;
|
||||||
@@ -362,9 +362,9 @@ public:
|
|||||||
};
|
};
|
||||||
bool SaveScreenshot( RString sPath, GraphicsFileFormat format );
|
bool SaveScreenshot( RString sPath, GraphicsFileFormat format );
|
||||||
|
|
||||||
virtual RString GetTextureDiagnostics( std::uintptr_t /* id */ ) const { return RString(); }
|
virtual RString GetTextureDiagnostics( uintptr_t /* id */ ) const { return RString(); }
|
||||||
virtual RageSurface* CreateScreenshot() = 0; // allocates a surface. Caller must delete it.
|
virtual RageSurface* CreateScreenshot() = 0; // allocates a surface. Caller must delete it.
|
||||||
virtual RageSurface *GetTexture( std::uintptr_t /* iTexture */ ) { return nullptr; } // allocates a surface. Caller must delete it.
|
virtual RageSurface *GetTexture( uintptr_t /* iTexture */ ) { return nullptr; } // allocates a surface. Caller must delete it.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ) = 0;
|
virtual void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ) = 0;
|
||||||
|
|||||||
+16
-16
@@ -48,13 +48,13 @@ const D3DFORMAT g_DefaultAdapterFormat = D3DFMT_X8R8G8B8;
|
|||||||
/* Direct3D doesn't associate a palette with textures. Instead, we load a
|
/* Direct3D doesn't associate a palette with textures. Instead, we load a
|
||||||
* palette into a slot. We need to keep track of which texture's palette is
|
* palette into a slot. We need to keep track of which texture's palette is
|
||||||
* stored in what slot. */
|
* stored in what slot. */
|
||||||
std::map<std::uintptr_t, size_t> g_TexResourceToPaletteIndex;
|
std::map<uintptr_t, size_t> g_TexResourceToPaletteIndex;
|
||||||
std::list<size_t> g_PaletteIndex;
|
std::list<size_t> g_PaletteIndex;
|
||||||
struct TexturePalette { PALETTEENTRY p[256]; };
|
struct TexturePalette { PALETTEENTRY p[256]; };
|
||||||
std::map<std::uintptr_t, TexturePalette> g_TexResourceToTexturePalette;
|
std::map<uintptr_t, TexturePalette> g_TexResourceToTexturePalette;
|
||||||
|
|
||||||
// Load the palette, if any, for the given texture into a palette slot, and make it current.
|
// Load the palette, if any, for the given texture into a palette slot, and make it current.
|
||||||
static void SetPalette( std::uintptr_t TexResource )
|
static void SetPalette( uintptr_t TexResource )
|
||||||
{
|
{
|
||||||
// If the texture isn't paletted, we have nothing to do.
|
// If the texture isn't paletted, we have nothing to do.
|
||||||
if( g_TexResourceToTexturePalette.find(TexResource) == g_TexResourceToTexturePalette.end() )
|
if( g_TexResourceToTexturePalette.find(TexResource) == g_TexResourceToTexturePalette.end() )
|
||||||
@@ -67,7 +67,7 @@ static void SetPalette( std::uintptr_t TexResource )
|
|||||||
UINT iPalIndex = static_cast<UINT>(g_PaletteIndex.front());
|
UINT iPalIndex = static_cast<UINT>(g_PaletteIndex.front());
|
||||||
|
|
||||||
// If any other texture is currently using this slot, mark that palette unloaded.
|
// If any other texture is currently using this slot, mark that palette unloaded.
|
||||||
for( std::map<std::uintptr_t, size_t>::iterator i = g_TexResourceToPaletteIndex.begin(); i != g_TexResourceToPaletteIndex.end(); ++i )
|
for( std::map<uintptr_t, size_t>::iterator i = g_TexResourceToPaletteIndex.begin(); i != g_TexResourceToPaletteIndex.end(); ++i )
|
||||||
{
|
{
|
||||||
if( i->second != iPalIndex )
|
if( i->second != iPalIndex )
|
||||||
continue;
|
continue;
|
||||||
@@ -798,7 +798,7 @@ public:
|
|||||||
|
|
||||||
for( size_t j=0; j<Triangles.size(); j++ )
|
for( size_t j=0; j<Triangles.size(); j++ )
|
||||||
for( size_t k=0; k<3; k++ )
|
for( size_t k=0; k<3; k++ )
|
||||||
m_vTriangles[meshInfo.iTriangleStart+j].nVertexIndices[k] = (std::uint16_t) meshInfo.iVertexStart + Triangles[j].nVertexIndices[k];
|
m_vTriangles[meshInfo.iTriangleStart+j].nVertexIndices[k] = (uint16_t) meshInfo.iVertexStart + Triangles[j].nVertexIndices[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Draw( int iMeshIndex ) const
|
void Draw( int iMeshIndex ) const
|
||||||
@@ -854,11 +854,11 @@ void RageDisplay_D3D::DrawQuadsInternal( const RageSpriteVertex v[], int iNumVer
|
|||||||
int iNumIndices = iNumTriangles*3;
|
int iNumIndices = iNumTriangles*3;
|
||||||
|
|
||||||
// make a temporary index buffer
|
// make a temporary index buffer
|
||||||
static std::vector<std::uint16_t> vIndices;
|
static std::vector<uint16_t> vIndices;
|
||||||
size_t uOldSize = vIndices.size();
|
size_t uOldSize = vIndices.size();
|
||||||
size_t uNewSize = std::max(uOldSize, static_cast<size_t>(iNumIndices));
|
size_t uNewSize = std::max(uOldSize, static_cast<size_t>(iNumIndices));
|
||||||
vIndices.resize( uNewSize );
|
vIndices.resize( uNewSize );
|
||||||
for( std::uint16_t i=(std::uint16_t)uOldSize/6; i<(std::uint16_t)iNumQuads; i++ )
|
for( uint16_t i=(uint16_t)uOldSize/6; i<(uint16_t)iNumQuads; i++ )
|
||||||
{
|
{
|
||||||
vIndices[i*6+0] = i*4+0;
|
vIndices[i*6+0] = i*4+0;
|
||||||
vIndices[i*6+1] = i*4+1;
|
vIndices[i*6+1] = i*4+1;
|
||||||
@@ -890,11 +890,11 @@ void RageDisplay_D3D::DrawQuadStripInternal( const RageSpriteVertex v[], int iNu
|
|||||||
int iNumIndices = iNumTriangles*3;
|
int iNumIndices = iNumTriangles*3;
|
||||||
|
|
||||||
// make a temporary index buffer
|
// make a temporary index buffer
|
||||||
static std::vector<std::uint16_t> vIndices;
|
static std::vector<uint16_t> vIndices;
|
||||||
size_t uOldSize = vIndices.size();
|
size_t uOldSize = vIndices.size();
|
||||||
size_t uNewSize = std::max(uOldSize, static_cast<size_t>(iNumIndices));
|
size_t uNewSize = std::max(uOldSize, static_cast<size_t>(iNumIndices));
|
||||||
vIndices.resize( uNewSize );
|
vIndices.resize( uNewSize );
|
||||||
for( std::uint16_t i=(std::uint16_t)uOldSize/6; i<(std::uint16_t)iNumQuads; i++ )
|
for( uint16_t i=(uint16_t)uOldSize/6; i<(uint16_t)iNumQuads; i++ )
|
||||||
{
|
{
|
||||||
vIndices[i*6+0] = i*2+0;
|
vIndices[i*6+0] = i*2+0;
|
||||||
vIndices[i*6+1] = i*2+1;
|
vIndices[i*6+1] = i*2+1;
|
||||||
@@ -925,11 +925,11 @@ void RageDisplay_D3D::DrawSymmetricQuadStripInternal( const RageSpriteVertex v[]
|
|||||||
int iNumIndices = iNumTriangles*3;
|
int iNumIndices = iNumTriangles*3;
|
||||||
|
|
||||||
// make a temporary index buffer
|
// make a temporary index buffer
|
||||||
static std::vector<std::uint16_t> vIndices;
|
static std::vector<uint16_t> vIndices;
|
||||||
size_t uOldSize = vIndices.size();
|
size_t uOldSize = vIndices.size();
|
||||||
size_t uNewSize = std::max(uOldSize, static_cast<size_t>(iNumIndices));
|
size_t uNewSize = std::max(uOldSize, static_cast<size_t>(iNumIndices));
|
||||||
vIndices.resize( uNewSize );
|
vIndices.resize( uNewSize );
|
||||||
for( std::uint16_t i=(std::uint16_t)uOldSize/12; i<(std::uint16_t)iNumPieces; i++ )
|
for( uint16_t i=(uint16_t)uOldSize/12; i<(uint16_t)iNumPieces; i++ )
|
||||||
{
|
{
|
||||||
// { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 }
|
// { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 }
|
||||||
vIndices[i*12+0] = i*3+1;
|
vIndices[i*12+0] = i*3+1;
|
||||||
@@ -1052,7 +1052,7 @@ int RageDisplay_D3D::GetNumTextureUnits()
|
|||||||
return g_DeviceCaps.MaxSimultaneousTextures;
|
return g_DeviceCaps.MaxSimultaneousTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_D3D::SetTexture( TextureUnit tu, std::uintptr_t iTexture )
|
void RageDisplay_D3D::SetTexture( TextureUnit tu, uintptr_t iTexture )
|
||||||
{
|
{
|
||||||
// g_DeviceCaps.MaxSimultaneousTextures = 1;
|
// g_DeviceCaps.MaxSimultaneousTextures = 1;
|
||||||
if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported
|
if( tu >= (int) g_DeviceCaps.MaxSimultaneousTextures ) // not supported
|
||||||
@@ -1360,7 +1360,7 @@ void RageDisplay_D3D::SetCullMode( CullMode mode )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_D3D::DeleteTexture( std::uintptr_t iTexHandle )
|
void RageDisplay_D3D::DeleteTexture( uintptr_t iTexHandle )
|
||||||
{
|
{
|
||||||
if( iTexHandle == 0 )
|
if( iTexHandle == 0 )
|
||||||
return;
|
return;
|
||||||
@@ -1376,7 +1376,7 @@ void RageDisplay_D3D::DeleteTexture( std::uintptr_t iTexHandle )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::uintptr_t RageDisplay_D3D::CreateTexture(
|
uintptr_t RageDisplay_D3D::CreateTexture(
|
||||||
RagePixelFormat pixfmt,
|
RagePixelFormat pixfmt,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
bool bGenerateMipMaps )
|
bool bGenerateMipMaps )
|
||||||
@@ -1389,7 +1389,7 @@ std::uintptr_t RageDisplay_D3D::CreateTexture(
|
|||||||
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
|
RageException::Throw( "CreateTexture(%i,%i,%s) failed: %s",
|
||||||
img->w, img->h, RagePixelFormatToString(pixfmt).c_str(), GetErrorString(hr).c_str() );
|
img->w, img->h, RagePixelFormatToString(pixfmt).c_str(), GetErrorString(hr).c_str() );
|
||||||
|
|
||||||
std::uintptr_t uTexHandle = reinterpret_cast<std::uintptr_t>(pTex);
|
uintptr_t uTexHandle = reinterpret_cast<uintptr_t>(pTex);
|
||||||
|
|
||||||
if( pixfmt == RagePixelFormat_PAL )
|
if( pixfmt == RagePixelFormat_PAL )
|
||||||
{
|
{
|
||||||
@@ -1415,7 +1415,7 @@ std::uintptr_t RageDisplay_D3D::CreateTexture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_D3D::UpdateTexture(
|
void RageDisplay_D3D::UpdateTexture(
|
||||||
std::uintptr_t uTexHandle,
|
uintptr_t uTexHandle,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
int xoffset, int yoffset, int width, int height )
|
int xoffset, int yoffset, int width, int height )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,19 +26,19 @@ public:
|
|||||||
bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false );
|
bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false );
|
||||||
bool SupportsThreadedRendering();
|
bool SupportsThreadedRendering();
|
||||||
bool SupportsPerVertexMatrixScale() { return false; }
|
bool SupportsPerVertexMatrixScale() { return false; }
|
||||||
std::uintptr_t CreateTexture(
|
uintptr_t CreateTexture(
|
||||||
RagePixelFormat pixfmt,
|
RagePixelFormat pixfmt,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
bool bGenerateMipMaps );
|
bool bGenerateMipMaps );
|
||||||
void UpdateTexture(
|
void UpdateTexture(
|
||||||
std::uintptr_t iTexHandle,
|
uintptr_t iTexHandle,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
int xoffset, int yoffset, int width, int height
|
int xoffset, int yoffset, int width, int height
|
||||||
);
|
);
|
||||||
void DeleteTexture( std::uintptr_t iTexHandle );
|
void DeleteTexture( uintptr_t iTexHandle );
|
||||||
void ClearAllTextures();
|
void ClearAllTextures();
|
||||||
int GetNumTextureUnits();
|
int GetNumTextureUnits();
|
||||||
void SetTexture( TextureUnit tu, std::uintptr_t iTexture );
|
void SetTexture( TextureUnit tu, uintptr_t iTexture );
|
||||||
void SetTextureMode( TextureUnit tu, TextureMode tm );
|
void SetTextureMode( TextureUnit tu, TextureMode tm );
|
||||||
void SetTextureWrapping( TextureUnit tu, bool b );
|
void SetTextureWrapping( TextureUnit tu, bool b );
|
||||||
int GetMaxTextureSize() const;
|
int GetMaxTextureSize() const;
|
||||||
|
|||||||
@@ -564,7 +564,7 @@ RageDisplay_GLES2::SupportsPerVertexMatrixScale()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uintptr_t
|
uintptr_t
|
||||||
RageDisplay_GLES2::CreateTexture(
|
RageDisplay_GLES2::CreateTexture(
|
||||||
RagePixelFormat pixfmt,
|
RagePixelFormat pixfmt,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
@@ -577,7 +577,7 @@ RageDisplay_GLES2::CreateTexture(
|
|||||||
|
|
||||||
void
|
void
|
||||||
RageDisplay_GLES2::UpdateTexture(
|
RageDisplay_GLES2::UpdateTexture(
|
||||||
std::uintptr_t iTexHandle,
|
uintptr_t iTexHandle,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
int xoffset, int yoffset, int width, int height
|
int xoffset, int yoffset, int width, int height
|
||||||
)
|
)
|
||||||
@@ -586,7 +586,7 @@ RageDisplay_GLES2::UpdateTexture(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RageDisplay_GLES2::DeleteTexture( std::uintptr_t iTexHandle )
|
RageDisplay_GLES2::DeleteTexture( uintptr_t iTexHandle )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@@ -618,7 +618,7 @@ SetTextureUnit( TextureUnit tu )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RageDisplay_GLES2::SetTexture( TextureUnit tu, std::uintptr_t iTexture )
|
RageDisplay_GLES2::SetTexture( TextureUnit tu, uintptr_t iTexture )
|
||||||
{
|
{
|
||||||
if (!SetTextureUnit( tu ))
|
if (!SetTextureUnit( tu ))
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -20,18 +20,18 @@ public:
|
|||||||
void SetBlendMode( BlendMode mode );
|
void SetBlendMode( BlendMode mode );
|
||||||
bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false );
|
bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false );
|
||||||
bool SupportsPerVertexMatrixScale();
|
bool SupportsPerVertexMatrixScale();
|
||||||
std::uintptr_t CreateTexture(
|
uintptr_t CreateTexture(
|
||||||
RagePixelFormat pixfmt,
|
RagePixelFormat pixfmt,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
bool bGenerateMipMaps );
|
bool bGenerateMipMaps );
|
||||||
void UpdateTexture(
|
void UpdateTexture(
|
||||||
std::uintptr_t iTexHandle,
|
uintptr_t iTexHandle,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
int xoffset, int yoffset, int width, int height );
|
int xoffset, int yoffset, int width, int height );
|
||||||
void DeleteTexture( std::uintptr_t iTexHandle );
|
void DeleteTexture( uintptr_t iTexHandle );
|
||||||
void ClearAllTextures();
|
void ClearAllTextures();
|
||||||
int GetNumTextureUnits();
|
int GetNumTextureUnits();
|
||||||
void SetTexture( TextureUnit tu, std::uintptr_t iTexture );
|
void SetTexture( TextureUnit tu, uintptr_t iTexture );
|
||||||
void SetTextureMode( TextureUnit tu, TextureMode tm );
|
void SetTextureMode( TextureUnit tu, TextureMode tm );
|
||||||
void SetTextureWrapping( TextureUnit tu, bool b );
|
void SetTextureWrapping( TextureUnit tu, bool b );
|
||||||
int GetMaxTextureSize() const;
|
int GetMaxTextureSize() const;
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ public:
|
|||||||
void SetBlendMode( BlendMode ) { }
|
void SetBlendMode( BlendMode ) { }
|
||||||
bool SupportsTextureFormat( RagePixelFormat, bool /* realtime */ =false ) { return true; }
|
bool SupportsTextureFormat( RagePixelFormat, bool /* realtime */ =false ) { return true; }
|
||||||
bool SupportsPerVertexMatrixScale() { return false; }
|
bool SupportsPerVertexMatrixScale() { return false; }
|
||||||
std::uintptr_t CreateTexture(
|
uintptr_t CreateTexture(
|
||||||
RagePixelFormat,
|
RagePixelFormat,
|
||||||
RageSurface* /* img */,
|
RageSurface* /* img */,
|
||||||
bool /* bGenerateMipMaps */ ) { return 1; }
|
bool /* bGenerateMipMaps */ ) { return 1; }
|
||||||
void UpdateTexture(
|
void UpdateTexture(
|
||||||
std::uintptr_t /* iTexHandle */,
|
uintptr_t /* iTexHandle */,
|
||||||
RageSurface* /* img */,
|
RageSurface* /* img */,
|
||||||
int /* xoffset */, int /* yoffset */, int /* width */, int /* height */
|
int /* xoffset */, int /* yoffset */, int /* width */, int /* height */
|
||||||
) { }
|
) { }
|
||||||
void DeleteTexture( std::uintptr_t /* iTexHandle */ ) { }
|
void DeleteTexture( uintptr_t /* iTexHandle */ ) { }
|
||||||
void ClearAllTextures() { }
|
void ClearAllTextures() { }
|
||||||
int GetNumTextureUnits() { return 1; }
|
int GetNumTextureUnits() { return 1; }
|
||||||
void SetTexture( TextureUnit, std::uintptr_t /* iTexture */ ) { }
|
void SetTexture( TextureUnit, uintptr_t /* iTexture */ ) { }
|
||||||
void SetTextureMode( TextureUnit, TextureMode ) { }
|
void SetTextureMode( TextureUnit, TextureMode ) { }
|
||||||
void SetTextureWrapping( TextureUnit, bool ) { }
|
void SetTextureWrapping( TextureUnit, bool ) { }
|
||||||
int GetMaxTextureSize() const { return 2048; }
|
int GetMaxTextureSize() const { return 2048; }
|
||||||
|
|||||||
+25
-25
@@ -66,7 +66,7 @@ static const GLenum RageSpriteVertexFormat = GL_T2F_C4F_N3F_V3F;
|
|||||||
/* If we support texture matrix scaling, a handle to the vertex program: */
|
/* If we support texture matrix scaling, a handle to the vertex program: */
|
||||||
static GLhandleARB g_bTextureMatrixShader = 0;
|
static GLhandleARB g_bTextureMatrixShader = 0;
|
||||||
|
|
||||||
static std::map<std::uintptr_t, RenderTarget *> g_mapRenderTargets;
|
static std::map<uintptr_t, RenderTarget *> g_mapRenderTargets;
|
||||||
static RenderTarget *g_pCurrentRenderTarget = nullptr;
|
static RenderTarget *g_pCurrentRenderTarget = nullptr;
|
||||||
|
|
||||||
static LowLevelWindow *g_pWind;
|
static LowLevelWindow *g_pWind;
|
||||||
@@ -800,7 +800,7 @@ RString RageDisplay_Legacy::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
|
|
||||||
/* Delete all render targets. They may have associated resources other than
|
/* Delete all render targets. They may have associated resources other than
|
||||||
* the texture itself. */
|
* the texture itself. */
|
||||||
for (std::pair<std::uintptr_t const, RenderTarget *> &rt : g_mapRenderTargets)
|
for (std::pair<uintptr_t const, RenderTarget *> &rt : g_mapRenderTargets)
|
||||||
delete rt.second;
|
delete rt.second;
|
||||||
g_mapRenderTargets.clear();
|
g_mapRenderTargets.clear();
|
||||||
|
|
||||||
@@ -927,7 +927,7 @@ RageSurface* RageDisplay_Legacy::CreateScreenshot()
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSurface *RageDisplay_Legacy::GetTexture( std::uintptr_t iTexture )
|
RageSurface *RageDisplay_Legacy::GetTexture( uintptr_t iTexture )
|
||||||
{
|
{
|
||||||
if (iTexture == 0)
|
if (iTexture == 0)
|
||||||
return nullptr; // XXX
|
return nullptr; // XXX
|
||||||
@@ -1071,7 +1071,7 @@ public:
|
|||||||
for( unsigned k=0; k<3; k++ )
|
for( unsigned k=0; k<3; k++ )
|
||||||
{
|
{
|
||||||
int iVertexIndexInVBO = meshInfo.iVertexStart + Triangles[j].nVertexIndices[k];
|
int iVertexIndexInVBO = meshInfo.iVertexStart + Triangles[j].nVertexIndices[k];
|
||||||
m_vTriangles[meshInfo.iTriangleStart+j].nVertexIndices[k] = (std::uint16_t) iVertexIndexInVBO;
|
m_vTriangles[meshInfo.iTriangleStart+j].nVertexIndices[k] = (uint16_t) iVertexIndexInVBO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1513,11 +1513,11 @@ void RageDisplay_Legacy::DrawSymmetricQuadStripInternal( const RageSpriteVertex
|
|||||||
int iNumIndices = iNumTriangles*3;
|
int iNumIndices = iNumTriangles*3;
|
||||||
|
|
||||||
// make a temporary index buffer
|
// make a temporary index buffer
|
||||||
static std::vector<std::uint16_t> vIndices;
|
static std::vector<uint16_t> vIndices;
|
||||||
unsigned uOldSize = vIndices.size();
|
unsigned uOldSize = vIndices.size();
|
||||||
unsigned uNewSize = std::max(uOldSize,(unsigned)iNumIndices);
|
unsigned uNewSize = std::max(uOldSize,(unsigned)iNumIndices);
|
||||||
vIndices.resize( uNewSize );
|
vIndices.resize( uNewSize );
|
||||||
for( std::uint16_t i=(std::uint16_t)uOldSize/12; i<(std::uint16_t)iNumPieces; i++ )
|
for( uint16_t i=(uint16_t)uOldSize/12; i<(uint16_t)iNumPieces; i++ )
|
||||||
{
|
{
|
||||||
// { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 }
|
// { 1, 3, 0 } { 1, 4, 3 } { 1, 5, 4 } { 1, 2, 5 }
|
||||||
vIndices[i*12+0] = i*3+1;
|
vIndices[i*12+0] = i*3+1;
|
||||||
@@ -1687,7 +1687,7 @@ int RageDisplay_Legacy::GetNumTextureUnits()
|
|||||||
return g_iMaxTextureUnits;
|
return g_iMaxTextureUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_Legacy::SetTexture( TextureUnit tu, std::uintptr_t iTexture )
|
void RageDisplay_Legacy::SetTexture( TextureUnit tu, uintptr_t iTexture )
|
||||||
{
|
{
|
||||||
if (!SetTextureUnit( tu ))
|
if (!SetTextureUnit( tu ))
|
||||||
return;
|
return;
|
||||||
@@ -2114,7 +2114,7 @@ void RageDisplay_Legacy::EndConcurrentRendering()
|
|||||||
g_pWind->EndConcurrentRendering();
|
g_pWind->EndConcurrentRendering();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_Legacy::DeleteTexture( std::uintptr_t iTexture )
|
void RageDisplay_Legacy::DeleteTexture( uintptr_t iTexture )
|
||||||
{
|
{
|
||||||
if (iTexture == 0)
|
if (iTexture == 0)
|
||||||
return;
|
return;
|
||||||
@@ -2199,7 +2199,7 @@ void SetPixelMapForSurface( int glImageFormat, int glTexFormat, const RageSurfac
|
|||||||
DebugAssertNoGLError();
|
DebugAssertNoGLError();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uintptr_t RageDisplay_Legacy::CreateTexture(
|
uintptr_t RageDisplay_Legacy::CreateTexture(
|
||||||
RagePixelFormat pixfmt,
|
RagePixelFormat pixfmt,
|
||||||
RageSurface* pImg,
|
RageSurface* pImg,
|
||||||
bool bGenerateMipMaps )
|
bool bGenerateMipMaps )
|
||||||
@@ -2244,7 +2244,7 @@ std::uintptr_t RageDisplay_Legacy::CreateTexture(
|
|||||||
SetTextureUnit( TextureUnit_1 );
|
SetTextureUnit( TextureUnit_1 );
|
||||||
|
|
||||||
// allocate OpenGL texture resource
|
// allocate OpenGL texture resource
|
||||||
std::uintptr_t iTexHandle;
|
uintptr_t iTexHandle;
|
||||||
glGenTextures( 1, reinterpret_cast<GLuint*>(&iTexHandle) );
|
glGenTextures( 1, reinterpret_cast<GLuint*>(&iTexHandle) );
|
||||||
ASSERT( iTexHandle != 0 );
|
ASSERT( iTexHandle != 0 );
|
||||||
|
|
||||||
@@ -2352,7 +2352,7 @@ public:
|
|||||||
m_iTexHandle = 0;
|
m_iTexHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lock( std::uintptr_t iTexHandle, RageSurface *pSurface )
|
void Lock( uintptr_t iTexHandle, RageSurface *pSurface )
|
||||||
{
|
{
|
||||||
ASSERT( m_iTexHandle == 0 );
|
ASSERT( m_iTexHandle == 0 );
|
||||||
ASSERT( pSurface->pixels == nullptr );
|
ASSERT( pSurface->pixels == nullptr );
|
||||||
@@ -2366,7 +2366,7 @@ public:
|
|||||||
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, iSize, nullptr, GL_STREAM_DRAW );
|
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, iSize, nullptr, GL_STREAM_DRAW );
|
||||||
|
|
||||||
void *pSurfaceMemory = glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
|
void *pSurfaceMemory = glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY );
|
||||||
pSurface->pixels = (std::uint8_t *) pSurfaceMemory;
|
pSurface->pixels = (uint8_t *) pSurfaceMemory;
|
||||||
pSurface->pixels_owned = false;
|
pSurface->pixels_owned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2374,7 +2374,7 @@ public:
|
|||||||
{
|
{
|
||||||
glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB );
|
glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB );
|
||||||
|
|
||||||
pSurface->pixels = (std::uint8_t *) BUFFER_OFFSET(0);
|
pSurface->pixels = (uint8_t *) BUFFER_OFFSET(0);
|
||||||
|
|
||||||
if (bChanged)
|
if (bChanged)
|
||||||
DISPLAY->UpdateTexture( m_iTexHandle, pSurface, 0, 0, pSurface->w, pSurface->h );
|
DISPLAY->UpdateTexture( m_iTexHandle, pSurface, 0, 0, pSurface->w, pSurface->h );
|
||||||
@@ -2398,7 +2398,7 @@ private:
|
|||||||
|
|
||||||
GLuint m_iBuffer;
|
GLuint m_iBuffer;
|
||||||
|
|
||||||
std::uintptr_t m_iTexHandle;
|
uintptr_t m_iTexHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
RageTextureLock *RageDisplay_Legacy::CreateTextureLock()
|
RageTextureLock *RageDisplay_Legacy::CreateTextureLock()
|
||||||
@@ -2410,7 +2410,7 @@ RageTextureLock *RageDisplay_Legacy::CreateTextureLock()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_Legacy::UpdateTexture(
|
void RageDisplay_Legacy::UpdateTexture(
|
||||||
std::uintptr_t iTexHandle,
|
uintptr_t iTexHandle,
|
||||||
RageSurface* pImg,
|
RageSurface* pImg,
|
||||||
int iXOffset, int iYOffset, int iWidth, int iHeight )
|
int iXOffset, int iYOffset, int iWidth, int iHeight )
|
||||||
{
|
{
|
||||||
@@ -2452,16 +2452,16 @@ public:
|
|||||||
RenderTarget_FramebufferObject();
|
RenderTarget_FramebufferObject();
|
||||||
~RenderTarget_FramebufferObject();
|
~RenderTarget_FramebufferObject();
|
||||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||||
std::uintptr_t GetTexture() const { return m_iTexHandle; }
|
uintptr_t GetTexture() const { return m_iTexHandle; }
|
||||||
void StartRenderingTo();
|
void StartRenderingTo();
|
||||||
void FinishRenderingTo();
|
void FinishRenderingTo();
|
||||||
|
|
||||||
virtual bool InvertY() const { return true; }
|
virtual bool InvertY() const { return true; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::uintptr_t m_iFrameBufferHandle;
|
uintptr_t m_iFrameBufferHandle;
|
||||||
std::uintptr_t m_iTexHandle;
|
uintptr_t m_iTexHandle;
|
||||||
std::uintptr_t m_iDepthBufferHandle;
|
uintptr_t m_iDepthBufferHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
RenderTarget_FramebufferObject::RenderTarget_FramebufferObject()
|
RenderTarget_FramebufferObject::RenderTarget_FramebufferObject()
|
||||||
@@ -2584,7 +2584,7 @@ bool RageDisplay_Legacy::SupportsFullscreenBorderlessWindow() const
|
|||||||
* particularly GeForce 2, but is simpler and faster when available.
|
* particularly GeForce 2, but is simpler and faster when available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
std::uintptr_t RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut )
|
uintptr_t RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut )
|
||||||
{
|
{
|
||||||
RenderTarget *pTarget;
|
RenderTarget *pTarget;
|
||||||
if (GLEW_EXT_framebuffer_object)
|
if (GLEW_EXT_framebuffer_object)
|
||||||
@@ -2594,22 +2594,22 @@ std::uintptr_t RageDisplay_Legacy::CreateRenderTarget( const RenderTargetParam &
|
|||||||
|
|
||||||
pTarget->Create( param, iTextureWidthOut, iTextureHeightOut );
|
pTarget->Create( param, iTextureWidthOut, iTextureHeightOut );
|
||||||
|
|
||||||
std::uintptr_t iTexture = pTarget->GetTexture();
|
uintptr_t iTexture = pTarget->GetTexture();
|
||||||
|
|
||||||
ASSERT( g_mapRenderTargets.find(iTexture) == g_mapRenderTargets.end() );
|
ASSERT( g_mapRenderTargets.find(iTexture) == g_mapRenderTargets.end() );
|
||||||
g_mapRenderTargets[iTexture] = pTarget;
|
g_mapRenderTargets[iTexture] = pTarget;
|
||||||
return iTexture;
|
return iTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uintptr_t RageDisplay_Legacy::GetRenderTarget()
|
uintptr_t RageDisplay_Legacy::GetRenderTarget()
|
||||||
{
|
{
|
||||||
for( std::map<std::uintptr_t, RenderTarget*>::const_iterator it = g_mapRenderTargets.begin(); it != g_mapRenderTargets.end(); ++it )
|
for( std::map<uintptr_t, RenderTarget*>::const_iterator it = g_mapRenderTargets.begin(); it != g_mapRenderTargets.end(); ++it )
|
||||||
if( it->second == g_pCurrentRenderTarget )
|
if( it->second == g_pCurrentRenderTarget )
|
||||||
return it->first;
|
return it->first;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageDisplay_Legacy::SetRenderTarget( std::uintptr_t iTexture, bool bPreserveTexture )
|
void RageDisplay_Legacy::SetRenderTarget( uintptr_t iTexture, bool bPreserveTexture )
|
||||||
{
|
{
|
||||||
if (iTexture == 0)
|
if (iTexture == 0)
|
||||||
{
|
{
|
||||||
@@ -2688,7 +2688,7 @@ void RageDisplay_Legacy::SetLineWidth(float fWidth)
|
|||||||
glLineWidth(fWidth);
|
glLineWidth(fWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
RString RageDisplay_Legacy::GetTextureDiagnostics(std::uintptr_t iTexture) const
|
RString RageDisplay_Legacy::GetTextureDiagnostics(uintptr_t iTexture) const
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
s << (bGenerateMipMaps? "gluBuild2DMipmaps":"glTexImage2D");
|
s << (bGenerateMipMaps? "gluBuild2DMipmaps":"glTexImage2D");
|
||||||
|
|||||||
@@ -55,23 +55,23 @@ public:
|
|||||||
void SetBlendMode( BlendMode mode );
|
void SetBlendMode( BlendMode mode );
|
||||||
bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false );
|
bool SupportsTextureFormat( RagePixelFormat pixfmt, bool realtime=false );
|
||||||
bool SupportsPerVertexMatrixScale();
|
bool SupportsPerVertexMatrixScale();
|
||||||
std::uintptr_t CreateTexture(
|
uintptr_t CreateTexture(
|
||||||
RagePixelFormat pixfmt,
|
RagePixelFormat pixfmt,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
bool bGenerateMipMaps );
|
bool bGenerateMipMaps );
|
||||||
void UpdateTexture(
|
void UpdateTexture(
|
||||||
std::uintptr_t iTexHandle,
|
uintptr_t iTexHandle,
|
||||||
RageSurface* img,
|
RageSurface* img,
|
||||||
int xoffset, int yoffset, int width, int height
|
int xoffset, int yoffset, int width, int height
|
||||||
);
|
);
|
||||||
void DeleteTexture( std::uintptr_t iTexHandle );
|
void DeleteTexture( uintptr_t iTexHandle );
|
||||||
bool UseOffscreenRenderTarget();
|
bool UseOffscreenRenderTarget();
|
||||||
RageSurface *GetTexture( std::uintptr_t iTexture );
|
RageSurface *GetTexture( uintptr_t iTexture );
|
||||||
RageTextureLock *CreateTextureLock();
|
RageTextureLock *CreateTextureLock();
|
||||||
|
|
||||||
void ClearAllTextures();
|
void ClearAllTextures();
|
||||||
int GetNumTextureUnits();
|
int GetNumTextureUnits();
|
||||||
void SetTexture( TextureUnit tu, std::uintptr_t iTexture );
|
void SetTexture( TextureUnit tu, uintptr_t iTexture );
|
||||||
void SetTextureMode( TextureUnit tu, TextureMode tm );
|
void SetTextureMode( TextureUnit tu, TextureMode tm );
|
||||||
void SetTextureWrapping( TextureUnit tu, bool b );
|
void SetTextureWrapping( TextureUnit tu, bool b );
|
||||||
int GetMaxTextureSize() const;
|
int GetMaxTextureSize() const;
|
||||||
@@ -80,9 +80,9 @@ public:
|
|||||||
bool IsEffectModeSupported( EffectMode effect );
|
bool IsEffectModeSupported( EffectMode effect );
|
||||||
bool SupportsRenderToTexture() const;
|
bool SupportsRenderToTexture() const;
|
||||||
bool SupportsFullscreenBorderlessWindow() const;
|
bool SupportsFullscreenBorderlessWindow() const;
|
||||||
std::uintptr_t CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
uintptr_t CreateRenderTarget( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||||
std::uintptr_t GetRenderTarget();
|
uintptr_t GetRenderTarget();
|
||||||
void SetRenderTarget( std::uintptr_t iHandle, bool bPreserveTexture );
|
void SetRenderTarget( uintptr_t iHandle, bool bPreserveTexture );
|
||||||
bool IsZWriteEnabled() const;
|
bool IsZWriteEnabled() const;
|
||||||
bool IsZTestEnabled() const;
|
bool IsZTestEnabled() const;
|
||||||
void SetZWrite( bool b );
|
void SetZWrite( bool b );
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
virtual void SetPolygonMode( PolygonMode pm );
|
virtual void SetPolygonMode( PolygonMode pm );
|
||||||
virtual void SetLineWidth( float fWidth );
|
virtual void SetLineWidth( float fWidth );
|
||||||
|
|
||||||
RString GetTextureDiagnostics( std::uintptr_t id ) const;
|
RString GetTextureDiagnostics( uintptr_t id ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts );
|
void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts );
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
virtual ~RenderTarget() { }
|
virtual ~RenderTarget() { }
|
||||||
virtual void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ) = 0;
|
virtual void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut ) = 0;
|
||||||
|
|
||||||
virtual std::uintptr_t GetTexture() const = 0;
|
virtual uintptr_t GetTexture() const = 0;
|
||||||
|
|
||||||
/* Render to this RenderTarget. */
|
/* Render to this RenderTarget. */
|
||||||
virtual void StartRenderingTo() = 0;
|
virtual void StartRenderingTo() = 0;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using CrashHandler::IsDebuggerPresent;
|
|||||||
using CrashHandler::DebugBreak;
|
using CrashHandler::DebugBreak;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::uint64_t g_HandlerThreadID = RageThread::GetInvalidThreadID();
|
static uint64_t g_HandlerThreadID = RageThread::GetInvalidThreadID();
|
||||||
static void (*g_CleanupHandler)( const RString &sError ) = nullptr;
|
static void (*g_CleanupHandler)( const RString &sError ) = nullptr;
|
||||||
void RageException::SetCleanupHandler( void (*pHandler)(const RString &sError) )
|
void RageException::SetCleanupHandler( void (*pHandler)(const RString &sError) )
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-10
@@ -111,7 +111,7 @@ void RageFile::EnableCRC32( bool on )
|
|||||||
m_File->EnableCRC32( on );
|
m_File->EnableCRC32( on );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageFile::GetCRC32( std::uint32_t *iRet )
|
bool RageFile::GetCRC32( uint32_t *iRet )
|
||||||
{
|
{
|
||||||
ASSERT_OPEN;
|
ASSERT_OPEN;
|
||||||
return m_File->GetCRC32( iRet );
|
return m_File->GetCRC32( iRet );
|
||||||
@@ -267,20 +267,20 @@ void FileReading::Seek( RageFileBasic &f, int iOffset, RString &sError )
|
|||||||
sError = "Unexpected end of file";
|
sError = "Unexpected end of file";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t FileReading::read_8( RageFileBasic &f, RString &sError )
|
uint8_t FileReading::read_8( RageFileBasic &f, RString &sError )
|
||||||
{
|
{
|
||||||
std::uint8_t val;
|
uint8_t val;
|
||||||
ReadBytes( f, &val, sizeof(std::uint8_t), sError );
|
ReadBytes( f, &val, sizeof(uint8_t), sError );
|
||||||
if( sError.size() == 0 )
|
if( sError.size() == 0 )
|
||||||
return val;
|
return val;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint16_t FileReading::read_u16_le( RageFileBasic &f, RString &sError )
|
uint16_t FileReading::read_u16_le( RageFileBasic &f, RString &sError )
|
||||||
{
|
{
|
||||||
std::uint16_t val;
|
uint16_t val;
|
||||||
ReadBytes( f, &val, sizeof(std::uint16_t), sError );
|
ReadBytes( f, &val, sizeof(uint16_t), sError );
|
||||||
if( sError.size() == 0 )
|
if( sError.size() == 0 )
|
||||||
return Swap16LE( val );
|
return Swap16LE( val );
|
||||||
else
|
else
|
||||||
@@ -297,10 +297,10 @@ std::int16_t FileReading::read_16_le( RageFileBasic &f, RString &sError )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t FileReading::read_u32_le( RageFileBasic &f, RString &sError )
|
uint32_t FileReading::read_u32_le( RageFileBasic &f, RString &sError )
|
||||||
{
|
{
|
||||||
std::uint32_t val;
|
uint32_t val;
|
||||||
ReadBytes( f, &val, sizeof(std::uint32_t), sError );
|
ReadBytes( f, &val, sizeof(uint32_t), sError );
|
||||||
if( sError.size() == 0 )
|
if( sError.size() == 0 )
|
||||||
return Swap32LE( val );
|
return Swap32LE( val );
|
||||||
else
|
else
|
||||||
|
|||||||
+4
-4
@@ -78,7 +78,7 @@ public:
|
|||||||
int PutLine( const RString &str );
|
int PutLine( const RString &str );
|
||||||
|
|
||||||
void EnableCRC32( bool on=true );
|
void EnableCRC32( bool on=true );
|
||||||
bool GetCRC32( std::uint32_t *iRet );
|
bool GetCRC32( uint32_t *iRet );
|
||||||
|
|
||||||
// Lua
|
// Lua
|
||||||
virtual void PushSelf( lua_State *L );
|
virtual void PushSelf( lua_State *L );
|
||||||
@@ -103,11 +103,11 @@ namespace FileReading
|
|||||||
void SkipBytes( RageFileBasic &f, int size, RString &sError );
|
void SkipBytes( RageFileBasic &f, int size, RString &sError );
|
||||||
void Seek( RageFileBasic &f, int iOffset, RString &sError );
|
void Seek( RageFileBasic &f, int iOffset, RString &sError );
|
||||||
RString ReadString( RageFileBasic &f, int size, RString &sError );
|
RString ReadString( RageFileBasic &f, int size, RString &sError );
|
||||||
std::uint8_t read_8( RageFileBasic &f, RString &sError );
|
uint8_t read_8( RageFileBasic &f, RString &sError );
|
||||||
std::int16_t read_16_le( RageFileBasic &f, RString &sError );
|
std::int16_t read_16_le( RageFileBasic &f, RString &sError );
|
||||||
std::uint16_t read_u16_le( RageFileBasic &f, RString &sError );
|
uint16_t read_u16_le( RageFileBasic &f, RString &sError );
|
||||||
std::int32_t read_32_le( RageFileBasic &f, RString &sError );
|
std::int32_t read_32_le( RageFileBasic &f, RString &sError );
|
||||||
std::uint32_t read_u32_le( RageFileBasic &f, RString &sError );
|
uint32_t read_u32_le( RageFileBasic &f, RString &sError );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ void RageFileObj::EnableCRC32( bool bOn )
|
|||||||
m_iCRC32 = 0;
|
m_iCRC32 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageFileObj::GetCRC32( std::uint32_t *iRet )
|
bool RageFileObj::GetCRC32( uint32_t *iRet )
|
||||||
{
|
{
|
||||||
if( !m_bCRC32Enabled )
|
if( !m_bCRC32Enabled )
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-3
@@ -55,7 +55,7 @@ public:
|
|||||||
virtual int PutLine( const RString &str ) = 0;
|
virtual int PutLine( const RString &str ) = 0;
|
||||||
|
|
||||||
virtual void EnableCRC32( bool on=true ) = 0;
|
virtual void EnableCRC32( bool on=true ) = 0;
|
||||||
virtual bool GetCRC32( std::uint32_t *iRet ) = 0;
|
virtual bool GetCRC32( uint32_t *iRet ) = 0;
|
||||||
|
|
||||||
virtual int GetFileSize() const = 0;
|
virtual int GetFileSize() const = 0;
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ public:
|
|||||||
int PutLine( const RString &str );
|
int PutLine( const RString &str );
|
||||||
|
|
||||||
void EnableCRC32( bool on=true );
|
void EnableCRC32( bool on=true );
|
||||||
bool GetCRC32( std::uint32_t *iRet );
|
bool GetCRC32( uint32_t *iRet );
|
||||||
|
|
||||||
virtual int GetFileSize() const = 0;
|
virtual int GetFileSize() const = 0;
|
||||||
virtual int GetFD() { return -1; }
|
virtual int GetFD() { return -1; }
|
||||||
@@ -156,7 +156,7 @@ private:
|
|||||||
* This is only meaningful if EnableCRC32() is called at the very start of the
|
* This is only meaningful if EnableCRC32() is called at the very start of the
|
||||||
* file, and no seeking is performed. */
|
* file, and no seeking is performed. */
|
||||||
bool m_bCRC32Enabled;
|
bool m_bCRC32Enabled;
|
||||||
std::uint32_t m_iCRC32;
|
uint32_t m_iCRC32;
|
||||||
|
|
||||||
// Swallow up warnings. If they must be used, define them.
|
// Swallow up warnings. If they must be used, define them.
|
||||||
RageFileObj& operator=(const RageFileObj& rhs);
|
RageFileObj& operator=(const RageFileObj& rhs);
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ int RageFileObjDeflate::FlushInternal()
|
|||||||
* Parse a .gz file, check the header CRC16 if present, and return the data
|
* Parse a .gz file, check the header CRC16 if present, and return the data
|
||||||
* CRC32 and a decompressor. pFile will be deleted.
|
* CRC32 and a decompressor. pFile will be deleted.
|
||||||
*/
|
*/
|
||||||
RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, std::uint32_t *iCRC32 )
|
RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, uint32_t *iCRC32 )
|
||||||
{
|
{
|
||||||
std::unique_ptr<RageFileBasic> pFile(pFile_);
|
std::unique_ptr<RageFileBasic> pFile(pFile_);
|
||||||
|
|
||||||
@@ -336,8 +336,8 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, std::uin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t iCompressionMethod = FileReading::read_8( *pFile, sError );
|
uint8_t iCompressionMethod = FileReading::read_8( *pFile, sError );
|
||||||
std::uint8_t iFlags = FileReading::read_8( *pFile, sError );
|
uint8_t iFlags = FileReading::read_8( *pFile, sError );
|
||||||
FileReading::read_32_le( *pFile, sError ); /* time */
|
FileReading::read_32_le( *pFile, sError ); /* time */
|
||||||
FileReading::read_8( *pFile, sError ); /* xfl */
|
FileReading::read_8( *pFile, sError ); /* xfl */
|
||||||
FileReading::read_8( *pFile, sError ); /* os */
|
FileReading::read_8( *pFile, sError ); /* os */
|
||||||
@@ -381,12 +381,12 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, std::uin
|
|||||||
{
|
{
|
||||||
/* Get the CRC of the data read so far. Be sure to do this before
|
/* Get the CRC of the data read so far. Be sure to do this before
|
||||||
* reading iExpectedCRC16. */
|
* reading iExpectedCRC16. */
|
||||||
std::uint32_t iActualCRC32;
|
uint32_t iActualCRC32;
|
||||||
bool bOK = pFile->GetCRC32( &iActualCRC32 );
|
bool bOK = pFile->GetCRC32( &iActualCRC32 );
|
||||||
ASSERT( bOK );
|
ASSERT( bOK );
|
||||||
|
|
||||||
std::uint16_t iExpectedCRC16 = FileReading::read_u16_le( *pFile, sError );
|
uint16_t iExpectedCRC16 = FileReading::read_u16_le( *pFile, sError );
|
||||||
std::uint16_t iActualCRC16 = std::int16_t( iActualCRC32 & 0xFFFF );
|
uint16_t iActualCRC16 = std::int16_t( iActualCRC32 & 0xFFFF );
|
||||||
if( sError != "" )
|
if( sError != "" )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -411,8 +411,8 @@ RageFileObjInflate *GunzipFile( RageFileBasic *pFile_, RString &sError, std::uin
|
|||||||
|
|
||||||
FileReading::Seek( *pFile, iFooterPos, sError );
|
FileReading::Seek( *pFile, iFooterPos, sError );
|
||||||
|
|
||||||
std::uint32_t iExpectedCRC32 = FileReading::read_u32_le( *pFile, sError );
|
uint32_t iExpectedCRC32 = FileReading::read_u32_le( *pFile, sError );
|
||||||
std::uint32_t iUncompressedSize = FileReading::read_u32_le( *pFile, sError );
|
uint32_t iUncompressedSize = FileReading::read_u32_le( *pFile, sError );
|
||||||
if( iCRC32 != nullptr )
|
if( iCRC32 != nullptr )
|
||||||
*iCRC32 = iExpectedCRC32;
|
*iCRC32 = iExpectedCRC32;
|
||||||
|
|
||||||
@@ -487,12 +487,12 @@ int RageFileObjGzip::Finish()
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Read the CRC of the data that's been written. */
|
/* Read the CRC of the data that's been written. */
|
||||||
std::uint32_t iCRC;
|
uint32_t iCRC;
|
||||||
bool bOK = this->GetCRC32( &iCRC );
|
bool bOK = this->GetCRC32( &iCRC );
|
||||||
ASSERT( bOK );
|
ASSERT( bOK );
|
||||||
|
|
||||||
/* Figure out the size of the data. */
|
/* Figure out the size of the data. */
|
||||||
std::uint32_t iSize = Tell() - m_iDataStartOffset;
|
uint32_t iSize = Tell() - m_iDataStartOffset;
|
||||||
|
|
||||||
/* Write the CRC and size directly to the file, so they don't get compressed. */
|
/* Write the CRC and size directly to the file, so they don't get compressed. */
|
||||||
iCRC = Swap32LE( iCRC );
|
iCRC = Swap32LE( iCRC );
|
||||||
@@ -533,7 +533,7 @@ bool GunzipString( const RString &sIn, RString &sOut, RString &sError )
|
|||||||
RageFileObjMem *mem = new RageFileObjMem;
|
RageFileObjMem *mem = new RageFileObjMem;
|
||||||
mem->PutString( sIn );
|
mem->PutString( sIn );
|
||||||
|
|
||||||
std::uint32_t iCRC32;
|
uint32_t iCRC32;
|
||||||
RageFileBasic *pFile = GunzipFile( mem, sError, &iCRC32 );
|
RageFileBasic *pFile = GunzipFile( mem, sError, &iCRC32 );
|
||||||
if( pFile == nullptr )
|
if( pFile == nullptr )
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ private:
|
|||||||
int m_iDataStartOffset;
|
int m_iDataStartOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
RageFileObjInflate *GunzipFile( RageFileBasic *pFile, RString &sError, std::uint32_t *iCRC32 );
|
RageFileObjInflate *GunzipFile( RageFileBasic *pFile, RString &sError, uint32_t *iCRC32 );
|
||||||
|
|
||||||
/* Quick helpers: */
|
/* Quick helpers: */
|
||||||
void GzipString( const RString &sIn, RString &sOut );
|
void GzipString( const RString &sIn, RString &sOut );
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ size_t zipRead(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
|
|||||||
RageFile *f = static_cast<RageFile*>(pOpaque);
|
RageFile *f = static_cast<RageFile*>(pOpaque);
|
||||||
|
|
||||||
const int pos = f->Seek(file_ofs);
|
const int pos = f->Seek(file_ofs);
|
||||||
if (pos >= 0 && static_cast<std::uint64_t>(pos) != file_ofs)
|
if (pos >= 0 && static_cast<uint64_t>(pos) != file_ofs)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ void RageModelGeometry::MergeMeshes( int iFromIndex, int iToIndex )
|
|||||||
{
|
{
|
||||||
for( int j=0; j<3; j++ )
|
for( int j=0; j<3; j++ )
|
||||||
{
|
{
|
||||||
std::uint16_t &iIndex = meshTo.Triangles[i].nVertexIndices[j];
|
uint16_t &iIndex = meshTo.Triangles[i].nVertexIndices[j];
|
||||||
iIndex = std::uint16_t(iIndex + iShiftTriangleVertexIndicesBy);
|
iIndex = uint16_t(iIndex + iShiftTriangleVertexIndicesBy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ void RageModelGeometry::LoadMilkshapeAscii( const RString& _sPath, bool bNeedsNo
|
|||||||
|
|
||||||
mesh.sName = szName;
|
mesh.sName = szName;
|
||||||
// mesh.nFlags = nFlags;
|
// mesh.nFlags = nFlags;
|
||||||
mesh.nMaterialIndex = (std::uint8_t) nIndex;
|
mesh.nMaterialIndex = (uint8_t) nIndex;
|
||||||
|
|
||||||
mesh.m_iBoneIndex = -1;
|
mesh.m_iBoneIndex = -1;
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ void RageModelGeometry::LoadMilkshapeAscii( const RString& _sPath, bool bNeedsNo
|
|||||||
v.t[0] = v.p[0] / v.t[0];
|
v.t[0] = v.p[0] / v.t[0];
|
||||||
v.t[1] = v.p[1] / v.t[1];
|
v.t[1] = v.p[1] / v.t[1];
|
||||||
}
|
}
|
||||||
v.bone = (std::uint8_t) nIndex;
|
v.bone = (uint8_t) nIndex;
|
||||||
RageVec3AddToBounds( v.p, m_vMins, m_vMaxs );
|
RageVec3AddToBounds( v.p, m_vMins, m_vMaxs );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,8 +240,8 @@ void RageModelGeometry::LoadMilkshapeAscii( const RString& _sPath, bool bNeedsNo
|
|||||||
if( f.GetLine( sLine ) <= 0 )
|
if( f.GetLine( sLine ) <= 0 )
|
||||||
THROW;
|
THROW;
|
||||||
|
|
||||||
std::uint16_t nIndices[3];
|
uint16_t nIndices[3];
|
||||||
std::uint16_t nNormalIndices[3];
|
uint16_t nNormalIndices[3];
|
||||||
if( sscanf (sLine, "%d %hu %hu %hu %hu %hu %hu %d",
|
if( sscanf (sLine, "%d %hu %hu %hu %hu %hu %hu %d",
|
||||||
&nFlags,
|
&nFlags,
|
||||||
&nIndices[0], &nIndices[1], &nIndices[2],
|
&nIndices[0], &nIndices[1], &nIndices[2],
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void RageSoundMixBuffer::SetWriteOffset( int iOffset )
|
|||||||
|
|
||||||
void RageSoundMixBuffer::Extend(unsigned iSamples)
|
void RageSoundMixBuffer::Extend(unsigned iSamples)
|
||||||
{
|
{
|
||||||
const std::uint64_t realsize = static_cast<std::uint64_t>(iSamples) + static_cast<std::uint64_t>(m_iOffset);
|
const uint64_t realsize = static_cast<uint64_t>(iSamples) + static_cast<uint64_t>(m_iOffset);
|
||||||
if( m_iBufSize < realsize )
|
if( m_iBufSize < realsize )
|
||||||
{
|
{
|
||||||
m_pMixbuf = static_cast<float*>(std::realloc(m_pMixbuf, sizeof(float) * realsize));
|
m_pMixbuf = static_cast<float*>(std::realloc(m_pMixbuf, sizeof(float) * realsize));
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
float *m_pMixbuf;
|
float *m_pMixbuf;
|
||||||
std::uint64_t m_iBufSize; // actual allocated samples
|
uint64_t m_iBufSize; // actual allocated samples
|
||||||
std::uint64_t m_iBufUsed; // used samples
|
uint64_t m_iBufUsed; // used samples
|
||||||
int m_iOffset;
|
int m_iOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ struct madlib_t
|
|||||||
bitrate = 0;
|
bitrate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t inbuf[16384];
|
uint8_t inbuf[16384];
|
||||||
float outbuf[8192];
|
float outbuf[8192];
|
||||||
int outpos;
|
int outpos;
|
||||||
unsigned outleft;
|
unsigned outleft;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace
|
|||||||
void Convert8bitToFloat( void *pBuf, int iSamples )
|
void Convert8bitToFloat( void *pBuf, int iSamples )
|
||||||
{
|
{
|
||||||
/* Convert in reverse, so we can do it in-place. */
|
/* Convert in reverse, so we can do it in-place. */
|
||||||
const std::uint8_t *pIn = (std::uint8_t *) pBuf;
|
const uint8_t *pIn = (uint8_t *) pBuf;
|
||||||
float *pOut = (float *) pBuf;
|
float *pOut = (float *) pBuf;
|
||||||
for( int i = iSamples-1; i >= 0; --i )
|
for( int i = iSamples-1; i >= 0; --i )
|
||||||
{
|
{
|
||||||
@@ -309,7 +309,7 @@ public:
|
|||||||
pBuffer[m_iBufferAvail++] = (std::int16_t)iSamp1[i] / 32768.0f;
|
pBuffer[m_iBufferAvail++] = (std::int16_t)iSamp1[i] / 32768.0f;
|
||||||
|
|
||||||
std::int8_t iBufSize = 0;
|
std::int8_t iBufSize = 0;
|
||||||
std::uint8_t iBuf = 0;
|
uint8_t iBuf = 0;
|
||||||
|
|
||||||
bool bDone = false;
|
bool bDone = false;
|
||||||
for( int i = 2; !bDone && i < m_iFramesPerBlock; ++i )
|
for( int i = 2; !bDone && i < m_iFramesPerBlock; ++i )
|
||||||
@@ -331,7 +331,7 @@ public:
|
|||||||
|
|
||||||
/* Store the nibble in signed char, so we get an arithmetic shift. */
|
/* Store the nibble in signed char, so we get an arithmetic shift. */
|
||||||
std::int8_t iErrorDelta = (std::int8_t)(iBuf) >> 4;
|
std::int8_t iErrorDelta = (std::int8_t)(iBuf) >> 4;
|
||||||
std::uint8_t iErrorDeltaUnsigned = iBuf >> 4;
|
uint8_t iErrorDeltaUnsigned = iBuf >> 4;
|
||||||
iBuf <<= 4;
|
iBuf <<= 4;
|
||||||
--iBufSize;
|
--iBufSize;
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -61,7 +61,7 @@ RageSurfaceFormat::RageSurfaceFormat( const RageSurfaceFormat &cpy ):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceFormat::GetRGB( std::uint32_t val, std::uint8_t *r, std::uint8_t *g, std::uint8_t *b ) const
|
void RageSurfaceFormat::GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b ) const
|
||||||
{
|
{
|
||||||
if( BytesPerPixel == 1 )
|
if( BytesPerPixel == 1 )
|
||||||
{
|
{
|
||||||
@@ -76,7 +76,7 @@ void RageSurfaceFormat::GetRGB( std::uint32_t val, std::uint8_t *r, std::uint8_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageSurfaceFormat::MapRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint32_t &val ) const
|
bool RageSurfaceFormat::MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint32_t &val ) const
|
||||||
{
|
{
|
||||||
if( BytesPerPixel == 1 )
|
if( BytesPerPixel == 1 )
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ bool RageSurfaceFormat::MapRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b,
|
|||||||
std::int32_t n = palette->FindColor( c );
|
std::int32_t n = palette->FindColor( c );
|
||||||
if( n == -1 )
|
if( n == -1 )
|
||||||
return false;
|
return false;
|
||||||
val = (std::uint32_t) n;
|
val = (uint32_t) n;
|
||||||
} else {
|
} else {
|
||||||
val =
|
val =
|
||||||
(r >> Loss[0] << Shift[0]) |
|
(r >> Loss[0] << Shift[0]) |
|
||||||
@@ -137,7 +137,7 @@ RageSurface::RageSurface( const RageSurface &cpy )
|
|||||||
pixels_owned = true;
|
pixels_owned = true;
|
||||||
if( cpy.pixels )
|
if( cpy.pixels )
|
||||||
{
|
{
|
||||||
pixels = new std::uint8_t[ pitch*h ];
|
pixels = new uint8_t[ pitch*h ];
|
||||||
memcpy( pixels, cpy.pixels, pitch*h );
|
memcpy( pixels, cpy.pixels, pitch*h );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -150,7 +150,7 @@ RageSurface::~RageSurface()
|
|||||||
delete [] pixels;
|
delete [] pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetShiftFromMask( std::uint32_t mask )
|
static int GetShiftFromMask( uint32_t mask )
|
||||||
{
|
{
|
||||||
if( !mask )
|
if( !mask )
|
||||||
return 0;
|
return 0;
|
||||||
@@ -164,7 +164,7 @@ static int GetShiftFromMask( std::uint32_t mask )
|
|||||||
return iShift;
|
return iShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetBitsFromMask( std::uint32_t mask )
|
static int GetBitsFromMask( uint32_t mask )
|
||||||
{
|
{
|
||||||
if( !mask )
|
if( !mask )
|
||||||
return 0;
|
return 0;
|
||||||
@@ -182,7 +182,7 @@ static int GetBitsFromMask( std::uint32_t mask )
|
|||||||
|
|
||||||
|
|
||||||
void SetupFormat( RageSurfaceFormat &fmt,
|
void SetupFormat( RageSurfaceFormat &fmt,
|
||||||
int width, int height, int BitsPerPixel, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask )
|
int width, int height, int BitsPerPixel, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask )
|
||||||
{
|
{
|
||||||
fmt.BitsPerPixel = BitsPerPixel;
|
fmt.BitsPerPixel = BitsPerPixel;
|
||||||
fmt.BytesPerPixel = BitsPerPixel/8;
|
fmt.BytesPerPixel = BitsPerPixel/8;
|
||||||
@@ -209,14 +209,14 @@ void SetupFormat( RageSurfaceFormat &fmt,
|
|||||||
fmt.Shift[2] = GetShiftFromMask( Bmask );
|
fmt.Shift[2] = GetShiftFromMask( Bmask );
|
||||||
fmt.Shift[3] = GetShiftFromMask( Amask );
|
fmt.Shift[3] = GetShiftFromMask( Amask );
|
||||||
|
|
||||||
fmt.Loss[0] = (std::uint8_t) (8-GetBitsFromMask( Rmask ));
|
fmt.Loss[0] = (uint8_t) (8-GetBitsFromMask( Rmask ));
|
||||||
fmt.Loss[1] = (std::uint8_t) (8-GetBitsFromMask( Gmask ));
|
fmt.Loss[1] = (uint8_t) (8-GetBitsFromMask( Gmask ));
|
||||||
fmt.Loss[2] = (std::uint8_t) (8-GetBitsFromMask( Bmask ));
|
fmt.Loss[2] = (uint8_t) (8-GetBitsFromMask( Bmask ));
|
||||||
fmt.Loss[3] = (std::uint8_t) (8-GetBitsFromMask( Amask ));
|
fmt.Loss[3] = (uint8_t) (8-GetBitsFromMask( Amask ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSurface *CreateSurface( int width, int height, int BitsPerPixel, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask )
|
RageSurface *CreateSurface( int width, int height, int BitsPerPixel, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask )
|
||||||
{
|
{
|
||||||
RageSurface *pImg = new RageSurface;
|
RageSurface *pImg = new RageSurface;
|
||||||
|
|
||||||
@@ -226,7 +226,7 @@ RageSurface *CreateSurface( int width, int height, int BitsPerPixel, std::uint32
|
|||||||
pImg->h = height;
|
pImg->h = height;
|
||||||
pImg->flags = 0;
|
pImg->flags = 0;
|
||||||
pImg->pitch = width*BitsPerPixel/8;
|
pImg->pitch = width*BitsPerPixel/8;
|
||||||
pImg->pixels = new std::uint8_t[ pImg->pitch*height ];
|
pImg->pixels = new uint8_t[ pImg->pitch*height ];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if( BitsPerPixel == 8 )
|
if( BitsPerPixel == 8 )
|
||||||
@@ -238,7 +238,7 @@ RageSurface *CreateSurface( int width, int height, int BitsPerPixel, std::uint32
|
|||||||
return pImg;
|
return pImg;
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSurface *CreateSurfaceFrom( int width, int height, int BitsPerPixel, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask, std::uint8_t *pPixels, std::uint32_t pitch )
|
RageSurface *CreateSurfaceFrom( int width, int height, int BitsPerPixel, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask, uint8_t *pPixels, uint32_t pitch )
|
||||||
{
|
{
|
||||||
RageSurface *pImg = new RageSurface;
|
RageSurface *pImg = new RageSurface;
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -10,9 +10,9 @@
|
|||||||
/* XXX remove? */
|
/* XXX remove? */
|
||||||
struct RageSurfaceColor
|
struct RageSurfaceColor
|
||||||
{
|
{
|
||||||
std::uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
RageSurfaceColor(): r(0), g(0), b(0), a(0) { }
|
RageSurfaceColor(): r(0), g(0), b(0), a(0) { }
|
||||||
RageSurfaceColor( std::uint8_t r_, std::uint8_t g_, std::uint8_t b_, std::uint8_t a_ ):
|
RageSurfaceColor( uint8_t r_, uint8_t g_, uint8_t b_, uint8_t a_ ):
|
||||||
r(r_), g(g_), b(b_), a(a_) { }
|
r(r_), g(g_), b(b_), a(a_) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,22 +48,22 @@ struct RageSurfaceFormat
|
|||||||
|
|
||||||
std::int32_t BytesPerPixel;
|
std::int32_t BytesPerPixel;
|
||||||
std::int32_t BitsPerPixel;
|
std::int32_t BitsPerPixel;
|
||||||
std::array<std::uint32_t, 4> Mask;
|
std::array<uint32_t, 4> Mask;
|
||||||
std::array<std::uint32_t, 4> Shift;
|
std::array<uint32_t, 4> Shift;
|
||||||
std::array<std::uint32_t, 4> Loss;
|
std::array<uint32_t, 4> Loss;
|
||||||
std::uint32_t &Rmask, &Gmask, &Bmask, &Amask; /* deprecated */
|
uint32_t &Rmask, &Gmask, &Bmask, &Amask; /* deprecated */
|
||||||
std::uint32_t &Rshift, &Gshift, &Bshift, &Ashift; /* deprecated */
|
uint32_t &Rshift, &Gshift, &Bshift, &Ashift; /* deprecated */
|
||||||
std::unique_ptr<RageSurfacePalette> palette;
|
std::unique_ptr<RageSurfacePalette> palette;
|
||||||
|
|
||||||
void GetRGB( std::uint32_t val, std::uint8_t *r, std::uint8_t *g, std::uint8_t *b ) const;
|
void GetRGB( uint32_t val, uint8_t *r, uint8_t *g, uint8_t *b ) const;
|
||||||
|
|
||||||
/* Return the decoded value for the given color; the result can be compared to
|
/* Return the decoded value for the given color; the result can be compared to
|
||||||
* decodepixel() results. If the image is paletted and the color isn't found,
|
* decodepixel() results. If the image is paletted and the color isn't found,
|
||||||
* val is undefined and false is returned. */
|
* val is undefined and false is returned. */
|
||||||
bool MapRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a, std::uint32_t &val ) const;
|
bool MapRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint32_t &val ) const;
|
||||||
|
|
||||||
/* MapRGBA, but also do a nearest-match on palette colors. */
|
/* MapRGBA, but also do a nearest-match on palette colors. */
|
||||||
std::uint32_t MapNearestRGBA( std::uint8_t r, std::uint8_t g, std::uint8_t b, std::uint8_t a ) const;
|
uint32_t MapNearestRGBA( uint8_t r, uint8_t g, uint8_t b, uint8_t a ) const;
|
||||||
|
|
||||||
bool operator== ( const RageSurfaceFormat &rhs ) const;
|
bool operator== ( const RageSurfaceFormat &rhs ) const;
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ struct RageSurface
|
|||||||
RageSurfaceFormat *format; /* compatibility only */
|
RageSurfaceFormat *format; /* compatibility only */
|
||||||
RageSurfaceFormat fmt;
|
RageSurfaceFormat fmt;
|
||||||
|
|
||||||
std::uint8_t *pixels;
|
uint8_t *pixels;
|
||||||
bool pixels_owned;
|
bool pixels_owned;
|
||||||
std::int32_t w, h, pitch;
|
std::int32_t w, h, pitch;
|
||||||
std::int32_t flags;
|
std::int32_t flags;
|
||||||
@@ -87,8 +87,8 @@ struct RageSurface
|
|||||||
~RageSurface();
|
~RageSurface();
|
||||||
};
|
};
|
||||||
|
|
||||||
RageSurface *CreateSurface( int width, int height, int bpp, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask );
|
RageSurface *CreateSurface( int width, int height, int bpp, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask );
|
||||||
RageSurface *CreateSurfaceFrom( int width, int height, int bpp, std::uint32_t Rmask, std::uint32_t Gmask, std::uint32_t Bmask, std::uint32_t Amask, std::uint8_t *pPixels, std::uint32_t pitch );
|
RageSurface *CreateSurfaceFrom( int width, int height, int bpp, uint32_t Rmask, uint32_t Gmask, uint32_t Bmask, uint32_t Amask, uint8_t *pPixels, uint32_t pitch );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+91
-91
@@ -9,47 +9,47 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
std::uint32_t RageSurfaceUtils::decodepixel( const std::uint8_t *p, int bpp )
|
uint32_t RageSurfaceUtils::decodepixel( const uint8_t *p, int bpp )
|
||||||
{
|
{
|
||||||
switch(bpp)
|
switch(bpp)
|
||||||
{
|
{
|
||||||
case 1: return *p;
|
case 1: return *p;
|
||||||
case 2: return *(std::uint16_t *)p;
|
case 2: return *(uint16_t *)p;
|
||||||
case 3:
|
case 3:
|
||||||
if constexpr ( Endian::big )
|
if constexpr ( Endian::big )
|
||||||
return p[0] << 16 | p[1] << 8 | p[2];
|
return p[0] << 16 | p[1] << 8 | p[2];
|
||||||
else
|
else
|
||||||
return p[0] | p[1] << 8 | p[2] << 16;
|
return p[0] | p[1] << 8 | p[2] << 16;
|
||||||
|
|
||||||
case 4: return *(std::uint32_t *)p;
|
case 4: return *(uint32_t *)p;
|
||||||
default: return 0; // shouldn't happen, but avoids warnings
|
default: return 0; // shouldn't happen, but avoids warnings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::encodepixel( std::uint8_t *p, int bpp, std::uint32_t pixel )
|
void RageSurfaceUtils::encodepixel( uint8_t *p, int bpp, uint32_t pixel )
|
||||||
{
|
{
|
||||||
switch(bpp)
|
switch(bpp)
|
||||||
{
|
{
|
||||||
case 1: *p = std::uint8_t(pixel); break;
|
case 1: *p = uint8_t(pixel); break;
|
||||||
case 2: *(std::uint16_t *)p = std::uint16_t(pixel); break;
|
case 2: *(uint16_t *)p = uint16_t(pixel); break;
|
||||||
case 3:
|
case 3:
|
||||||
if constexpr ( Endian::big )
|
if constexpr ( Endian::big )
|
||||||
{
|
{
|
||||||
p[0] = std::uint8_t((pixel >> 16) & 0xff);
|
p[0] = uint8_t((pixel >> 16) & 0xff);
|
||||||
p[1] = std::uint8_t((pixel >> 8) & 0xff);
|
p[1] = uint8_t((pixel >> 8) & 0xff);
|
||||||
p[2] = std::uint8_t(pixel & 0xff);
|
p[2] = uint8_t(pixel & 0xff);
|
||||||
} else {
|
} else {
|
||||||
p[0] = std::uint8_t(pixel & 0xff);
|
p[0] = uint8_t(pixel & 0xff);
|
||||||
p[1] = std::uint8_t((pixel >> 8) & 0xff);
|
p[1] = uint8_t((pixel >> 8) & 0xff);
|
||||||
p[2] = std::uint8_t((pixel >> 16) & 0xff);
|
p[2] = uint8_t((pixel >> 16) & 0xff);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4: *(std::uint32_t *)p = pixel; break;
|
case 4: *(uint32_t *)p = pixel; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get and set colors without scaling to 0..255.
|
// Get and set colors without scaling to 0..255.
|
||||||
void RageSurfaceUtils::GetRawRGBAV( std::uint32_t pixel, const RageSurfaceFormat &fmt, std::uint8_t *v )
|
void RageSurfaceUtils::GetRawRGBAV( uint32_t pixel, const RageSurfaceFormat &fmt, uint8_t *v )
|
||||||
{
|
{
|
||||||
if( fmt.BytesPerPixel == 1 )
|
if( fmt.BytesPerPixel == 1 )
|
||||||
{
|
{
|
||||||
@@ -58,20 +58,20 @@ void RageSurfaceUtils::GetRawRGBAV( std::uint32_t pixel, const RageSurfaceFormat
|
|||||||
v[2] = fmt.palette->colors[pixel].b;
|
v[2] = fmt.palette->colors[pixel].b;
|
||||||
v[3] = fmt.palette->colors[pixel].a;
|
v[3] = fmt.palette->colors[pixel].a;
|
||||||
} else {
|
} else {
|
||||||
v[0] = std::uint8_t((pixel & fmt.Rmask) >> fmt.Rshift);
|
v[0] = uint8_t((pixel & fmt.Rmask) >> fmt.Rshift);
|
||||||
v[1] = std::uint8_t((pixel & fmt.Gmask) >> fmt.Gshift);
|
v[1] = uint8_t((pixel & fmt.Gmask) >> fmt.Gshift);
|
||||||
v[2] = std::uint8_t((pixel & fmt.Bmask) >> fmt.Bshift);
|
v[2] = uint8_t((pixel & fmt.Bmask) >> fmt.Bshift);
|
||||||
v[3] = std::uint8_t((pixel & fmt.Amask) >> fmt.Ashift);
|
v[3] = uint8_t((pixel & fmt.Amask) >> fmt.Ashift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::GetRawRGBAV( const std::uint8_t *p, const RageSurfaceFormat &fmt, std::uint8_t *v )
|
void RageSurfaceUtils::GetRawRGBAV( const uint8_t *p, const RageSurfaceFormat &fmt, uint8_t *v )
|
||||||
{
|
{
|
||||||
std::uint32_t pixel = decodepixel( p, fmt.BytesPerPixel );
|
uint32_t pixel = decodepixel( p, fmt.BytesPerPixel );
|
||||||
GetRawRGBAV( pixel, fmt, v );
|
GetRawRGBAV( pixel, fmt, v );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::GetRGBAV( std::uint32_t pixel, const RageSurface *src, std::uint8_t *v )
|
void RageSurfaceUtils::GetRGBAV( uint32_t pixel, const RageSurface *src, uint8_t *v )
|
||||||
{
|
{
|
||||||
GetRawRGBAV(pixel, src->fmt, v);
|
GetRawRGBAV(pixel, src->fmt, v);
|
||||||
const RageSurfaceFormat *fmt = src->format;
|
const RageSurfaceFormat *fmt = src->format;
|
||||||
@@ -83,9 +83,9 @@ void RageSurfaceUtils::GetRGBAV( std::uint32_t pixel, const RageSurface *src, st
|
|||||||
v[3] = 255;
|
v[3] = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::GetRGBAV( const std::uint8_t *p, const RageSurface *src, std::uint8_t *v )
|
void RageSurfaceUtils::GetRGBAV( const uint8_t *p, const RageSurface *src, uint8_t *v )
|
||||||
{
|
{
|
||||||
std::uint32_t pixel = decodepixel(p, src->format->BytesPerPixel);
|
uint32_t pixel = decodepixel(p, src->format->BytesPerPixel);
|
||||||
if( src->format->BytesPerPixel == 1 ) // paletted
|
if( src->format->BytesPerPixel == 1 ) // paletted
|
||||||
{
|
{
|
||||||
memcpy( v, &src->format->palette->colors[pixel], sizeof(RageSurfaceColor));
|
memcpy( v, &src->format->palette->colors[pixel], sizeof(RageSurfaceColor));
|
||||||
@@ -96,7 +96,7 @@ void RageSurfaceUtils::GetRGBAV( const std::uint8_t *p, const RageSurface *src,
|
|||||||
|
|
||||||
|
|
||||||
// Inverse of GetRawRGBAV.
|
// Inverse of GetRawRGBAV.
|
||||||
std::uint32_t RageSurfaceUtils::SetRawRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v )
|
uint32_t RageSurfaceUtils::SetRawRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v )
|
||||||
{
|
{
|
||||||
return v[0] << fmt->Rshift |
|
return v[0] << fmt->Rshift |
|
||||||
v[1] << fmt->Gshift |
|
v[1] << fmt->Gshift |
|
||||||
@@ -104,14 +104,14 @@ std::uint32_t RageSurfaceUtils::SetRawRGBAV( const RageSurfaceFormat *fmt, const
|
|||||||
v[3] << fmt->Ashift;
|
v[3] << fmt->Ashift;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::SetRawRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v )
|
void RageSurfaceUtils::SetRawRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v )
|
||||||
{
|
{
|
||||||
std::uint32_t pixel = SetRawRGBAV(src->format, v);
|
uint32_t pixel = SetRawRGBAV(src->format, v);
|
||||||
encodepixel(p, src->format->BytesPerPixel, pixel);
|
encodepixel(p, src->format->BytesPerPixel, pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inverse of GetRGBAV.
|
// Inverse of GetRGBAV.
|
||||||
std::uint32_t RageSurfaceUtils::SetRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v )
|
uint32_t RageSurfaceUtils::SetRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v )
|
||||||
{
|
{
|
||||||
return (v[0] >> fmt->Loss[0]) << fmt->Shift[0] |
|
return (v[0] >> fmt->Loss[0]) << fmt->Shift[0] |
|
||||||
(v[1] >> fmt->Loss[1]) << fmt->Shift[1] |
|
(v[1] >> fmt->Loss[1]) << fmt->Shift[1] |
|
||||||
@@ -119,14 +119,14 @@ std::uint32_t RageSurfaceUtils::SetRGBAV( const RageSurfaceFormat *fmt, const st
|
|||||||
(v[3] >> fmt->Loss[3]) << fmt->Shift[3];
|
(v[3] >> fmt->Loss[3]) << fmt->Shift[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::SetRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v )
|
void RageSurfaceUtils::SetRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v )
|
||||||
{
|
{
|
||||||
std::uint32_t pixel = SetRGBAV(src->format, v);
|
uint32_t pixel = SetRGBAV(src->format, v);
|
||||||
encodepixel(p, src->format->BytesPerPixel, pixel);
|
encodepixel(p, src->format->BytesPerPixel, pixel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RageSurfaceUtils::GetBitsPerChannel( const RageSurfaceFormat *fmt, std::uint32_t bits[4] )
|
void RageSurfaceUtils::GetBitsPerChannel( const RageSurfaceFormat *fmt, uint32_t bits[4] )
|
||||||
{
|
{
|
||||||
// The actual bits stored in each color is 8-loss.
|
// The actual bits stored in each color is 8-loss.
|
||||||
for( int c = 0; c < 4; ++c )
|
for( int c = 0; c < 4; ++c )
|
||||||
@@ -147,7 +147,7 @@ void RageSurfaceUtils::CopySurface( const RageSurface *src, RageSurface *dest )
|
|||||||
|
|
||||||
bool RageSurfaceUtils::ConvertSurface( const RageSurface *src, RageSurface *&dst,
|
bool RageSurfaceUtils::ConvertSurface( const RageSurface *src, RageSurface *&dst,
|
||||||
int width, int height, int bpp,
|
int width, int height, int bpp,
|
||||||
std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A )
|
uint32_t R, uint32_t G, uint32_t B, uint32_t A )
|
||||||
{
|
{
|
||||||
dst = CreateSurface( width, height, bpp, R, G, B, A );
|
dst = CreateSurface( width, height, bpp, R, G, B, A );
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ bool RageSurfaceUtils::ConvertSurface( const RageSurface *src, RageSurface *&dst
|
|||||||
|
|
||||||
void RageSurfaceUtils::ConvertSurface(RageSurface *&image,
|
void RageSurfaceUtils::ConvertSurface(RageSurface *&image,
|
||||||
int width, int height, int bpp,
|
int width, int height, int bpp,
|
||||||
std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A)
|
uint32_t R, uint32_t G, uint32_t B, uint32_t A)
|
||||||
{
|
{
|
||||||
RageSurface *ret_image;
|
RageSurface *ret_image;
|
||||||
if( !ConvertSurface( image, ret_image, width, height, bpp, R, G, B, A ) )
|
if( !ConvertSurface( image, ret_image, width, height, bpp, R, G, B, A ) )
|
||||||
@@ -177,7 +177,7 @@ void RageSurfaceUtils::ConvertSurface(RageSurface *&image,
|
|||||||
|
|
||||||
|
|
||||||
// Local helper for FixHiddenAlpha.
|
// Local helper for FixHiddenAlpha.
|
||||||
static void FindAlphaRGB(const RageSurface *img, std::uint8_t &r, std::uint8_t &g, std::uint8_t &b, bool reverse)
|
static void FindAlphaRGB(const RageSurface *img, uint8_t &r, uint8_t &g, uint8_t &b, bool reverse)
|
||||||
{
|
{
|
||||||
r = g = b = 0;
|
r = g = b = 0;
|
||||||
|
|
||||||
@@ -189,13 +189,13 @@ static void FindAlphaRGB(const RageSurface *img, std::uint8_t &r, std::uint8_t &
|
|||||||
for(int y = reverse? img->h-1:0;
|
for(int y = reverse? img->h-1:0;
|
||||||
reverse? (y >=0):(y < img->h); reverse? (--y):(++y))
|
reverse? (y >=0):(y < img->h); reverse? (--y):(++y))
|
||||||
{
|
{
|
||||||
std::uint8_t *row = (std::uint8_t *)img->pixels + img->pitch*y;
|
uint8_t *row = (uint8_t *)img->pixels + img->pitch*y;
|
||||||
if(reverse)
|
if(reverse)
|
||||||
row += img->format->BytesPerPixel * (img->w-1);
|
row += img->format->BytesPerPixel * (img->w-1);
|
||||||
|
|
||||||
for(int x = 0; x < img->w; ++x)
|
for(int x = 0; x < img->w; ++x)
|
||||||
{
|
{
|
||||||
std::uint32_t val = RageSurfaceUtils::decodepixel(row, img->format->BytesPerPixel);
|
uint32_t val = RageSurfaceUtils::decodepixel(row, img->format->BytesPerPixel);
|
||||||
if( img->format->BitsPerPixel == 8 )
|
if( img->format->BitsPerPixel == 8 )
|
||||||
{
|
{
|
||||||
if( img->format->palette->colors[val].a )
|
if( img->format->palette->colors[val].a )
|
||||||
@@ -230,7 +230,7 @@ static void FindAlphaRGB(const RageSurface *img, std::uint8_t &r, std::uint8_t &
|
|||||||
|
|
||||||
/* Local helper for FixHiddenAlpha. Set the underlying RGB values of all pixels
|
/* Local helper for FixHiddenAlpha. Set the underlying RGB values of all pixels
|
||||||
* in img that are completely transparent. */
|
* in img that are completely transparent. */
|
||||||
static void SetAlphaRGB(const RageSurface *pImg, std::uint8_t r, std::uint8_t g, std::uint8_t b)
|
static void SetAlphaRGB(const RageSurface *pImg, uint8_t r, uint8_t g, uint8_t b)
|
||||||
{
|
{
|
||||||
// If it's a paletted surface, all we have to do is change the palette.
|
// If it's a paletted surface, all we have to do is change the palette.
|
||||||
if( pImg->format->BitsPerPixel == 8 )
|
if( pImg->format->BitsPerPixel == 8 )
|
||||||
@@ -250,15 +250,15 @@ static void SetAlphaRGB(const RageSurface *pImg, std::uint8_t r, std::uint8_t g,
|
|||||||
if( pImg->format->BitsPerPixel > 8 && !pImg->format->Amask )
|
if( pImg->format->BitsPerPixel > 8 && !pImg->format->Amask )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::uint32_t trans;
|
uint32_t trans;
|
||||||
pImg->format->MapRGBA( r, g, b, 0, trans );
|
pImg->format->MapRGBA( r, g, b, 0, trans );
|
||||||
for( int y = 0; y < pImg->h; ++y )
|
for( int y = 0; y < pImg->h; ++y )
|
||||||
{
|
{
|
||||||
std::uint8_t *row = pImg->pixels + pImg->pitch*y;
|
uint8_t *row = pImg->pixels + pImg->pitch*y;
|
||||||
|
|
||||||
for( int x = 0; x < pImg->w; ++x )
|
for( int x = 0; x < pImg->w; ++x )
|
||||||
{
|
{
|
||||||
std::uint32_t val = RageSurfaceUtils::decodepixel( row, pImg->format->BytesPerPixel );
|
uint32_t val = RageSurfaceUtils::decodepixel( row, pImg->format->BytesPerPixel );
|
||||||
if( val != trans && !(val&pImg->format->Amask) )
|
if( val != trans && !(val&pImg->format->Amask) )
|
||||||
{
|
{
|
||||||
RageSurfaceUtils::encodepixel( row, pImg->format->BytesPerPixel, trans );
|
RageSurfaceUtils::encodepixel( row, pImg->format->BytesPerPixel, trans );
|
||||||
@@ -290,10 +290,10 @@ void RageSurfaceUtils::FixHiddenAlpha( RageSurface *pImg )
|
|||||||
if( pImg->format->BitsPerPixel != 8 && pImg->format->Amask == 0 )
|
if( pImg->format->BitsPerPixel != 8 && pImg->format->Amask == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::uint8_t r, g, b;
|
uint8_t r, g, b;
|
||||||
FindAlphaRGB( pImg, r, g, b, false );
|
FindAlphaRGB( pImg, r, g, b, false );
|
||||||
|
|
||||||
std::uint8_t cr, cg, cb; // compare
|
uint8_t cr, cg, cb; // compare
|
||||||
FindAlphaRGB( pImg, cr, cg, cb, true );
|
FindAlphaRGB( pImg, cr, cg, cb, true );
|
||||||
|
|
||||||
if( cr != r || cg != g || cb != b )
|
if( cr != r || cg != g || cb != b )
|
||||||
@@ -311,7 +311,7 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img )
|
|||||||
const int NEEDS_NO_ALPHA=0, NEEDS_BOOL_ALPHA=1, NEEDS_FULL_ALPHA=2;
|
const int NEEDS_NO_ALPHA=0, NEEDS_BOOL_ALPHA=1, NEEDS_FULL_ALPHA=2;
|
||||||
int alpha_type = NEEDS_NO_ALPHA;
|
int alpha_type = NEEDS_NO_ALPHA;
|
||||||
|
|
||||||
std::uint32_t max_alpha;
|
uint32_t max_alpha;
|
||||||
if( img->format->BitsPerPixel == 8 )
|
if( img->format->BitsPerPixel == 8 )
|
||||||
{
|
{
|
||||||
// Short circuit if we already know we have no transparency.
|
// Short circuit if we already know we have no transparency.
|
||||||
@@ -338,13 +338,13 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img )
|
|||||||
|
|
||||||
for(int y = 0; y < img->h; ++y)
|
for(int y = 0; y < img->h; ++y)
|
||||||
{
|
{
|
||||||
std::uint8_t *row = (std::uint8_t *)img->pixels + img->pitch*y;
|
uint8_t *row = (uint8_t *)img->pixels + img->pitch*y;
|
||||||
|
|
||||||
for(int x = 0; x < img->w; ++x)
|
for(int x = 0; x < img->w; ++x)
|
||||||
{
|
{
|
||||||
std::uint32_t val = decodepixel(row, img->format->BytesPerPixel);
|
uint32_t val = decodepixel(row, img->format->BytesPerPixel);
|
||||||
|
|
||||||
std::uint32_t alpha;
|
uint32_t alpha;
|
||||||
if( img->format->BitsPerPixel == 8 )
|
if( img->format->BitsPerPixel == 8 )
|
||||||
alpha = img->format->palette->colors[val].a;
|
alpha = img->format->palette->colors[val].a;
|
||||||
else
|
else
|
||||||
@@ -374,10 +374,10 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img )
|
|||||||
|
|
||||||
|
|
||||||
// Local helper for BlitTransform.
|
// Local helper for BlitTransform.
|
||||||
static inline void GetRawRGBAV_XY( const RageSurface *src, std::uint8_t *v, int x, int y )
|
static inline void GetRawRGBAV_XY( const RageSurface *src, uint8_t *v, int x, int y )
|
||||||
{
|
{
|
||||||
const std::uint8_t *srcp = (const std::uint8_t *) src->pixels + (y * src->pitch);
|
const uint8_t *srcp = (const uint8_t *) src->pixels + (y * src->pitch);
|
||||||
const std::uint8_t *srcpx = srcp + (x * src->fmt.BytesPerPixel);
|
const uint8_t *srcpx = srcp + (x * src->fmt.BytesPerPixel);
|
||||||
|
|
||||||
RageSurfaceUtils::GetRawRGBAV( srcpx, src->fmt, v );
|
RageSurfaceUtils::GetRawRGBAV( srcpx, src->fmt, v );
|
||||||
}
|
}
|
||||||
@@ -405,8 +405,8 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
|
|||||||
|
|
||||||
for( int y = 0; y < dst->h; ++y )
|
for( int y = 0; y < dst->h; ++y )
|
||||||
{
|
{
|
||||||
std::uint8_t *dstp = (std::uint8_t *) dst->pixels + (y * dst->pitch); /* line */
|
uint8_t *dstp = (uint8_t *) dst->pixels + (y * dst->pitch); /* line */
|
||||||
std::uint8_t *dstpx = dstp; // pixel
|
uint8_t *dstpx = dstp; // pixel
|
||||||
|
|
||||||
const float start_y = scale(float(y), 0, float(dst->h), Coords[TL_Y], Coords[BL_Y]);
|
const float start_y = scale(float(y), 0, float(dst->h), Coords[TL_Y], Coords[BL_Y]);
|
||||||
const float end_y = scale(float(y), 0, float(dst->h), Coords[TR_Y], Coords[BR_Y]);
|
const float end_y = scale(float(y), 0, float(dst->h), Coords[TR_Y], Coords[BR_Y]);
|
||||||
@@ -437,7 +437,7 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
|
|||||||
src_y[1] = std::clamp(src_y[1], 0, src->h);
|
src_y[1] = std::clamp(src_y[1], 0, src->h);
|
||||||
|
|
||||||
// Decode our four pixels.
|
// Decode our four pixels.
|
||||||
std::uint8_t v[4][4];
|
uint8_t v[4][4];
|
||||||
GetRawRGBAV_XY(src, v[0], src_x[0], src_y[0]);
|
GetRawRGBAV_XY(src, v[0], src_x[0], src_y[0]);
|
||||||
GetRawRGBAV_XY(src, v[1], src_x[0], src_y[1]);
|
GetRawRGBAV_XY(src, v[1], src_x[0], src_y[1]);
|
||||||
GetRawRGBAV_XY(src, v[2], src_x[1], src_y[0]);
|
GetRawRGBAV_XY(src, v[2], src_x[1], src_y[0]);
|
||||||
@@ -448,7 +448,7 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
|
|||||||
float weight_y = src_yp - (src_y[0] + 0.5f);
|
float weight_y = src_yp - (src_y[0] + 0.5f);
|
||||||
|
|
||||||
// Filter:
|
// Filter:
|
||||||
std::uint8_t out[4] = { 0,0,0,0 };
|
uint8_t out[4] = { 0,0,0,0 };
|
||||||
for(int i = 0; i < 4; ++i)
|
for(int i = 0; i < 4; ++i)
|
||||||
{
|
{
|
||||||
float sum = 0;
|
float sum = 0;
|
||||||
@@ -456,12 +456,12 @@ void RageSurfaceUtils::BlitTransform( const RageSurface *src, RageSurface *dst,
|
|||||||
sum += v[1][i] * (1-weight_x) * (weight_y);
|
sum += v[1][i] * (1-weight_x) * (weight_y);
|
||||||
sum += v[2][i] * (weight_x) * (1-weight_y);
|
sum += v[2][i] * (weight_x) * (1-weight_y);
|
||||||
sum += v[3][i] * (weight_x) * (weight_y);
|
sum += v[3][i] * (weight_x) * (weight_y);
|
||||||
out[i] = (std::uint8_t) std::clamp( std::lrint(sum), 0L, 255L );
|
out[i] = (uint8_t) std::clamp( std::lrint(sum), 0L, 255L );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the source has no alpha, set the destination to opaque.
|
// If the source has no alpha, set the destination to opaque.
|
||||||
if( src->format->Amask == 0 )
|
if( src->format->Amask == 0 )
|
||||||
out[3] = std::uint8_t( dst->format->Amask >> dst->format->Ashift );
|
out[3] = uint8_t( dst->format->Amask >> dst->format->Ashift );
|
||||||
|
|
||||||
SetRawRGBAV(dstpx, dst, out);
|
SetRawRGBAV(dstpx, dst, out);
|
||||||
|
|
||||||
@@ -487,8 +487,8 @@ static bool blit_same_type( const RageSurface *src_surf, const RageSurface *dst_
|
|||||||
src_surf->format->Amask != dst_surf->format->Amask )
|
src_surf->format->Amask != dst_surf->format->Amask )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const std::uint8_t *src = src_surf->pixels;
|
const uint8_t *src = src_surf->pixels;
|
||||||
std::uint8_t *dst = dst_surf->pixels;
|
uint8_t *dst = dst_surf->pixels;
|
||||||
|
|
||||||
// If possible, memcpy the whole thing.
|
// If possible, memcpy the whole thing.
|
||||||
if( src_surf->w == width && dst_surf->w == width && src_surf->pitch == dst_surf->pitch )
|
if( src_surf->w == width && dst_surf->w == width && src_surf->pitch == dst_surf->pitch )
|
||||||
@@ -515,23 +515,23 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
|
|||||||
if( src_surf->format->BytesPerPixel == 1 || dst_surf->format->BytesPerPixel == 1 )
|
if( src_surf->format->BytesPerPixel == 1 || dst_surf->format->BytesPerPixel == 1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const std::uint8_t *src = src_surf->pixels;
|
const uint8_t *src = src_surf->pixels;
|
||||||
std::uint8_t *dst = dst_surf->pixels;
|
uint8_t *dst = dst_surf->pixels;
|
||||||
|
|
||||||
// Bytes to skip at the end of a line.
|
// Bytes to skip at the end of a line.
|
||||||
const int srcskip = src_surf->pitch - width*src_surf->format->BytesPerPixel;
|
const int srcskip = src_surf->pitch - width*src_surf->format->BytesPerPixel;
|
||||||
const int dstskip = dst_surf->pitch - width*dst_surf->format->BytesPerPixel;
|
const int dstskip = dst_surf->pitch - width*dst_surf->format->BytesPerPixel;
|
||||||
|
|
||||||
const std::array<std::uint32_t, 4> &src_shifts = src_surf->format->Shift;
|
const std::array<uint32_t, 4> &src_shifts = src_surf->format->Shift;
|
||||||
const std::array<std::uint32_t, 4> &dst_shifts = dst_surf->format->Shift;
|
const std::array<uint32_t, 4> &dst_shifts = dst_surf->format->Shift;
|
||||||
const std::array<std::uint32_t, 4> &src_masks = src_surf->format->Mask;
|
const std::array<uint32_t, 4> &src_masks = src_surf->format->Mask;
|
||||||
const std::array<std::uint32_t, 4> &dst_masks = dst_surf->format->Mask;
|
const std::array<uint32_t, 4> &dst_masks = dst_surf->format->Mask;
|
||||||
|
|
||||||
std::uint8_t lookup[4][256];
|
uint8_t lookup[4][256];
|
||||||
for( int c = 0; c < 4; ++c )
|
for( int c = 0; c < 4; ++c )
|
||||||
{
|
{
|
||||||
const std::uint32_t max_src_val = src_masks[c] >> src_shifts[c];
|
const uint32_t max_src_val = src_masks[c] >> src_shifts[c];
|
||||||
const std::uint32_t max_dst_val = dst_masks[c] >> dst_shifts[c];
|
const uint32_t max_dst_val = dst_masks[c] >> dst_shifts[c];
|
||||||
ASSERT( max_src_val <= 0xFF );
|
ASSERT( max_src_val <= 0xFF );
|
||||||
ASSERT( max_dst_val <= 0xFF );
|
ASSERT( max_dst_val <= 0xFF );
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
|
|||||||
/* The source is missing a channel. Alpha defaults to opaque, other
|
/* The source is missing a channel. Alpha defaults to opaque, other
|
||||||
* channels default to 0. */
|
* channels default to 0. */
|
||||||
if( c == 3 )
|
if( c == 3 )
|
||||||
lookup[c][0] = (std::uint8_t) max_dst_val;
|
lookup[c][0] = (uint8_t) max_dst_val;
|
||||||
else
|
else
|
||||||
lookup[c][0] = 0;
|
lookup[c][0] = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -571,11 +571,11 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
|
|||||||
* Having separate formulas for increasing and decreasing resolution seems
|
* Having separate formulas for increasing and decreasing resolution seems
|
||||||
* strange; what's wrong here? */
|
* strange; what's wrong here? */
|
||||||
if( max_src_val > max_dst_val )
|
if( max_src_val > max_dst_val )
|
||||||
for( std::uint32_t i = 0; i <= max_src_val; ++i )
|
for( uint32_t i = 0; i <= max_src_val; ++i )
|
||||||
lookup[c][i] = (std::uint8_t) SCALE( i, 0, max_src_val+1, 0, max_dst_val+1 );
|
lookup[c][i] = (uint8_t) SCALE( i, 0, max_src_val+1, 0, max_dst_val+1 );
|
||||||
else
|
else
|
||||||
for( std::uint32_t i = 0; i <= max_src_val; ++i )
|
for( uint32_t i = 0; i <= max_src_val; ++i )
|
||||||
lookup[c][i] = (std::uint8_t) SCALE( i, 0, max_src_val, 0, max_dst_val );
|
lookup[c][i] = (uint8_t) SCALE( i, 0, max_src_val, 0, max_dst_val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,8 +613,8 @@ static bool blit_generic( const RageSurface *src_surf, const RageSurface *dst_su
|
|||||||
if( src_surf->format->BytesPerPixel != 1 || dst_surf->format->BytesPerPixel == 1 )
|
if( src_surf->format->BytesPerPixel != 1 || dst_surf->format->BytesPerPixel == 1 )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const std::uint8_t *src = src_surf->pixels;
|
const uint8_t *src = src_surf->pixels;
|
||||||
std::uint8_t *dst = dst_surf->pixels;
|
uint8_t *dst = dst_surf->pixels;
|
||||||
|
|
||||||
// Bytes to skip at the end of a line.
|
// Bytes to skip at the end of a line.
|
||||||
const int srcskip = src_surf->pitch - width*src_surf->format->BytesPerPixel;
|
const int srcskip = src_surf->pitch - width*src_surf->format->BytesPerPixel;
|
||||||
@@ -627,7 +627,7 @@ static bool blit_generic( const RageSurface *src_surf, const RageSurface *dst_su
|
|||||||
{
|
{
|
||||||
unsigned int pixel = RageSurfaceUtils::decodepixel( src, src_surf->format->BytesPerPixel );
|
unsigned int pixel = RageSurfaceUtils::decodepixel( src, src_surf->format->BytesPerPixel );
|
||||||
|
|
||||||
std::uint8_t colors[4];
|
uint8_t colors[4];
|
||||||
// Convert pixel to the destination RGBA.
|
// Convert pixel to the destination RGBA.
|
||||||
colors[0] = src_surf->format->palette->colors[pixel].r;
|
colors[0] = src_surf->format->palette->colors[pixel].r;
|
||||||
colors[1] = src_surf->format->palette->colors[pixel].g;
|
colors[1] = src_surf->format->palette->colors[pixel].g;
|
||||||
@@ -713,11 +713,11 @@ void RageSurfaceUtils::CorrectBorderPixels( RageSurface *img, int width, int hei
|
|||||||
{
|
{
|
||||||
// Duplicate the last column.
|
// Duplicate the last column.
|
||||||
int offset = img->format->BytesPerPixel * (width-1);
|
int offset = img->format->BytesPerPixel * (width-1);
|
||||||
std::uint8_t *p = (std::uint8_t *) img->pixels + offset;
|
uint8_t *p = (uint8_t *) img->pixels + offset;
|
||||||
|
|
||||||
for( int y = 0; y < height; ++y )
|
for( int y = 0; y < height; ++y )
|
||||||
{
|
{
|
||||||
std::uint32_t pixel = decodepixel( p, img->format->BytesPerPixel );
|
uint32_t pixel = decodepixel( p, img->format->BytesPerPixel );
|
||||||
encodepixel( p+img->format->BytesPerPixel, img->format->BytesPerPixel, pixel );
|
encodepixel( p+img->format->BytesPerPixel, img->format->BytesPerPixel, pixel );
|
||||||
|
|
||||||
p += img->pitch;
|
p += img->pitch;
|
||||||
@@ -727,7 +727,7 @@ void RageSurfaceUtils::CorrectBorderPixels( RageSurface *img, int width, int hei
|
|||||||
if( height < img->h )
|
if( height < img->h )
|
||||||
{
|
{
|
||||||
// Duplicate the last row.
|
// Duplicate the last row.
|
||||||
std::uint8_t *srcp = img->pixels;
|
uint8_t *srcp = img->pixels;
|
||||||
srcp += img->pitch * (height-1);
|
srcp += img->pitch * (height-1);
|
||||||
memcpy( srcp + img->pitch, srcp, img->pitch );
|
memcpy( srcp + img->pitch, srcp, img->pitch );
|
||||||
}
|
}
|
||||||
@@ -865,10 +865,10 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
|
|||||||
const unsigned int A = (index & Amask) >> Ashift;
|
const unsigned int A = (index & Amask) >> Ashift;
|
||||||
|
|
||||||
// if only one intensity value, always fullbright
|
// if only one intensity value, always fullbright
|
||||||
const std::uint8_t ScaledI = Ivalues == 1 ? 255 : std::clamp( std::lrint(I * (255.0f / (Ivalues-1))), 0L, 255L );
|
const uint8_t ScaledI = Ivalues == 1 ? 255 : std::clamp( std::lrint(I * (255.0f / (Ivalues-1))), 0L, 255L );
|
||||||
|
|
||||||
// if only one alpha value, always opaque
|
// if only one alpha value, always opaque
|
||||||
const std::uint8_t ScaledA = Avalues == 1 ? 255 : std::clamp( std::lrint(A * (255.0f / (Avalues-1))), 0L, 255L );
|
const uint8_t ScaledA = Avalues == 1 ? 255 : std::clamp( std::lrint(A * (255.0f / (Avalues-1))), 0L, 255L );
|
||||||
|
|
||||||
RageSurfaceColor c;
|
RageSurfaceColor c;
|
||||||
c.r = ScaledI;
|
c.r = ScaledI;
|
||||||
@@ -879,8 +879,8 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
|
|||||||
dst_surf->fmt.palette->colors[index] = c;
|
dst_surf->fmt.palette->colors[index] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::uint8_t *src = src_surf->pixels;
|
const uint8_t *src = src_surf->pixels;
|
||||||
std::uint8_t *dst = dst_surf->pixels;
|
uint8_t *dst = dst_surf->pixels;
|
||||||
|
|
||||||
int height = src_surf->h;
|
int height = src_surf->h;
|
||||||
int width = src_surf->w;
|
int width = src_surf->w;
|
||||||
@@ -896,7 +896,7 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
|
|||||||
{
|
{
|
||||||
unsigned int pixel = decodepixel( src, src_surf->format->BytesPerPixel );
|
unsigned int pixel = decodepixel( src, src_surf->format->BytesPerPixel );
|
||||||
|
|
||||||
std::uint8_t colors[4];
|
uint8_t colors[4];
|
||||||
GetRGBAV(pixel, src_surf, colors);
|
GetRGBAV(pixel, src_surf, colors);
|
||||||
|
|
||||||
int Ival = 0;
|
int Ival = 0;
|
||||||
@@ -909,7 +909,7 @@ RageSurface *RageSurfaceUtils::PalettizeToGrayscale( const RageSurface *src_surf
|
|||||||
(colors[3] >> Aloss) << Ashift;
|
(colors[3] >> Aloss) << Ashift;
|
||||||
|
|
||||||
// Store it.
|
// Store it.
|
||||||
*dst = std::uint8_t(pixel);
|
*dst = uint8_t(pixel);
|
||||||
|
|
||||||
src += src_surf->format->BytesPerPixel;
|
src += src_surf->format->BytesPerPixel;
|
||||||
dst += dst_surf->format->BytesPerPixel;
|
dst += dst_surf->format->BytesPerPixel;
|
||||||
@@ -939,14 +939,14 @@ RageSurface *RageSurfaceUtils::MakeDummySurface( int height, int width )
|
|||||||
* Search the edge for it; if we find it, use that as the color key. */
|
* Search the edge for it; if we find it, use that as the color key. */
|
||||||
static bool ImageUsesOffHotPink( const RageSurface *img )
|
static bool ImageUsesOffHotPink( const RageSurface *img )
|
||||||
{
|
{
|
||||||
std::uint32_t OffHotPink;
|
uint32_t OffHotPink;
|
||||||
if( !img->format->MapRGBA( 0xF8, 0, 0xF8, 0xFF, OffHotPink ) )
|
if( !img->format->MapRGBA( 0xF8, 0, 0xF8, 0xFF, OffHotPink ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const std::uint8_t *p = img->pixels;
|
const uint8_t *p = img->pixels;
|
||||||
for( int x = 0; x < img->w; ++x )
|
for( int x = 0; x < img->w; ++x )
|
||||||
{
|
{
|
||||||
std::uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel );
|
uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel );
|
||||||
if( val == OffHotPink )
|
if( val == OffHotPink )
|
||||||
return true;
|
return true;
|
||||||
p += img->format->BytesPerPixel;
|
p += img->format->BytesPerPixel;
|
||||||
@@ -956,7 +956,7 @@ static bool ImageUsesOffHotPink( const RageSurface *img )
|
|||||||
p += img->pitch * (img->h-1);
|
p += img->pitch * (img->h-1);
|
||||||
for( int i=0; i < img->w; i++ )
|
for( int i=0; i < img->w; i++ )
|
||||||
{
|
{
|
||||||
std::uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel );
|
uint32_t val = RageSurfaceUtils::decodepixel( p, img->format->BytesPerPixel );
|
||||||
if( val == OffHotPink )
|
if( val == OffHotPink )
|
||||||
return true;
|
return true;
|
||||||
p += img->format->BytesPerPixel;
|
p += img->format->BytesPerPixel;
|
||||||
@@ -970,7 +970,7 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img )
|
|||||||
{
|
{
|
||||||
if( img->format->BitsPerPixel == 8 )
|
if( img->format->BitsPerPixel == 8 )
|
||||||
{
|
{
|
||||||
std::uint32_t color;
|
uint32_t color;
|
||||||
if( img->format->MapRGBA( 0xF8, 0, 0xF8, 0xFF, color ) )
|
if( img->format->MapRGBA( 0xF8, 0, 0xF8, 0xFF, color ) )
|
||||||
img->format->palette->colors[ color ].a = 0;
|
img->format->palette->colors[ color ].a = 0;
|
||||||
if( img->format->MapRGBA( 0xFF, 0, 0xFF, 0xFF, color ) )
|
if( img->format->MapRGBA( 0xFF, 0, 0xFF, 0xFF, color ) )
|
||||||
@@ -992,7 +992,7 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img )
|
|||||||
{
|
{
|
||||||
img->format->Amask = 1<<i;
|
img->format->Amask = 1<<i;
|
||||||
img->format->Aloss = 7;
|
img->format->Aloss = 7;
|
||||||
img->format->Ashift = (std::uint8_t) i;
|
img->format->Ashift = (uint8_t) i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -1002,7 +1002,7 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img )
|
|||||||
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF );
|
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint32_t HotPink;
|
uint32_t HotPink;
|
||||||
|
|
||||||
bool bHaveColorKey;
|
bool bHaveColorKey;
|
||||||
if( ImageUsesOffHotPink(img) )
|
if( ImageUsesOffHotPink(img) )
|
||||||
@@ -1014,11 +1014,11 @@ void RageSurfaceUtils::ApplyHotPinkColorKey( RageSurface *&img )
|
|||||||
|
|
||||||
for( int y = 0; y < img->h; ++y )
|
for( int y = 0; y < img->h; ++y )
|
||||||
{
|
{
|
||||||
std::uint8_t *row = img->pixels + img->pitch*y;
|
uint8_t *row = img->pixels + img->pitch*y;
|
||||||
|
|
||||||
for( int x = 0; x < img->w; ++x )
|
for( int x = 0; x < img->w; ++x )
|
||||||
{
|
{
|
||||||
std::uint32_t val = decodepixel( row, img->format->BytesPerPixel );
|
uint32_t val = decodepixel( row, img->format->BytesPerPixel );
|
||||||
if( val == HotPink )
|
if( val == HotPink )
|
||||||
encodepixel( row, img->format->BytesPerPixel, 0 );
|
encodepixel( row, img->format->BytesPerPixel, 0 );
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -13,27 +13,27 @@ struct RageSurface;
|
|||||||
/** @brief Utility functions for the RageSurfaces. */
|
/** @brief Utility functions for the RageSurfaces. */
|
||||||
namespace RageSurfaceUtils
|
namespace RageSurfaceUtils
|
||||||
{
|
{
|
||||||
std::uint32_t decodepixel( const std::uint8_t *p, int bpp );
|
uint32_t decodepixel( const uint8_t *p, int bpp );
|
||||||
void encodepixel( std::uint8_t *p, int bpp, std::uint32_t pixel );
|
void encodepixel( uint8_t *p, int bpp, uint32_t pixel );
|
||||||
|
|
||||||
void GetRawRGBAV( std::uint32_t pixel, const RageSurfaceFormat &fmt, std::uint8_t *v );
|
void GetRawRGBAV( uint32_t pixel, const RageSurfaceFormat &fmt, uint8_t *v );
|
||||||
void GetRawRGBAV( const std::uint8_t *p, const RageSurfaceFormat &fmt, std::uint8_t *v );
|
void GetRawRGBAV( const uint8_t *p, const RageSurfaceFormat &fmt, uint8_t *v );
|
||||||
void GetRGBAV( std::uint32_t pixel, const RageSurface *src, std::uint8_t *v );
|
void GetRGBAV( uint32_t pixel, const RageSurface *src, uint8_t *v );
|
||||||
void GetRGBAV( const std::uint8_t *p, const RageSurface *src, std::uint8_t *v );
|
void GetRGBAV( const uint8_t *p, const RageSurface *src, uint8_t *v );
|
||||||
|
|
||||||
std::uint32_t SetRawRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v );
|
uint32_t SetRawRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v );
|
||||||
void SetRawRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v );
|
void SetRawRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v );
|
||||||
std::uint32_t SetRGBAV( const RageSurfaceFormat *fmt, const std::uint8_t *v );
|
uint32_t SetRGBAV( const RageSurfaceFormat *fmt, const uint8_t *v );
|
||||||
void SetRGBAV( std::uint8_t *p, const RageSurface *src, const std::uint8_t *v );
|
void SetRGBAV( uint8_t *p, const RageSurface *src, const uint8_t *v );
|
||||||
|
|
||||||
/* Get the number of bits representing each color channel in fmt. */
|
/* Get the number of bits representing each color channel in fmt. */
|
||||||
void GetBitsPerChannel( const RageSurfaceFormat *fmt, std::uint32_t bits[4] );
|
void GetBitsPerChannel( const RageSurfaceFormat *fmt, uint32_t bits[4] );
|
||||||
|
|
||||||
void CopySurface( const RageSurface *src, RageSurface *dest );
|
void CopySurface( const RageSurface *src, RageSurface *dest );
|
||||||
bool ConvertSurface( const RageSurface *src, RageSurface *&dst,
|
bool ConvertSurface( const RageSurface *src, RageSurface *&dst,
|
||||||
int width, int height, int bpp, std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A );
|
int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A );
|
||||||
void ConvertSurface( RageSurface *&image,
|
void ConvertSurface( RageSurface *&image,
|
||||||
int width, int height, int bpp, std::uint32_t R, std::uint32_t G, std::uint32_t B, std::uint32_t A );
|
int width, int height, int bpp, uint32_t R, uint32_t G, uint32_t B, uint32_t A );
|
||||||
|
|
||||||
void FixHiddenAlpha( RageSurface *img );
|
void FixHiddenAlpha( RageSurface *img );
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ static const int DitherMat[DitherMatDim][DitherMatDim] =
|
|||||||
static int DitherMatCalc[DitherMatDim][DitherMatDim];
|
static int DitherMatCalc[DitherMatDim][DitherMatDim];
|
||||||
|
|
||||||
// conv is the ratio from the input to the output.
|
// conv is the ratio from the input to the output.
|
||||||
static std::uint8_t DitherPixel(int x, int y, int intensity, int conv)
|
static uint8_t DitherPixel(int x, int y, int intensity, int conv)
|
||||||
{
|
{
|
||||||
// The intensity matrix wraps. This assumes the matrix dims are a power of 2.
|
// The intensity matrix wraps. This assumes the matrix dims are a power of 2.
|
||||||
x &= DitherMatDim-1;
|
x &= DitherMatDim-1;
|
||||||
@@ -43,7 +43,7 @@ static std::uint8_t DitherPixel(int x, int y, int intensity, int conv)
|
|||||||
out_intensity += DitherMatCalc[y][x];
|
out_intensity += DitherMatCalc[y][x];
|
||||||
|
|
||||||
// Truncate, and add e to make sure a value of 14.999998 -> 15.
|
// Truncate, and add e to make sure a value of 14.999998 -> 15.
|
||||||
return std::uint8_t((out_intensity + 1) >> 16);
|
return uint8_t((out_intensity + 1) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst )
|
void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst )
|
||||||
@@ -68,7 +68,7 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst )
|
|||||||
// We can't dither to paletted surfaces.
|
// We can't dither to paletted surfaces.
|
||||||
ASSERT( dst->format->BytesPerPixel > 1 );
|
ASSERT( dst->format->BytesPerPixel > 1 );
|
||||||
|
|
||||||
std::uint32_t src_cbits[4], dst_cbits[4];
|
uint32_t src_cbits[4], dst_cbits[4];
|
||||||
RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits );
|
RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits );
|
||||||
RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits );
|
RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits );
|
||||||
|
|
||||||
@@ -86,18 +86,18 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Max alpha value; used when there's no alpha source.
|
// Max alpha value; used when there's no alpha source.
|
||||||
const std::uint8_t alpha_max = std::uint8_t((1 << dst_cbits[3]) - 1);
|
const uint8_t alpha_max = uint8_t((1 << dst_cbits[3]) - 1);
|
||||||
|
|
||||||
// For each row:
|
// For each row:
|
||||||
for( int row = 0; row < src->h; ++row )
|
for( int row = 0; row < src->h; ++row )
|
||||||
{
|
{
|
||||||
const std::uint8_t *srcp = src->pixels + row * src->pitch;
|
const uint8_t *srcp = src->pixels + row * src->pitch;
|
||||||
std::uint8_t *dstp = dst->pixels + row * dst->pitch;
|
uint8_t *dstp = dst->pixels + row * dst->pitch;
|
||||||
|
|
||||||
// For each pixel:
|
// For each pixel:
|
||||||
for( int col = 0; col < src->w; ++col )
|
for( int col = 0; col < src->w; ++col )
|
||||||
{
|
{
|
||||||
std::uint8_t colors[4];
|
uint8_t colors[4];
|
||||||
RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors );
|
RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors );
|
||||||
|
|
||||||
// Note that we don't dither the alpha channel.
|
// Note that we don't dither the alpha channel.
|
||||||
@@ -119,7 +119,7 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst )
|
|||||||
int out_intensity = colors[3] * conv[3];
|
int out_intensity = colors[3] * conv[3];
|
||||||
|
|
||||||
// Round:
|
// Round:
|
||||||
colors[3] = std::uint8_t((out_intensity + 32767) >> 16);
|
colors[3] = uint8_t((out_intensity + 32767) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw value -> int -> pixel
|
// Raw value -> int -> pixel
|
||||||
@@ -132,7 +132,7 @@ void RageSurfaceUtils::OrderedDither( const RageSurface *src, RageSurface *dst )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static std::uint8_t EDDitherPixel( int x, int y, int intensity, int conv, std::int32_t &accumError )
|
static uint8_t EDDitherPixel( int x, int y, int intensity, int conv, std::int32_t &accumError )
|
||||||
{
|
{
|
||||||
// Convert the number to the destination range.
|
// Convert the number to the destination range.
|
||||||
int out_intensity = intensity * conv;
|
int out_intensity = intensity * conv;
|
||||||
@@ -151,7 +151,7 @@ static std::uint8_t EDDitherPixel( int x, int y, int intensity, int conv, std::i
|
|||||||
clamped_intensity &= 0xFF0000;
|
clamped_intensity &= 0xFF0000;
|
||||||
|
|
||||||
// Truncate.
|
// Truncate.
|
||||||
std::uint8_t ret = std::uint8_t(clamped_intensity >> 16);
|
uint8_t ret = uint8_t(clamped_intensity >> 16);
|
||||||
|
|
||||||
accumError = out_intensity - clamped_intensity;
|
accumError = out_intensity - clamped_intensity;
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface
|
|||||||
// We can't dither to paletted surfaces.
|
// We can't dither to paletted surfaces.
|
||||||
ASSERT( dst->format->BytesPerPixel > 1 );
|
ASSERT( dst->format->BytesPerPixel > 1 );
|
||||||
|
|
||||||
std::uint32_t src_cbits[4], dst_cbits[4];
|
uint32_t src_cbits[4], dst_cbits[4];
|
||||||
RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits );
|
RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits );
|
||||||
RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits );
|
RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits );
|
||||||
|
|
||||||
@@ -190,20 +190,20 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Max alpha value; used when there's no alpha source.
|
// Max alpha value; used when there's no alpha source.
|
||||||
const std::uint8_t alpha_max = std::uint8_t((1 << dst_cbits[3]) - 1);
|
const uint8_t alpha_max = uint8_t((1 << dst_cbits[3]) - 1);
|
||||||
|
|
||||||
// For each row:
|
// For each row:
|
||||||
for(int row = 0; row < src->h; ++row)
|
for(int row = 0; row < src->h; ++row)
|
||||||
{
|
{
|
||||||
std::int32_t accumError[4] = { 0, 0, 0, 0 }; // accum error values are reset every row
|
std::int32_t accumError[4] = { 0, 0, 0, 0 }; // accum error values are reset every row
|
||||||
|
|
||||||
const std::uint8_t *srcp = src->pixels + row * src->pitch;
|
const uint8_t *srcp = src->pixels + row * src->pitch;
|
||||||
std::uint8_t *dstp = dst->pixels + row * dst->pitch;
|
uint8_t *dstp = dst->pixels + row * dst->pitch;
|
||||||
|
|
||||||
// For each pixel in row:
|
// For each pixel in row:
|
||||||
for( int col = 0; col < src->w; ++col )
|
for( int col = 0; col < src->w; ++col )
|
||||||
{
|
{
|
||||||
std::uint8_t colors[4];
|
uint8_t colors[4];
|
||||||
RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors );
|
RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors );
|
||||||
|
|
||||||
for( int c = 0; c < 3; ++c )
|
for( int c = 0; c < 3; ++c )
|
||||||
@@ -223,7 +223,7 @@ void RageSurfaceUtils::ErrorDiffusionDither( const RageSurface *src, RageSurface
|
|||||||
int out_intensity = colors[3] * conv[3];
|
int out_intensity = colors[3] * conv[3];
|
||||||
|
|
||||||
// Round:
|
// Round:
|
||||||
colors[3] = std::uint8_t((out_intensity + 32767) >> 16);
|
colors[3] = uint8_t((out_intensity + 32767) >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSurfaceUtils::SetRawRGBAV( dstp, dst, colors );
|
RageSurfaceUtils::SetRawRGBAV( dstp, dst, colors );
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
typedef std::uint8_t pixval;
|
typedef uint8_t pixval;
|
||||||
typedef std::uint8_t apixel[4];
|
typedef uint8_t apixel[4];
|
||||||
|
|
||||||
#define PAM_GETR(p) ((p)[0])
|
#define PAM_GETR(p) ((p)[0])
|
||||||
#define PAM_GETG(p) ((p)[1])
|
#define PAM_GETG(p) ((p)[1])
|
||||||
@@ -20,7 +20,7 @@ typedef std::uint8_t apixel[4];
|
|||||||
#define PAM_EQUAL(p,q) \
|
#define PAM_EQUAL(p,q) \
|
||||||
((p)[0] == (q)[0] && (p)[1] == (q)[1] && (p)[2] == (q)[2] && (p)[3] == (q)[3])
|
((p)[0] == (q)[0] && (p)[1] == (q)[1] && (p)[2] == (q)[2] && (p)[3] == (q)[3])
|
||||||
#define PAM_DEPTH(p) \
|
#define PAM_DEPTH(p) \
|
||||||
PAM_ASSIGN( (p), (std::uint8_t) table[PAM_GETR(p)], (std::uint8_t) table[PAM_GETG(p)], (std::uint8_t) table[PAM_GETB(p)], (std::uint8_t) table[PAM_GETA(p)] )
|
PAM_ASSIGN( (p), (uint8_t) table[PAM_GETR(p)], (uint8_t) table[PAM_GETG(p)], (uint8_t) table[PAM_GETB(p)], (uint8_t) table[PAM_GETA(p)] )
|
||||||
|
|
||||||
struct acolorhist_item
|
struct acolorhist_item
|
||||||
{
|
{
|
||||||
@@ -92,8 +92,8 @@ static bool compare_index_3( const acolorhist_item &ch1, const acolorhist_item &
|
|||||||
}
|
}
|
||||||
|
|
||||||
static acolorhist_item *pam_computeacolorhist( const RageSurface *src, int maxacolors, int* acolorsP );
|
static acolorhist_item *pam_computeacolorhist( const RageSurface *src, int maxacolors, int* acolorsP );
|
||||||
static void pam_addtoacolorhash( acolorhash_hash &acht, const std::uint8_t acolorP[4], int value );
|
static void pam_addtoacolorhash( acolorhash_hash &acht, const uint8_t acolorP[4], int value );
|
||||||
static int pam_lookupacolor( const acolorhash_hash &acht, const std::uint8_t acolorP[4] );
|
static int pam_lookupacolor( const acolorhash_hash &acht, const uint8_t acolorP[4] );
|
||||||
static void pam_freeacolorhist( acolorhist_item *achv );
|
static void pam_freeacolorhist( acolorhist_item *achv );
|
||||||
|
|
||||||
struct pixerror_t
|
struct pixerror_t
|
||||||
@@ -134,7 +134,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither
|
|||||||
int table[256];
|
int table[256];
|
||||||
for( int c = 0; c <= maxval; ++c )
|
for( int c = 0; c <= maxval; ++c )
|
||||||
{
|
{
|
||||||
table[c] = ( (std::uint8_t) c * newmaxval + maxval/2 ) / maxval;
|
table[c] = ( (uint8_t) c * newmaxval + maxval/2 ) / maxval;
|
||||||
}
|
}
|
||||||
for( int row = 0; row < pImg->h; ++row )
|
for( int row = 0; row < pImg->h; ++row )
|
||||||
{
|
{
|
||||||
@@ -203,15 +203,15 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither
|
|||||||
limitcol = -1;
|
limitcol = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::uint8_t *pIn = pImg->pixels + row*pImg->pitch;
|
const uint8_t *pIn = pImg->pixels + row*pImg->pitch;
|
||||||
std::uint8_t *pOut = pRet->pixels + row*pRet->pitch;
|
uint8_t *pOut = pRet->pixels + row*pRet->pitch;
|
||||||
pIn += col * 4;
|
pIn += col * 4;
|
||||||
pOut += col;
|
pOut += col;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
std::int32_t sc[4];
|
std::int32_t sc[4];
|
||||||
std::uint8_t pixel[4] = { pIn[0], pIn[1], pIn[2], pIn[3] };
|
uint8_t pixel[4] = { pIn[0], pIn[1], pIn[2], pIn[3] };
|
||||||
if( bDither )
|
if( bDither )
|
||||||
{
|
{
|
||||||
// Use Floyd-Steinberg errors to adjust actual color.
|
// Use Floyd-Steinberg errors to adjust actual color.
|
||||||
@@ -221,7 +221,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither
|
|||||||
sc[c] = std::clamp( sc[c], 0, (std::int32_t) maxval );
|
sc[c] = std::clamp( sc[c], 0, (std::int32_t) maxval );
|
||||||
}
|
}
|
||||||
|
|
||||||
PAM_ASSIGN( pixel, (std::uint8_t)sc[0], (std::uint8_t)sc[1], (std::uint8_t)sc[2], (std::uint8_t)sc[3] );
|
PAM_ASSIGN( pixel, (uint8_t)sc[0], (uint8_t)sc[1], (uint8_t)sc[2], (uint8_t)sc[3] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check hash table to see if we have already matched this color.
|
// Check hash table to see if we have already matched this color.
|
||||||
@@ -240,7 +240,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither
|
|||||||
long dist = 2000000000;
|
long dist = 2000000000;
|
||||||
for( int i = 0; i < newcolors; ++i )
|
for( int i = 0; i < newcolors; ++i )
|
||||||
{
|
{
|
||||||
const std::uint8_t *colors2 = acolormap[i].acolor;
|
const uint8_t *colors2 = acolormap[i].acolor;
|
||||||
|
|
||||||
int newdist = 0;
|
int newdist = 0;
|
||||||
newdist += pSquareTable[ int(pixel[0]) - colors2[0] ];
|
newdist += pSquareTable[ int(pixel[0]) - colors2[0] ];
|
||||||
@@ -283,7 +283,7 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*pOut = (std::uint8_t) ind;
|
*pOut = (uint8_t) ind;
|
||||||
|
|
||||||
if( !fs_direction )
|
if( !fs_direction )
|
||||||
{
|
{
|
||||||
@@ -480,7 +480,7 @@ static acolorhist_item *mediancut( acolorhist_item *achv, int colors, int sum, i
|
|||||||
b = std::min( b, (long) maxval );
|
b = std::min( b, (long) maxval );
|
||||||
a = a / lSum;
|
a = a / lSum;
|
||||||
a = std::min( a, (long) maxval );
|
a = std::min( a, (long) maxval );
|
||||||
PAM_ASSIGN( acolormap[bi].acolor, (std::uint8_t)r, (std::uint8_t)g, (std::uint8_t)b, (std::uint8_t)a );
|
PAM_ASSIGN( acolormap[bi].acolor, (uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a );
|
||||||
#endif // REP_AVERAGE_PIXELS
|
#endif // REP_AVERAGE_PIXELS
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,7 +579,7 @@ static acolorhist_item *pam_computeacolorhist( const RageSurface *src, int maxac
|
|||||||
return achv;
|
return achv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pam_addtoacolorhash( acolorhash_hash &acht, const std::uint8_t acolorP[4], int value )
|
static void pam_addtoacolorhash( acolorhash_hash &acht, const uint8_t acolorP[4], int value )
|
||||||
{
|
{
|
||||||
acolorhist_list achl = (acolorhist_list) malloc( sizeof(struct acolorhist_list_item) );
|
acolorhist_list achl = (acolorhist_list) malloc( sizeof(struct acolorhist_list_item) );
|
||||||
ASSERT( achl != nullptr );
|
ASSERT( achl != nullptr );
|
||||||
@@ -592,7 +592,7 @@ static void pam_addtoacolorhash( acolorhash_hash &acht, const std::uint8_t acolo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int pam_lookupacolor( const acolorhash_hash &acht, const std::uint8_t acolorP[4] )
|
static int pam_lookupacolor( const acolorhash_hash &acht, const uint8_t acolorP[4] )
|
||||||
{
|
{
|
||||||
const int hash = pam_hashapixel( acolorP );
|
const int hash = pam_hashapixel( acolorP );
|
||||||
for ( acolorhist_list_item *achl = acht.hash[hash]; achl != nullptr; achl = achl->next )
|
for ( acolorhist_list_item *achl = acht.hash[hash]; achl != nullptr; achl = achl->next )
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
* (Look at a grid: map coordinates to the lines, not the squares between the
|
* (Look at a grid: map coordinates to the lines, not the squares between the
|
||||||
* lines.) */
|
* lines.) */
|
||||||
|
|
||||||
static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector<std::uint32_t> &percent, int src, int dst )
|
static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector<uint32_t> &percent, int src, int dst )
|
||||||
{
|
{
|
||||||
if( src >= dst )
|
if( src >= dst )
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector
|
|||||||
/* sax is somewhere between the centers of both sampled
|
/* sax is somewhere between the centers of both sampled
|
||||||
* pixels; find the percentage: */
|
* pixels; find the percentage: */
|
||||||
const float p = (1.0f - (sax - fleft) / xdist) * 16777216.0f;
|
const float p = (1.0f - (sax - fleft) / xdist) * 16777216.0f;
|
||||||
percent.push_back( std::uint32_t(p) );
|
percent.push_back( uint32_t(p) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ static void InitVectors( std::vector<int> &s0, std::vector<int> &s1, std::vector
|
|||||||
s1.push_back( std::clamp(int(sax+1), 0, src-1) );
|
s1.push_back( std::clamp(int(sax+1), 0, src-1) );
|
||||||
|
|
||||||
const float p = (1.0f - (sax - std::floor(sax))) * 16777216.0f;
|
const float p = (1.0f - (sax - std::floor(sax))) * 16777216.0f;
|
||||||
percent.push_back( std::uint32_t(p) );
|
percent.push_back( uint32_t(p) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,42 +85,42 @@ static void ZoomSurface( const RageSurface * src, RageSurface * dst )
|
|||||||
/* For each destination coordinate, two source rows, two source columns
|
/* For each destination coordinate, two source rows, two source columns
|
||||||
* and the percentage of the first row and first column: */
|
* and the percentage of the first row and first column: */
|
||||||
std::vector<int> esx0, esx1, esy0, esy1;
|
std::vector<int> esx0, esx1, esy0, esy1;
|
||||||
std::vector<std::uint32_t> ex0, ey0;
|
std::vector<uint32_t> ex0, ey0;
|
||||||
|
|
||||||
InitVectors( esx0, esx1, ex0, src->w, dst->w );
|
InitVectors( esx0, esx1, ex0, src->w, dst->w );
|
||||||
InitVectors( esy0, esy1, ey0, src->h, dst->h );
|
InitVectors( esy0, esy1, ey0, src->h, dst->h );
|
||||||
|
|
||||||
// This is where all of the real work is done.
|
// This is where all of the real work is done.
|
||||||
const std::uint8_t *sp = (std::uint8_t *) src->pixels;
|
const uint8_t *sp = (uint8_t *) src->pixels;
|
||||||
const int height = dst->h;
|
const int height = dst->h;
|
||||||
const int width = dst->w;
|
const int width = dst->w;
|
||||||
for( int y = 0; y < height; y++ )
|
for( int y = 0; y < height; y++ )
|
||||||
{
|
{
|
||||||
std::uint8_t *dp = (std::uint8_t *) (dst->pixels + dst->pitch*y);
|
uint8_t *dp = (uint8_t *) (dst->pixels + dst->pitch*y);
|
||||||
/* current source pointer and next source pointer (first and second
|
/* current source pointer and next source pointer (first and second
|
||||||
* rows sampled for this row): */
|
* rows sampled for this row): */
|
||||||
const std::uint8_t *csp = sp + esy0[y] * src->pitch;
|
const uint8_t *csp = sp + esy0[y] * src->pitch;
|
||||||
const std::uint8_t *ncsp = sp + esy1[y] * src->pitch;
|
const uint8_t *ncsp = sp + esy1[y] * src->pitch;
|
||||||
|
|
||||||
for( int x = 0; x < width; x++ )
|
for( int x = 0; x < width; x++ )
|
||||||
{
|
{
|
||||||
// Grab pointers to the sampled pixels:
|
// Grab pointers to the sampled pixels:
|
||||||
const std::uint8_t *c00 = csp + esx0[x]*4;
|
const uint8_t *c00 = csp + esx0[x]*4;
|
||||||
const std::uint8_t *c01 = csp + esx1[x]*4;
|
const uint8_t *c01 = csp + esx1[x]*4;
|
||||||
const std::uint8_t *c10 = ncsp + esx0[x]*4;
|
const uint8_t *c10 = ncsp + esx0[x]*4;
|
||||||
const std::uint8_t *c11 = ncsp + esx1[x]*4;
|
const uint8_t *c11 = ncsp + esx1[x]*4;
|
||||||
|
|
||||||
for( int c = 0; c < 4; ++c )
|
for( int c = 0; c < 4; ++c )
|
||||||
{
|
{
|
||||||
std::uint32_t x0 = std::uint32_t(c00[c]) * ex0[x];
|
uint32_t x0 = uint32_t(c00[c]) * ex0[x];
|
||||||
x0 += std::uint32_t(c01[c]) * (16777216 - ex0[x]);
|
x0 += uint32_t(c01[c]) * (16777216 - ex0[x]);
|
||||||
x0 >>= 24;
|
x0 >>= 24;
|
||||||
std::uint32_t x1 = std::uint32_t(c10[c]) * ex0[x];
|
uint32_t x1 = uint32_t(c10[c]) * ex0[x];
|
||||||
x1 += std::uint32_t(c11[c]) * (16777216 - ex0[x]);
|
x1 += uint32_t(c11[c]) * (16777216 - ex0[x]);
|
||||||
x1 >>= 24;
|
x1 >>= 24;
|
||||||
|
|
||||||
const std::uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24;
|
const uint32_t res = ((x0 * ey0[y]) + (x1 * (16777216-ey0[y])) + 8388608) >> 24;
|
||||||
dp[c] = std::uint8_t(res);
|
dp[c] = uint8_t(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance destination pointer.
|
// Advance destination pointer.
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ static RageSurfaceUtils::OpenResult LoadBMP( RageFile &f, RageSurface *&img, RSt
|
|||||||
|
|
||||||
read_u32_le( f, sError ); /* file size */
|
read_u32_le( f, sError ); /* file size */
|
||||||
read_u32_le( f, sError ); /* unused */
|
read_u32_le( f, sError ); /* unused */
|
||||||
std::uint32_t iDataOffset = read_u32_le( f, sError );
|
uint32_t iDataOffset = read_u32_le( f, sError );
|
||||||
std::uint32_t iHeaderSize = read_u32_le( f, sError );
|
uint32_t iHeaderSize = read_u32_le( f, sError );
|
||||||
|
|
||||||
std::uint32_t iWidth, iHeight, iPlanes, iBPP, iCompression = COMP_BI_RGB, iColors = 0;
|
uint32_t iWidth, iHeight, iPlanes, iBPP, iCompression = COMP_BI_RGB, iColors = 0;
|
||||||
if( iHeaderSize == 12 )
|
if( iHeaderSize == 12 )
|
||||||
{
|
{
|
||||||
/* OS/2 format */
|
/* OS/2 format */
|
||||||
@@ -157,7 +157,7 @@ static RageSurfaceUtils::OpenResult LoadBMP( RageFile &f, RageSurface *&img, RSt
|
|||||||
|
|
||||||
for( int y = (int) iHeight-1; y >= 0; --y )
|
for( int y = (int) iHeight-1; y >= 0; --y )
|
||||||
{
|
{
|
||||||
std::uint8_t *pRow = img->pixels + img->pitch*y;
|
uint8_t *pRow = img->pixels + img->pitch*y;
|
||||||
RString buf;
|
RString buf;
|
||||||
|
|
||||||
f.Read( buf, iFilePitch );
|
f.Read( buf, iFilePitch );
|
||||||
|
|||||||
@@ -60,9 +60,9 @@ RageSurface *RageSurface_Load_XPM( char * const *xpm, RString &error )
|
|||||||
if( sscanf( clr, "%2x%2x%2x", &r, &g, &b ) != 3 )
|
if( sscanf( clr, "%2x%2x%2x", &r, &g, &b ) != 3 )
|
||||||
continue;
|
continue;
|
||||||
RageSurfaceColor colorval;
|
RageSurfaceColor colorval;
|
||||||
colorval.r = (std::uint8_t) r;
|
colorval.r = (uint8_t) r;
|
||||||
colorval.g = (std::uint8_t) g;
|
colorval.g = (uint8_t) g;
|
||||||
colorval.b = (std::uint8_t) b;
|
colorval.b = (uint8_t) b;
|
||||||
colorval.a = 0xFF;
|
colorval.a = 0xFF;
|
||||||
|
|
||||||
colors.push_back( colorval );
|
colors.push_back( colorval );
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ static void WriteBytes( RageFile &f, RString &sError, const void *buf, int size
|
|||||||
sError = f.GetError();
|
sError = f.GetError();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_le16( RageFile &f, RString &sError, std::uint16_t val )
|
static void write_le16( RageFile &f, RString &sError, uint16_t val )
|
||||||
{
|
{
|
||||||
val = Swap16LE( val );
|
val = Swap16LE( val );
|
||||||
WriteBytes( f, sError, &val, sizeof(std::uint16_t) );
|
WriteBytes( f, sError, &val, sizeof(uint16_t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_le32( RageFile &f, RString &sError, std::uint32_t val )
|
static void write_le32( RageFile &f, RString &sError, uint32_t val )
|
||||||
{
|
{
|
||||||
val = Swap32LE( val );
|
val = Swap32LE( val );
|
||||||
WriteBytes( f, sError, &val, sizeof(std::uint32_t) );
|
WriteBytes( f, sError, &val, sizeof(uint32_t) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f )
|
bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f )
|
||||||
@@ -53,7 +53,7 @@ bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f )
|
|||||||
write_le32( f, sError, surface->w ); // width (offset 0x14)
|
write_le32( f, sError, surface->w ); // width (offset 0x14)
|
||||||
write_le32( f, sError, surface->h ); // height (offset 0x18)
|
write_le32( f, sError, surface->h ); // height (offset 0x18)
|
||||||
write_le16( f, sError, 1 ); // planes (offset 0x1A)
|
write_le16( f, sError, 1 ); // planes (offset 0x1A)
|
||||||
write_le16( f, sError, (std::uint16_t) converted_surface->fmt.BytesPerPixel*8 ); // bpp (offset 0x1C)
|
write_le16( f, sError, (uint16_t) converted_surface->fmt.BytesPerPixel*8 ); // bpp (offset 0x1C)
|
||||||
write_le32( f, sError, 0 ); // compression (offset 0x1E)
|
write_le32( f, sError, 0 ); // compression (offset 0x1E)
|
||||||
write_le32( f, sError, iDataSize ); // bitmap size (offset 0x22)
|
write_le32( f, sError, iDataSize ); // bitmap size (offset 0x22)
|
||||||
write_le32( f, sError, 0 ); // horiz resolution (offset 0x26)
|
write_le32( f, sError, 0 ); // horiz resolution (offset 0x26)
|
||||||
@@ -63,11 +63,11 @@ bool RageSurfaceUtils::SaveBMP( RageSurface *surface, RageFile &f )
|
|||||||
|
|
||||||
for( int y = converted_surface->h-1; y >= 0; --y )
|
for( int y = converted_surface->h-1; y >= 0; --y )
|
||||||
{
|
{
|
||||||
const std::uint8_t *pRow = converted_surface->pixels + converted_surface->pitch*y;
|
const uint8_t *pRow = converted_surface->pixels + converted_surface->pitch*y;
|
||||||
WriteBytes( f, sError, pRow, converted_surface->pitch );
|
WriteBytes( f, sError, pRow, converted_surface->pitch );
|
||||||
|
|
||||||
/* Pad the row to the pitch. */
|
/* Pad the row to the pitch. */
|
||||||
std::uint8_t padding[4] = { 0,0,0,0 };
|
uint8_t padding[4] = { 0,0,0,0 };
|
||||||
WriteBytes( f, sError, padding, iFilePitch-converted_surface->pitch );
|
WriteBytes( f, sError, padding, iFilePitch-converted_surface->pitch );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ typedef struct
|
|||||||
struct jpeg::jpeg_destination_mgr pub;
|
struct jpeg::jpeg_destination_mgr pub;
|
||||||
|
|
||||||
RageFile *f;
|
RageFile *f;
|
||||||
std::uint8_t buffer[OUTPUT_BUFFER_SIZE];
|
uint8_t buffer[OUTPUT_BUFFER_SIZE];
|
||||||
} my_destination_mgr;
|
} my_destination_mgr;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public:
|
|||||||
virtual void Update( float /* fDeltaTime */ ) {}
|
virtual void Update( float /* fDeltaTime */ ) {}
|
||||||
virtual void Reload() {}
|
virtual void Reload() {}
|
||||||
virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */
|
virtual void Invalidate() { } /* only called by RageTextureManager::InvalidateTextures */
|
||||||
virtual std::uintptr_t GetTexHandle() const = 0; // accessed by RageDisplay
|
virtual uintptr_t GetTexHandle() const = 0; // accessed by RageDisplay
|
||||||
|
|
||||||
// movie texture/animated texture stuff
|
// movie texture/animated texture stuff
|
||||||
virtual void SetPosition( float /* fSeconds */ ) {} // seek
|
virtual void SetPosition( float /* fSeconds */ ) {} // seek
|
||||||
|
|||||||
@@ -133,10 +133,10 @@ public:
|
|||||||
m_iImageWidth = m_iImageHeight = 1;
|
m_iImageWidth = m_iImageHeight = 1;
|
||||||
CreateFrameRects();
|
CreateFrameRects();
|
||||||
}
|
}
|
||||||
std::uintptr_t GetTexHandle() const { return m_uTexHandle; }
|
uintptr_t GetTexHandle() const { return m_uTexHandle; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::uintptr_t m_uTexHandle;
|
uintptr_t m_uTexHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load and unload textures from disk.
|
// Load and unload textures from disk.
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
virtual ~RageTextureRenderTarget();
|
virtual ~RageTextureRenderTarget();
|
||||||
virtual void Invalidate() { m_iTexHandle = 0; /* don't Destroy() */ }
|
virtual void Invalidate() { m_iTexHandle = 0; /* don't Destroy() */ }
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
virtual std::uintptr_t GetTexHandle() const { return m_iTexHandle; }
|
virtual uintptr_t GetTexHandle() const { return m_iTexHandle; }
|
||||||
|
|
||||||
void BeginRenderingTo( bool bPreserveTexture = true );
|
void BeginRenderingTo( bool bPreserveTexture = true );
|
||||||
void FinishRenderingTo();
|
void FinishRenderingTo();
|
||||||
@@ -28,8 +28,8 @@ private:
|
|||||||
|
|
||||||
void Create();
|
void Create();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
std::uintptr_t m_iTexHandle;
|
uintptr_t m_iTexHandle;
|
||||||
std::uintptr_t m_iPreviousRenderTarget;
|
uintptr_t m_iPreviousRenderTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+10
-10
@@ -46,7 +46,7 @@ struct ThreadSlot
|
|||||||
char m_szThreadFormattedOutput[1024];
|
char m_szThreadFormattedOutput[1024];
|
||||||
|
|
||||||
bool m_bUsed;
|
bool m_bUsed;
|
||||||
std::uint64_t m_iID;
|
uint64_t m_iID;
|
||||||
|
|
||||||
ThreadImpl *m_pImpl;
|
ThreadImpl *m_pImpl;
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ static void InitThreads()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ThreadSlot *GetThreadSlotFromID( std::uint64_t iID )
|
static ThreadSlot *GetThreadSlotFromID( uint64_t iID )
|
||||||
{
|
{
|
||||||
InitThreads();
|
InitThreads();
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ const char *RageThread::GetCurrentThreadName()
|
|||||||
return GetThreadNameByID( GetCurrentThreadID() );
|
return GetThreadNameByID( GetCurrentThreadID() );
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *RageThread::GetThreadNameByID( std::uint64_t iID )
|
const char *RageThread::GetThreadNameByID( uint64_t iID )
|
||||||
{
|
{
|
||||||
ThreadSlot *slot = GetThreadSlotFromID( iID );
|
ThreadSlot *slot = GetThreadSlotFromID( iID );
|
||||||
if( slot == nullptr )
|
if( slot == nullptr )
|
||||||
@@ -293,7 +293,7 @@ const char *RageThread::GetThreadNameByID( std::uint64_t iID )
|
|||||||
return slot->GetThreadName();
|
return slot->GetThreadName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageThread::EnumThreadIDs( int n, std::uint64_t &iID )
|
bool RageThread::EnumThreadIDs( int n, uint64_t &iID )
|
||||||
{
|
{
|
||||||
if( n >= MAX_THREADS )
|
if( n >= MAX_THREADS )
|
||||||
return false;
|
return false;
|
||||||
@@ -337,7 +337,7 @@ void RageThread::Resume() {
|
|||||||
|
|
||||||
void RageThread::HaltAllThreads( bool Kill )
|
void RageThread::HaltAllThreads( bool Kill )
|
||||||
{
|
{
|
||||||
const std::uint64_t ThisThreadID = GetThisThreadId();
|
const uint64_t ThisThreadID = GetThisThreadId();
|
||||||
for( int entry = 0; entry < MAX_THREADS; ++entry )
|
for( int entry = 0; entry < MAX_THREADS; ++entry )
|
||||||
{
|
{
|
||||||
if( !g_ThreadSlots[entry].m_bUsed )
|
if( !g_ThreadSlots[entry].m_bUsed )
|
||||||
@@ -350,7 +350,7 @@ void RageThread::HaltAllThreads( bool Kill )
|
|||||||
|
|
||||||
void RageThread::ResumeAllThreads()
|
void RageThread::ResumeAllThreads()
|
||||||
{
|
{
|
||||||
const std::uint64_t ThisThreadID = GetThisThreadId();
|
const uint64_t ThisThreadID = GetThisThreadId();
|
||||||
for( int entry = 0; entry < MAX_THREADS; ++entry )
|
for( int entry = 0; entry < MAX_THREADS; ++entry )
|
||||||
{
|
{
|
||||||
if( !g_ThreadSlots[entry].m_bUsed )
|
if( !g_ThreadSlots[entry].m_bUsed )
|
||||||
@@ -362,11 +362,11 @@ void RageThread::ResumeAllThreads()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t RageThread::GetCurrentThreadID()
|
uint64_t RageThread::GetCurrentThreadID()
|
||||||
{
|
{
|
||||||
return GetThisThreadId();
|
return GetThisThreadId();
|
||||||
}
|
}
|
||||||
std::uint64_t RageThread::GetInvalidThreadID()
|
uint64_t RageThread::GetInvalidThreadID()
|
||||||
{
|
{
|
||||||
return GetInvalidThreadId();
|
return GetInvalidThreadId();
|
||||||
}
|
}
|
||||||
@@ -583,7 +583,7 @@ RageMutex::~RageMutex()
|
|||||||
|
|
||||||
void RageMutex::Lock()
|
void RageMutex::Lock()
|
||||||
{
|
{
|
||||||
std::uint64_t iThisThreadId = GetThisThreadId();
|
uint64_t iThisThreadId = GetThisThreadId();
|
||||||
if( m_LockedBy == iThisThreadId )
|
if( m_LockedBy == iThisThreadId )
|
||||||
{
|
{
|
||||||
++m_LockCnt;
|
++m_LockCnt;
|
||||||
@@ -607,7 +607,7 @@ void RageMutex::Lock()
|
|||||||
#if defined(CRASH_HANDLER)
|
#if defined(CRASH_HANDLER)
|
||||||
/* Don't leave GetThreadSlotsLock() locked when we call ForceCrashHandlerDeadlock. */
|
/* Don't leave GetThreadSlotsLock() locked when we call ForceCrashHandlerDeadlock. */
|
||||||
GetThreadSlotsLock().Lock();
|
GetThreadSlotsLock().Lock();
|
||||||
std::uint64_t CrashHandle = OtherSlot? OtherSlot->m_iID:0;
|
uint64_t CrashHandle = OtherSlot? OtherSlot->m_iID:0;
|
||||||
GetThreadSlotsLock().Unlock();
|
GetThreadSlotsLock().Unlock();
|
||||||
|
|
||||||
/* Pass the crash handle of the other thread, so it can backtrace that thread. */
|
/* Pass the crash handle of the other thread, so it can backtrace that thread. */
|
||||||
|
|||||||
+5
-5
@@ -30,11 +30,11 @@ public:
|
|||||||
/* If HaltAllThreads was called (with Kill==false), resume. */
|
/* If HaltAllThreads was called (with Kill==false), resume. */
|
||||||
static void ResumeAllThreads();
|
static void ResumeAllThreads();
|
||||||
|
|
||||||
static std::uint64_t GetCurrentThreadID();
|
static uint64_t GetCurrentThreadID();
|
||||||
|
|
||||||
static const char *GetCurrentThreadName();
|
static const char *GetCurrentThreadName();
|
||||||
static const char *GetThreadNameByID( std::uint64_t iID );
|
static const char *GetThreadNameByID( uint64_t iID );
|
||||||
static bool EnumThreadIDs( int n, std::uint64_t &iID );
|
static bool EnumThreadIDs( int n, uint64_t &iID );
|
||||||
int Wait();
|
int Wait();
|
||||||
bool IsCreated() const { return m_pSlot != nullptr; }
|
bool IsCreated() const { return m_pSlot != nullptr; }
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
static bool GetIsShowingDialog() { return s_bIsShowingDialog; }
|
static bool GetIsShowingDialog() { return s_bIsShowingDialog; }
|
||||||
static void SetIsShowingDialog( bool b ) { s_bIsShowingDialog = b; }
|
static void SetIsShowingDialog( bool b ) { s_bIsShowingDialog = b; }
|
||||||
static std::uint64_t GetInvalidThreadID();
|
static uint64_t GetInvalidThreadID();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ThreadSlot *m_pSlot;
|
ThreadSlot *m_pSlot;
|
||||||
@@ -111,7 +111,7 @@ protected:
|
|||||||
|
|
||||||
int m_UniqueID;
|
int m_UniqueID;
|
||||||
|
|
||||||
std::uint64_t m_LockedBy;
|
uint64_t m_LockedBy;
|
||||||
int m_LockCnt;
|
int m_LockCnt;
|
||||||
|
|
||||||
void MarkLockedMutex();
|
void MarkLockedMutex();
|
||||||
|
|||||||
+6
-6
@@ -30,16 +30,16 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
const std::uint64_t ONE_SECOND_IN_MICROSECONDS_ULL = 1000000ULL;
|
const uint64_t ONE_SECOND_IN_MICROSECONDS_ULL = 1000000ULL;
|
||||||
const std::int64_t ONE_SECOND_IN_MICROSECONDS_LL = 1000000LL;
|
const std::int64_t ONE_SECOND_IN_MICROSECONDS_LL = 1000000LL;
|
||||||
const uint_fast64_t ONE_SECOND_IN_MICROSECONDS_FAST_ULL = 1000000ULL;
|
const uint_fast64_t ONE_SECOND_IN_MICROSECONDS_FAST_ULL = 1000000ULL;
|
||||||
const double ONE_SECOND_IN_MICROSECONDS_DBL = 1000000.0;
|
const double ONE_SECOND_IN_MICROSECONDS_DBL = 1000000.0;
|
||||||
|
|
||||||
const RageTimer RageZeroTimer(0,0);
|
const RageTimer RageZeroTimer(0,0);
|
||||||
static const std::uint64_t g_iStartTime = ArchHooks::GetSystemTimeInMicroseconds();
|
static const uint64_t g_iStartTime = ArchHooks::GetSystemTimeInMicroseconds();
|
||||||
static uint_fast64_t g_iStartTimeFast64 = g_iStartTime;
|
static uint_fast64_t g_iStartTimeFast64 = g_iStartTime;
|
||||||
|
|
||||||
static std::uint64_t GetTime()
|
static uint64_t GetTime()
|
||||||
{
|
{
|
||||||
return ArchHooks::GetSystemTimeInMicroseconds();
|
return ArchHooks::GetSystemTimeInMicroseconds();
|
||||||
}
|
}
|
||||||
@@ -71,10 +71,10 @@ uint_fast64_t RageTimer::GetTimeSinceStartMicroseconds()
|
|||||||
|
|
||||||
void RageTimer::Touch()
|
void RageTimer::Touch()
|
||||||
{
|
{
|
||||||
std::uint64_t usecs = GetTime();
|
uint64_t usecs = GetTime();
|
||||||
|
|
||||||
this->m_secs = std::uint64_t(usecs / ONE_SECOND_IN_MICROSECONDS_ULL);
|
this->m_secs = uint64_t(usecs / ONE_SECOND_IN_MICROSECONDS_ULL);
|
||||||
this->m_us = std::uint64_t(usecs % ONE_SECOND_IN_MICROSECONDS_ULL);
|
this->m_us = uint64_t(usecs % ONE_SECOND_IN_MICROSECONDS_ULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
float RageTimer::Ago() const
|
float RageTimer::Ago() const
|
||||||
|
|||||||
+1
-1
@@ -46,7 +46,7 @@ public:
|
|||||||
* microseconds values into two integers and combining them later allows for
|
* microseconds values into two integers and combining them later allows for
|
||||||
* better precision. Use caution when changing data types, since resolution
|
* better precision. Use caution when changing data types, since resolution
|
||||||
* mismatch errors are easy to cause when changing things in RageTimer. */
|
* mismatch errors are easy to cause when changing things in RageTimer. */
|
||||||
std::uint64_t m_secs, m_us;
|
uint64_t m_secs, m_us;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RageTimer Sum( const RageTimer &lhs, float tm );
|
static RageTimer Sum( const RageTimer &lhs, float tm );
|
||||||
|
|||||||
+1
-1
@@ -290,7 +290,7 @@ inline unsigned char FTOC(float a)
|
|||||||
class RageVColor
|
class RageVColor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::uint8_t b,g,r,a; // specific ordering required by Direct3D
|
uint8_t b,g,r,a; // specific ordering required by Direct3D
|
||||||
|
|
||||||
RageVColor(): b(0), g(0), r(0), a(0) { }
|
RageVColor(): b(0), g(0), r(0), a(0) { }
|
||||||
RageVColor(const RageColor &rc): b(0), g(0), r(0), a(0) { *this = rc; }
|
RageVColor(const RageColor &rc): b(0), g(0), r(0), a(0) { *this = rc; }
|
||||||
|
|||||||
+1
-1
@@ -196,7 +196,7 @@ bool HexToBinary( const RString &s, unsigned char *stringOut )
|
|||||||
break;
|
break;
|
||||||
RString sByte = s.substr( i*2, 2 );
|
RString sByte = s.substr( i*2, 2 );
|
||||||
|
|
||||||
std::uint8_t val = 0;
|
uint8_t val = 0;
|
||||||
if( sscanf( sByte, "%hhx", &val ) != 1 )
|
if( sscanf( sByte, "%hhx", &val ) != 1 )
|
||||||
return false;
|
return false;
|
||||||
stringOut[i] = val;
|
stringOut[i] = val;
|
||||||
|
|||||||
+6
-6
@@ -225,12 +225,12 @@ namespace Endian
|
|||||||
#define Swap16(n) __builtin_bswap16(n)
|
#define Swap16(n) __builtin_bswap16(n)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline std::uint32_t Swap32LE( std::uint32_t n ) { return Endian::little ? n : Swap32( n ); }
|
inline uint32_t Swap32LE( uint32_t n ) { return Endian::little ? n : Swap32( n ); }
|
||||||
inline std::uint32_t Swap24LE( std::uint32_t n ) { return Endian::little ? n : Swap24( n ); }
|
inline uint32_t Swap24LE( uint32_t n ) { return Endian::little ? n : Swap24( n ); }
|
||||||
inline std::uint16_t Swap16LE( std::uint16_t n ) { return Endian::little ? n : Swap16( n ); }
|
inline uint16_t Swap16LE( uint16_t n ) { return Endian::little ? n : Swap16( n ); }
|
||||||
inline std::uint32_t Swap32BE( std::uint32_t n ) { return Endian::big ? n : Swap32( n ); }
|
inline uint32_t Swap32BE( uint32_t n ) { return Endian::big ? n : Swap32( n ); }
|
||||||
inline std::uint32_t Swap24BE( std::uint32_t n ) { return Endian::big ? n : Swap24( n ); }
|
inline uint32_t Swap24BE( uint32_t n ) { return Endian::big ? n : Swap24( n ); }
|
||||||
inline std::uint16_t Swap16BE( std::uint16_t n ) { return Endian::big ? n : Swap16( n ); }
|
inline uint16_t Swap16BE( uint16_t n ) { return Endian::big ? n : Swap16( n ); }
|
||||||
|
|
||||||
class MersenneTwister : public std::mt19937
|
class MersenneTwister : public std::mt19937
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ void ScoreKeeperNormal::AddScoreInternal( TapNoteScore score )
|
|||||||
|
|
||||||
m_iTapNotesHit++;
|
m_iTapNotesHit++;
|
||||||
|
|
||||||
const std::int64_t N = std::uint64_t(m_iNumTapsAndHolds);
|
const std::int64_t N = uint64_t(m_iNumTapsAndHolds);
|
||||||
const std::int64_t sum = (N * (N + 1)) / 2;
|
const std::int64_t sum = (N * (N + 1)) / 2;
|
||||||
const int Z = m_iMaxPossiblePoints/10;
|
const int Z = m_iMaxPossiblePoints/10;
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ void WheelNotifyIcon::Update( float fDeltaTime )
|
|||||||
/* We should probably end up parsing the vector and then dynamically
|
/* We should probably end up parsing the vector and then dynamically
|
||||||
* insert flag icons based on "priority". Easy to do, hopefully
|
* insert flag icons based on "priority". Easy to do, hopefully
|
||||||
- Midiman */
|
- Midiman */
|
||||||
static std::uint_fast32_t updateCounter = 0;
|
static uint_fast32_t updateCounter = 0;
|
||||||
updateCounter++;
|
updateCounter++;
|
||||||
const int index = updateCounter % m_vIconsToShow.size();
|
const int index = updateCounter % m_vIconsToShow.size();
|
||||||
Sprite::SetState(m_vIconsToShow[index]);
|
Sprite::SetState(m_vIconsToShow[index]);
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ std::int64_t ArchHooks::FixupTimeIfLooped( std::int64_t usecs )
|
|||||||
static std::int64_t offset_us = 0;
|
static std::int64_t offset_us = 0;
|
||||||
|
|
||||||
/* The time has wrapped if the last time was very high and the current time is very low. */
|
/* The time has wrapped if the last time was very high and the current time is very low. */
|
||||||
const std::int64_t i32BitMaxMs = std::uint64_t(1) << 32;
|
const std::int64_t i32BitMaxMs = uint64_t(1) << 32;
|
||||||
const std::int64_t i32BitMaxUs = i32BitMaxMs*1000;
|
const std::int64_t i32BitMaxUs = i32BitMaxMs*1000;
|
||||||
const std::int64_t one_day = std::uint64_t(24*60*60)*1000000;
|
const std::int64_t one_day = uint64_t(24*60*60)*1000000;
|
||||||
if( last > (i32BitMaxUs-one_day) && usecs < one_day )
|
if( last > (i32BitMaxUs-one_day) && usecs < one_day )
|
||||||
offset_us += i32BitMaxUs;
|
offset_us += i32BitMaxUs;
|
||||||
|
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
|||||||
float fRam;
|
float fRam;
|
||||||
char ramPower;
|
char ramPower;
|
||||||
{
|
{
|
||||||
std::uint64_t iRam = 0;
|
uint64_t iRam = 0;
|
||||||
GET_PARAM( "hw.memsize", iRam );
|
GET_PARAM( "hw.memsize", iRam );
|
||||||
|
|
||||||
fRam = float( double(iRam) / 1073741824.0 );
|
fRam = float( double(iRam) / 1073741824.0 );
|
||||||
@@ -176,7 +176,7 @@ void ArchHooks_MacOSX::DumpDebugInfo()
|
|||||||
RString sModel("Unknown");
|
RString sModel("Unknown");
|
||||||
do {
|
do {
|
||||||
char szModel[128];
|
char szModel[128];
|
||||||
std::uint64_t iFreq;
|
uint64_t iFreq;
|
||||||
|
|
||||||
GET_PARAM( "hw.logicalcpu_max", iMaxCPUs );
|
GET_PARAM( "hw.logicalcpu_max", iMaxCPUs );
|
||||||
GET_PARAM( "hw.logicalcpu", iCPUs );
|
GET_PARAM( "hw.logicalcpu", iCPUs );
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ static HANDLE g_hInstanceMutex;
|
|||||||
static bool g_bIsMultipleInstance = false;
|
static bool g_bIsMultipleInstance = false;
|
||||||
|
|
||||||
void InvalidParameterHandler( const wchar_t *szExpression, const wchar_t *szFunction, const wchar_t *szFile,
|
void InvalidParameterHandler( const wchar_t *szExpression, const wchar_t *szFunction, const wchar_t *szFile,
|
||||||
unsigned int iLine, std::uintptr_t pReserved )
|
unsigned int iLine, uintptr_t pReserved )
|
||||||
{
|
{
|
||||||
FAIL_M( "Invalid parameter" ); //TODO: Make this more informative
|
FAIL_M( "Invalid parameter" ); //TODO: Make this more informative
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ struct EventDevice
|
|||||||
|
|
||||||
static std::vector<EventDevice *> g_apEventDevices;
|
static std::vector<EventDevice *> g_apEventDevices;
|
||||||
|
|
||||||
static bool BitIsSet( const std::uint8_t *pArray, std::uint32_t iBit )
|
static bool BitIsSet( const uint8_t *pArray, uint32_t iBit )
|
||||||
{
|
{
|
||||||
return !!(pArray[iBit/8] & (1<<(iBit%8)));
|
return !!(pArray[iBit/8] & (1<<(iBit%8)));
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
|
|||||||
DevInfo.version, m_sName.c_str() );
|
DevInfo.version, m_sName.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t iABSMask[ABS_MAX/8 + 1];
|
uint8_t iABSMask[ABS_MAX/8 + 1];
|
||||||
memset( iABSMask, 0, sizeof(iABSMask) );
|
memset( iABSMask, 0, sizeof(iABSMask) );
|
||||||
if( ioctl(m_iFD, EVIOCGBIT(EV_ABS, sizeof(iABSMask)), iABSMask) < 0 )
|
if( ioctl(m_iFD, EVIOCGBIT(EV_ABS, sizeof(iABSMask)), iABSMask) < 0 )
|
||||||
LOG->Warn( "ioctl(EVIOCGBIT(EV_ABS)): %s", strerror(errno) );
|
LOG->Warn( "ioctl(EVIOCGBIT(EV_ABS)): %s", strerror(errno) );
|
||||||
@@ -145,12 +145,12 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t iKeyMask[KEY_MAX/8 + 1];
|
uint8_t iKeyMask[KEY_MAX/8 + 1];
|
||||||
memset( iKeyMask, 0, sizeof(iKeyMask) );
|
memset( iKeyMask, 0, sizeof(iKeyMask) );
|
||||||
if( ioctl(m_iFD, EVIOCGBIT(EV_KEY, sizeof(iKeyMask)), iKeyMask) < 0 )
|
if( ioctl(m_iFD, EVIOCGBIT(EV_KEY, sizeof(iKeyMask)), iKeyMask) < 0 )
|
||||||
LOG->Warn( "ioctl(EVIOCGBIT(EV_KEY)): %s", strerror(errno) );
|
LOG->Warn( "ioctl(EVIOCGBIT(EV_KEY)): %s", strerror(errno) );
|
||||||
|
|
||||||
std::uint8_t iEventTypes[EV_MAX/8];
|
uint8_t iEventTypes[EV_MAX/8];
|
||||||
memset( iEventTypes, 0, sizeof(iEventTypes) );
|
memset( iEventTypes, 0, sizeof(iEventTypes) );
|
||||||
if( ioctl(m_iFD, EVIOCGBIT(0, EV_MAX), iEventTypes) == -1 )
|
if( ioctl(m_iFD, EVIOCGBIT(0, EV_MAX), iEventTypes) == -1 )
|
||||||
LOG->Warn( "ioctl(EV_MAX): %s", strerror(errno) );
|
LOG->Warn( "ioctl(EV_MAX): %s", strerror(errno) );
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ class InputHandler_SextetStream::Impl
|
|||||||
handler->ButtonPressed(di);
|
handler->ButtonPressed(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint8_t stateBuffer[STATE_BUFFER_SIZE];
|
uint8_t stateBuffer[STATE_BUFFER_SIZE];
|
||||||
size_t timeout_ms;
|
size_t timeout_ms;
|
||||||
RageThread inputThread;
|
RageThread inputThread;
|
||||||
bool continueInputThread;
|
bool continueInputThread;
|
||||||
@@ -192,7 +192,7 @@ class InputHandler_SextetStream::Impl
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void GetNewState(std::uint8_t * buffer, RString& line)
|
inline void GetNewState(uint8_t * buffer, RString& line)
|
||||||
{
|
{
|
||||||
size_t lineLen = line.length();
|
size_t lineLen = line.length();
|
||||||
size_t i, cursor;
|
size_t i, cursor;
|
||||||
@@ -228,10 +228,10 @@ class InputHandler_SextetStream::Impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ReactToChanges(const std::uint8_t * newStateBuffer)
|
inline void ReactToChanges(const uint8_t * newStateBuffer)
|
||||||
{
|
{
|
||||||
InputDevice id = InputDevice(FIRST_DEVICE);
|
InputDevice id = InputDevice(FIRST_DEVICE);
|
||||||
std::uint8_t changes[STATE_BUFFER_SIZE];
|
uint8_t changes[STATE_BUFFER_SIZE];
|
||||||
RageTimer now;
|
RageTimer now;
|
||||||
|
|
||||||
// XOR to find differences
|
// XOR to find differences
|
||||||
@@ -276,7 +276,7 @@ class InputHandler_SextetStream::Impl
|
|||||||
if(linereader->ReadLine(line)) {
|
if(linereader->ReadLine(line)) {
|
||||||
LOG->Trace("Got line: '%s'", line.c_str());
|
LOG->Trace("Got line: '%s'", line.c_str());
|
||||||
if(line.length() > 0) {
|
if(line.length() > 0) {
|
||||||
std::uint8_t newStateBuffer[STATE_BUFFER_SIZE];
|
uint8_t newStateBuffer[STATE_BUFFER_SIZE];
|
||||||
GetNewState(newStateBuffer, line);
|
GetNewState(newStateBuffer, line);
|
||||||
ReactToChanges(newStateBuffer);
|
ReactToChanges(newStateBuffer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <process.h>
|
#include <process.h>
|
||||||
|
|
||||||
typedef int (*thread_create_t)(
|
typedef int (*thread_create_t)(
|
||||||
int (*proc)(void*), void* ctx, std::uint32_t stack_sz, unsigned int priority);
|
int (*proc)(void*), void* ctx, uint32_t stack_sz, unsigned int priority);
|
||||||
typedef void (*thread_join_t)(int thread_id, int* result);
|
typedef void (*thread_join_t)(int thread_id, int* result);
|
||||||
typedef void (*thread_destroy_t)(int thread_id);
|
typedef void (*thread_destroy_t)(int thread_id);
|
||||||
|
|
||||||
@@ -28,13 +28,13 @@ static DDRIO_IO_INIT ddrio_io_init;
|
|||||||
typedef int (*DDRIO_READ_PAD)();
|
typedef int (*DDRIO_READ_PAD)();
|
||||||
static DDRIO_READ_PAD ddrio_io_read_pad;
|
static DDRIO_READ_PAD ddrio_io_read_pad;
|
||||||
|
|
||||||
typedef int (*DDRIO_SETLIGHTS_P3IO)(std::uint32_t lights);
|
typedef int (*DDRIO_SETLIGHTS_P3IO)(uint32_t lights);
|
||||||
static DDRIO_SETLIGHTS_P3IO ddrio_set_lights_p3io;
|
static DDRIO_SETLIGHTS_P3IO ddrio_set_lights_p3io;
|
||||||
|
|
||||||
typedef int (*DDRIO_SETLIGHTS_EXTIO)(std::uint32_t lights);
|
typedef int (*DDRIO_SETLIGHTS_EXTIO)(uint32_t lights);
|
||||||
static DDRIO_SETLIGHTS_EXTIO ddrio_set_lights_extio;
|
static DDRIO_SETLIGHTS_EXTIO ddrio_set_lights_extio;
|
||||||
|
|
||||||
typedef int (*DDRIO_SETLIGHTS_HDXSPANEL)(std::uint32_t lights);
|
typedef int (*DDRIO_SETLIGHTS_HDXSPANEL)(uint32_t lights);
|
||||||
static DDRIO_SETLIGHTS_HDXSPANEL ddrio_set_lights_hdxs_panel;
|
static DDRIO_SETLIGHTS_HDXSPANEL ddrio_set_lights_hdxs_panel;
|
||||||
|
|
||||||
typedef int (*DDRIO_FINI)();
|
typedef int (*DDRIO_FINI)();
|
||||||
@@ -69,13 +69,13 @@ static unsigned int crt_thread_shim(void* outer_ctx)
|
|||||||
|
|
||||||
|
|
||||||
int crt_thread_create(
|
int crt_thread_create(
|
||||||
int (*proc)(void*), void* ctx, std::uint32_t stack_sz, unsigned int priority)
|
int (*proc)(void*), void* ctx, uint32_t stack_sz, unsigned int priority)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG->Trace("crt_thread_create");
|
LOG->Trace("crt_thread_create");
|
||||||
|
|
||||||
struct shim_ctx sctx;
|
struct shim_ctx sctx;
|
||||||
std::uintptr_t thread_id;
|
uintptr_t thread_id;
|
||||||
|
|
||||||
sctx.barrier = CreateEvent(NULL, TRUE, FALSE, NULL);
|
sctx.barrier = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
sctx.proc = proc;
|
sctx.proc = proc;
|
||||||
@@ -96,7 +96,7 @@ void crt_thread_destroy(int thread_id)
|
|||||||
{
|
{
|
||||||
LOG->Trace("crt_thread_destroy %d", thread_id);
|
LOG->Trace("crt_thread_destroy %d", thread_id);
|
||||||
|
|
||||||
CloseHandle((HANDLE)(std::uintptr_t)thread_id);
|
CloseHandle((HANDLE)(uintptr_t)thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -104,11 +104,11 @@ void crt_thread_join(int thread_id, int* result)
|
|||||||
{
|
{
|
||||||
LOG->Trace("crt_thread_join %d", thread_id);
|
LOG->Trace("crt_thread_join %d", thread_id);
|
||||||
|
|
||||||
WaitForSingleObject((HANDLE)(std::uintptr_t)thread_id, INFINITE);
|
WaitForSingleObject((HANDLE)(uintptr_t)thread_id, INFINITE);
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
GetExitCodeThread((HANDLE)(std::uintptr_t)thread_id, (DWORD*)result);
|
GetExitCodeThread((HANDLE)(uintptr_t)thread_id, (DWORD*)result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ int InputHandler_Win32_ddrio::InputThread_Start( void *p )
|
|||||||
|
|
||||||
void InputHandler_Win32_ddrio::InputThreadMain()
|
void InputHandler_Win32_ddrio::InputThreadMain()
|
||||||
{
|
{
|
||||||
std::uint32_t prevInput = 0, newInput = 0;
|
uint32_t prevInput = 0, newInput = 0;
|
||||||
LightsState prevLS = { 0 };
|
LightsState prevLS = { 0 };
|
||||||
LightsState newLS = { 0 };
|
LightsState newLS = { 0 };
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ void InputHandler_Win32_ddrio::InputThreadMain()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler_Win32_ddrio::PushInputState(std::uint32_t newInput)
|
void InputHandler_Win32_ddrio::PushInputState(uint32_t newInput)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 32; i++)
|
for (int i = 0; i < 32; i++)
|
||||||
{
|
{
|
||||||
@@ -337,9 +337,9 @@ bool InputHandler_Win32_ddrio::IsLightChange(LightsState prevLS, LightsState new
|
|||||||
|
|
||||||
void InputHandler_Win32_ddrio::PushLightState(LightsState newLS)
|
void InputHandler_Win32_ddrio::PushLightState(LightsState newLS)
|
||||||
{
|
{
|
||||||
std::uint32_t p3io = 0;
|
uint32_t p3io = 0;
|
||||||
std::uint32_t hdxs = 0;
|
uint32_t hdxs = 0;
|
||||||
std::uint32_t extio = 0;
|
uint32_t extio = 0;
|
||||||
|
|
||||||
//lighting state has already been verified to have changed in this method, so create the new one from scratch.
|
//lighting state has already been verified to have changed in this method, so create the new one from scratch.
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ private:
|
|||||||
static int InputThread_Start( void *p );
|
static int InputThread_Start( void *p );
|
||||||
void InputThreadMain();
|
void InputThreadMain();
|
||||||
|
|
||||||
void PushInputState(std::uint32_t newInput);
|
void PushInputState(uint32_t newInput);
|
||||||
|
|
||||||
bool IsLightChange(LightsState prevLS, LightsState newLS);
|
bool IsLightChange(LightsState prevLS, LightsState newLS);
|
||||||
void PushLightState(LightsState newLS);
|
void PushLightState(LightsState newLS);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ void LightsDriver_LinuxPacDrive::Set( const LightsState *ls )
|
|||||||
{
|
{
|
||||||
if ( !DeviceHandle ) return;
|
if ( !DeviceHandle ) return;
|
||||||
|
|
||||||
std::uint16_t outb = 0;
|
uint16_t outb = 0;
|
||||||
|
|
||||||
switch (iLightingOrder) {
|
switch (iLightingOrder) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -245,13 +245,13 @@ void LightsDriver_LinuxPacDrive::OpenDevice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightsDriver_LinuxPacDrive::WriteDevice(std::uint16_t out)
|
void LightsDriver_LinuxPacDrive::WriteDevice(uint16_t out)
|
||||||
{
|
{
|
||||||
if ( !DeviceHandle ) return;
|
if ( !DeviceHandle ) return;
|
||||||
|
|
||||||
// output is within the first 16 bits - accept a
|
// output is within the first 16 bits - accept a
|
||||||
// 16-bit arg and cast it, for simplicity's sake.
|
// 16-bit arg and cast it, for simplicity's sake.
|
||||||
std::uint32_t data = (out << 16);
|
uint32_t data = (out << 16);
|
||||||
int expected = sizeof(data);
|
int expected = sizeof(data);
|
||||||
|
|
||||||
int result = usb_control_msg( DeviceHandle, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
int result = usb_control_msg( DeviceHandle, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
|
|
||||||
void FindDevice();
|
void FindDevice();
|
||||||
void OpenDevice();
|
void OpenDevice();
|
||||||
void WriteDevice(std::uint16_t out);
|
void WriteDevice(uint16_t out);
|
||||||
void CloseDevice();
|
void CloseDevice();
|
||||||
|
|
||||||
struct usb_device *Device;
|
struct usb_device *Device;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
class LightsDriver_Linux_Leds : public LightsDriver
|
class LightsDriver_Linux_Leds : public LightsDriver
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const std::uint8_t LINUX_LED_STATE_ON = 255;
|
static const uint8_t LINUX_LED_STATE_ON = 255;
|
||||||
static const std::uint8_t LINUX_LED_STATE_OFF = 0;
|
static const uint8_t LINUX_LED_STATE_OFF = 0;
|
||||||
static const int LINUX_LED_MAX_DIRECTORY_LENGTH = PATH_MAX;
|
static const int LINUX_LED_MAX_DIRECTORY_LENGTH = PATH_MAX;
|
||||||
|
|
||||||
const InputScheme *pInput;
|
const InputScheme *pInput;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
REGISTER_LIGHTS_DRIVER_CLASS2(stac, Linux_stac);
|
REGISTER_LIGHTS_DRIVER_CLASS2(stac, Linux_stac);
|
||||||
|
|
||||||
StacDevice::StacDevice(std::uint8_t pn)
|
StacDevice::StacDevice(uint8_t pn)
|
||||||
{
|
{
|
||||||
memset(outputBuffer, 0x00, sizeof(outputBuffer));
|
memset(outputBuffer, 0x00, sizeof(outputBuffer));
|
||||||
|
|
||||||
@@ -177,11 +177,11 @@ void StacDevice::Close()
|
|||||||
void StacDevice::SetInBuffer(int index, bool lightState)
|
void StacDevice::SetInBuffer(int index, bool lightState)
|
||||||
{
|
{
|
||||||
//the first byte is the report ID, so we offset it here to adjust.
|
//the first byte is the report ID, so we offset it here to adjust.
|
||||||
std::uint8_t index_offset = index + 1;
|
uint8_t index_offset = index + 1;
|
||||||
|
|
||||||
//each index in the array represents a single light,
|
//each index in the array represents a single light,
|
||||||
//the light will turn on for any value that isn't 0x00
|
//the light will turn on for any value that isn't 0x00
|
||||||
std::uint8_t val = lightState ? 0xFF : 0x00;
|
uint8_t val = lightState ? 0xFF : 0x00;
|
||||||
|
|
||||||
//ensure the index is valid and the light value has changed.
|
//ensure the index is valid and the light value has changed.
|
||||||
if (index_offset < STAC_HIDREPORT_SIZE && outputBuffer[index_offset] != val)
|
if (index_offset < STAC_HIDREPORT_SIZE && outputBuffer[index_offset] != val)
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ public:
|
|||||||
const char *devicePath;
|
const char *devicePath;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
|
||||||
std::uint8_t playerNumber = 0;
|
uint8_t playerNumber = 0;
|
||||||
bool newState = false;
|
bool newState = false;
|
||||||
|
|
||||||
std::uint8_t outputBuffer[STAC_HIDREPORT_SIZE];
|
uint8_t outputBuffer[STAC_HIDREPORT_SIZE];
|
||||||
|
|
||||||
StacDevice(std::uint8_t pn);
|
StacDevice(uint8_t pn);
|
||||||
|
|
||||||
void FindDevice();
|
void FindDevice();
|
||||||
void Connect();
|
void Connect();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace
|
|||||||
class SextetImpl
|
class SextetImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::uint8_t lastOutput[FULL_SEXTET_COUNT];
|
uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||||
RageFile * out;
|
RageFile * out;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -41,7 +41,7 @@ namespace
|
|||||||
|
|
||||||
void Set(const LightsState * ls)
|
void Set(const LightsState * ls)
|
||||||
{
|
{
|
||||||
std::uint8_t buffer[FULL_SEXTET_COUNT];
|
uint8_t buffer[FULL_SEXTET_COUNT];
|
||||||
|
|
||||||
packLine(buffer, ls);
|
packLine(buffer, ls);
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ LightsDriver_Win32Serial::~LightsDriver_Win32Serial()
|
|||||||
void LightsDriver_Win32Serial::Set(const LightsState* ls)
|
void LightsDriver_Win32Serial::Set(const LightsState* ls)
|
||||||
{
|
{
|
||||||
if (serialPort != INVALID_HANDLE_VALUE) {
|
if (serialPort != INVALID_HANDLE_VALUE) {
|
||||||
std::uint8_t buffer[FULL_SEXTET_COUNT];
|
uint8_t buffer[FULL_SEXTET_COUNT];
|
||||||
|
|
||||||
packLine(buffer, ls);
|
packLine(buffer, ls);
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
class LightsDriver_Win32Serial : public LightsDriver
|
class LightsDriver_Win32Serial : public LightsDriver
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::uint8_t lastOutput[FULL_SEXTET_COUNT];
|
uint8_t lastOutput[FULL_SEXTET_COUNT];
|
||||||
public:
|
public:
|
||||||
LightsDriver_Win32Serial();
|
LightsDriver_Win32Serial();
|
||||||
virtual ~LightsDriver_Win32Serial();
|
virtual ~LightsDriver_Win32Serial();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ static const size_t FULL_SEXTET_COUNT = CABINET_SEXTET_COUNT + (NUM_GameControll
|
|||||||
// Encodes the low 6 bits of a byte as a printable, non-space ASCII
|
// Encodes the low 6 bits of a byte as a printable, non-space ASCII
|
||||||
// character (i.e., within the range 0x21-0x7E) such that the low 6 bits of
|
// character (i.e., within the range 0x21-0x7E) such that the low 6 bits of
|
||||||
// the character are the same as the input.
|
// the character are the same as the input.
|
||||||
inline std::uint8_t printableSextet(std::uint8_t data)
|
inline uint8_t printableSextet(uint8_t data)
|
||||||
{
|
{
|
||||||
// Maps the 6-bit value into the range 0x30-0x6F, wrapped in such a way
|
// Maps the 6-bit value into the range 0x30-0x6F, wrapped in such a way
|
||||||
// that the low 6 bits of the result are the same as the data (so
|
// that the low 6 bits of the result are the same as the data (so
|
||||||
@@ -38,13 +38,13 @@ inline std::uint8_t printableSextet(std::uint8_t data)
|
|||||||
// the top two bits T of the input like so:
|
// the top two bits T of the input like so:
|
||||||
// H = ((T + 1) mod 4) + 3
|
// H = ((T + 1) mod 4) + 3
|
||||||
|
|
||||||
return ((data + (std::uint8_t)0x10) & (std::uint8_t)0x3F) + (std::uint8_t)0x30;
|
return ((data + (uint8_t)0x10) & (uint8_t)0x3F) + (uint8_t)0x30;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packs 6 booleans into a 6-bit value
|
// Packs 6 booleans into a 6-bit value
|
||||||
inline std::uint8_t packPlainSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
inline uint8_t packPlainSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
||||||
{
|
{
|
||||||
return (std::uint8_t)(
|
return (uint8_t)(
|
||||||
(b0 ? 0x01 : 0) |
|
(b0 ? 0x01 : 0) |
|
||||||
(b1 ? 0x02 : 0) |
|
(b1 ? 0x02 : 0) |
|
||||||
(b2 ? 0x04 : 0) |
|
(b2 ? 0x04 : 0) |
|
||||||
@@ -54,13 +54,13 @@ inline std::uint8_t packPlainSextet(bool b0, bool b1, bool b2, bool b3, bool b4,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Packs 6 booleans into a printable sextet
|
// Packs 6 booleans into a printable sextet
|
||||||
inline std::uint8_t packPrintableSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
inline uint8_t packPrintableSextet(bool b0, bool b1, bool b2, bool b3, bool b4, bool b5)
|
||||||
{
|
{
|
||||||
return printableSextet(packPlainSextet(b0, b1, b2, b3, b4, b5));
|
return printableSextet(packPlainSextet(b0, b1, b2, b3, b4, b5));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Packs the cabinet lights into a printable sextet and adds it to a buffer
|
// Packs the cabinet lights into a printable sextet and adds it to a buffer
|
||||||
inline size_t packCabinetLights(const LightsState* ls, std::uint8_t* buffer)
|
inline size_t packCabinetLights(const LightsState* ls, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
buffer[0] = packPrintableSextet(
|
buffer[0] = packPrintableSextet(
|
||||||
ls->m_bCabinetLights[LIGHT_MARQUEE_UP_LEFT],
|
ls->m_bCabinetLights[LIGHT_MARQUEE_UP_LEFT],
|
||||||
@@ -74,7 +74,7 @@ inline size_t packCabinetLights(const LightsState* ls, std::uint8_t* buffer)
|
|||||||
|
|
||||||
// Packs the button lights for a controller into 6 printable sextets and
|
// Packs the button lights for a controller into 6 printable sextets and
|
||||||
// adds them to a buffer
|
// adds them to a buffer
|
||||||
inline size_t packControllerLights(const LightsState* ls, GameController gc, std::uint8_t* buffer)
|
inline size_t packControllerLights(const LightsState* ls, GameController gc, uint8_t* buffer)
|
||||||
{
|
{
|
||||||
// Menu buttons
|
// Menu buttons
|
||||||
buffer[0] = packPrintableSextet(
|
buffer[0] = packPrintableSextet(
|
||||||
@@ -127,7 +127,7 @@ inline size_t packControllerLights(const LightsState* ls, GameController gc, std
|
|||||||
return CONTROLLER_SEXTET_COUNT;
|
return CONTROLLER_SEXTET_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline size_t packLine(std::uint8_t* buffer, const LightsState* ls)
|
inline size_t packLine(uint8_t* buffer, const LightsState* ls)
|
||||||
{
|
{
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void LoadingWindow_Gtk::SetText( RString s )
|
|||||||
|
|
||||||
static void DeletePixels( guchar *pixels, gpointer data )
|
static void DeletePixels( guchar *pixels, gpointer data )
|
||||||
{
|
{
|
||||||
delete[] (std::uint8_t *)pixels;
|
delete[] (uint8_t *)pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
|
static GdkPixbuf *MakePixbuf( const RageSurface *pSrc )
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <objc/objc.h>
|
#include <objc/objc.h>
|
||||||
|
|
||||||
typedef const struct __CFDictionary *CFDictionaryRef;
|
typedef const struct __CFDictionary *CFDictionaryRef;
|
||||||
typedef std::uint32_t CGDirectDisplayID;
|
typedef uint32_t CGDirectDisplayID;
|
||||||
|
|
||||||
class LowLevelWindow_MacOSX : public LowLevelWindow
|
class LowLevelWindow_MacOSX : public LowLevelWindow
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ public:
|
|||||||
RenderTarget_MacOSX( id shareContext );
|
RenderTarget_MacOSX( id shareContext );
|
||||||
~RenderTarget_MacOSX();
|
~RenderTarget_MacOSX();
|
||||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||||
std::uintptr_t GetTexture() const { return static_cast<std::uintptr_t>(m_iTexHandle); }
|
uintptr_t GetTexture() const { return static_cast<uintptr_t>(m_iTexHandle); }
|
||||||
void StartRenderingTo();
|
void StartRenderingTo();
|
||||||
void FinishRenderingTo();
|
void FinishRenderingTo();
|
||||||
|
|
||||||
@@ -326,11 +326,11 @@ void *LowLevelWindow_MacOSX::GetProcAddress( RString s )
|
|||||||
// http://developer.apple.com/qa/qa2001/qa1188.html
|
// http://developer.apple.com/qa/qa2001/qa1188.html
|
||||||
// Both functions mentioned in there are deprecated in 10.4.
|
// Both functions mentioned in there are deprecated in 10.4.
|
||||||
const RString& symbolName( '_' + s );
|
const RString& symbolName( '_' + s );
|
||||||
const std::uint32_t count = _dyld_image_count();
|
const uint32_t count = _dyld_image_count();
|
||||||
NSSymbol symbol = nil;
|
NSSymbol symbol = nil;
|
||||||
const std::uint32_t options = NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR;
|
const uint32_t options = NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR;
|
||||||
|
|
||||||
for( std::uint32_t i = 0; i < count && !symbol; ++i )
|
for( uint32_t i = 0; i < count && !symbol; ++i )
|
||||||
symbol = NSLookupSymbolInImage( _dyld_get_image_header(i), symbolName, options );
|
symbol = NSLookupSymbolInImage( _dyld_get_image_header(i), symbolName, options );
|
||||||
return symbol ? NSAddressOfSymbol( symbol ) : nil;
|
return symbol ? NSAddressOfSymbol( symbol ) : nil;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ public:
|
|||||||
virtual ~RenderTarget_Win32();
|
virtual ~RenderTarget_Win32();
|
||||||
|
|
||||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||||
std::uintptr_t GetTexture() const { return static_cast<std::uintptr_t>(m_texHandle); }
|
uintptr_t GetTexture() const { return static_cast<uintptr_t>(m_texHandle); }
|
||||||
void StartRenderingTo();
|
void StartRenderingTo();
|
||||||
void FinishRenderingTo();
|
void FinishRenderingTo();
|
||||||
|
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
// If an output name has been specified, search for it
|
// If an output name has been specified, search for it
|
||||||
RROutput targetOut = None;
|
RROutput targetOut = None;
|
||||||
if (p.sDisplayId.length() > 0) {
|
if (p.sDisplayId.length() > 0) {
|
||||||
for (unsigned int i = 0; i < static_cast<std::uint32_t>(scrRes->noutput) && targetOut == None; ++i) {
|
for (unsigned int i = 0; i < static_cast<uint32_t>(scrRes->noutput) && targetOut == None; ++i) {
|
||||||
XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]);
|
XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]);
|
||||||
std::string outName = std::string(outInfo->name, static_cast<unsigned int> (outInfo->nameLen));
|
std::string outName = std::string(outInfo->name, static_cast<unsigned int> (outInfo->nameLen));
|
||||||
if (p.sDisplayId == outName) {
|
if (p.sDisplayId == outName) {
|
||||||
@@ -341,7 +341,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
// (it is possible the connection state could be unknown), we'll at least
|
// (it is possible the connection state could be unknown), we'll at least
|
||||||
// look for an output with a CRTC driving it
|
// look for an output with a CRTC driving it
|
||||||
RROutput connected = None, hasCrtc = None;
|
RROutput connected = None, hasCrtc = None;
|
||||||
for (unsigned int i = 0; i < static_cast<std::uint32_t>(scrRes->noutput); ++i) {
|
for (unsigned int i = 0; i < static_cast<uint32_t>(scrRes->noutput); ++i) {
|
||||||
XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]);
|
XRROutputInfo *outInfo = XRRGetOutputInfo(Dpy, scrRes, scrRes->outputs[i]);
|
||||||
if (outInfo->connection == RR_Connected) { // Check for CONNECTED state: Connected == 0
|
if (outInfo->connection == RR_Connected) { // Check for CONNECTED state: Connected == 0
|
||||||
connected = scrRes->outputs[i];
|
connected = scrRes->outputs[i];
|
||||||
@@ -368,7 +368,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
RRCrtc tgtOutCrtc = tgtOutInfo->crtc;
|
RRCrtc tgtOutCrtc = tgtOutInfo->crtc;
|
||||||
if (tgtOutCrtc == None)
|
if (tgtOutCrtc == None)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < static_cast<std::uint32_t>(tgtOutInfo->ncrtc); ++i)
|
for (unsigned int i = 0; i < static_cast<uint32_t>(tgtOutInfo->ncrtc); ++i)
|
||||||
{
|
{
|
||||||
XRRCrtcInfo *crtcInfo = XRRGetCrtcInfo( Dpy, scrRes, tgtOutInfo->crtcs[i] );
|
XRRCrtcInfo *crtcInfo = XRRGetCrtcInfo( Dpy, scrRes, tgtOutInfo->crtcs[i] );
|
||||||
if (crtcInfo->mode == None)
|
if (crtcInfo->mode == None)
|
||||||
@@ -396,7 +396,7 @@ RString LowLevelWindow_X11::TryVideoMode( const VideoModeParams &p, bool &bNewDe
|
|||||||
const XRRModeInfo &thisMI = scrRes->modes[i];
|
const XRRModeInfo &thisMI = scrRes->modes[i];
|
||||||
const unsigned int modeWidth = bPortrait ? thisMI.height : thisMI.width;
|
const unsigned int modeWidth = bPortrait ? thisMI.height : thisMI.width;
|
||||||
const unsigned int modeHeight = bPortrait ? thisMI.width : thisMI.height;
|
const unsigned int modeHeight = bPortrait ? thisMI.width : thisMI.height;
|
||||||
if (p.width >= 0 && p.height >= 0 && modeWidth == static_cast<std::uint32_t>(p.width) && modeHeight == static_cast<std::uint32_t>(p.height)) {
|
if (p.width >= 0 && p.height >= 0 && modeWidth == static_cast<uint32_t>(p.width) && modeHeight == static_cast<uint32_t>(p.height)) {
|
||||||
float fTempRefresh = calcRandRRefresh(thisMI.dotClock, thisMI.hTotal, thisMI.vTotal);
|
float fTempRefresh = calcRandRRefresh(thisMI.dotClock, thisMI.hTotal, thisMI.vTotal);
|
||||||
float fTempDiff = std::abs(p.rate - fTempRefresh);
|
float fTempDiff = std::abs(p.rate - fTempRefresh);
|
||||||
if ((p.rate != REFRESH_DEFAULT && fTempDiff < fRefreshDiff) ||
|
if ((p.rate != REFRESH_DEFAULT && fTempDiff < fRefreshDiff) ||
|
||||||
@@ -670,11 +670,11 @@ void LowLevelWindow_X11::GetDisplaySpecs(DisplaySpecs &out) const {
|
|||||||
int nsizes = 0;
|
int nsizes = 0;
|
||||||
XRRScreenSize *screenSizes = XRRSizes( Dpy, screenNum, &nsizes);
|
XRRScreenSize *screenSizes = XRRSizes( Dpy, screenNum, &nsizes);
|
||||||
DisplayMode screenCurMode{};
|
DisplayMode screenCurMode{};
|
||||||
for (unsigned int szIdx = 0, mode_idx = 0; nsizes >= 0 && szIdx < static_cast<std::uint32_t>(nsizes); ++szIdx) {
|
for (unsigned int szIdx = 0, mode_idx = 0; nsizes >= 0 && szIdx < static_cast<uint32_t>(nsizes); ++szIdx) {
|
||||||
XRRScreenSize &size = screenSizes[szIdx];
|
XRRScreenSize &size = screenSizes[szIdx];
|
||||||
int nrates = 0;
|
int nrates = 0;
|
||||||
short *rates = XRRRates(Dpy, screenNum, szIdx, &nrates);
|
short *rates = XRRRates(Dpy, screenNum, szIdx, &nrates);
|
||||||
for (unsigned int rIdx = 0; nrates >=0 && rIdx < static_cast<std::uint32_t>(nrates); ++rIdx, ++mode_idx) {
|
for (unsigned int rIdx = 0; nrates >=0 && rIdx < static_cast<uint32_t>(nrates); ++rIdx, ++mode_idx) {
|
||||||
DisplayMode m = {static_cast<unsigned int> (size.width), static_cast<unsigned int> (size.height), static_cast<double> (rates[rIdx])};
|
DisplayMode m = {static_cast<unsigned int> (size.width), static_cast<unsigned int> (size.height), static_cast<double> (rates[rIdx])};
|
||||||
screenModes.insert(m);
|
screenModes.insert(m);
|
||||||
if (rates[rIdx] == curRate && szIdx == curSizeId) {
|
if (rates[rIdx] == curRate && szIdx == curSizeId) {
|
||||||
@@ -704,7 +704,7 @@ void LowLevelWindow_X11::GetDisplaySpecs(DisplaySpecs &out) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now, for each output, build a corresponding DisplaySpec
|
// Now, for each output, build a corresponding DisplaySpec
|
||||||
for (unsigned int outIdx = 0; outIdx < static_cast<std::uint32_t>(scrRes->noutput); ++outIdx)
|
for (unsigned int outIdx = 0; outIdx < static_cast<uint32_t>(scrRes->noutput); ++outIdx)
|
||||||
{
|
{
|
||||||
XRROutputInfo *outInfo = XRRGetOutputInfo( Dpy, scrRes, scrRes->outputs[outIdx] );
|
XRROutputInfo *outInfo = XRRGetOutputInfo( Dpy, scrRes, scrRes->outputs[outIdx] );
|
||||||
if (outInfo->nmode > 0)
|
if (outInfo->nmode > 0)
|
||||||
@@ -727,7 +727,7 @@ void LowLevelWindow_X11::GetDisplaySpecs(DisplaySpecs &out) const {
|
|||||||
std::set<DisplayMode> outputSupported;
|
std::set<DisplayMode> outputSupported;
|
||||||
DisplayMode outputCurMode{};
|
DisplayMode outputCurMode{};
|
||||||
RectI outBounds;
|
RectI outBounds;
|
||||||
for (unsigned int modeIdx = 0; modeIdx < static_cast<std::uint32_t>(outInfo->nmode); ++modeIdx)
|
for (unsigned int modeIdx = 0; modeIdx < static_cast<uint32_t>(outInfo->nmode); ++modeIdx)
|
||||||
{
|
{
|
||||||
DisplayMode mode = outputModes[outInfo->modes[modeIdx]];
|
DisplayMode mode = outputModes[outInfo->modes[modeIdx]];
|
||||||
unsigned int modeWidth = bPortrait ? mode.height : mode.width;
|
unsigned int modeWidth = bPortrait ? mode.height : mode.width;
|
||||||
@@ -768,7 +768,7 @@ public:
|
|||||||
~RenderTarget_X11();
|
~RenderTarget_X11();
|
||||||
|
|
||||||
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
void Create( const RenderTargetParam ¶m, int &iTextureWidthOut, int &iTextureHeightOut );
|
||||||
std::uintptr_t GetTexture() const { return static_cast<std::uintptr_t>(m_iTexHandle); }
|
uintptr_t GetTexture() const { return static_cast<uintptr_t>(m_iTexHandle); }
|
||||||
void StartRenderingTo();
|
void StartRenderingTo();
|
||||||
void FinishRenderingTo();
|
void FinishRenderingTo();
|
||||||
|
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ void MemoryCardDriverThreaded_MacOSX::GetUSBStorageDevices( std::vector<UsbStora
|
|||||||
|
|
||||||
LOG->Trace( "Found memory card at path: %s.", fs[i].f_mntonname );
|
LOG->Trace( "Found memory card at path: %s.", fs[i].f_mntonname );
|
||||||
usbd.SetOsMountDir( fs[i].f_mntonname );
|
usbd.SetOsMountDir( fs[i].f_mntonname );
|
||||||
usbd.iVolumeSizeMB = int( (std::uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20 );
|
usbd.iVolumeSizeMB = int( (uint64_t(fs[i].f_blocks) * fs[i].f_bsize) >> 20 );
|
||||||
|
|
||||||
// Now we can get some more information from the registry tree.
|
// Now we can get some more information from the registry tree.
|
||||||
usbd.iBus = GetIntProperty( device, CFSTR("USB Address") );
|
usbd.iBus = GetIntProperty( device, CFSTR("USB Address") );
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ static RString averr_ssprintf(int err, const char* fmt, ...)
|
|||||||
return s + " (" + Error + ")";
|
return s + " (" + Error + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
static int AVIORageFile_ReadPacket(void* opaque, std::uint8_t* buf, int buf_size)
|
static int AVIORageFile_ReadPacket(void* opaque, uint8_t* buf, int buf_size)
|
||||||
{
|
{
|
||||||
RageFile* f = (RageFile*)opaque;
|
RageFile* f = (RageFile*)opaque;
|
||||||
int n = f->Read(buf, buf_size);
|
int n = f->Read(buf, buf_size);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ private:
|
|||||||
static struct AVPixelFormat_t
|
static struct AVPixelFormat_t
|
||||||
{
|
{
|
||||||
int bpp;
|
int bpp;
|
||||||
std::uint32_t masks[4];
|
uint32_t masks[4];
|
||||||
avcodec::AVPixelFormat pf;
|
avcodec::AVPixelFormat pf;
|
||||||
bool bHighColor;
|
bool bHighColor;
|
||||||
bool bByteSwapOnLittleEndian;
|
bool bByteSwapOnLittleEndian;
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public:
|
|||||||
|
|
||||||
virtual void Invalidate() { m_uTexHandle = 0; }
|
virtual void Invalidate() { m_uTexHandle = 0; }
|
||||||
virtual void Reload() { }
|
virtual void Reload() { }
|
||||||
virtual std::uintptr_t GetTexHandle() const
|
virtual uintptr_t GetTexHandle() const
|
||||||
{
|
{
|
||||||
return m_uTexHandle;
|
return m_uTexHandle;
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ private:
|
|||||||
delete pSurface;
|
delete pSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uintptr_t m_uTexHandle;
|
uintptr_t m_uTexHandle;
|
||||||
RageSurfaceFormat m_SurfaceFormat;
|
RageSurfaceFormat m_SurfaceFormat;
|
||||||
RagePixelFormat m_PixFmt;
|
RagePixelFormat m_PixFmt;
|
||||||
};
|
};
|
||||||
@@ -339,7 +339,7 @@ void MovieTexture_Generic::UpdateFrame()
|
|||||||
|
|
||||||
if(m_pTextureLock != nullptr)
|
if(m_pTextureLock != nullptr)
|
||||||
{
|
{
|
||||||
std::uintptr_t iHandle = m_pTextureIntermediate != nullptr ? m_pTextureIntermediate->GetTexHandle(): this->GetTexHandle();
|
uintptr_t iHandle = m_pTextureIntermediate != nullptr ? m_pTextureIntermediate->GetTexHandle(): this->GetTexHandle();
|
||||||
m_pTextureLock->Lock(iHandle, m_pSurface);
|
m_pTextureLock->Lock(iHandle, m_pSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ void MovieTexture_Generic::SetPosition(float fSeconds)
|
|||||||
m_pDecoder->Rewind();
|
m_pDecoder->Rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uintptr_t MovieTexture_Generic::GetTexHandle() const
|
uintptr_t MovieTexture_Generic::GetTexHandle() const
|
||||||
{
|
{
|
||||||
if( m_pRenderTarget != nullptr )
|
if( m_pRenderTarget != nullptr )
|
||||||
return m_pRenderTarget->GetTexHandle();
|
return m_pRenderTarget->GetTexHandle();
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
virtual void UpdateMovie( float fSeconds );
|
virtual void UpdateMovie( float fSeconds );
|
||||||
virtual void SetPlaybackRate( float fRate ) { m_fRate = fRate; }
|
virtual void SetPlaybackRate( float fRate ) { m_fRate = fRate; }
|
||||||
void SetLooping( bool bLooping=true ) { m_bLoop = bLooping; }
|
void SetLooping( bool bLooping=true ) { m_bLoop = bLooping; }
|
||||||
std::uintptr_t GetTexHandle() const;
|
uintptr_t GetTexHandle() const;
|
||||||
|
|
||||||
static EffectMode GetEffectMode( MovieDecoderPixelFormatYCbCr fmt );
|
static EffectMode GetEffectMode( MovieDecoderPixelFormatYCbCr fmt );
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ private:
|
|||||||
// If true, halts all decoding and display.
|
// If true, halts all decoding and display.
|
||||||
bool m_failure = false;
|
bool m_failure = false;
|
||||||
|
|
||||||
std::uintptr_t m_uTexHandle;
|
uintptr_t m_uTexHandle;
|
||||||
RageTextureRenderTarget *m_pRenderTarget;
|
RageTextureRenderTarget *m_pRenderTarget;
|
||||||
RageTexture *m_pTextureIntermediate;
|
RageTexture *m_pTextureIntermediate;
|
||||||
Sprite *m_pSprite;
|
Sprite *m_pSprite;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
MovieTexture_Null(RageTextureID ID);
|
MovieTexture_Null(RageTextureID ID);
|
||||||
virtual ~MovieTexture_Null();
|
virtual ~MovieTexture_Null();
|
||||||
void Invalidate() { texHandle = 0; }
|
void Invalidate() { texHandle = 0; }
|
||||||
std::uintptr_t GetTexHandle() const { return texHandle; }
|
uintptr_t GetTexHandle() const { return texHandle; }
|
||||||
void Update(float /* delta */) { }
|
void Update(float /* delta */) { }
|
||||||
void Reload() { }
|
void Reload() { }
|
||||||
void SetPosition(float /* seconds */) { }
|
void SetPosition(float /* seconds */) { }
|
||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool playing;
|
bool playing;
|
||||||
bool loop;
|
bool loop;
|
||||||
std::uintptr_t texHandle;
|
uintptr_t texHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
|
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
|
||||||
|
|||||||
@@ -519,14 +519,14 @@ std::int64_t RageSoundDriver::GetHardwareFrame( RageTimer *pTimestamp=nullptr )
|
|||||||
*/
|
*/
|
||||||
int iTries = 3;
|
int iTries = 3;
|
||||||
std::int64_t iPositionFrames;
|
std::int64_t iPositionFrames;
|
||||||
std::uint64_t iStartTime;
|
uint64_t iStartTime;
|
||||||
const std::uint64_t iThreshold = 2000ULL;
|
const uint64_t iThreshold = 2000ULL;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
iStartTime = RageTimer::GetTimeSinceStartMicroseconds();
|
iStartTime = RageTimer::GetTimeSinceStartMicroseconds();
|
||||||
iPositionFrames = GetPosition();
|
iPositionFrames = GetPosition();
|
||||||
std::uint64_t elapsedTime = RageTimer::GetTimeSinceStartMicroseconds() - iStartTime;
|
uint64_t elapsedTime = RageTimer::GetTimeSinceStartMicroseconds() - iStartTime;
|
||||||
if (elapsedTime <= iThreshold) break;
|
if (elapsedTime <= iThreshold) break;
|
||||||
} while (--iTries);
|
} while (--iTries);
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
*
|
*
|
||||||
* "The server tries to assure that at least tlength bytes are always
|
* "The server tries to assure that at least tlength bytes are always
|
||||||
* available in the per-stream server-side playback buffer. It is
|
* available in the per-stream server-side playback buffer. It is
|
||||||
* recommended to set this to (std::uint32_t) -1, which will initialize
|
* recommended to set this to (uint32_t) -1, which will initialize
|
||||||
* this to a value that is deemed sensible by the server. However,
|
* this to a value that is deemed sensible by the server. However,
|
||||||
* this value will default to something like 2s, i.e. for applications
|
* this value will default to something like 2s, i.e. for applications
|
||||||
* that have specific latency requirements this value should be set to
|
* that have specific latency requirements this value should be set to
|
||||||
@@ -197,10 +197,10 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
|
|
||||||
/* maxlength: Maximum length of the buffer
|
/* maxlength: Maximum length of the buffer
|
||||||
*
|
*
|
||||||
* "Setting this to (std::uint32_t) -1 will initialize this to the maximum
|
* "Setting this to (uint32_t) -1 will initialize this to the maximum
|
||||||
* value supported by server, which is recommended."
|
* value supported by server, which is recommended."
|
||||||
*
|
*
|
||||||
* (std::uint32_t)-1 is NOT working here, setting it to tlength*2, like
|
* (uint32_t)-1 is NOT working here, setting it to tlength*2, like
|
||||||
* openal-soft-pulseaudio does.
|
* openal-soft-pulseaudio does.
|
||||||
*/
|
*/
|
||||||
attr.maxlength = attr.tlength*2;
|
attr.maxlength = attr.tlength*2;
|
||||||
@@ -209,10 +209,10 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
*
|
*
|
||||||
* "The server does not request less than minreq bytes from the client,
|
* "The server does not request less than minreq bytes from the client,
|
||||||
* instead waits until the buffer is free enough to request more bytes
|
* instead waits until the buffer is free enough to request more bytes
|
||||||
* at once. It is recommended to set this to (std::uint32_t) -1, which will
|
* at once. It is recommended to set this to (uint32_t) -1, which will
|
||||||
* initialize this to a value that is deemed sensible by the server."
|
* initialize this to a value that is deemed sensible by the server."
|
||||||
*
|
*
|
||||||
* (std::uint32_t)-1 is NOT working here, setting it to 0, like
|
* (uint32_t)-1 is NOT working here, setting it to 0, like
|
||||||
* openal-soft-pulseaudio does.
|
* openal-soft-pulseaudio does.
|
||||||
*/
|
*/
|
||||||
attr.minreq = 0;
|
attr.minreq = 0;
|
||||||
@@ -221,10 +221,10 @@ void RageSoundDriver_PulseAudio::m_InitStream(void)
|
|||||||
*
|
*
|
||||||
* "The server does not start with playback before at least prebuf
|
* "The server does not start with playback before at least prebuf
|
||||||
* bytes are available in the buffer. It is recommended to set this
|
* bytes are available in the buffer. It is recommended to set this
|
||||||
* to (std::uint32_t) -1, which will initialize this to the same value as
|
* to (uint32_t) -1, which will initialize this to the same value as
|
||||||
* tlength"
|
* tlength"
|
||||||
*/
|
*/
|
||||||
attr.prebuf = (std::uint32_t)-1;
|
attr.prebuf = (uint32_t)-1;
|
||||||
|
|
||||||
/* log the used target buffer length */
|
/* log the used target buffer length */
|
||||||
LOG->Trace("Pulse: using target buffer length of %i bytes", attr.tlength);
|
LOG->Trace("Pulse: using target buffer length of %i bytes", attr.tlength);
|
||||||
|
|||||||
@@ -1142,7 +1142,7 @@ void RageSoundDriver_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos,
|
|||||||
|
|
||||||
bool RageSoundDriver_WDMKS::Fill( int iPacket, RString &sError )
|
bool RageSoundDriver_WDMKS::Fill( int iPacket, RString &sError )
|
||||||
{
|
{
|
||||||
std::uint64_t iCurrentFrame = GetPosition();
|
uint64_t iCurrentFrame = GetPosition();
|
||||||
// if( iCurrentFrame == m_iLastCursorPos )
|
// if( iCurrentFrame == m_iLastCursorPos )
|
||||||
// LOG->Trace( "underrun" );
|
// LOG->Trace( "underrun" );
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
* implementation-defined, except that each thread has exactly one ID
|
* implementation-defined, except that each thread has exactly one ID
|
||||||
* and each ID corresponds to one thread. (This means that Win32
|
* and each ID corresponds to one thread. (This means that Win32
|
||||||
* thread handles are not acceptable as ThreadIds.) */
|
* thread handles are not acceptable as ThreadIds.) */
|
||||||
virtual std::uint64_t GetThreadId() const = 0;
|
virtual uint64_t GetThreadId() const = 0;
|
||||||
|
|
||||||
virtual int Wait() = 0;
|
virtual int Wait() = 0;
|
||||||
};
|
};
|
||||||
@@ -71,16 +71,16 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// These functions must be implemented by the thread implementation.
|
// These functions must be implemented by the thread implementation.
|
||||||
ThreadImpl *MakeThread( int (*fn)(void *), void *data, std::uint64_t *piThreadID );
|
ThreadImpl *MakeThread( int (*fn)(void *), void *data, uint64_t *piThreadID );
|
||||||
ThreadImpl *MakeThisThread();
|
ThreadImpl *MakeThisThread();
|
||||||
MutexImpl *MakeMutex( RageMutex *pParent );
|
MutexImpl *MakeMutex( RageMutex *pParent );
|
||||||
EventImpl *MakeEvent( MutexImpl *pMutex );
|
EventImpl *MakeEvent( MutexImpl *pMutex );
|
||||||
SemaImpl *MakeSemaphore( int iInitialValue );
|
SemaImpl *MakeSemaphore( int iInitialValue );
|
||||||
std::uint64_t GetThisThreadId();
|
uint64_t GetThisThreadId();
|
||||||
|
|
||||||
/* Since ThreadId is implementation-defined, we can't define a universal
|
/* Since ThreadId is implementation-defined, we can't define a universal
|
||||||
* invalid value. Return the invalid value for this implementation. */
|
* invalid value. Return the invalid value for this implementation. */
|
||||||
std::uint64_t GetInvalidThreadId();
|
uint64_t GetInvalidThreadId();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void ThreadImpl_Pthreads::Resume()
|
|||||||
ResumeThread( threadHandle );
|
ResumeThread( threadHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t ThreadImpl_Pthreads::GetThreadId() const
|
uint64_t ThreadImpl_Pthreads::GetThreadId() const
|
||||||
{
|
{
|
||||||
return threadHandle;
|
return threadHandle;
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ static void *StartThread( void *pData )
|
|||||||
return new int(iRet);
|
return new int(iRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, std::uint64_t *piThreadID )
|
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThreadID )
|
||||||
{
|
{
|
||||||
ThreadImpl_Pthreads *thread = new ThreadImpl_Pthreads;
|
ThreadImpl_Pthreads *thread = new ThreadImpl_Pthreads;
|
||||||
thread->m_pFunc = pFunc;
|
thread->m_pFunc = pFunc;
|
||||||
@@ -227,12 +227,12 @@ void MutexImpl_Pthreads::Unlock()
|
|||||||
pthread_mutex_unlock( &mutex );
|
pthread_mutex_unlock( &mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetThisThreadId()
|
uint64_t GetThisThreadId()
|
||||||
{
|
{
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetInvalidThreadId()
|
uint64_t GetInvalidThreadId()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,17 +18,17 @@ public:
|
|||||||
* Keep a list of child PIDs, so we can send them SIGKILL. This has
|
* Keep a list of child PIDs, so we can send them SIGKILL. This has
|
||||||
* an added bonus: if this is corrupted, we'll just send signals and
|
* an added bonus: if this is corrupted, we'll just send signals and
|
||||||
* they'll fail; we won't blow up (unless we're root). */
|
* they'll fail; we won't blow up (unless we're root). */
|
||||||
std::uint64_t threadHandle;
|
uint64_t threadHandle;
|
||||||
|
|
||||||
// These are only used during initialization.
|
// These are only used during initialization.
|
||||||
int (*m_pFunc)( void *pData );
|
int (*m_pFunc)( void *pData );
|
||||||
void *m_pData;
|
void *m_pData;
|
||||||
std::uint64_t *m_piThreadID;
|
uint64_t *m_piThreadID;
|
||||||
SemaImpl *m_StartFinishedSem;
|
SemaImpl *m_StartFinishedSem;
|
||||||
|
|
||||||
void Halt( bool Kill );
|
void Halt( bool Kill );
|
||||||
void Resume();
|
void Resume();
|
||||||
std::uint64_t GetThreadId() const;
|
uint64_t GetThreadId() const;
|
||||||
int Wait();
|
int Wait();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ static void InitThreadIdMutex()
|
|||||||
g_pThreadIdMutex = new MutexImpl_Win32(nullptr);
|
g_pThreadIdMutex = new MutexImpl_Win32(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::uint64_t g_ThreadIds[MAX_THREADS];
|
static uint64_t g_ThreadIds[MAX_THREADS];
|
||||||
static HANDLE g_ThreadHandles[MAX_THREADS];
|
static HANDLE g_ThreadHandles[MAX_THREADS];
|
||||||
|
|
||||||
HANDLE Win32ThreadIdToHandle( std::uint64_t iID )
|
HANDLE Win32ThreadIdToHandle( uint64_t iID )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < MAX_THREADS; ++i )
|
for( int i = 0; i < MAX_THREADS; ++i )
|
||||||
{
|
{
|
||||||
@@ -44,9 +44,9 @@ void ThreadImpl_Win32::Resume()
|
|||||||
ResumeThread( ThreadHandle );
|
ResumeThread( ThreadHandle );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t ThreadImpl_Win32::GetThreadId() const
|
uint64_t ThreadImpl_Win32::GetThreadId() const
|
||||||
{
|
{
|
||||||
return (std::uint64_t) ThreadId;
|
return (uint64_t) ThreadId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ThreadImpl_Win32::Wait()
|
int ThreadImpl_Win32::Wait()
|
||||||
@@ -112,7 +112,7 @@ static DWORD WINAPI StartThread( LPVOID pData )
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetOpenSlot( std::uint64_t iID )
|
static int GetOpenSlot( uint64_t iID )
|
||||||
{
|
{
|
||||||
InitThreadIdMutex();
|
InitThreadIdMutex();
|
||||||
|
|
||||||
@@ -157,14 +157,14 @@ ThreadImpl *MakeThisThread()
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, std::uint64_t *piThreadID )
|
ThreadImpl *MakeThread( int (*pFunc)(void *pData), void *pData, uint64_t *piThreadID )
|
||||||
{
|
{
|
||||||
ThreadImpl_Win32 *thread = new ThreadImpl_Win32;
|
ThreadImpl_Win32 *thread = new ThreadImpl_Win32;
|
||||||
thread->m_pFunc = pFunc;
|
thread->m_pFunc = pFunc;
|
||||||
thread->m_pData = pData;
|
thread->m_pData = pData;
|
||||||
|
|
||||||
thread->ThreadHandle = CreateThread( nullptr, 0, &StartThread, thread, CREATE_SUSPENDED, &thread->ThreadId );
|
thread->ThreadHandle = CreateThread( nullptr, 0, &StartThread, thread, CREATE_SUSPENDED, &thread->ThreadId );
|
||||||
*piThreadID = (std::uint64_t) thread->ThreadId;
|
*piThreadID = (uint64_t) thread->ThreadId;
|
||||||
ASSERT_M( thread->ThreadHandle != nullptr, ssprintf("%s", werr_ssprintf(GetLastError(), "CreateThread").c_str() ) );
|
ASSERT_M( thread->ThreadHandle != nullptr, ssprintf("%s", werr_ssprintf(GetLastError(), "CreateThread").c_str() ) );
|
||||||
|
|
||||||
int slot = GetOpenSlot( thread->ThreadId );
|
int slot = GetOpenSlot( thread->ThreadId );
|
||||||
@@ -248,12 +248,12 @@ void MutexImpl_Win32::Unlock()
|
|||||||
sm_crash( werr_ssprintf( GetLastError(), "ReleaseMutex failed" ) );
|
sm_crash( werr_ssprintf( GetLastError(), "ReleaseMutex failed" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetThisThreadId()
|
uint64_t GetThisThreadId()
|
||||||
{
|
{
|
||||||
return GetCurrentThreadId();
|
return GetCurrentThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetInvalidThreadId()
|
uint64_t GetInvalidThreadId()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ public:
|
|||||||
|
|
||||||
void Halt( bool Kill );
|
void Halt( bool Kill );
|
||||||
void Resume();
|
void Resume();
|
||||||
std::uint64_t GetThreadId() const;
|
uint64_t GetThreadId() const;
|
||||||
int Wait();
|
int Wait();
|
||||||
};
|
};
|
||||||
|
|
||||||
HANDLE Win32ThreadIdToHandle( std::uint64_t iID );
|
HANDLE Win32ThreadIdToHandle( uint64_t iID );
|
||||||
|
|
||||||
class MutexImpl_Win32: public MutexImpl
|
class MutexImpl_Win32: public MutexImpl
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ static int PtraceDetach( int ThreadID )
|
|||||||
|
|
||||||
|
|
||||||
/* Get this thread's ID (this may be a TID or a PID). */
|
/* Get this thread's ID (this may be a TID or a PID). */
|
||||||
static std::uint64_t GetCurrentThreadIdInternal()
|
static uint64_t GetCurrentThreadIdInternal()
|
||||||
{
|
{
|
||||||
/* If we're under Valgrind, neither the PID nor the TID is associated with the
|
/* If we're under Valgrind, neither the PID nor the TID is associated with the
|
||||||
* thread. Return the pthread ID. This can't be used to kill threads, etc.,
|
* thread. Return the pthread ID. This can't be used to kill threads, etc.,
|
||||||
@@ -157,14 +157,14 @@ static std::uint64_t GetCurrentThreadIdInternal()
|
|||||||
return getpid();
|
return getpid();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetCurrentThreadId()
|
uint64_t GetCurrentThreadId()
|
||||||
{
|
{
|
||||||
#if defined(HAVE_TLS)
|
#if defined(HAVE_TLS)
|
||||||
/* This is called each time we lock a mutex, and gettid() is a little slow, so
|
/* This is called each time we lock a mutex, and gettid() is a little slow, so
|
||||||
* cache the result if we support TLS. */
|
* cache the result if we support TLS. */
|
||||||
if( RageThread::GetSupportsTLS() )
|
if( RageThread::GetSupportsTLS() )
|
||||||
{
|
{
|
||||||
static thread_local std::uint64_t cached_tid = 0;
|
static thread_local uint64_t cached_tid = 0;
|
||||||
static thread_local bool cached = false;
|
static thread_local bool cached = false;
|
||||||
if( !cached )
|
if( !cached )
|
||||||
{
|
{
|
||||||
@@ -178,7 +178,7 @@ std::uint64_t GetCurrentThreadId()
|
|||||||
return GetCurrentThreadIdInternal();
|
return GetCurrentThreadIdInternal();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SuspendThread( std::uint64_t ThreadID )
|
int SuspendThread( uint64_t ThreadID )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Linux: We can't simply kill(SIGSTOP) (or tkill), since that will stop all processes
|
* Linux: We can't simply kill(SIGSTOP) (or tkill), since that will stop all processes
|
||||||
@@ -189,7 +189,7 @@ int SuspendThread( std::uint64_t ThreadID )
|
|||||||
// kill( ThreadID, SIGSTOP );
|
// kill( ThreadID, SIGSTOP );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ResumeThread( std::uint64_t ThreadID )
|
int ResumeThread( uint64_t ThreadID )
|
||||||
{
|
{
|
||||||
return PtraceDetach( int(ThreadID) );
|
return PtraceDetach( int(ThreadID) );
|
||||||
// kill( ThreadID, SIGSTOP );
|
// kill( ThreadID, SIGSTOP );
|
||||||
@@ -205,7 +205,7 @@ int ResumeThread( std::uint64_t ThreadID )
|
|||||||
* This call leaves the given thread suspended, so the returned context doesn't become invalid.
|
* This call leaves the given thread suspended, so the returned context doesn't become invalid.
|
||||||
* ResumeThread() can be used to resume a thread after this call. */
|
* ResumeThread() can be used to resume a thread after this call. */
|
||||||
#if defined(CRASH_HANDLER)
|
#if defined(CRASH_HANDLER)
|
||||||
bool GetThreadBacktraceContext( std::uint64_t ThreadID, BacktraceContext *ctx )
|
bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx )
|
||||||
{
|
{
|
||||||
/* Can't GetThreadBacktraceContext the current thread. */
|
/* Can't GetThreadBacktraceContext the current thread. */
|
||||||
ASSERT( ThreadID != GetCurrentThreadId() );
|
ASSERT( ThreadID != GetCurrentThreadId() );
|
||||||
@@ -266,17 +266,17 @@ RString ThreadsVersion()
|
|||||||
return "(unknown)";
|
return "(unknown)";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetCurrentThreadId()
|
uint64_t GetCurrentThreadId()
|
||||||
{
|
{
|
||||||
return std::uint64_t( pthread_self() );
|
return uint64_t( pthread_self() );
|
||||||
}
|
}
|
||||||
|
|
||||||
int SuspendThread( std::uint64_t id )
|
int SuspendThread( uint64_t id )
|
||||||
{
|
{
|
||||||
return pthread_kill( pthread_t(id), SIGSTOP );
|
return pthread_kill( pthread_t(id), SIGSTOP );
|
||||||
}
|
}
|
||||||
|
|
||||||
int ResumeThread( std::uint64_t id )
|
int ResumeThread( uint64_t id )
|
||||||
{
|
{
|
||||||
return pthread_kill( pthread_t(id), SIGCONT );
|
return pthread_kill( pthread_t(id), SIGCONT );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,16 +8,16 @@
|
|||||||
RString ThreadsVersion();
|
RString ThreadsVersion();
|
||||||
|
|
||||||
/* Get the current thread's ThreadID. */
|
/* Get the current thread's ThreadID. */
|
||||||
std::uint64_t GetCurrentThreadId();
|
uint64_t GetCurrentThreadId();
|
||||||
|
|
||||||
/* Return true if NPTL libraries are in use, false if linuxthreads. */
|
/* Return true if NPTL libraries are in use, false if linuxthreads. */
|
||||||
bool UsingNPTL();
|
bool UsingNPTL();
|
||||||
|
|
||||||
int SuspendThread( std::uint64_t ThreadID );
|
int SuspendThread( uint64_t ThreadID );
|
||||||
int ResumeThread( std::uint64_t ThreadID );
|
int ResumeThread( uint64_t ThreadID );
|
||||||
|
|
||||||
struct BacktraceContext;
|
struct BacktraceContext;
|
||||||
int GetThreadContext( std::uint64_t ThreadID, BacktraceContext *ctx );
|
int GetThreadContext( uint64_t ThreadID, BacktraceContext *ctx );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -8,22 +8,22 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
bool SuspendThread( std::uint64_t threadHandle )
|
bool SuspendThread( uint64_t threadHandle )
|
||||||
{
|
{
|
||||||
return !thread_suspend( thread_act_t(threadHandle) );
|
return !thread_suspend( thread_act_t(threadHandle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResumeThread( std::uint64_t threadHandle )
|
bool ResumeThread( uint64_t threadHandle )
|
||||||
{
|
{
|
||||||
return !thread_resume( thread_act_t(threadHandle) );
|
return !thread_resume( thread_act_t(threadHandle) );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::uint64_t GetCurrentThreadId()
|
uint64_t GetCurrentThreadId()
|
||||||
{
|
{
|
||||||
return mach_thread_self();
|
return mach_thread_self();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetThreadBacktraceContext( std::uint64_t iID, BacktraceContext *ctx )
|
bool GetThreadBacktraceContext( uint64_t iID, BacktraceContext *ctx )
|
||||||
{
|
{
|
||||||
/* Can't GetThreadBacktraceContext the current thread. */
|
/* Can't GetThreadBacktraceContext the current thread. */
|
||||||
ASSERT( iID != GetCurrentThreadId() );
|
ASSERT( iID != GetCurrentThreadId() );
|
||||||
|
|||||||
@@ -7,16 +7,16 @@
|
|||||||
* @brief Attempt to suspend the specified thread.
|
* @brief Attempt to suspend the specified thread.
|
||||||
* @param threadHandle the thread to suspend.
|
* @param threadHandle the thread to suspend.
|
||||||
* @return true if the thread is suspended, false otherwise. */
|
* @return true if the thread is suspended, false otherwise. */
|
||||||
bool SuspendThread( std::uint64_t threadHandle );
|
bool SuspendThread( uint64_t threadHandle );
|
||||||
/**
|
/**
|
||||||
* @brief Attempt to resume the specified thread.
|
* @brief Attempt to resume the specified thread.
|
||||||
* @param threadHandle the thread to resume.
|
* @param threadHandle the thread to resume.
|
||||||
* @return true if the thread is resumed, false otherwise. */
|
* @return true if the thread is resumed, false otherwise. */
|
||||||
bool ResumeThread( std::uint64_t threadHandle );
|
bool ResumeThread( uint64_t threadHandle );
|
||||||
/**
|
/**
|
||||||
* @brief Retrieve the current thread ID.
|
* @brief Retrieve the current thread ID.
|
||||||
* @return the current thread ID. */
|
* @return the current thread ID. */
|
||||||
std::uint64_t GetCurrentThreadId();
|
uint64_t GetCurrentThreadId();
|
||||||
/**
|
/**
|
||||||
* @brief Set the precedence for the thread.
|
* @brief Set the precedence for the thread.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ namespace __gnu_cxx
|
|||||||
{
|
{
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
template<>
|
template<>
|
||||||
struct hash<IOHIDElementCookie> : private hash<std::uintptr_t>
|
struct hash<IOHIDElementCookie> : private hash<uintptr_t>
|
||||||
{
|
{
|
||||||
size_t operator()( const IOHIDElementCookie& cookie ) const
|
size_t operator()( const IOHIDElementCookie& cookie ) const
|
||||||
{
|
{
|
||||||
return hash<unsigned long>::operator()( std::uintptr_t(cookie) );
|
return hash<unsigned long>::operator()( uintptr_t(cookie) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ bool JoystickDevice::InitDevice( int vid, int pid )
|
|||||||
if( vid != 0x0507 || pid != 0x0011 )
|
if( vid != 0x0507 || pid != 0x0011 )
|
||||||
return true;
|
return true;
|
||||||
// It's a Para controller, so try to power it on.
|
// It's a Para controller, so try to power it on.
|
||||||
std::uint8_t powerOn = 1;
|
uint8_t powerOn = 1;
|
||||||
IOReturn ret = SetReport( kIOHIDReportTypeFeature, 0, &powerOn, 1, 10 );
|
IOReturn ret = SetReport( kIOHIDReportTypeFeature, 0, &powerOn, 1, 10 );
|
||||||
|
|
||||||
if( ret )
|
if( ret )
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void PumpDevice::GetButtonPresses( std::vector<DeviceInput>& vPresses, IOHIDElem
|
|||||||
bool pressed1 = !(value & 0x1);
|
bool pressed1 = !(value & 0x1);
|
||||||
bool pressed2 = !(value & 0x2);
|
bool pressed2 = !(value & 0x2);
|
||||||
|
|
||||||
switch( std::uintptr_t(cookie) )
|
switch( uintptr_t(cookie) )
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
db2 = JOY_BUTTON_1; // bit 9
|
db2 = JOY_BUTTON_1; // bit 9
|
||||||
|
|||||||
@@ -599,7 +599,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
|||||||
// Make sure this is on the stack
|
// Make sure this is on the stack
|
||||||
if( !GetRegionInfo(self, frame, start, protection) || protection != PROT_RW )
|
if( !GetRegionInfo(self, frame, start, protection) || protection != PROT_RW )
|
||||||
break;
|
break;
|
||||||
if( (start != g_StackPointer && start != stackPointer) || std::uintptr_t(frame)-std::uintptr_t(start) < sizeof(Frame) )
|
if( (start != g_StackPointer && start != stackPointer) || uintptr_t(frame)-uintptr_t(start) < sizeof(Frame) )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* The stack pointer is always 16 byte aligned _before_ the call. Thus a valid frame
|
/* The stack pointer is always 16 byte aligned _before_ the call. Thus a valid frame
|
||||||
@@ -617,7 +617,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
|||||||
* Therefore, frame + 8 should be on a 16 byte boundary, the frame link should be
|
* Therefore, frame + 8 should be on a 16 byte boundary, the frame link should be
|
||||||
* at a higher address, the link should be on the stack and it should be RW. The
|
* at a higher address, the link should be on the stack and it should be RW. The
|
||||||
* return address should be EXE and point to a valid call (well, just after). */
|
* return address should be EXE and point to a valid call (well, just after). */
|
||||||
if( (((std::uintptr_t)frame+8) & 0xF) != 0 ||// boundary
|
if( (((uintptr_t)frame+8) & 0xF) != 0 ||// boundary
|
||||||
frame->link <= frame || // the frame link goes up
|
frame->link <= frame || // the frame link goes up
|
||||||
!GetRegionInfo(self, frame->link, start, protection) ||
|
!GetRegionInfo(self, frame->link, start, protection) ||
|
||||||
(start != g_StackPointer && start != stackPointer) || // the link is on the stack
|
(start != g_StackPointer && start != stackPointer) || // the link is on the stack
|
||||||
@@ -629,7 +629,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
|||||||
/* This is not a valid frame but we might be in code compiled with
|
/* This is not a valid frame but we might be in code compiled with
|
||||||
* -fomit-frame-pointer so look at each address on the stack that is
|
* -fomit-frame-pointer so look at each address on the stack that is
|
||||||
* 4 bytes below a 16 byte boundary. */
|
* 4 bytes below a 16 byte boundary. */
|
||||||
if( (((std::uintptr_t)frame+4) & 0xF) == 0 )
|
if( (((uintptr_t)frame+4) & 0xF) == 0 )
|
||||||
{
|
{
|
||||||
void *p = *(void **)frame;
|
void *p = *(void **)frame;
|
||||||
if( GetRegionInfo(self, p, start, protection) &&
|
if( GetRegionInfo(self, p, start, protection) &&
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx =
|
|||||||
|
|
||||||
/* Set up a BacktraceContext to get a backtrace for a thread. ThreadID may
|
/* Set up a BacktraceContext to get a backtrace for a thread. ThreadID may
|
||||||
* not be the current thread. True is returned on success, false on failure. */
|
* not be the current thread. True is returned on success, false on failure. */
|
||||||
bool GetThreadBacktraceContext( std::uint64_t ThreadID, BacktraceContext *ctx );
|
bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx );
|
||||||
|
|
||||||
/* Set up a BacktraceContext to get a backtrace after receiving a signal, given
|
/* Set up a BacktraceContext to get a backtrace after receiving a signal, given
|
||||||
* a ucontext_t (see sigaction(2)). (This interface is UNIX-specific.) */
|
* a ucontext_t (see sigaction(2)). (This interface is UNIX-specific.) */
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user