excessively large commit: use RageSurface
This commit is contained in:
@@ -11,10 +11,11 @@
|
||||
#include "SDL_utils.h"
|
||||
#include "SDL_dither.h"
|
||||
#include "SDL_rotozoom.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "RageTexture.h"
|
||||
#include "RageTextureManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
|
||||
#include "Banner.h"
|
||||
|
||||
@@ -44,7 +45,7 @@
|
||||
BannerCache *BANNERCACHE;
|
||||
|
||||
|
||||
static map<CString,SDL_Surface *> m_BannerPathToImage;
|
||||
static map<CString,RageSurface *> g_BannerPathToImage;
|
||||
|
||||
CString BannerCache::GetBannerCachePath( CString BannerPath )
|
||||
{
|
||||
@@ -63,11 +64,11 @@ void BannerCache::LoadBanner( CString BannerPath )
|
||||
|
||||
for( int tries = 0; tries < 2; ++tries )
|
||||
{
|
||||
if( m_BannerPathToImage.find(BannerPath) != m_BannerPathToImage.end() )
|
||||
if( g_BannerPathToImage.find(BannerPath) != g_BannerPathToImage.end() )
|
||||
return; /* already loaded */
|
||||
|
||||
CHECKPOINT_M( ssprintf( "BannerCache::LoadBanner: %s", CachePath.c_str() ) );
|
||||
SDL_Surface *img = mySDL_LoadSurface( CachePath );
|
||||
RageSurface *img = RageSurfaceUtils::LoadSurface( CachePath );
|
||||
if( img == NULL )
|
||||
{
|
||||
if(tries == 0)
|
||||
@@ -87,17 +88,17 @@ void BannerCache::LoadBanner( CString BannerPath )
|
||||
}
|
||||
}
|
||||
|
||||
m_BannerPathToImage[BannerPath] = img;
|
||||
g_BannerPathToImage[BannerPath] = img;
|
||||
}
|
||||
}
|
||||
|
||||
void BannerCache::OutputStats() const
|
||||
{
|
||||
map<CString,SDL_Surface *>::const_iterator ban;
|
||||
map<CString,RageSurface *>::const_iterator ban;
|
||||
int total_size = 0;
|
||||
for( ban = m_BannerPathToImage.begin(); ban != m_BannerPathToImage.end(); ++ban )
|
||||
for( ban = g_BannerPathToImage.begin(); ban != g_BannerPathToImage.end(); ++ban )
|
||||
{
|
||||
SDL_Surface * const &img = ban->second;
|
||||
RageSurface * const &img = ban->second;
|
||||
const int size = img->pitch * img->h;
|
||||
total_size += size;
|
||||
}
|
||||
@@ -106,11 +107,11 @@ void BannerCache::OutputStats() const
|
||||
|
||||
void BannerCache::UnloadAllBanners()
|
||||
{
|
||||
map<CString,SDL_Surface *>::iterator it;
|
||||
for( it = m_BannerPathToImage.begin(); it != m_BannerPathToImage.end(); ++it )
|
||||
SDL_FreeSurface(it->second);
|
||||
map<CString,RageSurface *>::iterator it;
|
||||
for( it = g_BannerPathToImage.begin(); it != g_BannerPathToImage.end(); ++it )
|
||||
delete it->second;
|
||||
|
||||
m_BannerPathToImage.clear();
|
||||
g_BannerPathToImage.clear();
|
||||
}
|
||||
|
||||
BannerCache::BannerCache()
|
||||
@@ -127,11 +128,11 @@ struct BannerTexture: public RageTexture
|
||||
{
|
||||
unsigned m_uTexHandle;
|
||||
unsigned GetTexHandle() const { return m_uTexHandle; }; // accessed by RageDisplay
|
||||
/* This is a reference to a pointer in m_BannerPathToImage. */
|
||||
SDL_Surface *&img;
|
||||
/* This is a reference to a pointer in g_BannerPathToImage. */
|
||||
RageSurface *&img;
|
||||
int width, height;
|
||||
|
||||
BannerTexture( RageTextureID name, SDL_Surface *&img_, int width_, int height_ ):
|
||||
BannerTexture( RageTextureID name, RageSurface *&img_, int width_, int height_ ):
|
||||
RageTexture(name), img(img_), width(width_), height(height_)
|
||||
{
|
||||
Create();
|
||||
@@ -159,7 +160,7 @@ struct BannerTexture: public RageTexture
|
||||
img->h > DISPLAY->GetMaxTextureSize() )
|
||||
{
|
||||
LOG->Warn("Converted %s at runtime", GetID().filename.c_str() );
|
||||
ConvertSDLSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
RageSurfaceUtils::ConvertSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
zoomSurface(img, min( img->w, DISPLAY->GetMaxTextureSize() ),
|
||||
min( img->h, DISPLAY->GetMaxTextureSize() ));
|
||||
}
|
||||
@@ -218,7 +219,7 @@ RageTextureID BannerCache::LoadCachedBanner( CString BannerPath )
|
||||
ID = Sprite::SongBannerTexture(ID);
|
||||
|
||||
/* It's not in a texture. Do we have it loaded? */
|
||||
if( m_BannerPathToImage.find(BannerPath) == m_BannerPathToImage.end() )
|
||||
if( g_BannerPathToImage.find(BannerPath) == g_BannerPathToImage.end() )
|
||||
{
|
||||
/* Oops, the image is missing. Warn and continue. */
|
||||
LOG->Warn( "Banner cache for '%s' wasn't loaded", BannerPath.c_str() );
|
||||
@@ -228,7 +229,7 @@ RageTextureID BannerCache::LoadCachedBanner( CString BannerPath )
|
||||
/* This is a reference to a pointer. BannerTexture's ctor may change it
|
||||
* when converting; this way, the conversion will end up in the map so we
|
||||
* only have to convert once. */
|
||||
SDL_Surface *&img = m_BannerPathToImage[BannerPath];
|
||||
RageSurface *&img = g_BannerPathToImage[BannerPath];
|
||||
ASSERT( img );
|
||||
|
||||
int src_width = 0, src_height = 0;
|
||||
@@ -300,7 +301,7 @@ void BannerCache::CacheBanner( CString BannerPath )
|
||||
|
||||
void BannerCache::CacheBannerInternal( CString BannerPath )
|
||||
{
|
||||
SDL_Surface *img = RageSurface::LoadFile( BannerPath );
|
||||
RageSurface *img = RageSurfaceUtils::LoadFile( BannerPath );
|
||||
if( img == NULL )
|
||||
{
|
||||
LOG->Warn( "BannerCache::CacheBanner: Couldn't load %s: %s", BannerPath.c_str(), SDL_GetError() );
|
||||
@@ -322,18 +323,18 @@ void BannerCache::CacheBannerInternal( CString BannerPath )
|
||||
* This also makes the banner take less memory, though that could also be
|
||||
* done by RLEing the surface.
|
||||
*/
|
||||
ApplyHotPinkColorKey( img );
|
||||
RageSurfaceUtils::ApplyHotPinkColorKey( img );
|
||||
|
||||
ConvertSDLSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
RageSurfaceUtils::ConvertSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
|
||||
SDL_Surface *dst = SDL_CreateRGBSurface(
|
||||
SDL_SWSURFACE, 256, 64, img->format->BitsPerPixel,
|
||||
RageSurface *dst = CreateSurface(
|
||||
256, 64, img->format->BitsPerPixel,
|
||||
img->format->Rmask, img->format->Gmask, img->format->Bmask, img->format->Amask );
|
||||
|
||||
if( img->format->BitsPerPixel == 8 )
|
||||
{
|
||||
ASSERT( img->format->palette );
|
||||
mySDL_SetPalette(dst, img->format->palette->colors, 0, 256);
|
||||
dst->fmt.palette = img->fmt.palette;
|
||||
}
|
||||
|
||||
const float fCustomImageCoords[8] = {
|
||||
@@ -343,10 +344,10 @@ void BannerCache::CacheBannerInternal( CString BannerPath )
|
||||
0.78f, 0.02f, // top right
|
||||
};
|
||||
|
||||
mySDL_BlitTransform( img, dst, fCustomImageCoords );
|
||||
RageSurfaceUtils::BlitTransform( img, dst, fCustomImageCoords );
|
||||
|
||||
// SDL_SaveBMP( dst, BannerPath + "-test.bmp" );
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
img = dst;
|
||||
|
||||
WasRotatedBanner = true;
|
||||
@@ -368,42 +369,42 @@ void BannerCache::CacheBannerInternal( CString BannerPath )
|
||||
width = max( width, min(32, power_of_two(src_width)) );
|
||||
height = max( height, min(32, power_of_two(src_height)) );
|
||||
|
||||
ApplyHotPinkColorKey( img );
|
||||
RageSurfaceUtils::ApplyHotPinkColorKey( img );
|
||||
|
||||
{
|
||||
ConvertSDLSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
RageSurfaceUtils::ConvertSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
zoomSurface(img, width, height);
|
||||
|
||||
/* Dither to the final format. We use A1RGB5, since that's usually supported
|
||||
* natively by both OpenGL and D3D. */
|
||||
SDL_Surface *dst = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, img->w, img->h,
|
||||
16, 0x7C00, 0x03E0, 0x001F, 0x8000 );
|
||||
RageSurface *dst = CreateSurface( img->w, img->h, 16,
|
||||
0x7C00, 0x03E0, 0x001F, 0x8000 );
|
||||
|
||||
/* SM_SDL_OrderedDither is still faster than SM_SDL_ErrorDiffusionDither, and
|
||||
* these images are very small and only displayed briefly. */
|
||||
SM_SDL_OrderedDither(img, dst);
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
img = dst;
|
||||
}
|
||||
|
||||
const CString CachePath = GetBannerCachePath(BannerPath);
|
||||
mySDL_SaveSurface( img, CachePath );
|
||||
RageSurfaceUtils::SaveSurface( img, CachePath );
|
||||
|
||||
if( PREFSMAN->m_BannerCache == PrefsManager::BNCACHE_LOW_RES )
|
||||
{
|
||||
/* If an old image is loaded, free it. */
|
||||
if( m_BannerPathToImage.find(BannerPath) != m_BannerPathToImage.end() )
|
||||
if( g_BannerPathToImage.find(BannerPath) != g_BannerPathToImage.end() )
|
||||
{
|
||||
SDL_Surface *oldimg = m_BannerPathToImage[BannerPath];
|
||||
SDL_FreeSurface( oldimg );
|
||||
m_BannerPathToImage.erase(BannerPath);
|
||||
RageSurface *oldimg = g_BannerPathToImage[BannerPath];
|
||||
delete oldimg;
|
||||
g_BannerPathToImage.erase(BannerPath);
|
||||
}
|
||||
|
||||
/* Keep it; we're just going to load it anyway. */
|
||||
m_BannerPathToImage[BannerPath] = img;
|
||||
g_BannerPathToImage[BannerPath] = img;
|
||||
}
|
||||
else
|
||||
SDL_FreeSurface(img);
|
||||
delete img;
|
||||
|
||||
/* Remember the original size. */
|
||||
BannerData.SetValue( BannerPath, "Path", CachePath );
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "RageTypes.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_rotozoom.h"
|
||||
@@ -67,26 +69,26 @@ void RageBitmapTexture::Create()
|
||||
|
||||
/* Create (and return) a surface ready to be loaded to OpenGL */
|
||||
/* Load the image into an SDL surface. */
|
||||
SDL_Surface *img = RageSurfaceUtils::LoadFile( actualID.filename );
|
||||
RageSurface *img = RageSurfaceUtils::LoadFile( actualID.filename );
|
||||
|
||||
/* Tolerate corrupt/unknown images. */
|
||||
if( img == NULL )
|
||||
{
|
||||
LOG->Warn( "RageBitmapTexture: Couldn't load %s: %s", actualID.filename.c_str(), SDL_GetError() );
|
||||
img = mySDL_MakeDummySurface( 64, 64 );
|
||||
img = RageSurfaceUtils::MakeDummySurface( 64, 64 );
|
||||
ASSERT( img != NULL );
|
||||
}
|
||||
|
||||
if(actualID.bHotPinkColorKey)
|
||||
ApplyHotPinkColorKey( img );
|
||||
if( actualID.bHotPinkColorKey )
|
||||
RageSurfaceUtils::ApplyHotPinkColorKey( img );
|
||||
|
||||
{
|
||||
/* Do this after setting the color key for paletted images; it'll also return
|
||||
* TRAIT_NO_TRANSPARENCY if the color key is never used. */
|
||||
int traits = FindSurfaceTraits(img);
|
||||
if(traits & TRAIT_NO_TRANSPARENCY)
|
||||
int traits = RageSurfaceUtils::FindSurfaceTraits(img);
|
||||
if( traits & RageSurfaceUtils::TRAIT_NO_TRANSPARENCY )
|
||||
actualID.iAlphaBits = 0;
|
||||
else if(traits & TRAIT_BOOL_TRANSPARENCY)
|
||||
else if( traits & RageSurfaceUtils::TRAIT_BOOL_TRANSPARENCY )
|
||||
actualID.iAlphaBits = 1;
|
||||
}
|
||||
|
||||
@@ -155,7 +157,7 @@ void RageBitmapTexture::Create()
|
||||
if( img->w != m_iImageWidth || img->h != m_iImageHeight )
|
||||
{
|
||||
/* resize currently only does RGBA8888 */
|
||||
ConvertSDLSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
RageSurfaceUtils::ConvertSurface(img, img->w, img->h, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
|
||||
zoomSurface(img, m_iImageWidth, m_iImageHeight );
|
||||
}
|
||||
|
||||
@@ -164,9 +166,9 @@ void RageBitmapTexture::Create()
|
||||
|
||||
if( actualID.iGrayscaleBits != -1 && DISPLAY->SupportsTextureFormat(RageDisplay::FMT_PAL) )
|
||||
{
|
||||
SDL_Surface *dst = mySDL_Palettize( img, actualID.iGrayscaleBits, actualID.iAlphaBits );
|
||||
RageSurface *dst = RageSurfaceUtils::Palettize( img, actualID.iGrayscaleBits, actualID.iAlphaBits );
|
||||
|
||||
SDL_FreeSurface(img);
|
||||
delete img;
|
||||
img = dst;
|
||||
}
|
||||
|
||||
@@ -218,11 +220,11 @@ void RageBitmapTexture::Create()
|
||||
{
|
||||
/* Dither down to the destination format. */
|
||||
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
|
||||
SDL_Surface *dst = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, img->w, img->h,
|
||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
|
||||
RageSurface *dst = CreateSurface( img->w, img->h, pfd->bpp,
|
||||
pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
||||
|
||||
SM_SDL_ErrorDiffusionDither(img, dst);
|
||||
SDL_FreeSurface(img);
|
||||
delete img;
|
||||
img = dst;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +232,7 @@ void RageBitmapTexture::Create()
|
||||
/* This needs to be done *after* the final resize, since that resize
|
||||
* may introduce new alpha bits that need to be set. It needs to be
|
||||
* done *before* we set up the palette, since it might change it. */
|
||||
FixHiddenAlpha(img);
|
||||
RageSurfaceUtils::FixHiddenAlpha(img);
|
||||
|
||||
/* Make we're using a supported format.
|
||||
* Every card supports either RGBA8 or RGBA4. */
|
||||
@@ -245,8 +247,8 @@ void RageBitmapTexture::Create()
|
||||
/* Convert the data to the destination format and dimensions
|
||||
* required by OpenGL if it's not in it already. */
|
||||
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
|
||||
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight,
|
||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
|
||||
RageSurfaceUtils::ConvertSurface( img, m_iTextureWidth, m_iTextureHeight,
|
||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
||||
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, img, actualID.bMipMaps );
|
||||
|
||||
@@ -293,7 +295,7 @@ void RageBitmapTexture::Create()
|
||||
|
||||
|
||||
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
|
||||
/* See if the apparent "size" is being overridden. */
|
||||
GetResolutionFromFileName(actualID.filename, m_iSourceWidth, m_iSourceHeight);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "RageFile.h"
|
||||
#include "SDL_SaveJPEG.h"
|
||||
#include "SDL_rotozoom.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
//
|
||||
// Statistics stuff
|
||||
@@ -572,14 +573,15 @@ RageMatrix RageDisplay::GetPerspectiveMatrix(float fovy, float aspect, float zNe
|
||||
return GetFrustumMatrix(xmin, xmax, ymin, ymax, zNear, zFar);
|
||||
}
|
||||
|
||||
SDL_Surface *RageDisplay::CreateSurfaceFromPixfmt( PixelFormat pixfmt,
|
||||
RageSurface *RageDisplay::CreateSurfaceFromPixfmt( PixelFormat pixfmt,
|
||||
void *pixels, int width, int height, int pitch )
|
||||
{
|
||||
const PixelFormatDesc *tpf = GetPixelFormatDesc(pixfmt);
|
||||
|
||||
SDL_Surface *surf = SDL_CreateRGBSurfaceFrom(
|
||||
pixels, width, height, tpf->bpp, pitch,
|
||||
tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3]);
|
||||
RageSurface *surf = CreateSurfaceFrom(
|
||||
width, height, tpf->bpp,
|
||||
tpf->masks[0], tpf->masks[1], tpf->masks[2], tpf->masks[3],
|
||||
(uint8_t *) pixels, pitch );
|
||||
|
||||
return surf;
|
||||
}
|
||||
@@ -629,7 +631,7 @@ void RageDisplay::ChangeCentering( int trans_x, int trans_y, float scale_x, floa
|
||||
|
||||
bool RageDisplay::SaveScreenshot( CString sPath, GraphicsFileFormat format )
|
||||
{
|
||||
SDL_Surface* surface = this->CreateScreenshot();
|
||||
RageSurface* surface = this->CreateScreenshot();
|
||||
|
||||
CString buf;
|
||||
buf.reserve( 1024*1024 );
|
||||
@@ -646,8 +648,12 @@ bool RageDisplay::SaveScreenshot( CString sPath, GraphicsFileFormat format )
|
||||
switch( format )
|
||||
{
|
||||
case SAVE_LOSSLESS:
|
||||
SDL_SaveBMP_RW( surface, &rw, false );
|
||||
{
|
||||
SDL_Surface *pSDLSurf = SDLSurfaceFromRageSurface( surface );
|
||||
SDL_SaveBMP_RW( pSDLSurf, &rw, false );
|
||||
delete pSDLSurf;
|
||||
break;
|
||||
}
|
||||
case SAVE_LOSSY_LOW_QUAL:
|
||||
IMG_SaveJPG_RW( surface, &rw, false );
|
||||
case SAVE_LOSSY_HIGH_QUAL:
|
||||
@@ -660,7 +666,7 @@ bool RageDisplay::SaveScreenshot( CString sPath, GraphicsFileFormat format )
|
||||
|
||||
SDL_RWclose( &rw );
|
||||
|
||||
SDL_FreeSurface( surface );
|
||||
delete surface;
|
||||
surface = NULL;
|
||||
|
||||
RageFile out;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "ModelTypes.h"
|
||||
|
||||
const int REFRESH_DEFAULT = 0;
|
||||
struct SDL_Surface;
|
||||
struct RageSurface;
|
||||
const int MAX_TEXTURE_UNITS = 2;
|
||||
|
||||
// RageCompiledGeometry holds vertex data in a format that is most efficient
|
||||
@@ -172,12 +172,12 @@ public:
|
||||
* (unsigned in OpenGL, texture pointer in D3D) */
|
||||
virtual unsigned CreateTexture(
|
||||
PixelFormat pixfmt, // format of img and of texture in video mem
|
||||
SDL_Surface* img, // must be in pixfmt
|
||||
RageSurface* img, // must be in pixfmt
|
||||
bool bGenerateMipMaps
|
||||
) = 0;
|
||||
virtual void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height
|
||||
) = 0;
|
||||
virtual void DeleteTexture( unsigned uTexHandle ) = 0;
|
||||
@@ -257,7 +257,7 @@ protected:
|
||||
// bNewDeviceOut is set true if a new device was created and textures
|
||||
// need to be reloaded.
|
||||
virtual CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ) = 0;
|
||||
virtual SDL_Surface* CreateScreenshot() = 0; // allocates a surface. Caller must SDL_FreeSurface it.
|
||||
virtual RageSurface* CreateScreenshot() = 0; // allocates a surface. Caller must SDL_FreeSurface it.
|
||||
|
||||
virtual void SetViewport(int shift_left, int shift_down) = 0;
|
||||
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
/* Centering matrix */
|
||||
void ChangeCentering( int trans_x, int trans_y, float scale_x, float scale_y );
|
||||
|
||||
SDL_Surface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch );
|
||||
RageSurface *CreateSurfaceFromPixfmt( PixelFormat pixfmt, void *pixels, int width, int height, int pitch );
|
||||
PixelFormat FindPixelFormat( int bpp, int Rmask, int Gmask, int Bmask, int Amask, bool realtime=false );
|
||||
|
||||
protected:
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
#include "StepMania.h"
|
||||
#include "RageUtil.h"
|
||||
#include "D3dx8math.h"
|
||||
#include "SDL_video.h" // for SDL_Surface
|
||||
#include "SDL_video.h" // for RageSurface
|
||||
#include "SDL_utils.h"
|
||||
#include "D3DX8Core.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
|
||||
#include "arch/arch.h"
|
||||
|
||||
@@ -654,7 +656,7 @@ bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt, bool realtime )
|
||||
return SUCCEEDED( hr );
|
||||
}
|
||||
|
||||
SDL_Surface* RageDisplay_D3D::CreateScreenshot()
|
||||
RageSurface* RageDisplay_D3D::CreateScreenshot()
|
||||
{
|
||||
#ifndef _XBOX
|
||||
/* Get the back buffer. */
|
||||
@@ -687,17 +689,17 @@ SDL_Surface* RageDisplay_D3D::CreateScreenshot()
|
||||
pCopy->LockRect( &lr, &rect, D3DLOCK_READONLY );
|
||||
}
|
||||
|
||||
SDL_Surface *surface = CreateSurfaceFromPixfmt( FMT_RGBA8, lr.pBits, desc.Width, desc.Height, lr.Pitch);
|
||||
RageSurface *surface = CreateSurfaceFromPixfmt( FMT_RGBA8, lr.pBits, desc.Width, desc.Height, lr.Pitch);
|
||||
ASSERT( surface );
|
||||
|
||||
/* We need to make a copy, since lr.pBits will go away when we call UnlockRect(). */
|
||||
SDL_Surface *SurfaceCopy =
|
||||
SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, surface->w, surface->h,
|
||||
RageSurface *SurfaceCopy =
|
||||
CreateSurface( surface->w, surface->h,
|
||||
surface->format->BitsPerPixel,
|
||||
surface->format->Rmask, surface->format->Gmask,
|
||||
surface->format->Bmask, surface->format->Amask );
|
||||
CopySDLSurface( surface, SurfaceCopy );
|
||||
SDL_FreeSurface( surface );
|
||||
RageSurfaceUtils::CopySurface( surface, SurfaceCopy );
|
||||
delete surface;
|
||||
|
||||
pCopy->UnlockRect();
|
||||
pCopy->Release();
|
||||
@@ -1164,7 +1166,7 @@ void RageDisplay_D3D::DeleteTexture( unsigned uTexHandle )
|
||||
|
||||
unsigned RageDisplay_D3D::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps )
|
||||
{
|
||||
// texture must be power of two
|
||||
@@ -1188,11 +1190,11 @@ unsigned RageDisplay_D3D::CreateTexture(
|
||||
memset( pal.p, 0, sizeof(pal.p) );
|
||||
for( int i=0; i<img->format->palette->ncolors; i++ )
|
||||
{
|
||||
SDL_Color c = img->format->palette->colors[i];
|
||||
RageSurfaceColor &c = img->format->palette->colors[i];
|
||||
pal.p[i].peRed = c.r;
|
||||
pal.p[i].peGreen = c.g;
|
||||
pal.p[i].peBlue = c.b;
|
||||
pal.p[i].peFlags = c.unused;
|
||||
pal.p[i].peFlags = c.a;
|
||||
}
|
||||
|
||||
ASSERT( g_TexResourceToTexturePalette.find(uTexHandle) == g_TexResourceToTexturePalette.end() );
|
||||
@@ -1206,7 +1208,7 @@ unsigned RageDisplay_D3D::CreateTexture(
|
||||
|
||||
void RageDisplay_D3D::UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height )
|
||||
{
|
||||
IDirect3DTexture8* pTex = (IDirect3DTexture8*)uTexHandle;
|
||||
@@ -1251,18 +1253,15 @@ void RageDisplay_D3D::UpdateTexture(
|
||||
if(D3DFORMATS[texpixfmt] == desc.Format) break;
|
||||
ASSERT( texpixfmt != NUM_PIX_FORMATS );
|
||||
|
||||
SDL_Surface *Texture = CreateSurfaceFromPixfmt(PixelFormat(texpixfmt), lr.pBits, width, height, lr.Pitch);
|
||||
RageSurface *Texture = CreateSurfaceFromPixfmt(PixelFormat(texpixfmt), lr.pBits, width, height, lr.Pitch);
|
||||
ASSERT( Texture );
|
||||
SDL_Rect area;
|
||||
area.x = area.y = 0;
|
||||
area.w = (uint16_t) width;
|
||||
area.h = (uint16_t) height;
|
||||
SDL_SetAlpha( img, 0, SDL_ALPHA_OPAQUE );
|
||||
// SDL_SetColorKey( img, 0, 0 );
|
||||
// SDL_BlitSurface( img, &area, Texture, &area );
|
||||
mySDL_BlitSurface( img, Texture, width, height, false );
|
||||
RageSurfaceUtils::Blit( img, Texture, width, height, false );
|
||||
|
||||
SDL_FreeSurface( Texture );
|
||||
delete Texture;
|
||||
#endif
|
||||
|
||||
pTex->UnlockRect( 0 );
|
||||
|
||||
@@ -33,11 +33,11 @@ public:
|
||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
||||
unsigned CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps );
|
||||
void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height
|
||||
);
|
||||
void DeleteTexture( unsigned uTexHandle );
|
||||
@@ -86,7 +86,7 @@ protected:
|
||||
void DrawCompiledGeometryInternal( const RageCompiledGeometry *p, int iMeshIndex );
|
||||
|
||||
CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut );
|
||||
SDL_Surface* CreateScreenshot();
|
||||
RageSurface* CreateScreenshot();
|
||||
void SetViewport(int shift_left, int shift_down);
|
||||
RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf );
|
||||
};
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "RageTypes.h"
|
||||
#include "StepMania.h"
|
||||
#include "RageUtil.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
static RageDisplay::PixelFormatDesc PIXEL_FORMAT_DESC[RageDisplay::NUM_PIX_FORMATS] = {
|
||||
{
|
||||
@@ -78,12 +79,12 @@ RageDisplay_Null::RageDisplay_Null( VideoModeParams p )
|
||||
SetVideoMode( p );
|
||||
}
|
||||
|
||||
SDL_Surface* RageDisplay_Null::CreateScreenshot()
|
||||
RageSurface* RageDisplay_Null::CreateScreenshot()
|
||||
{
|
||||
const PixelFormatDesc &desc = PIXEL_FORMAT_DESC[FMT_RGB8];
|
||||
SDL_Surface *image = SDL_CreateRGBSurfaceSane(
|
||||
SDL_SWSURFACE, 640, 480,
|
||||
desc.bpp, desc.masks[0], desc.masks[1], desc.masks[2], desc.masks[3] );
|
||||
RageSurface *image = CreateSurface(
|
||||
640, 480, desc.bpp,
|
||||
desc.masks[0], desc.masks[1], desc.masks[2], desc.masks[3] );
|
||||
|
||||
memset( image->pixels, 0, 480*image->pitch );
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* RageDisplay_Null: diagnostic display device
|
||||
*/
|
||||
/* RageDisplay_Null: diagnostic display device */
|
||||
|
||||
#ifndef RAGEDISPLAY_NULL_H
|
||||
#define RAGEDISPLAY_NULL_H
|
||||
@@ -21,11 +19,11 @@ public:
|
||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false ) { return true; }
|
||||
unsigned CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps ) { return 1; }
|
||||
void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height
|
||||
) { }
|
||||
void DeleteTexture( unsigned uTexHandle ) { }
|
||||
@@ -76,7 +74,7 @@ protected:
|
||||
|
||||
VideoModeParams m_Params;
|
||||
CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut ) { m_Params = params; return ""; }
|
||||
SDL_Surface* CreateScreenshot();
|
||||
RageSurface* CreateScreenshot();
|
||||
void SetViewport(int shift_left, int shift_down) { }
|
||||
RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf );
|
||||
bool SupportsSurfaceFormat( PixelFormat pixfmt ) { return true; }
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include "glext.h"
|
||||
|
||||
#include "RageFile.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
#include "PrefsManager.h" // XXX
|
||||
|
||||
/* Windows's broken gl.h defines GL_EXT_paletted_texture incompletely: */
|
||||
@@ -831,15 +833,14 @@ void RageDisplay_OGL::EndFrame()
|
||||
ProcessStatsOnFlip();
|
||||
}
|
||||
|
||||
SDL_Surface* RageDisplay_OGL::CreateScreenshot()
|
||||
RageSurface* RageDisplay_OGL::CreateScreenshot()
|
||||
{
|
||||
int width = wind->GetVideoModeParams().width;
|
||||
int height = wind->GetVideoModeParams().height;
|
||||
|
||||
const PixelFormatDesc &desc = PIXEL_FORMAT_DESC[FMT_RGBA8];
|
||||
SDL_Surface *image = SDL_CreateRGBSurfaceSane(
|
||||
SDL_SWSURFACE, width, height,
|
||||
desc.bpp, desc.masks[0], desc.masks[1], desc.masks[2], 0 );
|
||||
RageSurface *image = CreateSurface( width, height, desc.bpp,
|
||||
desc.masks[0], desc.masks[1], desc.masks[2], 0 );
|
||||
|
||||
glReadPixels(0, 0, wind->GetVideoModeParams().width, wind->GetVideoModeParams().height, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, image->pixels);
|
||||
@@ -1612,7 +1613,7 @@ void RageDisplay_OGL::DeleteTexture( unsigned uTexHandle )
|
||||
}
|
||||
|
||||
|
||||
RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img, bool &FreeImg, int width, int height )
|
||||
RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( RageSurface* &img, bool &FreeImg, int width, int height )
|
||||
{
|
||||
PixelFormat pixfmt = FindPixelFormat( img->format->BitsPerPixel, img->format->Rmask, img->format->Gmask, img->format->Bmask, img->format->Amask );
|
||||
|
||||
@@ -1627,16 +1628,9 @@ RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img,
|
||||
|
||||
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
|
||||
|
||||
SDL_SetAlpha( img, 0, SDL_ALPHA_OPAQUE );
|
||||
|
||||
SDL_Rect area;
|
||||
area.x = area.y = 0;
|
||||
area.w = short(width);
|
||||
area.h = short(height);
|
||||
|
||||
SDL_Surface *imgconv = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, width, height,
|
||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
|
||||
SDL_BlitSurface(img, &area, imgconv, &area);
|
||||
RageSurface *imgconv = CreateSurface( width, height,
|
||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
||||
RageSurfaceUtils::Blit( img, imgconv, width, height, false );
|
||||
img = imgconv;
|
||||
FreeImg = true;
|
||||
}
|
||||
@@ -1648,7 +1642,7 @@ RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img,
|
||||
|
||||
unsigned RageDisplay_OGL::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps )
|
||||
{
|
||||
ASSERT( pixfmt < NUM_PIX_FORMATS );
|
||||
@@ -1731,7 +1725,7 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
palette[p++] = img->format->palette->colors[i].r;
|
||||
palette[p++] = img->format->palette->colors[i].g;
|
||||
palette[p++] = img->format->palette->colors[i].b;
|
||||
palette[p++] = img->format->palette->colors[i].unused;
|
||||
palette[p++] = img->format->palette->colors[i].a;
|
||||
}
|
||||
|
||||
/* Set the palette. */
|
||||
@@ -1803,14 +1797,14 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
glFlush();
|
||||
|
||||
if( FreeImg )
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
return uTexHandle;
|
||||
}
|
||||
|
||||
|
||||
void RageDisplay_OGL::UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height )
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, uTexHandle );
|
||||
@@ -1834,7 +1828,7 @@ void RageDisplay_OGL::UpdateTexture(
|
||||
glFlush();
|
||||
|
||||
if( FreeImg )
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
}
|
||||
|
||||
CString RageDisplay_OGL::GetTextureDiagnostics( unsigned id ) const
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
* RageDisplay_OGL: OpenGL display implementation
|
||||
*/
|
||||
/* RageDisplay_OGL: OpenGL display implementation */
|
||||
|
||||
#ifndef RAGEDISPLAY_OGL_H
|
||||
#define RAGEDISPLAY_OGL_H
|
||||
@@ -23,11 +21,11 @@ public:
|
||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
||||
unsigned CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
bool bGenerateMipMaps );
|
||||
void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height
|
||||
);
|
||||
void DeleteTexture( unsigned uTexHandle );
|
||||
@@ -79,10 +77,10 @@ protected:
|
||||
void DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth );
|
||||
|
||||
CString TryVideoMode( VideoModeParams params, bool &bNewDeviceOut );
|
||||
SDL_Surface* CreateScreenshot();
|
||||
RageSurface* CreateScreenshot();
|
||||
void SetViewport(int shift_left, int shift_down);
|
||||
RageMatrix GetOrthoMatrix( float l, float r, float b, float t, float zn, float zf );
|
||||
PixelFormat GetImgPixelFormat( SDL_Surface* &img, bool &FreeImg, int width, int height );
|
||||
PixelFormat GetImgPixelFormat( RageSurface* &img, bool &FreeImg, int width, int height );
|
||||
bool SupportsSurfaceFormat( PixelFormat pixfmt );
|
||||
void SendCurrentMatrices();
|
||||
};
|
||||
|
||||
@@ -42,7 +42,6 @@ uint32_t RageSoundReader_WAV::ConvertBytePosToMs(int BytesPerSample, int channel
|
||||
return (uint32_t) ((frame_no / frames_per_ms) + 0.5f);
|
||||
}
|
||||
|
||||
/* Better than SDL_ReadLE16, since you can detect i/o errors... */
|
||||
bool RageSoundReader_WAV::read_le16( RageFile &f, int16_t *si16 ) const
|
||||
{
|
||||
const int ret = f.Read( si16, sizeof(int16_t) );
|
||||
@@ -68,7 +67,6 @@ bool RageSoundReader_WAV::read_le16( RageFile &f, uint16_t *ui16 ) const
|
||||
}
|
||||
|
||||
|
||||
/* Better than SDL_ReadLE32, since you can detect i/o errors... */
|
||||
bool RageSoundReader_WAV::read_le32( RageFile &f, int32_t *si32 ) const
|
||||
{
|
||||
const int ret = f.Read( si32, sizeof(int32_t) );
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* Utility functions for RageSurfaces. */
|
||||
|
||||
#ifndef RAGE_SURFACE_UTILS_H
|
||||
#define RAGE_SURFACE_UTILS_H
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "SDL_utils.h"
|
||||
#include <set>
|
||||
|
||||
static RageSurfaceUtils::OpenResult RageSurface_Load_BMP( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
|
||||
static RageSurfaceUtils::OpenResult RageSurface_Load_BMP( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error )
|
||||
{
|
||||
RageFile f;
|
||||
if( !f.Open(sPath) )
|
||||
@@ -20,23 +20,24 @@ static RageSurfaceUtils::OpenResult RageSurface_Load_BMP( const CString &sPath,
|
||||
|
||||
SDL_RWops rw;
|
||||
OpenRWops( &rw, &f );
|
||||
ret = SDL_LoadBMP_RW( &rw, false );
|
||||
SDL_Surface *pSDLSurface = SDL_LoadBMP_RW( &rw, false );
|
||||
SDL_RWclose( &rw );
|
||||
|
||||
if( ret == NULL )
|
||||
if( pSDLSurface == NULL )
|
||||
{
|
||||
error = SDL_GetError();
|
||||
return RageSurfaceUtils::OPEN_UNKNOWN_FILE_FORMAT;
|
||||
}
|
||||
|
||||
mySDL_FixupPalettedAlpha( ret );
|
||||
ret = RageSurfaceFromSDLSurface( pSDLSurface );
|
||||
|
||||
return RageSurfaceUtils::OPEN_OK;
|
||||
}
|
||||
|
||||
|
||||
static SDL_Surface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error, CString format, bool &bKeepTrying )
|
||||
static RageSurface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error, CString format, bool &bKeepTrying )
|
||||
{
|
||||
SDL_Surface *ret = NULL;
|
||||
RageSurface *ret = NULL;
|
||||
RageSurfaceUtils::OpenResult result;
|
||||
if( !format.CompareNoCase("png") )
|
||||
result = RageSurface_Load_PNG( sPath, ret, bHeaderOnly, error );
|
||||
@@ -96,7 +97,7 @@ static SDL_Surface *TryOpenFile( CString sPath, bool bHeaderOnly, CString &error
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_Surface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly )
|
||||
RageSurface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly )
|
||||
{
|
||||
{
|
||||
RageFile TestOpen;
|
||||
@@ -123,7 +124,7 @@ SDL_Surface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly
|
||||
/* If the extension matches a format, try that first. */
|
||||
if( FileTypes.find(format) != FileTypes.end() )
|
||||
{
|
||||
SDL_Surface *ret = TryOpenFile( sPath, bHeaderOnly, error, format, bKeepTrying );
|
||||
RageSurface *ret = TryOpenFile( sPath, bHeaderOnly, error, format, bKeepTrying );
|
||||
if( ret )
|
||||
return ret;
|
||||
FileTypes.erase( format );
|
||||
@@ -131,7 +132,7 @@ SDL_Surface *RageSurfaceUtils::LoadFile( const CString &sPath, bool bHeaderOnly
|
||||
|
||||
for( set<CString>::iterator it = FileTypes.begin(); bKeepTrying && it != FileTypes.end(); ++it )
|
||||
{
|
||||
SDL_Surface *ret = TryOpenFile( sPath, bHeaderOnly, error, *it, bKeepTrying );
|
||||
RageSurface *ret = TryOpenFile( sPath, bHeaderOnly, error, *it, bKeepTrying );
|
||||
if( ret )
|
||||
{
|
||||
LOG->Warn("File \"%s\" is really %s", sPath.c_str(), it->c_str());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef RAGE_SURFACE_LOAD_H
|
||||
#define RAGE_SURFACE_LOAD_H
|
||||
|
||||
struct SDL_Surface;
|
||||
struct RageSurface;
|
||||
namespace RageSurfaceUtils
|
||||
{
|
||||
enum OpenResult
|
||||
@@ -13,7 +13,7 @@ namespace RageSurfaceUtils
|
||||
|
||||
/* If bHeaderOnly is true, the loader is only required to return a surface
|
||||
* with the width and height set (but may return a complete surface). */
|
||||
SDL_Surface *LoadFile( const CString &sPath, bool bHeaderOnly=false );
|
||||
RageSurface *LoadFile( const CString &sPath, bool bHeaderOnly=false );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
#define MAXCOLORMAPSIZE 256
|
||||
|
||||
@@ -18,11 +19,11 @@
|
||||
#define LM_to_uint(a,b) (((b)<<8)|(a))
|
||||
|
||||
|
||||
static SDL_Surface *ReadImage( RageFile &f, int len, int height,
|
||||
const SDL_Color localColorMap[MAXCOLORMAPSIZE],
|
||||
static RageSurface *ReadImage( RageFile &f, int len, int height,
|
||||
const RageSurfaceColor localColorMap[MAXCOLORMAPSIZE],
|
||||
int interlace, int ignore );
|
||||
|
||||
static bool ReadPalette( RageFile &f, int number, SDL_Color buffer[MAXCOLORMAPSIZE] )
|
||||
static bool ReadPalette( RageFile &f, int number, RageSurfaceColor buffer[MAXCOLORMAPSIZE] )
|
||||
{
|
||||
for( int i = 0; i < number; ++i )
|
||||
{
|
||||
@@ -32,7 +33,7 @@ static bool ReadPalette( RageFile &f, int number, SDL_Color buffer[MAXCOLORMAPSI
|
||||
return false;
|
||||
if( !ReadOK(f, &buffer[i].b, sizeof(buffer[i].b)) )
|
||||
return false;
|
||||
buffer[i].unused = 0xFF;
|
||||
buffer[i].a = 0xFF;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -58,7 +59,7 @@ static int GetDataBlock( RageFile &f, unsigned char *buf )
|
||||
}
|
||||
|
||||
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error )
|
||||
{
|
||||
unsigned char buf[256];
|
||||
int imageCount = 0;
|
||||
@@ -100,7 +101,7 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Sur
|
||||
return RageSurfaceUtils::OPEN_FATAL_ERROR;
|
||||
}
|
||||
|
||||
SDL_Color GlobalColorMap[MAXCOLORMAPSIZE];
|
||||
RageSurfaceColor GlobalColorMap[MAXCOLORMAPSIZE];
|
||||
unsigned int GlobalBitPixel = 0;
|
||||
|
||||
GlobalBitPixel = 2 << (buf[4] & 0x07);
|
||||
@@ -172,7 +173,7 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Sur
|
||||
}
|
||||
|
||||
int bitPixel = 1 << ((buf[8] & 0x07) + 1);
|
||||
SDL_Color LocalColorMap[MAXCOLORMAPSIZE];
|
||||
RageSurfaceColor LocalColorMap[MAXCOLORMAPSIZE];
|
||||
|
||||
if( BitSet(buf[8], LOCALCOLORMAP) )
|
||||
{
|
||||
@@ -194,7 +195,7 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Sur
|
||||
continue;
|
||||
|
||||
if( transparency != -1 )
|
||||
mySDL_AddColorKey( ret, transparency );
|
||||
ret->format->palette->colors[ transparency ].a = 0;
|
||||
|
||||
return RageSurfaceUtils::OPEN_OK;
|
||||
}
|
||||
@@ -388,8 +389,8 @@ int LWZState::ReadByte( RageFile &f )
|
||||
return code;
|
||||
}
|
||||
|
||||
static SDL_Surface *ReadImage( RageFile &f, int len, int height,
|
||||
const SDL_Color localColorMap[MAXCOLORMAPSIZE],
|
||||
static RageSurface *ReadImage( RageFile &f, int len, int height,
|
||||
const RageSurfaceColor localColorMap[MAXCOLORMAPSIZE],
|
||||
int interlace, int ignore )
|
||||
{
|
||||
int xpos = 0, ypos = 0, pass = 0;
|
||||
@@ -409,8 +410,8 @@ static SDL_Surface *ReadImage( RageFile &f, int len, int height,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_Surface *image = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, len, height, 8, 0, 0, 0, 0 );
|
||||
mySDL_SetPalette( image, localColorMap, 0, 256 );
|
||||
RageSurface *image = CreateSurface( len, height, 8, 0, 0, 0, 0 );
|
||||
memcpy( image->fmt.palette->colors, localColorMap, 256*sizeof(RageSurfaceColor) );
|
||||
|
||||
int v;
|
||||
while( (v = state.ReadByte(f)) >= 0 )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RAGE_SURFACE_LOAD_GIF_H
|
||||
|
||||
#include "RageSurface_Load.h"
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
@@ -105,7 +106,7 @@ void RageFile_JPEG_term_source( j_decompress_ptr cinfo )
|
||||
{
|
||||
}
|
||||
|
||||
static SDL_Surface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char errorbuf[JMSG_LENGTH_MAX] )
|
||||
static RageSurface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char errorbuf[JMSG_LENGTH_MAX] )
|
||||
{
|
||||
struct jpeg_decompress_struct cinfo;
|
||||
|
||||
@@ -114,7 +115,7 @@ static SDL_Surface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char err
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
jerr.pub.output_message = my_output_message;
|
||||
|
||||
SDL_Surface *volatile img = NULL; /* volatile to prevent possible problems with setjmp */
|
||||
RageSurface *volatile img = NULL; /* volatile to prevent possible problems with setjmp */
|
||||
|
||||
if( setjmp(jerr.setjmp_buffer) )
|
||||
{
|
||||
@@ -122,8 +123,7 @@ static SDL_Surface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char err
|
||||
memcpy( errorbuf, myerr->errorbuf, JMSG_LENGTH_MAX );
|
||||
|
||||
jpeg_destroy_decompress( &cinfo );
|
||||
if( img )
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -164,17 +164,17 @@ static SDL_Surface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char err
|
||||
|
||||
if( cinfo.out_color_space == JCS_GRAYSCALE )
|
||||
{
|
||||
img = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, cinfo.output_width, cinfo.output_height, 8, 0, 0, 0, 0 );
|
||||
img = CreateSurface( cinfo.output_width, cinfo.output_height, 8, 0, 0, 0, 0 );
|
||||
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
SDL_Color color;
|
||||
RageSurfaceColor color;
|
||||
color.r = color.g = color.b = (int8_t) i;
|
||||
color.unused = 0xFF;
|
||||
mySDL_SetPalette( img, &color, i, 1 );
|
||||
color.a = 0xFF;
|
||||
img->fmt.palette->colors[i] = color;
|
||||
}
|
||||
} else {
|
||||
img = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, cinfo.output_width, cinfo.output_height, 24,
|
||||
img = CreateSurface( cinfo.output_width, cinfo.output_height, 24,
|
||||
Swap24BE( 0xFF0000 ),
|
||||
Swap24BE( 0x00FF00 ),
|
||||
Swap24BE( 0x0000FF ),
|
||||
@@ -195,7 +195,7 @@ static SDL_Surface *RageSurface_Load_JPEG( RageFile *f, const char *fn, char err
|
||||
}
|
||||
|
||||
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_JPEG( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error )
|
||||
{
|
||||
RageFile f;
|
||||
if( !f.Open( sPath ) )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RAGE_SURFACE_LOAD_JPEG_H
|
||||
|
||||
#include "RageSurface_Load.h"
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_JPEG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_JPEG( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#include "libpng/include/png.h"
|
||||
@@ -51,7 +52,7 @@ static void PNG_Warning( png_struct *png, const char *warning )
|
||||
|
||||
/* Since libpng forces us to use longjmp (gross!), this function shouldn't create any C++
|
||||
* objects, and needs to watch out for memleaks. */
|
||||
static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char errorbuf[1024], bool bHeaderOnly )
|
||||
static RageSurface *RageSurface_Load_PNG( RageFile *f, const char *fn, char errorbuf[1024], bool bHeaderOnly )
|
||||
{
|
||||
error_info error;
|
||||
error.err = errorbuf;
|
||||
@@ -72,12 +73,11 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_Surface *volatile img = NULL;
|
||||
RageSurface *volatile img = NULL;
|
||||
if( setjmp(png_jmpbuf(png)) )
|
||||
{
|
||||
png_destroy_read_struct( &png, &info_ptr, NULL );
|
||||
if( img )
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
* the image. Just return an empty surface with only the width and height set. */
|
||||
if( bHeaderOnly )
|
||||
{
|
||||
img = SDL_CreateRGBSurfaceFrom( NULL, width, height, 32, width*4, 0, 0, 0, 0 );
|
||||
img = CreateSurfaceFrom( width, height, 32, 0, 0, 0, 0, NULL, width*4 );
|
||||
png_destroy_read_struct( &png, &info_ptr, NULL );
|
||||
if( !img )
|
||||
{
|
||||
@@ -113,7 +113,7 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
png_set_gray_1_2_4_to_8( png );
|
||||
|
||||
/* These are set for type == PALETTE. */
|
||||
SDL_Color colors[256];
|
||||
RageSurfaceColor colors[256];
|
||||
int iColorKey = -1;
|
||||
|
||||
/* We import three types of files: paletted, RGBX and RGBA. The only difference
|
||||
@@ -127,7 +127,7 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
for( int i = 0; i < 256; ++i )
|
||||
{
|
||||
colors[i].r = colors[i].g = colors[i].b = (int8_t) i;
|
||||
colors[i].unused = 0xFF;
|
||||
colors[i].a = 0xFF;
|
||||
}
|
||||
|
||||
type = PALETTE;
|
||||
@@ -185,9 +185,9 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
colors[i].r = palette[i].red;
|
||||
colors[i].g = palette[i].green;
|
||||
colors[i].b = palette[i].blue;
|
||||
colors[i].unused = 0xFF;
|
||||
colors[i].a = 0xFF;
|
||||
if( i < num_trans )
|
||||
colors[i].unused = trans[i];
|
||||
colors[i].a = trans[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,16 +198,16 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
switch( type )
|
||||
{
|
||||
case PALETTE:
|
||||
img = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, width, height, 8, 0, 0, 0, 0 );
|
||||
mySDL_SetPalette( img, colors, 0, 256 );
|
||||
img = CreateSurface( width, height, 8, 0, 0, 0, 0 );
|
||||
memcpy( img->fmt.palette->colors, colors, 256*sizeof(RageSurfaceColor) );
|
||||
|
||||
if( iColorKey != -1 )
|
||||
mySDL_AddColorKey( img, iColorKey );
|
||||
img->format->palette->colors[ iColorKey ].a = 0;
|
||||
|
||||
break;
|
||||
case RGBX:
|
||||
case RGBA:
|
||||
img = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, width, height, 32,
|
||||
img = CreateSurface( width, height, 32,
|
||||
Swap32BE( 0xFF000000 ),
|
||||
Swap32BE( 0x00FF0000 ),
|
||||
Swap32BE( 0x0000FF00 ),
|
||||
@@ -236,7 +236,7 @@ static SDL_Surface *RageSurface_Load_PNG( RageFile *f, const char *fn, char erro
|
||||
}
|
||||
|
||||
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error )
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_PNG( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error )
|
||||
{
|
||||
RageFile f;
|
||||
if( !f.Open( sPath ) )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define RAGE_SURFACE_LOAD_PNG_H
|
||||
|
||||
#include "RageSurface_Load.h"
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_PNG( const CString &sPath, SDL_Surface *&ret, bool bHeaderOnly, CString &error );
|
||||
RageSurfaceUtils::OpenResult RageSurface_Load_PNG( const CString &sPath, RageSurface *&ret, bool bHeaderOnly, CString &error );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
#define CheckLine() \
|
||||
if( xpm[line] == NULL ) { \
|
||||
@@ -13,7 +14,7 @@
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
RageSurface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
{
|
||||
int line = 0;
|
||||
|
||||
@@ -32,7 +33,7 @@ SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vector<SDL_Color> colors;
|
||||
vector<RageSurfaceColor> colors;
|
||||
|
||||
map<CString,int> name_to_color;
|
||||
for( int i = 0; i < num_colors; ++i )
|
||||
@@ -55,24 +56,24 @@ SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
int r, g, b;
|
||||
if( sscanf( clr, "%2x%2x%2x", &r, &g, &b ) != 3 )
|
||||
continue;
|
||||
SDL_Color colorval;
|
||||
RageSurfaceColor colorval;
|
||||
colorval.r = (uint8_t) r;
|
||||
colorval.g = (uint8_t) g;
|
||||
colorval.b = (uint8_t) b;
|
||||
colorval.unused = 0xFF;
|
||||
colorval.a = 0xFF;
|
||||
|
||||
colors.push_back( colorval );
|
||||
|
||||
name_to_color[name] = colors.size()-1;
|
||||
}
|
||||
|
||||
SDL_Surface *img;
|
||||
RageSurface *img;
|
||||
if( colors.size() <= 256 )
|
||||
{
|
||||
img = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, width, height, 8, 0, 0, 0, 0 );
|
||||
mySDL_SetPalette( img, &colors[0], 0, colors.size() );
|
||||
img = CreateSurface( width, height, 8, 0, 0, 0, 0 );
|
||||
memcpy( img->fmt.palette->colors, &colors[0], colors.size()*sizeof(RageSurfaceColor) );
|
||||
} else {
|
||||
img = SDL_CreateRGBSurfaceSane( SDL_SWSURFACE, width, height, 32,
|
||||
img = CreateSurface( width, height, 32,
|
||||
0xFF000000, 0x00FF0000, 0x0000FF00, 0 );
|
||||
}
|
||||
|
||||
@@ -83,7 +84,7 @@ SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
if( (int) row.size() != width*color_length )
|
||||
{
|
||||
error = ssprintf( "row %i is not expected length (%i != %i)", y, int(row.size()), width*color_length );
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
if( it == name_to_color.end() )
|
||||
{
|
||||
error = ssprintf( "%ix%i is unknown color \"%s\"", x, y, color_name.c_str() );
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error )
|
||||
{
|
||||
p[x] = (int8_t) it->second;
|
||||
} else {
|
||||
const SDL_Color &color = colors[it->second];
|
||||
const RageSurfaceColor &color = colors[it->second];
|
||||
p32[x] = (color.r << 24) + (color.g << 16) + (color.b << 8);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef RAGE_SURFACE_LOAD_XPM_H
|
||||
#define RAGE_SURFACE_LOAD_XPM_H
|
||||
|
||||
struct SDL_Surface;
|
||||
SDL_Surface *RageSurface_Load_XPM( char * const *xpm, CString &error );
|
||||
struct RageSurface;
|
||||
RageSurface *RageSurface_Load_XPM( char * const *xpm, CString &error );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "SDL.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
@@ -95,10 +96,10 @@ static void jpeg_SDL_RW_dest( jpeg::j_compress_ptr cinfo, SDL_RWops *ctx )
|
||||
}
|
||||
|
||||
/* Save a JPEG to a file. cjpeg.c and example.c from jpeglib were helpful in writing this. */
|
||||
void IMG_SaveJPG_RW( SDL_Surface *surface, SDL_RWops *dest, bool bHighQual )
|
||||
void IMG_SaveJPG_RW( RageSurface *surface, SDL_RWops *dest, bool bHighQual )
|
||||
{
|
||||
SDL_Surface *dst_surface;
|
||||
if( ConvertSDLSurface( surface, dst_surface,
|
||||
RageSurface *dst_surface;
|
||||
if( RageSurfaceUtils::ConvertSurface( surface, dst_surface,
|
||||
surface->w, surface->h, 24, Swap24BE(0xFF0000), Swap24BE(0x00FF00), Swap24BE(0x0000FF), 0 ) )
|
||||
surface = dst_surface;
|
||||
|
||||
@@ -150,8 +151,7 @@ void IMG_SaveJPG_RW( SDL_Surface *surface, SDL_RWops *dest, bool bHighQual )
|
||||
jpeg::jpeg_finish_compress( &cinfo );
|
||||
jpeg::jpeg_destroy_compress( &cinfo );
|
||||
|
||||
if( dst_surface )
|
||||
SDL_FreeSurface( dst_surface );
|
||||
delete dst_surface;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef SDL_SAVE_JPEG_H
|
||||
#define SDL_SAVE_JPEG_H
|
||||
|
||||
struct SDL_Surface;
|
||||
void IMG_SaveJPG_RW( SDL_Surface *surface, SDL_RWops *dest, bool bHighQual=true );
|
||||
struct RageSurface;
|
||||
void IMG_SaveJPG_RW( RageSurface *surface, SDL_RWops *dest, bool bHighQual=true );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "global.h"
|
||||
|
||||
#include "RageUtil.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_dither.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
|
||||
#define DitherMatDim 4
|
||||
|
||||
@@ -52,7 +52,7 @@ static uint8_t DitherPixel(int x, int y, int intensity, int conv)
|
||||
return uint8_t((out_intensity + 1) >> 16);
|
||||
}
|
||||
|
||||
void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
void SM_SDL_OrderedDither(const RageSurface *src, RageSurface *dst)
|
||||
{
|
||||
static bool DitherMatCalc_initted = false;
|
||||
if( !DitherMatCalc_initted )
|
||||
@@ -75,8 +75,8 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
ASSERT( dst->format->BytesPerPixel > 1 );
|
||||
|
||||
uint32_t src_cbits[4], dst_cbits[4];
|
||||
mySDL_GetBitsPerChannel( src->format, src_cbits );
|
||||
mySDL_GetBitsPerChannel( dst->format, dst_cbits );
|
||||
RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits );
|
||||
RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits );
|
||||
|
||||
/* Calculate the ratio from the old bit depth to the new for each color channel. */
|
||||
int conv[4];
|
||||
@@ -104,7 +104,7 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
for( int col = 0; col < src->w; ++col )
|
||||
{
|
||||
uint8_t colors[4];
|
||||
mySDL_GetRawRGBAV( srcp, src, colors );
|
||||
RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors );
|
||||
|
||||
/* Note that we don't dither the alpha channel. */
|
||||
for( int c = 0; c < 3; ++c )
|
||||
@@ -135,7 +135,7 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
}
|
||||
|
||||
/* Raw value -> int -> pixel */
|
||||
mySDL_SetRawRGBAV(dstp, dst, colors);
|
||||
RageSurfaceUtils::SetRawRGBAV(dstp, dst, colors);
|
||||
|
||||
srcp += src->format->BytesPerPixel;
|
||||
dstp += dst->format->BytesPerPixel;
|
||||
@@ -167,14 +167,14 @@ void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
/* This is very similar to SM_SDL_OrderedDither, except instead of using a matrix
|
||||
* containing rounding values, we truncate and then add the resulting error for
|
||||
* each pixel to the next pixel on the same line. (Maybe we could do both?) */
|
||||
void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
void SM_SDL_ErrorDiffusionDither(const RageSurface *src, RageSurface *dst)
|
||||
{
|
||||
/* We can't dither to paletted surfaces. */
|
||||
ASSERT( dst->format->BytesPerPixel > 1 );
|
||||
|
||||
uint32_t src_cbits[4], dst_cbits[4];
|
||||
mySDL_GetBitsPerChannel( src->format, src_cbits );
|
||||
mySDL_GetBitsPerChannel( dst->format, dst_cbits );
|
||||
RageSurfaceUtils::GetBitsPerChannel( src->format, src_cbits );
|
||||
RageSurfaceUtils::GetBitsPerChannel( dst->format, dst_cbits );
|
||||
|
||||
/* Calculate the ratio from the old bit depth to the new for each color channel. */
|
||||
int conv[4];
|
||||
@@ -204,7 +204,7 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
for( int col = 0; col < src->w; ++col )
|
||||
{
|
||||
uint8_t colors[4];
|
||||
mySDL_GetRawRGBAV( srcp, src, colors );
|
||||
RageSurfaceUtils::GetRawRGBAV( srcp, src->fmt, colors );
|
||||
|
||||
for( int c = 0; c < 3; ++c )
|
||||
{
|
||||
@@ -264,7 +264,7 @@ void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst)
|
||||
colors[3] = uint8_t((out_intensity + 32767) >> 16);
|
||||
}
|
||||
|
||||
mySDL_SetRawRGBAV( dstp, dst, colors );
|
||||
RageSurfaceUtils::SetRawRGBAV( dstp, dst, colors );
|
||||
|
||||
srcp += src->format->BytesPerPixel;
|
||||
dstp += dst->format->BytesPerPixel;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef SM_SDL_DITHER_H
|
||||
#define SM_SDL_DITHER_H
|
||||
|
||||
struct SDL_Surface;
|
||||
void SM_SDL_OrderedDither(const SDL_Surface *src, SDL_Surface *dst);
|
||||
void SM_SDL_ErrorDiffusionDither(const SDL_Surface *src, SDL_Surface *dst);
|
||||
struct RageSurface;
|
||||
void SM_SDL_OrderedDither(const RageSurface *src, RageSurface *dst);
|
||||
void SM_SDL_ErrorDiffusionDither(const RageSurface *src, RageSurface *dst);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "SDL_rotozoom.h"
|
||||
#include "SDL.h"
|
||||
#include "RageSurface.h"
|
||||
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
@@ -13,7 +13,7 @@ using namespace std;
|
||||
* lines.)
|
||||
*/
|
||||
|
||||
static void ZoomSurface( SDL_Surface * src, SDL_Surface * dst )
|
||||
static void ZoomSurface( RageSurface * src, RageSurface * dst )
|
||||
{
|
||||
/* Ratio from source to dest. */
|
||||
const float sx = float(src->w) / dst->w;
|
||||
@@ -121,7 +121,7 @@ static void ZoomSurface( SDL_Surface * src, SDL_Surface * dst )
|
||||
}
|
||||
|
||||
|
||||
void zoomSurface( SDL_Surface *&src, int dstwidth, int dstheight )
|
||||
void zoomSurface( RageSurface *&src, int dstwidth, int dstheight )
|
||||
{
|
||||
if( src == NULL )
|
||||
return;
|
||||
@@ -140,14 +140,14 @@ void zoomSurface( SDL_Surface *&src, int dstwidth, int dstheight )
|
||||
int target_width = int(src->w*xscale + .5);
|
||||
int target_height = int(src->h*yscale + .5);
|
||||
|
||||
SDL_Surface *dst =
|
||||
SDL_CreateRGBSurface(SDL_SWSURFACE, target_width, target_height, 32,
|
||||
RageSurface *dst =
|
||||
CreateSurface(target_width, target_height, 32,
|
||||
src->format->Rmask, src->format->Gmask,
|
||||
src->format->Bmask, src->format->Amask);
|
||||
|
||||
ZoomSurface( src, dst );
|
||||
|
||||
SDL_FreeSurface(src);
|
||||
delete src;
|
||||
|
||||
src = dst;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef SDL_ROTOZOOM_H
|
||||
#define SDL_ROTOZOOM_H
|
||||
|
||||
struct SDL_Surface;
|
||||
void zoomSurface( SDL_Surface *&src, int dstwidth, int dstheight );
|
||||
struct RageSurface;
|
||||
void zoomSurface( RageSurface *&src, int dstwidth, int dstheight );
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+82
-1083
File diff suppressed because it is too large
Load Diff
@@ -10,78 +10,27 @@
|
||||
#include "SDL_syswm.h" // for SDL_SysWMinfo
|
||||
#undef Font
|
||||
#undef Screen
|
||||
|
||||
Uint32 decodepixel(const Uint8 *p, int bpp);
|
||||
void encodepixel(Uint8 *p, int bpp, Uint32 pixel);
|
||||
|
||||
void mySDL_GetRawRGBAV(Uint32 pixel, const SDL_Surface *src, Uint8 *v);
|
||||
void mySDL_GetRawRGBAV(const Uint8 *p, const SDL_Surface *src, Uint8 *v);
|
||||
void mySDL_GetRGBAV(Uint32 pixel, const SDL_Surface *src, Uint8 *v);
|
||||
void mySDL_GetRGBAV(const Uint8 *p, const SDL_Surface *src, Uint8 *v);
|
||||
|
||||
Uint32 mySDL_SetRawRGBAV(const SDL_PixelFormat *fmt, const Uint8 *v);
|
||||
void mySDL_SetRawRGBAV(Uint8 *p, const SDL_Surface *src, const Uint8 *v);
|
||||
Uint32 mySDL_SetRGBAV(const SDL_PixelFormat *fmt, const Uint8 *v);
|
||||
void mySDL_SetRGBAV(Uint8 *p, const SDL_Surface *src, const Uint8 *v);
|
||||
|
||||
void mySDL_GetBitsPerChannel(const SDL_PixelFormat *fmt, Uint32 bits[4]);
|
||||
void mySDL_SetPalette( SDL_Surface *dst, const SDL_Color *colors, int start, int cnt );
|
||||
void CopySDLSurface( SDL_Surface *src, SDL_Surface *dest );
|
||||
bool ConvertSDLSurface( SDL_Surface *src, SDL_Surface *&dst,
|
||||
int width, int height, int bpp,
|
||||
Uint32 R, Uint32 G, Uint32 B, Uint32 A );
|
||||
void ConvertSDLSurface(SDL_Surface *&image,
|
||||
int width, int height, int bpp,
|
||||
Uint32 R, Uint32 G, Uint32 B, Uint32 A);
|
||||
SDL_Surface *SDL_CreateRGBSurfaceSane
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
|
||||
void FixHiddenAlpha(SDL_Surface *img);
|
||||
struct RageSurface;
|
||||
|
||||
/* Check for an event; return true if one was waiting. */
|
||||
bool SDL_GetEvent(SDL_Event &event, int mask);
|
||||
|
||||
/* Change the event state without dropping extra events. */
|
||||
Uint8 mySDL_EventState(Uint8 type, int state);
|
||||
uint8_t mySDL_EventState(uint8_t type, int state);
|
||||
|
||||
void mySDL_GetAllEvents(vector<SDL_Event> &events);
|
||||
void mySDL_PushEvents(vector<SDL_Event> &events);
|
||||
|
||||
/* The surface contains no transparent pixels and/or never uses its color
|
||||
* key, so it doesn't need any alpha bits at all. */
|
||||
#define TRAIT_NO_TRANSPARENCY 0x0001 /* 0alpha */
|
||||
/* The surface contains only transparent values of 0 or 1; no translucency.
|
||||
* It only needs one bit of alpha. */
|
||||
#define TRAIT_BOOL_TRANSPARENCY 0x0002 /* 1alpha */
|
||||
int FindSurfaceTraits(const SDL_Surface *img);
|
||||
|
||||
|
||||
void mySDL_WM_SetIcon( CString sIconFile );
|
||||
|
||||
bool mySDL_SaveSurface( SDL_Surface *img, CString file );
|
||||
SDL_Surface *mySDL_LoadSurface( CString file );
|
||||
|
||||
bool mySDL_MapRGBExact( SDL_PixelFormat *fmt, Uint8 R, Uint8 G, Uint8 B, Uint32 &color );
|
||||
|
||||
void mySDL_BlitTransform( const SDL_Surface *src, SDL_Surface *dst,
|
||||
const float fCoords[8] /* TL, BR, BL, TR */ );
|
||||
void mySDL_BlitSurface(
|
||||
SDL_Surface *src, SDL_Surface *dst, int width, int height, bool ckey);
|
||||
|
||||
SDL_Surface *mySDL_Palettize( SDL_Surface *src_surf, int GrayBits, int AlphaBits );
|
||||
|
||||
void mySDL_FixupPalettedAlpha( SDL_Surface *img );
|
||||
void mySDL_AddColorKey( SDL_Surface *img, Uint32 color );
|
||||
void ApplyHotPinkColorKey( SDL_Surface *&img );
|
||||
|
||||
class RageFile;
|
||||
void OpenRWops( SDL_RWops *rw, RageFile *f );
|
||||
void OpenRWops( SDL_RWops *rw, CString *sBuf );
|
||||
SDL_Surface *mySDL_MakeDummySurface( int height, int width );
|
||||
|
||||
CString mySDL_GetError();
|
||||
|
||||
void mySDL_WM_SetIcon( CString sIconFile );
|
||||
SDL_Surface *SDLSurfaceFromRageSurface( RageSurface *surf );
|
||||
RageSurface *RageSurfaceFromSDLSurface( SDL_Surface *surf );
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "arch/arch.h"
|
||||
#include "RageFile.h"
|
||||
#include "RageFileManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include "NoteDataUtil.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "ProfileManager.h"
|
||||
@@ -697,7 +698,7 @@ void Song::TidyUpData()
|
||||
|
||||
CString sPath = m_sSongDir + arrayImages[i];
|
||||
/* We only care about the dimensions. */
|
||||
SDL_Surface *img = RageSurfaceUtils::LoadFile( sPath, true );
|
||||
RageSurface *img = RageSurfaceUtils::LoadFile( sPath, true );
|
||||
if( !img )
|
||||
{
|
||||
LOG->Trace("Couldn't load '%s': %s", sPath.c_str(), SDL_GetError());
|
||||
@@ -706,7 +707,7 @@ void Song::TidyUpData()
|
||||
|
||||
const int width = img->w;
|
||||
const int height = img->h;
|
||||
SDL_FreeSurface( img );
|
||||
delete img;
|
||||
|
||||
if( !HasBackground() && width >= 320 && height >= 240 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user