# HG changeset patch # User Sam Lantinga # Date 1227569136 0 # Node ID 5651642f4a78d47796773de5b4ee3172f71f2777 # Parent cc15254e44b6e9053a3f3040ee377ce99fbc77ac Added software fallback for YUV overlay code when YUV textures aren't available. diff -r cc15254e44b6 -r 5651642f4a78 VisualC/tests/testoverlay/testoverlay.dsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VisualC/tests/testoverlay/testoverlay.dsp Mon Nov 24 23:25:36 2008 +0000 @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="testoverlay" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=testoverlay - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "testoverlay.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "testoverlay.mak" CFG="testoverlay - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "testoverlay - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "testoverlay - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "testoverlay - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "testoverlay - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "testoverlay - Win32 Release" +# Name "testoverlay - Win32 Debug" +# Begin Source File + +SOURCE=..\..\Sdl\Debug\SDL.lib +# End Source File +# Begin Source File + +SOURCE=..\..\SDLmain\Debug\SDLmain.lib +# End Source File +# Begin Source File + +SOURCE=..\..\..\test\testoverlay.c +# End Source File +# End Target +# End Project diff -r cc15254e44b6 -r 5651642f4a78 VisualC/tests/testoverlay/testoverlay.vcproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VisualC/tests/testoverlay/testoverlay.vcproj Mon Nov 24 23:25:36 2008 +0000 @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r cc15254e44b6 -r 5651642f4a78 VisualC/tests/testoverlay2/testoverlay2.dsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VisualC/tests/testoverlay2/testoverlay2.dsp Mon Nov 24 23:25:36 2008 +0000 @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="testoverlay2" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=testoverlay2 - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "testoverlay2.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "testoverlay2.mak" CFG="testoverlay2 - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "testoverlay2 - Win32 Release" (based on "Win32 (x86) Application") +!MESSAGE "testoverlay2 - Win32 Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "testoverlay2 - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386 + +!ELSEIF "$(CFG)" == "testoverlay2 - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD CPP /nologo /MD /W3 /Gm /GX /Zi /Od /I "..\..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "testoverlay2 - Win32 Release" +# Name "testoverlay2 - Win32 Debug" +# Begin Source File + +SOURCE=..\..\Sdl\Debug\SDL.lib +# End Source File +# Begin Source File + +SOURCE=..\..\SDLmain\Debug\SDLmain.lib +# End Source File +# Begin Source File + +SOURCE=..\..\..\test\testoverlay2.c +# End Source File +# End Target +# End Project diff -r cc15254e44b6 -r 5651642f4a78 VisualC/tests/testoverlay2/testoverlay2.vcproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VisualC/tests/testoverlay2/testoverlay2.vcproj Mon Nov 24 23:25:36 2008 +0000 @@ -0,0 +1,217 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r cc15254e44b6 -r 5651642f4a78 VisualC/tests/tests.dsw --- a/VisualC/tests/tests.dsw Mon Nov 24 21:43:02 2008 +0000 +++ b/VisualC/tests/tests.dsw Mon Nov 24 23:25:36 2008 +0000 @@ -99,6 +99,30 @@ ############################################################################### +Project: "testoverlay"=".\testoverlay\testoverlay.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "testoverlay2"=".\testoverlay2\testoverlay2.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "testpalette"=".\testpalette\testpalette.dsp" - Package Owner=<4> Package=<5> diff -r cc15254e44b6 -r 5651642f4a78 VisualC/tests/tests.sln --- a/VisualC/tests/tests.sln Mon Nov 24 21:43:02 2008 +0000 +++ b/VisualC/tests/tests.sln Mon Nov 24 23:25:36 2008 +0000 @@ -28,6 +28,10 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "checkkeys", "checkkeys\checkkeys.vcproj", "{26828762-C95D-4637-9CB1-7F0979523813}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay", "testoverlay\testoverlay.vcproj", "{9E320A14-B443-4DD7-8725-B7020DCFF730}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testoverlay2", "testoverlay2\testoverlay2.vcproj", "{B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -90,6 +94,14 @@ {26828762-C95D-4637-9CB1-7F0979523813}.Debug|Win32.Build.0 = Debug|Win32 {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.ActiveCfg = Release|Win32 {26828762-C95D-4637-9CB1-7F0979523813}.Release|Win32.Build.0 = Release|Win32 + {9E320A14-B443-4DD7-8725-B7020DCFF730}.Debug|Win32.ActiveCfg = Debug|Win32 + {9E320A14-B443-4DD7-8725-B7020DCFF730}.Debug|Win32.Build.0 = Debug|Win32 + {9E320A14-B443-4DD7-8725-B7020DCFF730}.Release|Win32.ActiveCfg = Release|Win32 + {9E320A14-B443-4DD7-8725-B7020DCFF730}.Release|Win32.Build.0 = Release|Win32 + {B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Debug|Win32.ActiveCfg = Debug|Win32 + {B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Debug|Win32.Build.0 = Debug|Win32 + {B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|Win32.ActiveCfg = Release|Win32 + {B51E0D74-F0A2-45A2-BD2A-8B7D95B8204A}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff -r cc15254e44b6 -r 5651642f4a78 src/SDL_compat.c --- a/src/SDL_compat.c Mon Nov 24 21:43:02 2008 +0000 +++ b/src/SDL_compat.c Mon Nov 24 23:25:36 2008 +0000 @@ -28,6 +28,7 @@ #include "video/SDL_sysvideo.h" #include "video/SDL_pixels_c.h" +#include "video/SDL_yuv_sw_c.h" static SDL_WindowID SDL_VideoWindow = 0; static SDL_RendererInfo SDL_VideoRendererInfo; @@ -1349,6 +1350,8 @@ Uint16 pitches[3]; Uint8 *planes[3]; + SDL_SW_YUVTexture *sw; + SDL_TextureID textureID; }; @@ -1431,7 +1434,20 @@ overlay->hwdata->textureID = SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h); - if (!overlay->hwdata->textureID) { + if (overlay->hwdata->textureID) { + overlay->hwdata->sw = NULL; + } else { + overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h); + if (!overlay->hwdata->sw) { + SDL_FreeYUVOverlay(overlay); + return NULL; + } + + /* Create a supported RGB format texture for display */ + overlay->hwdata->textureID = + SDL_CreateTexture(SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h); + } + if (!overlay->hwdata->textureID) { SDL_FreeYUVOverlay(overlay); return NULL; } @@ -1449,10 +1465,16 @@ SDL_SetError("Passed a NULL overlay"); return -1; } - if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) - < 0) { - return -1; - } + if (overlay->hwdata->sw) { + if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch) < 0) { + return -1; + } + } else { + if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) + < 0) { + return -1; + } + } overlay->pixels[0] = (Uint8 *) pixels; overlay->pitches[0] = pitch; switch (overlay->format) { @@ -1479,7 +1501,22 @@ if (!overlay) { return; } - SDL_UnlockTexture(overlay->hwdata->textureID); + if (overlay->hwdata->sw) { + void *pixels; + int pitch; + if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) == 0) { + SDL_Rect srcrect; + + srcrect.x = 0; + srcrect.y = 0; + srcrect.w = overlay->w; + srcrect.h = overlay->h; + SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect, SDL_PIXELFORMAT_RGB888, overlay->w, overlay->h, pixels, pitch); + SDL_UnlockTexture(overlay->hwdata->textureID); + } + } else { + SDL_UnlockTexture(overlay->hwdata->textureID); + } } int diff -r cc15254e44b6 -r 5651642f4a78 src/stdlib/SDL_stdlib.c --- a/src/stdlib/SDL_stdlib.c Mon Nov 24 21:43:02 2008 +0000 +++ b/src/stdlib/SDL_stdlib.c Mon Nov 24 23:25:36 2008 +0000 @@ -90,7 +90,6 @@ } void -__declspec(naked) _ftol2_sse() { _ftol(); diff -r cc15254e44b6 -r 5651642f4a78 src/video/SDL_renderer_sw.c --- a/src/video/SDL_renderer_sw.c Mon Nov 24 21:43:02 2008 +0000 +++ b/src/video/SDL_renderer_sw.c Mon Nov 24 23:25:36 2008 +0000 @@ -361,7 +361,7 @@ SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - texture->driverdata = SDL_SW_CreateYUVTexture(texture); + texture->driverdata = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); } else { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; diff -r cc15254e44b6 -r 5651642f4a78 src/video/SDL_yuv_sw.c --- a/src/video/SDL_yuv_sw.c Mon Nov 24 21:43:02 2008 +0000 +++ b/src/video/SDL_yuv_sw.c Mon Nov 24 23:25:36 2008 +0000 @@ -91,9 +91,9 @@ struct SDL_SW_YUVTexture { - SDL_Texture *texture; - + Uint32 format; Uint32 target_format; + int w, h; Uint8 *pixels; int *colortab; Uint32 *rgb_2_pix; @@ -974,7 +974,7 @@ } /* You have chosen wisely... */ - switch (swdata->texture->format) { + switch (swdata->format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: if (SDL_BYTESPERPIXEL(target_format) == 2) { @@ -982,7 +982,7 @@ /* inline assembly functions */ if (SDL_HasMMX() && (Rmask == 0xF800) && (Gmask == 0x07E0) && (Bmask == 0x001F) - && (swdata->texture->w & 15) == 0) { + && (swdata->w & 15) == 0) { /*printf("Using MMX 16-bit 565 dither\n");*/ swdata->Display1X = Color565DitherYV12MMX1X; } else { @@ -1003,7 +1003,7 @@ /* inline assembly functions */ if (SDL_HasMMX() && (Rmask == 0x00FF0000) && (Gmask == 0x0000FF00) && - (Bmask == 0x000000FF) && (swdata->texture->w & 15) == 0) { + (Bmask == 0x000000FF) && (swdata->w & 15) == 0) { /*printf("Using MMX 32-bit dither\n");*/ swdata->Display1X = ColorRGBDitherYV12MMX1X; } else { @@ -1045,7 +1045,7 @@ } SDL_SW_YUVTexture * -SDL_SW_CreateYUVTexture(SDL_Texture * texture) +SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) { SDL_SW_YUVTexture *swdata; int *Cr_r_tab; @@ -1061,7 +1061,7 @@ return NULL; } - switch (texture->format) { + switch (format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: case SDL_PIXELFORMAT_YUY2: @@ -1073,9 +1073,11 @@ return NULL; } - swdata->texture = texture; + swdata->format = format; swdata->target_format = SDL_PIXELFORMAT_UNKNOWN; - swdata->pixels = (Uint8 *) SDL_malloc(texture->w * texture->h * 2); + swdata->w = w; + swdata->h = h; + swdata->pixels = (Uint8 *) SDL_malloc(w * h * 2); swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int)); swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32)); if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) { @@ -1101,22 +1103,22 @@ } /* Find the pitch and offset values for the overlay */ - switch (texture->format) { + switch (format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: - swdata->pitches[0] = texture->w; + swdata->pitches[0] = w; swdata->pitches[1] = swdata->pitches[0] / 2; swdata->pitches[2] = swdata->pitches[0] / 2; swdata->planes[0] = swdata->pixels; swdata->planes[1] = - swdata->planes[0] + swdata->pitches[0] * texture->h; + swdata->planes[0] + swdata->pitches[0] * h; swdata->planes[2] = - swdata->planes[1] + swdata->pitches[1] * texture->h / 2; + swdata->planes[1] + swdata->pitches[1] * h / 2; break; case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_UYVY: case SDL_PIXELFORMAT_YVYU: - swdata->pitches[0] = texture->w * 2; + swdata->pitches[0] = w * 2; swdata->planes[0] = swdata->pixels; break; default: @@ -1141,19 +1143,17 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, const void *pixels, int pitch) { - SDL_Texture *texture = swdata->texture; - - switch (texture->format) { + switch (swdata->format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: if (rect - && (rect->x != 0 || rect->y != 0 || rect->w != texture->w - || rect->h != texture->h)) { + && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w + || rect->h != swdata->h)) { SDL_SetError ("YV12 and IYUV textures only support full surface updates"); return -1; } - SDL_memcpy(swdata->pixels, pixels, texture->h * texture->w * 2); + SDL_memcpy(swdata->pixels, pixels, swdata->h * swdata->w * 2); break; case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_UYVY: @@ -1183,14 +1183,12 @@ SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, int markDirty, void **pixels, int *pitch) { - SDL_Texture *texture = swdata->texture; - - switch (texture->format) { + switch (swdata->format) { case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: if (rect - && (rect->x != 0 || rect->y != 0 || rect->w != texture->w - || rect->h != texture->h)) { + && (rect->x != 0 || rect->y != 0 || rect->w != swdata->w + || rect->h != swdata->h)) { SDL_SetError ("YV12 and IYUV textures only support full surface locks"); return -1; @@ -1213,7 +1211,6 @@ Uint32 target_format, int w, int h, void *pixels, int pitch) { - SDL_Texture *texture = swdata->texture; int stretch; int scale_2x; Uint8 *lum, *Cr, *Cb; @@ -1228,8 +1225,8 @@ stretch = 0; scale_2x = 0; - if (srcrect->x || srcrect->y || srcrect->w < texture->w - || srcrect->h < texture->h) { + if (srcrect->x || srcrect->y || srcrect->w < swdata->w + || srcrect->h < swdata->h) { /* The source rectangle has been clipped. Using a scratch surface is easier than adding clipped source support to all the blitters, plus that would @@ -1268,7 +1265,7 @@ SDL_PixelFormatEnumToMasks(target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); swdata->stretch = - SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, + SDL_CreateRGBSurface(0, swdata->w, swdata->h, bpp, Rmask, Gmask, Bmask, Amask); if (!swdata->stretch) { return (-1); @@ -1277,7 +1274,7 @@ pixels = swdata->stretch->pixels; pitch = swdata->stretch->pitch; } - switch (texture->format) { + switch (swdata->format) { case SDL_PIXELFORMAT_YV12: lum = swdata->planes[0]; Cr = swdata->planes[1]; @@ -1310,13 +1307,13 @@ mod = (pitch / SDL_BYTESPERPIXEL(target_format)); if (scale_2x) { - mod -= (texture->w * 2); + mod -= (swdata->w * 2); swdata->Display2X(swdata->colortab, swdata->rgb_2_pix, - lum, Cr, Cb, pixels, texture->h, texture->w, mod); + lum, Cr, Cb, pixels, swdata->h, swdata->w, mod); } else { - mod -= texture->w; + mod -= swdata->w; swdata->Display1X(swdata->colortab, swdata->rgb_2_pix, - lum, Cr, Cb, pixels, texture->h, texture->w, mod); + lum, Cr, Cb, pixels, swdata->h, swdata->w, mod); } if (stretch) { SDL_Rect rect = *srcrect; diff -r cc15254e44b6 -r 5651642f4a78 src/video/SDL_yuv_sw_c.h --- a/src/video/SDL_yuv_sw_c.h Mon Nov 24 21:43:02 2008 +0000 +++ b/src/video/SDL_yuv_sw_c.h Mon Nov 24 23:25:36 2008 +0000 @@ -28,7 +28,7 @@ typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture; -SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_Texture * texture); +SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h); int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, int *pitch); int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, diff -r cc15254e44b6 -r 5651642f4a78 src/video/win32/SDL_gdirender.c --- a/src/video/win32/SDL_gdirender.c Mon Nov 24 21:43:02 2008 +0000 +++ b/src/video/win32/SDL_gdirender.c Mon Nov 24 23:25:36 2008 +0000 @@ -294,7 +294,7 @@ texture->driverdata = data; if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - data->yuv = SDL_SW_CreateYUVTexture(texture); + data->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); if (!data->yuv) { return -1; }