use RageSurface

This commit is contained in:
Glenn Maynard
2004-06-14 01:09:11 +00:00
parent b481fc465b
commit 66fb9eece6
7 changed files with 53 additions and 38 deletions
@@ -14,7 +14,7 @@
#include "archutils/win32/WindowsResources.h" #include "archutils/win32/WindowsResources.h"
#include <mmsystem.h> #include <mmsystem.h>
#pragma comment(lib, "winmm.lib") // for GetMicrosecondsSinceStart #pragma comment(lib, "winmm.lib") // for timeGetTime
ArchHooks_Win32::ArchHooks_Win32() ArchHooks_Win32::ArchHooks_Win32()
{ {
@@ -7,6 +7,8 @@
#include "LoadingWindow_SDL.h" #include "LoadingWindow_SDL.h"
#include "loading.xpm" #include "loading.xpm"
#include "StepMania.xpm" /* icon */ #include "StepMania.xpm" /* icon */
#include "RageSurface.h"
#include "RageSurfaceUtils.h"
/* XXX: What is all this Xbox junk doing in LoadingWindow_SDL? */ /* XXX: What is all this Xbox junk doing in LoadingWindow_SDL? */
@@ -27,34 +29,40 @@ LoadingWindow_SDL::LoadingWindow_SDL()
SDL_WM_SetCaption("Loading StepMania", ""); SDL_WM_SetCaption("Loading StepMania", "");
CString error; CString error;
SDL_Surface *srf = RageSurface_Load_XPM( icon, error ); RageSurface *srf = RageSurface_Load_XPM( icon, error );
Uint32 color; uint32_t color;
if( mySDL_MapRGBExact( srf->format, 0xFF, 0, 0xFF, color ) ) if( srf->fmt.MapRGBA( 0xFF, 0, 0xFF, 0xFF, color ) )
mySDL_AddColorKey( srf, color ); srf->format->palette->colors[ color ].a = 0;
#if !defined(DARWIN) || !DARWIN #if !defined(DARWIN)
/* Windows icons are 32x32 and SDL can't resize them for us, which /* Windows icons are 32x32 and SDL can't resize them for us, which
* causes mask corruption. (Actually, the above icon *is* 32x32; * causes mask corruption. (Actually, the above icon *is* 32x32;
* this is here just in case it changes.) */ * this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h, RageSurfaceUtils::ConvertSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
zoomSurface(srf, 32, 32); zoomSurface(srf, 32, 32);
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE ); {
SDL_WM_SetIcon(srf, NULL /* derive from alpha */); SDL_Surface *pSDLSurface = SDLSurfaceFromRageSurface( srf );
SDL_FreeSurface(srf);
SDL_SetAlpha( pSDLSurface, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon( pSDLSurface, NULL ); /* derive from alpha */
SDL_FreeSurface( pSDLSurface );
}
delete srf;
#endif #endif
/* Load the BMP - we need its dimensions */ /* Load the BMP - we need its dimensions */
SDL_Surface *image = RageSurface_Load_XPM( loading, error ); srf = RageSurface_Load_XPM( loading, error );
if( image == NULL ) if( srf == NULL ) // XXX SDL_GetError
RageException::Throw("Couldn't load loading.bmp: %s",SDL_GetError()); RageException::Throw( "Couldn't load loading.bmp: %s",SDL_GetError() );
/* Initialize the window */ /* Initialize the window */
loading_screen = SDL_SetVideoMode(image->w, image->h, 16, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_NOFRAME); loading_screen = SDL_SetVideoMode( srf->w, srf->h, 16, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_NOFRAME );
if( loading_screen == NULL ) if( loading_screen == NULL )
RageException::Throw( "Couldn't initialize loading window: %s", SDL_GetError() ); RageException::Throw( "Couldn't initialize loading window: %s", SDL_GetError() );
@@ -86,12 +94,15 @@ LoadingWindow_SDL::LoadingWindow_SDL()
#endif #endif
SDL_BlitSurface(image, NULL, loading_screen, NULL); {
SDL_Surface *pSDLSurface = SDLSurfaceFromRageSurface( srf );
SDL_BlitSurface( pSDLSurface, NULL, loading_screen, NULL );
SDL_FreeSurface( pSDLSurface );
}
SDL_FreeSurface(image); delete srf;
SDL_UpdateRect(loading_screen, 0,0,0,0); SDL_UpdateRect( loading_screen, 0,0,0,0 );
SDL_UpdateRect(loading_screen, 0,0,0,0);
} }
#ifdef _XBOX #ifdef _XBOX
@@ -5,19 +5,20 @@
#include "RageFileManager.h" #include "RageFileManager.h"
#include "archutils/win32/WindowsResources.h" #include "archutils/win32/WindowsResources.h"
#include <windows.h> #include <windows.h>
#include "SDL_utils.h"
#include "RageSurface_Load.h" #include "RageSurface_Load.h"
#include "RageSurface.h"
#include "RageSurfaceUtils.h"
static HBITMAP g_hBitmap = NULL; static HBITMAP g_hBitmap = NULL;
/* Load a file into a GDI surface. */ /* Load a file into a GDI surface. */
HBITMAP LoadWin32Surface( CString fn ) HBITMAP LoadWin32Surface( CString fn )
{ {
SDL_Surface *s = RageSurfaceUtils::LoadFile( fn ); RageSurface *s = RageSurfaceUtils::LoadFile( fn );
if( s == NULL ) if( s == NULL )
return NULL; return NULL;
ConvertSDLSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 ); RageSurfaceUtils::ConvertSurface( s, s->w, s->h, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0 );
HBITMAP bitmap = CreateCompatibleBitmap( GetDC(NULL), s->w, s->h ); HBITMAP bitmap = CreateCompatibleBitmap( GetDC(NULL), s->w, s->h );
ASSERT( bitmap ); ASSERT( bitmap );
@@ -40,7 +41,7 @@ HBITMAP LoadWin32Surface( CString fn )
SelectObject( BitmapDC, NULL ); SelectObject( BitmapDC, NULL );
DeleteObject( BitmapDC ); DeleteObject( BitmapDC );
SDL_FreeSurface( s ); delete s;
return bitmap; return bitmap;
} }
@@ -18,6 +18,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageException.h" #include "RageException.h"
#include "RageSurface.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include "SDL_utils.h" #include "SDL_utils.h"
@@ -212,14 +213,14 @@ void MovieTexture_DShow::CheckFrame()
CreateTexture(); CreateTexture();
// DirectShow feeds us in BGR8 // DirectShow feeds us in BGR8
SDL_Surface *fromDShow = SDL_CreateRGBSurfaceFrom( RageSurface *fromDShow = CreateSurfaceFrom(
(void*)buffer, m_iSourceWidth, m_iSourceHeight, m_iSourceWidth, m_iSourceHeight,
24, 24,
m_iSourceWidth*3,
0xFF0000, 0xFF0000,
0x00FF00, 0x00FF00,
0x0000FF, 0x0000FF,
0x000000 ); 0x000000,
(uint8_t *) buffer, m_iSourceWidth*3 );
/* Optimization notes: /* Optimization notes:
* *
@@ -239,7 +240,7 @@ void MovieTexture_DShow::CheckFrame()
m_iImageWidth, m_iImageHeight ); m_iImageWidth, m_iImageHeight );
CHECKPOINT; CHECKPOINT;
SDL_FreeSurface( fromDShow ); delete fromDShow;
buffer = NULL; buffer = NULL;
@@ -464,12 +465,12 @@ void MovieTexture_DShow::CreateTexture()
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt); const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
SDL_Surface *img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, m_iTextureWidth, m_iTextureHeight, RageSurface *img = CreateSurface( m_iTextureWidth, m_iTextureHeight,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]); pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, img, false ); m_uTexHandle = DISPLAY->CreateTexture( pixfmt, img, false );
SDL_FreeSurface( img ); delete img;
} }
@@ -6,6 +6,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageTimer.h" #include "RageTimer.h"
#include "RageFile.h" #include "RageFile.h"
#include "RageSurface.h"
#include "SDL_utils.h" #include "SDL_utils.h"
#include "PrefsManager.h" #include "PrefsManager.h"
@@ -629,7 +630,7 @@ void MovieTexture_FFMpeg::DestroyTexture()
{ {
if( m_img ) if( m_img )
{ {
SDL_FreeSurface( m_img ); delete m_img;
m_img=NULL; m_img=NULL;
} }
if(m_uTexHandle) if(m_uTexHandle)
@@ -712,8 +713,8 @@ void MovieTexture_FFMpeg::CreateTexture()
LOG->Trace("format %i, %08x %08x %08x %08x", LOG->Trace("format %i, %08x %08x %08x %08x",
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]); pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
m_img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, m_iTextureWidth, m_iTextureHeight, m_img = CreateSurface( m_iTextureWidth, m_iTextureHeight, pfd->bpp,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]); pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
} }
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, m_img, false ); m_uTexHandle = DISPLAY->CreateTexture( pixfmt, m_img, false );
@@ -65,7 +65,7 @@ private:
unsigned m_uTexHandle; unsigned m_uTexHandle;
SDL_Surface *m_img; RageSurface *m_img;
int m_AVTexfmt; /* AVPixelFormat_t of m_img */ int m_AVTexfmt; /* AVPixelFormat_t of m_img */
SDL_sem *m_BufferFinished; SDL_sem *m_BufferFinished;
@@ -6,6 +6,7 @@
#include "RageException.h" #include "RageException.h"
#include "MovieTexture_Null.h" #include "MovieTexture_Null.h"
#include "SDL_utils.h" #include "SDL_utils.h"
#include "RageSurface.h"
MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID) MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
{ {
@@ -30,12 +31,12 @@ MovieTexture_Null::MovieTexture_Null(RageTextureID ID) : RageMovieTexture(ID)
RageDisplay::PixelFormat pixfmt = RageDisplay::FMT_RGBA4; RageDisplay::PixelFormat pixfmt = RageDisplay::FMT_RGBA4;
const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc( pixfmt ); const RageDisplay::PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc( pixfmt );
SDL_Surface *img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, size, size, pfd->bpp, pfd->masks[0], RageSurface *img = CreateSurface( size, size, pfd->bpp,
pfd->masks[1], pfd->masks[2], pfd->masks[3]); pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
texHandle = DISPLAY->CreateTexture( pixfmt, img, false ); texHandle = DISPLAY->CreateTexture( pixfmt, img, false );
SDL_FreeSurface(img); delete img;
} }
MovieTexture_Null::~MovieTexture_Null() MovieTexture_Null::~MovieTexture_Null()