mirror of https://github.com/libsdl-org/SDL
Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure. The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect(). SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types. SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value. SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
This commit is contained in:
parent
40ed098ce8
commit
2ba76dbe80
|
@ -558,6 +558,7 @@
|
|||
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_surface_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
|
||||
|
|
|
@ -436,6 +436,7 @@
|
|||
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_surface_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
|
||||
|
|
|
@ -185,6 +185,7 @@
|
|||
<ClInclude Include="..\src\video\SDL_pixels_c.h" />
|
||||
<ClInclude Include="..\src\video\SDL_rect_c.h" />
|
||||
<ClInclude Include="..\src\video\SDL_RLEaccel_c.h" />
|
||||
<ClInclude Include="..\src\video\SDL_surface_c.h" />
|
||||
<ClInclude Include="..\src\video\SDL_sysvideo.h" />
|
||||
<ClInclude Include="..\src\video\SDL_sysvidocapture.h" />
|
||||
<ClInclude Include="..\src\video\SDL_yuv_c.h" />
|
||||
|
|
|
@ -438,6 +438,9 @@
|
|||
<ClInclude Include="..\src\video\SDL_RLEaccel_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\video\SDL_surface_c.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\video\SDL_sysvideo.h">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -464,6 +464,7 @@
|
|||
<ClInclude Include="..\..\src\video\SDL_pixels_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_rect_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_surface_c.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
|
||||
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
|
||||
|
|
|
@ -615,6 +615,9 @@
|
|||
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h">
|
||||
<Filter>video</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\SDL_surface_c.h">
|
||||
<Filter>video</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\video\SDL_blit.h">
|
||||
<Filter>video</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1566,7 +1566,7 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
|
|||
@@
|
||||
@@
|
||||
- SDL_AllocFormat
|
||||
+ SDL_CreatePixelFormat
|
||||
+ SDL_GetPixelFormatDetails
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
|
@ -1575,23 +1575,18 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
|
|||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_FreeFormat
|
||||
+ SDL_DestroyPixelFormat
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_FreePalette
|
||||
+ SDL_DestroyPalette
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_MasksToPixelFormatEnum
|
||||
+ SDL_GetPixelFormatEnumForMasks
|
||||
+ SDL_GetPixelFormatForMasks
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_PixelFormatEnumToMasks
|
||||
+ SDL_GetMasksForPixelFormatEnum
|
||||
+ SDL_GetMasksForPixelFormat
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
|
@ -3488,3 +3483,21 @@ typedef SDL_Colour, SDL_Color;
|
|||
@@
|
||||
- SDLK_z
|
||||
+ SDLK_Z
|
||||
@@
|
||||
typedef SDL_PixelFormat, SDL_PackedPixelDetails;
|
||||
@@
|
||||
- SDL_PixelFormat
|
||||
+ SDL_PixelFormatDetails
|
||||
@@
|
||||
@@
|
||||
- SDL_ConvertSurfaceFormat
|
||||
+ SDL_ConvertSurface
|
||||
(...)
|
||||
@@
|
||||
@@
|
||||
- SDL_PREALLOC
|
||||
+ SDL_SURFACE_PREALLOCATED
|
||||
@@
|
||||
@@
|
||||
- SDL_SIMD_ALIGNED
|
||||
+ SDL_SURFACE_SIMD_ALIGNED
|
||||
|
|
|
@ -15,7 +15,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
screenSurface = SDL_GetWindowSurface(window);
|
||||
SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xff, 0xff, 0xff));
|
||||
SDL_FillSurfaceRect(screenSurface, NULL, SDL_MapSurfaceRGB(screenSurface, 0xff, 0xff, 0xff));
|
||||
SDL_UpdateWindowSurface(window);
|
||||
SDL_Delay(100);
|
||||
SDL_DestroyWindow(window);
|
||||
|
|
|
@ -1092,19 +1092,22 @@ The following symbols have been renamed:
|
|||
|
||||
## SDL_pixels.h
|
||||
|
||||
SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types.
|
||||
|
||||
SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
|
||||
|
||||
SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
|
||||
|
||||
SDL_GetMasksForPixelFormat() now returns the standard int error code.
|
||||
|
||||
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).
|
||||
|
||||
The BitsPerPixel and BytesPerPixel fields of SDL_PixelFormat have been renamed bits_per_pixel and bytes_per_pixel.
|
||||
|
||||
SDL_PixelFormatEnum is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
|
||||
|
||||
The following functions have been renamed:
|
||||
* SDL_AllocFormat() => SDL_CreatePixelFormat()
|
||||
* SDL_AllocFormat() => SDL_GetPixelFormatDetails()
|
||||
* SDL_AllocPalette() => SDL_CreatePalette()
|
||||
* SDL_FreeFormat() => SDL_DestroyPixelFormat()
|
||||
* SDL_FreePalette() => SDL_DestroyPalette()
|
||||
* SDL_MasksToPixelFormatEnum() => SDL_GetPixelFormatEnumForMasks()
|
||||
* SDL_PixelFormatEnumToMasks() => SDL_GetMasksForPixelFormatEnum()
|
||||
* SDL_MasksToPixelFormatEnum() => SDL_GetPixelFormatForMasks()
|
||||
* SDL_PixelFormatEnumToMasks() => SDL_GetMasksForPixelFormat()
|
||||
|
||||
The following symbols have been renamed:
|
||||
* SDL_PIXELFORMAT_BGR444 => SDL_PIXELFORMAT_XBGR4444
|
||||
|
@ -1114,9 +1117,16 @@ The following symbols have been renamed:
|
|||
* SDL_PIXELFORMAT_RGB555 => SDL_PIXELFORMAT_XRGB1555
|
||||
* SDL_PIXELFORMAT_RGB888 => SDL_PIXELFORMAT_XRGB8888
|
||||
|
||||
The following functions have been removed:
|
||||
* SDL_FreeFormat()
|
||||
* SDL_SetPixelFormatPalette()
|
||||
|
||||
The following macros have been removed:
|
||||
* SDL_Colour - use SDL_Color instead
|
||||
|
||||
The following structures have been renamed:
|
||||
* SDL_PixelFormat => SDL_PixelFormatDetails
|
||||
|
||||
## SDL_platform.h
|
||||
|
||||
The following platform preprocessor macros have been renamed:
|
||||
|
@ -1598,19 +1608,23 @@ The following functions have been removed:
|
|||
|
||||
## SDL_surface.h
|
||||
|
||||
SDL_Surface has been simplified and internal details are no longer in the public structure.
|
||||
|
||||
The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect().
|
||||
|
||||
The userdata member of SDL_Surface has been replaced with a more general properties interface, which can be queried with SDL_GetSurfaceProperties()
|
||||
|
||||
Removed unused 'flags' parameter from SDL_ConvertSurface and SDL_ConvertSurfaceFormat.
|
||||
Removed the unused 'flags' parameter from SDL_ConvertSurface.
|
||||
|
||||
SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceWithFormat() have been combined into a new function SDL_CreateSurface().
|
||||
SDL_CreateRGBSurfaceFrom() and SDL_CreateRGBSurfaceWithFormatFrom() have been combined into a new function SDL_CreateSurfaceFrom().
|
||||
SDL_CreateRGBSurfaceFrom() and SDL_CreateRGBSurfaceWithFormatFrom() have been combined into a new function SDL_CreateSurfaceFrom(), and the parameter order has changed for consistency with SDL_CreateSurface().
|
||||
|
||||
You can implement the old functions in your own code easily:
|
||||
```c
|
||||
SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
return SDL_CreateSurface(width, height,
|
||||
SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
|
||||
SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask));
|
||||
}
|
||||
|
||||
SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
|
||||
|
@ -1620,13 +1634,14 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height,
|
|||
|
||||
SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
return SDL_CreateSurfaceFrom(pixels, width, height, pitch,
|
||||
SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
|
||||
return SDL_CreateSurfaceFrom(width, height,
|
||||
SDL_GetPixelFormatForMasks(depth, Rmask, Gmask, Bmask, Amask),
|
||||
pixels, pitch);
|
||||
}
|
||||
|
||||
SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)
|
||||
{
|
||||
return SDL_CreateSurfaceFrom(pixels, width, height, pitch, format);
|
||||
return SDL_CreateSurfaceFrom(width, height, format, pixels, pitch);
|
||||
}
|
||||
|
||||
```
|
||||
|
@ -1645,10 +1660,15 @@ SDL_BlitSurfaceScaled() and SDL_BlitSurfaceUncheckedScaled() now take a scale pa
|
|||
|
||||
SDL_SoftStretch() now takes a scale paramater.
|
||||
|
||||
SDL_PixelFormatEnum is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
|
||||
SDL_PixelFormat is used instead of Uint32 for API functions that refer to pixel format by enumerated value.
|
||||
|
||||
SDL_SetSurfaceColorKey() takes an SDL_bool to enable and disable colorkey. RLE acceleration isn't controlled by the parameter, you should use SDL_SetSurfaceRLE() to change that separately.
|
||||
|
||||
SDL_SetSurfaceRLE() takes an SDL_bool to enable and disable RLE acceleration.
|
||||
|
||||
The following functions have been renamed:
|
||||
* SDL_BlitScaled() => SDL_BlitSurfaceScaled()
|
||||
* SDL_ConvertSurfaceFormat() => SDL_ConvertSurface()
|
||||
* SDL_FillRect() => SDL_FillSurfaceRect()
|
||||
* SDL_FillRects() => SDL_FillSurfaceRects()
|
||||
* SDL_FreeSurface() => SDL_DestroySurface()
|
||||
|
@ -1669,11 +1689,16 @@ The following symbols have been removed:
|
|||
* SDL_SWSURFACE
|
||||
|
||||
The following functions have been removed:
|
||||
* SDL_FreeFormat()
|
||||
* SDL_GetYUVConversionMode()
|
||||
* SDL_GetYUVConversionModeForResolution()
|
||||
* SDL_SetYUVConversionMode() - use SDL_SetSurfaceColorspace() to set the surface colorspace and SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER with SDL_CreateTextureWithProperties() to set the texture colorspace. The default colorspace for YUV pixel formats is SDL_COLORSPACE_JPEG.
|
||||
* SDL_SoftStretchLinear() - use SDL_SoftStretch() with SDL_SCALEMODE_LINEAR
|
||||
|
||||
The following symbols have been renamed:
|
||||
* SDL_PREALLOC => SDL_SURFACE_PREALLOCATED
|
||||
* SDL_SIMD_ALIGNED => SDL_SURFACE_SIMD_ALIGNED
|
||||
|
||||
## SDL_system.h
|
||||
|
||||
SDL_WindowsMessageHook has changed signatures so the message may be modified and it can block further message processing.
|
||||
|
@ -1835,7 +1860,7 @@ The callback passed to SDL_AddTimer() has changed parameters to:
|
|||
Uint32 SDLCALL TimerCallback(void *userdata, SDL_TimerID timerID, Uint32 interval);
|
||||
````
|
||||
|
||||
The return value of SDL_RemoveTimer() has changed to the standard int error code.
|
||||
SDL_RemoveTimer() now returns the standard int error code.
|
||||
|
||||
## SDL_touch.h
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ typedef struct SDL_Camera SDL_Camera;
|
|||
*/
|
||||
typedef struct SDL_CameraSpec
|
||||
{
|
||||
SDL_PixelFormatEnum format; /**< Frame format */
|
||||
SDL_PixelFormat format; /**< Frame format */
|
||||
SDL_Colorspace colorspace; /**< Frame colorspace */
|
||||
int width; /**< Frame width */
|
||||
int height; /**< Frame height */
|
||||
|
|
|
@ -453,19 +453,18 @@
|
|||
#define SDL_sem SDL_Semaphore
|
||||
|
||||
/* ##SDL_pixels.h */
|
||||
#define SDL_AllocFormat SDL_CreatePixelFormat
|
||||
#define SDL_AllocFormat SDL_GetPixelFormatDetails
|
||||
#define SDL_AllocPalette SDL_CreatePalette
|
||||
#define SDL_Colour SDL_Color
|
||||
#define SDL_FreeFormat SDL_DestroyPixelFormat
|
||||
#define SDL_FreePalette SDL_DestroyPalette
|
||||
#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatEnumForMasks
|
||||
#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatForMasks
|
||||
#define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_XBGR4444
|
||||
#define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_XBGR1555
|
||||
#define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_XBGR8888
|
||||
#define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_XRGB4444
|
||||
#define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_XRGB1555
|
||||
#define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_XRGB8888
|
||||
#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormatEnum
|
||||
#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormat
|
||||
|
||||
/* ##SDL_rect.h */
|
||||
#define SDL_EncloseFPoints SDL_GetRectEnclosingPointsFloat
|
||||
|
@ -580,6 +579,7 @@
|
|||
|
||||
/* ##SDL_surface.h */
|
||||
#define SDL_BlitScaled SDL_BlitSurfaceScaled
|
||||
#define SDL_ConvertSurfaceFormat SDL_ConvertSurface
|
||||
#define SDL_FillRect SDL_FillSurfaceRect
|
||||
#define SDL_FillRects SDL_FillSurfaceRects
|
||||
#define SDL_FreeSurface SDL_DestroySurface
|
||||
|
@ -590,6 +590,8 @@
|
|||
#define SDL_LoadBMP_RW SDL_LoadBMP_IO
|
||||
#define SDL_LowerBlit SDL_BlitSurfaceUnchecked
|
||||
#define SDL_LowerBlitScaled SDL_BlitSurfaceUncheckedScaled
|
||||
#define SDL_PREALLOC SDL_SURFACE_PREALLOCATED
|
||||
#define SDL_SIMD_ALIGNED SDL_SURFACE_SIMD_ALIGNED
|
||||
#define SDL_SaveBMP_RW SDL_SaveBMP_IO
|
||||
#define SDL_SetClipRect SDL_SetSurfaceClipRect
|
||||
#define SDL_SetColorKey SDL_SetSurfaceColorKey
|
||||
|
@ -1048,19 +1050,18 @@
|
|||
#define SDL_sem SDL_sem_renamed_SDL_Semaphore
|
||||
|
||||
/* ##SDL_pixels.h */
|
||||
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat
|
||||
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_GetPixelFormatDetails
|
||||
#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette
|
||||
#define SDL_Colour SDL_Colour_renamed_SDL_Color
|
||||
#define SDL_FreeFormat SDL_FreeFormat_renamed_SDL_DestroyPixelFormat
|
||||
#define SDL_FreePalette SDL_FreePalette_renamed_SDL_DestroyPalette
|
||||
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatEnumForMasks
|
||||
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatForMasks
|
||||
#define SDL_PIXELFORMAT_BGR444 SDL_PIXELFORMAT_BGR444_renamed_SDL_PIXELFORMAT_XBGR4444
|
||||
#define SDL_PIXELFORMAT_BGR555 SDL_PIXELFORMAT_BGR555_renamed_SDL_PIXELFORMAT_XBGR1555
|
||||
#define SDL_PIXELFORMAT_BGR888 SDL_PIXELFORMAT_BGR888_renamed_SDL_PIXELFORMAT_XBGR8888
|
||||
#define SDL_PIXELFORMAT_RGB444 SDL_PIXELFORMAT_RGB444_renamed_SDL_PIXELFORMAT_XRGB4444
|
||||
#define SDL_PIXELFORMAT_RGB555 SDL_PIXELFORMAT_RGB555_renamed_SDL_PIXELFORMAT_XRGB1555
|
||||
#define SDL_PIXELFORMAT_RGB888 SDL_PIXELFORMAT_RGB888_renamed_SDL_PIXELFORMAT_XRGB8888
|
||||
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormatEnum
|
||||
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormat
|
||||
|
||||
/* ##SDL_rect.h */
|
||||
#define SDL_EncloseFPoints SDL_EncloseFPoints_renamed_SDL_GetRectEnclosingPointsFloat
|
||||
|
@ -1175,6 +1176,7 @@
|
|||
|
||||
/* ##SDL_surface.h */
|
||||
#define SDL_BlitScaled SDL_BlitScaled_renamed_SDL_BlitSurfaceScaled
|
||||
#define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_renamed_SDL_ConvertSurface
|
||||
#define SDL_FillRect SDL_FillRect_renamed_SDL_FillSurfaceRect
|
||||
#define SDL_FillRects SDL_FillRects_renamed_SDL_FillSurfaceRects
|
||||
#define SDL_FreeSurface SDL_FreeSurface_renamed_SDL_DestroySurface
|
||||
|
@ -1185,6 +1187,8 @@
|
|||
#define SDL_LoadBMP_RW SDL_LoadBMP_RW_renamed_SDL_LoadBMP_IO
|
||||
#define SDL_LowerBlit SDL_LowerBlit_renamed_SDL_BlitSurfaceUnchecked
|
||||
#define SDL_LowerBlitScaled SDL_LowerBlitScaled_renamed_SDL_BlitSurfaceUncheckedScaled
|
||||
#define SDL_PREALLOC SDL_PREALLOC_renamed_SDL_SURFACE_PREALLOCATED
|
||||
#define SDL_SIMD_ALIGNED SDL_SIMD_ALIGNED_renamed_SDL_SURFACE_SIMD_ALIGNED
|
||||
#define SDL_SaveBMP_RW SDL_SaveBMP_RW_renamed_SDL_SaveBMP_IO
|
||||
#define SDL_SetClipRect SDL_SetClipRect_renamed_SDL_SetSurfaceClipRect
|
||||
#define SDL_SetColorKey SDL_SetColorKey_renamed_SDL_SetSurfaceColorKey
|
||||
|
|
|
@ -133,7 +133,8 @@ typedef enum SDL_PackedLayout
|
|||
#define SDL_PIXELTYPE(X) (((X) >> 24) & 0x0F)
|
||||
#define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F)
|
||||
#define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F)
|
||||
#define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF)
|
||||
#define SDL_BITSPERPIXEL(X) \
|
||||
(SDL_ISPIXELFORMAT_FOURCC(X) ? 0 : (((X) >> 8) & 0xFF))
|
||||
#define SDL_BYTESPERPIXEL(X) \
|
||||
(SDL_ISPIXELFORMAT_FOURCC(X) ? \
|
||||
((((X) == SDL_PIXELFORMAT_YUY2) || \
|
||||
|
@ -222,7 +223,7 @@ typedef enum SDL_PackedLayout
|
|||
*
|
||||
* \since This enum is available since SDL 3.0.0.
|
||||
*/
|
||||
typedef enum SDL_PixelFormatEnum
|
||||
typedef enum SDL_PixelFormat
|
||||
{
|
||||
SDL_PIXELFORMAT_UNKNOWN,
|
||||
SDL_PIXELFORMAT_INDEX1LSB =
|
||||
|
@ -426,7 +427,7 @@ typedef enum SDL_PixelFormatEnum
|
|||
SDL_DEFINE_PIXELFOURCC('P', '0', '1', '0'),
|
||||
SDL_PIXELFORMAT_EXTERNAL_OES = /**< Android video texture format */
|
||||
SDL_DEFINE_PIXELFOURCC('O', 'E', 'S', ' ')
|
||||
} SDL_PixelFormatEnum;
|
||||
} SDL_PixelFormat;
|
||||
|
||||
/**
|
||||
* Pixels are a representation of a color in a particular color space.
|
||||
|
@ -721,7 +722,6 @@ typedef struct SDL_FColor
|
|||
*
|
||||
* \since This struct is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_PixelFormat
|
||||
* \sa SDL_SetPaletteColors
|
||||
*/
|
||||
typedef struct SDL_Palette
|
||||
|
@ -735,15 +735,11 @@ typedef struct SDL_Palette
|
|||
/**
|
||||
* Details about the format of a pixel.
|
||||
*
|
||||
* Generally this is used with SDL_Surface, and covers many possible
|
||||
* configurations, including paletted data and various bit patterns.
|
||||
*
|
||||
* \since This struct is available since SDL 3.0.0.
|
||||
*/
|
||||
typedef struct SDL_PixelFormat
|
||||
typedef struct SDL_PixelFormatDetails
|
||||
{
|
||||
SDL_PixelFormatEnum format;
|
||||
SDL_Palette *palette;
|
||||
SDL_PixelFormat format;
|
||||
Uint8 bits_per_pixel;
|
||||
Uint8 bytes_per_pixel;
|
||||
Uint8 padding[2];
|
||||
|
@ -751,17 +747,15 @@ typedef struct SDL_PixelFormat
|
|||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
Uint8 Rloss;
|
||||
Uint8 Gloss;
|
||||
Uint8 Bloss;
|
||||
Uint8 Aloss;
|
||||
Uint8 Rbits;
|
||||
Uint8 Gbits;
|
||||
Uint8 Bbits;
|
||||
Uint8 Abits;
|
||||
Uint8 Rshift;
|
||||
Uint8 Gshift;
|
||||
Uint8 Bshift;
|
||||
Uint8 Ashift;
|
||||
int refcount;
|
||||
struct SDL_PixelFormat *next;
|
||||
} SDL_PixelFormat;
|
||||
} SDL_PixelFormatDetails;
|
||||
|
||||
/**
|
||||
* Get the human readable name of a pixel format.
|
||||
|
@ -772,32 +766,31 @@ typedef struct SDL_PixelFormat
|
|||
* \returns the human readable name of the specified pixel format or
|
||||
* `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(SDL_PixelFormatEnum format);
|
||||
extern SDL_DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(SDL_PixelFormat format);
|
||||
|
||||
/**
|
||||
* Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
|
||||
*
|
||||
* \param format one of the SDL_PixelFormatEnum values.
|
||||
* \param format one of the SDL_PixelFormat values.
|
||||
* \param bpp a bits per pixel value; usually 15, 16, or 32.
|
||||
* \param Rmask a pointer filled in with the red mask for the format.
|
||||
* \param Gmask a pointer filled in with the green mask for the format.
|
||||
* \param Bmask a pointer filled in with the blue mask for the format.
|
||||
* \param Amask a pointer filled in with the alpha mask for the format.
|
||||
* \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
|
||||
* possible; call SDL_GetError() for more information.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetPixelFormatEnumForMasks
|
||||
* \sa SDL_GetPixelFormatForMasks
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format,
|
||||
int *bpp,
|
||||
Uint32 * Rmask,
|
||||
Uint32 * Gmask,
|
||||
Uint32 * Bmask,
|
||||
Uint32 * Amask);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask);
|
||||
|
||||
/**
|
||||
* Convert a bpp value and RGBA masks to an enumerated pixel format.
|
||||
|
@ -810,47 +803,33 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormatEnum(SDL_PixelFor
|
|||
* \param Gmask the green mask for the format.
|
||||
* \param Bmask the blue mask for the format.
|
||||
* \param Amask the alpha mask for the format.
|
||||
* \returns the SDL_PixelFormatEnum value corresponding to the format masks,
|
||||
* \returns the SDL_PixelFormat value corresponding to the format masks,
|
||||
* or SDL_PIXELFORMAT_UNKNOWN if there isn't a match.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetMasksForPixelFormatEnum
|
||||
* \sa SDL_GetMasksForPixelFormat
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_PixelFormatEnum SDLCALL SDL_GetPixelFormatEnumForMasks(int bpp,
|
||||
Uint32 Rmask,
|
||||
Uint32 Gmask,
|
||||
Uint32 Bmask,
|
||||
Uint32 Amask);
|
||||
extern SDL_DECLSPEC SDL_PixelFormat SDLCALL SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
|
||||
/**
|
||||
* Create an SDL_PixelFormat structure corresponding to a pixel format.
|
||||
* Create an SDL_PixelFormatDetails structure corresponding to a pixel format.
|
||||
*
|
||||
* Returned structure may come from a shared global cache (i.e. not newly
|
||||
* allocated), and hence should not be modified, especially the palette. Weird
|
||||
* errors such as `Blit combination not supported` may occur.
|
||||
*
|
||||
* \param pixel_format one of the SDL_PixelFormatEnum values.
|
||||
* \returns the new SDL_PixelFormat structure or NULL on failure; call
|
||||
* \param format one of the SDL_PixelFormat values.
|
||||
* \returns a pointer to a SDL_PixelFormatDetails structure or NULL on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_DestroyPixelFormat
|
||||
* \sa SDL_SetPixelFormatPalette
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_PixelFormat * SDLCALL SDL_CreatePixelFormat(SDL_PixelFormatEnum pixel_format);
|
||||
|
||||
/**
|
||||
* Free an SDL_PixelFormat structure allocated by SDL_CreatePixelFormat().
|
||||
*
|
||||
* \param format the SDL_PixelFormat structure to free.
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_CreatePixelFormat
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
|
||||
extern SDL_DECLSPEC const SDL_PixelFormatDetails * SDLCALL SDL_GetPixelFormatDetails(SDL_PixelFormat format);
|
||||
|
||||
/**
|
||||
* Create a palette structure with the specified number of color entries.
|
||||
|
@ -862,27 +841,16 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format)
|
|||
* there wasn't enough memory); call SDL_GetError() for more
|
||||
* information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_DestroyPalette
|
||||
* \sa SDL_SetPaletteColors
|
||||
* \sa SDL_SetPixelFormatPalette
|
||||
* \sa SDL_SetSurfacePalette
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Palette *SDLCALL SDL_CreatePalette(int ncolors);
|
||||
|
||||
/**
|
||||
* Set the palette for a pixel format structure.
|
||||
*
|
||||
* \param format the SDL_PixelFormat structure that will use the palette.
|
||||
* \param palette the SDL_Palette structure that will be used.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
|
||||
SDL_Palette *palette);
|
||||
|
||||
/**
|
||||
* Set a range of colors in a palette.
|
||||
*
|
||||
|
@ -893,22 +861,24 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * form
|
|||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
|
||||
const SDL_Color * colors,
|
||||
int firstcolor, int ncolors);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
* Free a palette created with SDL_CreatePalette().
|
||||
*
|
||||
* \param palette the SDL_Palette structure to be freed.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as the palette is not modified or destroyed in another thread.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_CreatePalette
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette *palette);
|
||||
|
||||
/**
|
||||
* Map an RGB triple to an opaque pixel value for a given pixel format.
|
||||
|
@ -928,20 +898,22 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
|
|||
* format the return value can be assigned to a Uint16, and similarly a Uint8
|
||||
* for an 8-bpp format).
|
||||
*
|
||||
* \param format an SDL_PixelFormat structure describing the pixel format.
|
||||
* \param format a pointer to SDL_PixelFormatDetails describing the pixel format.
|
||||
* \param palette an optional palette for indexed formats, may be NULL.
|
||||
* \param r the red component of the pixel in the range 0-255.
|
||||
* \param g the green component of the pixel in the range 0-255.
|
||||
* \param b the blue component of the pixel in the range 0-255.
|
||||
* \returns a pixel value.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as the palette is not modified.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
* \sa SDL_GetRGBA
|
||||
* \sa SDL_MapRGBA
|
||||
* \sa SDL_MapSurfaceRGB
|
||||
*/
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
|
||||
Uint8 r, Uint8 g, Uint8 b);
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
/**
|
||||
* Map an RGBA quadruple to a pixel value for a given pixel format.
|
||||
|
@ -961,23 +933,23 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
|
|||
* format the return value can be assigned to a Uint16, and similarly a Uint8
|
||||
* for an 8-bpp format).
|
||||
*
|
||||
* \param format an SDL_PixelFormat structure describing the format of the
|
||||
* pixel.
|
||||
* \param format a pointer to SDL_PixelFormatDetails describing the pixel format.
|
||||
* \param palette an optional palette for indexed formats, may be NULL.
|
||||
* \param r the red component of the pixel in the range 0-255.
|
||||
* \param g the green component of the pixel in the range 0-255.
|
||||
* \param b the blue component of the pixel in the range 0-255.
|
||||
* \param a the alpha component of the pixel in the range 0-255.
|
||||
* \returns a pixel value.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as the palette is not modified.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetRGB
|
||||
* \sa SDL_GetRGBA
|
||||
* \sa SDL_MapRGB
|
||||
* \sa SDL_MapSurfaceRGBA
|
||||
*/
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
|
||||
Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a);
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/**
|
||||
* Get RGB values from a pixel in the specified format.
|
||||
|
@ -988,11 +960,13 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
|
|||
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
|
||||
*
|
||||
* \param pixel a pixel value.
|
||||
* \param format an SDL_PixelFormat structure describing the format of the
|
||||
* pixel.
|
||||
* \param r a pointer filled in with the red component.
|
||||
* \param g a pointer filled in with the green component.
|
||||
* \param b a pointer filled in with the blue component.
|
||||
* \param format a pointer to SDL_PixelFormatDetails describing the pixel format.
|
||||
* \param palette an optional palette for indexed formats, may be NULL.
|
||||
* \param r a pointer filled in with the red component, may be NULL.
|
||||
* \param g a pointer filled in with the green component, may be NULL.
|
||||
* \param b a pointer filled in with the blue component, may be NULL.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as the palette is not modified.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
|
@ -1000,9 +974,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
|
|||
* \sa SDL_MapRGB
|
||||
* \sa SDL_MapRGBA
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b);
|
||||
|
||||
/**
|
||||
* Get RGBA values from a pixel in the specified format.
|
||||
|
@ -1016,12 +988,14 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
|
|||
* (100% opaque).
|
||||
*
|
||||
* \param pixel a pixel value.
|
||||
* \param format an SDL_PixelFormat structure describing the format of the
|
||||
* pixel.
|
||||
* \param r a pointer filled in with the red component.
|
||||
* \param g a pointer filled in with the green component.
|
||||
* \param b a pointer filled in with the blue component.
|
||||
* \param a a pointer filled in with the alpha component.
|
||||
* \param format a pointer to SDL_PixelFormatDetails describing the pixel format.
|
||||
* \param palette an optional palette for indexed formats, may be NULL.
|
||||
* \param r a pointer filled in with the red component, may be NULL.
|
||||
* \param g a pointer filled in with the green component, may be NULL.
|
||||
* \param b a pointer filled in with the blue component, may be NULL.
|
||||
* \param a a pointer filled in with the alpha component, may be NULL.
|
||||
*
|
||||
* \threadsafety It is safe to call this function from any thread, as long as the palette is not modified.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
|
@ -1029,10 +1003,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
|
|||
* \sa SDL_MapRGB
|
||||
* \sa SDL_MapRGBA
|
||||
*/
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
||||
const SDL_PixelFormat * format,
|
||||
Uint8 * r, Uint8 * g, Uint8 * b,
|
||||
Uint8 * a);
|
||||
extern SDL_DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
|
|
|
@ -350,8 +350,7 @@ extern SDL_DECLSPEC const char *SDLCALL SDL_GetRendererName(SDL_Renderer *render
|
|||
* - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting
|
||||
* - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width
|
||||
* and height
|
||||
* - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormatEnum
|
||||
* *) array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
|
||||
* - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *) array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
|
||||
* representing the available texture formats for this renderer.
|
||||
* - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace value
|
||||
* describing the colorspace for output to the display, defaults to
|
||||
|
@ -485,7 +484,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *ren
|
|||
* Create a texture for a rendering context.
|
||||
*
|
||||
* \param renderer the rendering context.
|
||||
* \param format one of the enumerated values in SDL_PixelFormatEnum.
|
||||
* \param format one of the enumerated values in SDL_PixelFormat.
|
||||
* \param access one of the enumerated values in SDL_TextureAccess.
|
||||
* \param w the width of the texture in pixels.
|
||||
* \param h the height of the texture in pixels.
|
||||
|
@ -501,7 +500,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *ren
|
|||
* \sa SDL_GetTextureSize
|
||||
* \sa SDL_UpdateTexture
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Texture *SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormatEnum format, int access, int w, int h);
|
||||
extern SDL_DECLSPEC SDL_Texture *SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, int access, int w, int h);
|
||||
|
||||
/**
|
||||
* Create a texture from an existing surface.
|
||||
|
@ -540,7 +539,7 @@ extern SDL_DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureFromSurface(SDL_Render
|
|||
* SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for
|
||||
* YUV textures.
|
||||
* - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
|
||||
* SDL_PixelFormatEnum, defaults to the best RGBA format for the renderer
|
||||
* SDL_PixelFormat, defaults to the best RGBA format for the renderer
|
||||
* - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in
|
||||
* SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
|
||||
* - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in
|
||||
|
@ -672,7 +671,7 @@ extern SDL_DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureWithProperties(SDL_Ren
|
|||
* - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
|
||||
* the texture colorspace.
|
||||
* - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in
|
||||
* SDL_PixelFormatEnum.
|
||||
* SDL_PixelFormat.
|
||||
* - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in
|
||||
* SDL_TextureAccess.
|
||||
* - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.
|
||||
|
|
|
@ -45,34 +45,23 @@ extern "C" {
|
|||
/**
|
||||
* The flags on an SDL_Surface.
|
||||
*
|
||||
* These are generally meant to be considered read-only.
|
||||
* These are generally considered read-only.
|
||||
*
|
||||
* \since This datatype is available since SDL 3.0.0.
|
||||
*/
|
||||
typedef Uint32 SDL_SurfaceFlags;
|
||||
|
||||
#define SDL_PREALLOC 0x00000001u /**< Surface uses preallocated memory */
|
||||
#define SDL_RLEACCEL 0x00000002u /**< Surface is RLE encoded */
|
||||
#define SDL_DONTFREE 0x00000004u /**< Surface is referenced internally */
|
||||
#define SDL_SIMD_ALIGNED 0x00000008u /**< Surface uses aligned memory */
|
||||
#define SDL_SURFACE_USES_PROPERTIES 0x00000010u /**< Surface uses properties */
|
||||
#define SDL_SURFACE_PREALLOCATED 0x00000001u /**< Surface uses preallocated pixel memory */
|
||||
#define SDL_SURFACE_LOCK_NEEDED 0x00000002u /**< Surface needs to be locked to access pixels */
|
||||
#define SDL_SURFACE_LOCKED 0x00000004u /**< Surface is currently locked */
|
||||
#define SDL_SURFACE_SIMD_ALIGNED 0x00000008u /**< Surface uses pixel memory allocated with SDL_aligned_alloc() */
|
||||
|
||||
/**
|
||||
* Evaluates to true if the surface needs to be locked before access.
|
||||
*
|
||||
* \since This macro is available since SDL 3.0.0.
|
||||
*/
|
||||
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
|
||||
|
||||
/**
|
||||
* An opaque type used in SDL_Surface.
|
||||
*
|
||||
* This is used by SDL to keep track of how blit operations should work
|
||||
* internally; it is not for use directly by applications.
|
||||
*
|
||||
* \since This struct is available since SDL 3.0.0.
|
||||
*/
|
||||
typedef struct SDL_BlitMap SDL_BlitMap;
|
||||
#define SDL_MUSTLOCK(S) (((S)->flags & (SDL_SURFACE_LOCK_NEEDED | SDL_SURFACE_LOCKED)) == SDL_SURFACE_LOCK_NEEDED)
|
||||
|
||||
/**
|
||||
* The scaling mode.
|
||||
|
@ -98,6 +87,9 @@ typedef enum SDL_FlipMode
|
|||
SDL_FLIP_VERTICAL /**< flip vertically */
|
||||
} SDL_FlipMode;
|
||||
|
||||
/* Internal surface data */
|
||||
typedef struct SDL_SurfaceData SDL_SurfaceData;
|
||||
|
||||
/**
|
||||
* A collection of pixels used in software blitting.
|
||||
*
|
||||
|
@ -118,36 +110,24 @@ typedef enum SDL_FlipMode
|
|||
typedef struct SDL_Surface
|
||||
{
|
||||
SDL_SurfaceFlags flags; /**< Read-only */
|
||||
SDL_PixelFormat *format; /**< Read-only */
|
||||
SDL_PixelFormat format; /**< Read-only */
|
||||
int w, h; /**< Read-only */
|
||||
int pitch; /**< Read-only */
|
||||
void *pixels; /**< Read-write */
|
||||
void *pixels; /**< Read-only pointer, writable pixels if non-NULL */
|
||||
|
||||
void *reserved; /**< Private */
|
||||
int refcount; /**< Application reference count, used when freeing surface */
|
||||
|
||||
/** information needed for surfaces requiring locks */
|
||||
int locked; /**< Read-only */
|
||||
SDL_SurfaceData *internal; /**< Private */
|
||||
|
||||
/** list of BlitMap that hold a reference to this surface */
|
||||
void *list_blitmap; /**< Private */
|
||||
|
||||
/** clipping information */
|
||||
SDL_Rect clip_rect; /**< Read-only */
|
||||
|
||||
/** info for fast blit mapping to other surfaces */
|
||||
SDL_BlitMap *map; /**< Private */
|
||||
|
||||
/** Reference count -- used when freeing surface */
|
||||
int refcount; /**< Read-mostly */
|
||||
} SDL_Surface;
|
||||
|
||||
|
||||
/**
|
||||
* Allocate a new RGB surface with a specific pixel format.
|
||||
* Allocate a new surface with a specific pixel format.
|
||||
*
|
||||
* \param width the width of the surface.
|
||||
* \param height the height of the surface.
|
||||
* \param format the SDL_PixelFormatEnum for the new surface's pixel format.
|
||||
* \param format the SDL_PixelFormat for the new surface's pixel format.
|
||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
|
@ -156,11 +136,10 @@ typedef struct SDL_Surface
|
|||
* \sa SDL_CreateSurfaceFrom
|
||||
* \sa SDL_DestroySurface
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormatEnum format);
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurface(int width, int height, SDL_PixelFormat format);
|
||||
|
||||
/**
|
||||
* Allocate a new RGB surface with a specific pixel format and existing pixel
|
||||
* data.
|
||||
* Allocate a new surface with a specific pixel format and existing pixel data.
|
||||
*
|
||||
* No copy is made of the pixel data. Pixel data is not managed automatically;
|
||||
* you must free the surface before you free the pixel data.
|
||||
|
@ -171,11 +150,11 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurface(int width, int height
|
|||
* You may pass NULL for pixels and 0 for pitch to create a surface that you
|
||||
* will fill in with valid values later.
|
||||
*
|
||||
* \param pixels a pointer to existing pixel data.
|
||||
* \param width the width of the surface.
|
||||
* \param height the height of the surface.
|
||||
* \param format the SDL_PixelFormat for the new surface's pixel format.
|
||||
* \param pixels a pointer to existing pixel data.
|
||||
* \param pitch the number of bytes between each row, including padding.
|
||||
* \param format the SDL_PixelFormatEnum for the new surface's pixel format.
|
||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
|
@ -184,10 +163,10 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurface(int width, int height
|
|||
* \sa SDL_CreateSurface
|
||||
* \sa SDL_DestroySurface
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitch, SDL_PixelFormatEnum format);
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch);
|
||||
|
||||
/**
|
||||
* Free an RGB surface.
|
||||
* Free a surface.
|
||||
*
|
||||
* It is safe to pass NULL to this function.
|
||||
*
|
||||
|
@ -195,6 +174,7 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_CreateSurfaceFrom(void *pixels, int
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_CreateStackSurface
|
||||
* \sa SDL_CreateSurface
|
||||
* \sa SDL_CreateSurfaceFrom
|
||||
*/
|
||||
|
@ -254,6 +234,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac
|
|||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetSurfaceColorspace
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
|
||||
|
@ -265,14 +247,13 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, S
|
|||
* other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to query.
|
||||
* \param colorspace a pointer filled in with an SDL_ColorSpace value
|
||||
* describing the surface colorspace.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
* \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if the surface is NULL.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetSurfaceColorspace
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace *colorspace);
|
||||
extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface);
|
||||
|
||||
/**
|
||||
* Set the palette used by a surface.
|
||||
|
@ -285,9 +266,24 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface, S
|
|||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_CreatePalette
|
||||
* \sa SDL_GetSurfacePalette
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);
|
||||
|
||||
/**
|
||||
* Get the palette used by a surface.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to query.
|
||||
* \returns a pointer to the palette used by the surface, or NULL if there is no palette used.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_SetSurfacePalette
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *surface);
|
||||
|
||||
/**
|
||||
* Set up a surface for directly accessing the pixels.
|
||||
*
|
||||
|
@ -411,7 +407,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *fi
|
|||
* the surface must be locked before directly accessing the pixels.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to optimize.
|
||||
* \param flag 0 to disable, non-zero to enable RLE acceleration.
|
||||
* \param enabled SDL_TRUE to enable RLE acceleration, SDL_FALSE to disable it.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
|
@ -421,7 +417,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *fi
|
|||
* \sa SDL_LockSurface
|
||||
* \sa SDL_UnlockSurface
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, SDL_bool enabled);
|
||||
|
||||
/**
|
||||
* Returns whether the surface is RLE enabled.
|
||||
|
@ -447,11 +443,8 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
|
|||
* It is a pixel of the format used by the surface, as generated by
|
||||
* SDL_MapRGB().
|
||||
*
|
||||
* RLE acceleration can substantially speed up blitting of images with large
|
||||
* horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details.
|
||||
*
|
||||
* \param surface the SDL_Surface structure to update.
|
||||
* \param flag SDL_TRUE to enable color key, SDL_FALSE to disable color key.
|
||||
* \param enabled SDL_TRUE to enable color key, SDL_FALSE to disable color key.
|
||||
* \param key the transparent pixel.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
|
@ -459,9 +452,10 @@ extern SDL_DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
|
|||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetSurfaceColorKey
|
||||
* \sa SDL_SetSurfaceRLE
|
||||
* \sa SDL_SurfaceHasColorKey
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, SDL_bool enabled, Uint32 key);
|
||||
|
||||
/**
|
||||
* Returns whether the surface has a color key.
|
||||
|
@ -681,41 +675,19 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface *surfa
|
|||
* surface. The new, optimized surface can then be used as the source for
|
||||
* future blits, making them faster.
|
||||
*
|
||||
* If you are converting to an indexed surface and want to map colors to a palette, you can use SDL_ConvertSurfaceAndColorspace() instead.
|
||||
*
|
||||
* \param surface the existing SDL_Surface structure to convert.
|
||||
* \param format the SDL_PixelFormat structure that the new surface is
|
||||
* optimized for.
|
||||
* \param format the new pixel format.
|
||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ConvertSurfaceFormat
|
||||
* \sa SDL_ConvertSurfaceFormatAndColorspace
|
||||
* \sa SDL_CreatePixelFormat
|
||||
* \sa SDL_ConvertSurfaceAndColorspace
|
||||
* \sa SDL_DestroySurface
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format);
|
||||
|
||||
/**
|
||||
* Copy an existing surface to a new surface of the specified format.
|
||||
*
|
||||
* This function operates just like SDL_ConvertSurface(), but accepts an
|
||||
* SDL_PixelFormatEnum value instead of an SDL_PixelFormat structure. As such,
|
||||
* it might be easier to call but it doesn't have access to palette
|
||||
* information for the destination surface, in case that would be important.
|
||||
*
|
||||
* \param surface the existing SDL_Surface structure to convert.
|
||||
* \param pixel_format the new pixel format.
|
||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||
* call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ConvertSurface
|
||||
* \sa SDL_ConvertSurfaceFormatAndColorspace
|
||||
* \sa SDL_DestroySurface
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *surface, SDL_PixelFormatEnum pixel_format);
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format);
|
||||
|
||||
/**
|
||||
* Copy an existing surface to a new surface of the specified format and
|
||||
|
@ -726,7 +698,8 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *s
|
|||
* colorspace conversion needed.
|
||||
*
|
||||
* \param surface the existing SDL_Surface structure to convert.
|
||||
* \param pixel_format the new pixel format.
|
||||
* \param format the new pixel format.
|
||||
* \param palette an optional palette to use for indexed formats, may be NULL.
|
||||
* \param colorspace the new colorspace.
|
||||
* \param props an SDL_PropertiesID with additional color properties, or 0.
|
||||
* \returns the new SDL_Surface structure that is created or NULL if it fails;
|
||||
|
@ -735,20 +708,20 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *s
|
|||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_ConvertSurface
|
||||
* \sa SDL_ConvertSurfaceFormat
|
||||
* \sa SDL_ConvertSurface
|
||||
* \sa SDL_DestroySurface
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormatAndColorspace(SDL_Surface *surface, SDL_PixelFormatEnum pixel_format, SDL_Colorspace colorspace, SDL_PropertiesID props);
|
||||
extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, const SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props);
|
||||
|
||||
/**
|
||||
* Copy a block of pixels of one format to another format.
|
||||
*
|
||||
* \param width the width of the block to copy, in pixels.
|
||||
* \param height the height of the block to copy, in pixels.
|
||||
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
|
||||
* \param src_format an SDL_PixelFormat value of the `src` pixels format.
|
||||
* \param src a pointer to the source pixels.
|
||||
* \param src_pitch the pitch of the source pixels, in bytes.
|
||||
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
|
||||
* \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
|
||||
* \param dst a pointer to be filled in with new pixel data.
|
||||
* \param dst_pitch the pitch of the destination pixels, in bytes.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
|
@ -758,7 +731,7 @@ extern SDL_DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormatAndColorspace(S
|
|||
*
|
||||
* \sa SDL_ConvertPixelsAndColorspace
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormatEnum src_format, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
|
||||
|
||||
/**
|
||||
* Copy a block of pixels of one format and colorspace to another format and
|
||||
|
@ -766,14 +739,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_Pix
|
|||
*
|
||||
* \param width the width of the block to copy, in pixels.
|
||||
* \param height the height of the block to copy, in pixels.
|
||||
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
|
||||
* \param src_format an SDL_PixelFormat value of the `src` pixels format.
|
||||
* \param src_colorspace an SDL_ColorSpace value describing the colorspace of
|
||||
* the `src` pixels.
|
||||
* \param src_properties an SDL_PropertiesID with additional source color
|
||||
* properties, or 0.
|
||||
* \param src a pointer to the source pixels.
|
||||
* \param src_pitch the pitch of the source pixels, in bytes.
|
||||
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
|
||||
* \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
|
||||
* \param dst_colorspace an SDL_ColorSpace value describing the colorspace of
|
||||
* the `dst` pixels.
|
||||
* \param dst_properties an SDL_PropertiesID with additional destination color
|
||||
|
@ -787,7 +760,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, SDL_Pix
|
|||
*
|
||||
* \sa SDL_ConvertPixels
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
|
||||
/**
|
||||
* Premultiply the alpha on a block of pixels.
|
||||
|
@ -798,10 +771,10 @@ extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int he
|
|||
*
|
||||
* \param width the width of the block to convert, in pixels.
|
||||
* \param height the height of the block to convert, in pixels.
|
||||
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
|
||||
* \param src_format an SDL_PixelFormat value of the `src` pixels format.
|
||||
* \param src a pointer to the source pixels.
|
||||
* \param src_pitch the pitch of the source pixels, in bytes.
|
||||
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
|
||||
* \param dst_format an SDL_PixelFormat value of the `dst` pixels format.
|
||||
* \param dst a pointer to be filled in with premultiplied pixel data.
|
||||
* \param dst_pitch the pitch of the destination pixels, in bytes.
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
|
@ -809,7 +782,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int he
|
|||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormatEnum src_format, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch);
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch);
|
||||
|
||||
/**
|
||||
* Perform a fast fill of a rectangle with a specific color.
|
||||
|
@ -1033,6 +1006,67 @@ extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SD
|
|||
*/
|
||||
extern SDL_DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
|
||||
|
||||
/**
|
||||
* Map an RGB triple to an opaque pixel value for a surface.
|
||||
*
|
||||
* This function maps the RGB color value to the specified pixel format and
|
||||
* returns the pixel value best approximating the given RGB color value for
|
||||
* the given pixel format.
|
||||
*
|
||||
* If the surface has a palette, the index of the closest matching color
|
||||
* in the palette will be returned.
|
||||
*
|
||||
* If the surface pixel format has an alpha component it will be returned as
|
||||
* all 1 bits (fully opaque).
|
||||
*
|
||||
* If the pixel format bpp (color depth) is less than 32-bpp then the unused
|
||||
* upper bits of the return value can safely be ignored (e.g., with a 16-bpp
|
||||
* format the return value can be assigned to a Uint16, and similarly a Uint8
|
||||
* for an 8-bpp format).
|
||||
*
|
||||
* \param surface the surface to use for the pixel format and palette.
|
||||
* \param r the red component of the pixel in the range 0-255.
|
||||
* \param g the green component of the pixel in the range 0-255.
|
||||
* \param b the blue component of the pixel in the range 0-255.
|
||||
* \returns a pixel value.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_MapSurfaceRGBA
|
||||
*/
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
|
||||
|
||||
/**
|
||||
* Map an RGBA quadruple to a pixel value for a surface.
|
||||
*
|
||||
* This function maps the RGBA color value to the specified pixel format and
|
||||
* returns the pixel value best approximating the given RGBA color value for
|
||||
* the given pixel format.
|
||||
*
|
||||
* If the surface pixel format has no alpha component the alpha value will
|
||||
* be ignored (as it will be in formats with a palette).
|
||||
*
|
||||
* If the surface has a palette, the index of the closest matching color
|
||||
* in the palette will be returned.
|
||||
*
|
||||
* If the pixel format bpp (color depth) is less than 32-bpp then the unused
|
||||
* upper bits of the return value can safely be ignored (e.g., with a 16-bpp
|
||||
* format the return value can be assigned to a Uint16, and similarly a Uint8
|
||||
* for an 8-bpp format).
|
||||
*
|
||||
* \param surface the surface to use for the pixel format and palette.
|
||||
* \param r the red component of the pixel in the range 0-255.
|
||||
* \param g the green component of the pixel in the range 0-255.
|
||||
* \param b the blue component of the pixel in the range 0-255.
|
||||
* \param a the alpha component of the pixel in the range 0-255.
|
||||
* \returns a pixel value.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_MapSurfaceRGB
|
||||
*/
|
||||
extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/**
|
||||
* Retrieves a single pixel from a surface.
|
||||
*
|
||||
|
|
|
@ -88,7 +88,7 @@ typedef enum SDL_SystemTheme
|
|||
typedef struct SDL_DisplayMode
|
||||
{
|
||||
SDL_DisplayID displayID; /**< the display this mode is associated with */
|
||||
SDL_PixelFormatEnum format; /**< pixel format */
|
||||
SDL_PixelFormat format; /**< pixel format */
|
||||
int w; /**< width */
|
||||
int h; /**< height */
|
||||
float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "render/SDL_sysrender.h"
|
||||
#include "sensor/SDL_sensor_c.h"
|
||||
#include "stdlib/SDL_getenv_c.h"
|
||||
#include "video/SDL_pixels_c.h"
|
||||
#include "video/SDL_video_c.h"
|
||||
|
||||
#define SDL_INIT_EVERYTHING ~0U
|
||||
|
@ -549,6 +550,8 @@ void SDL_Quit(void)
|
|||
SDL_ClearHints();
|
||||
SDL_AssertionsQuit();
|
||||
|
||||
SDL_QuitPixelFormatDetails();
|
||||
|
||||
SDL_QuitCPUInfo();
|
||||
|
||||
SDL_QuitProperties();
|
||||
|
|
|
@ -317,3 +317,8 @@ SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused)
|
|||
}
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
void SDL_NukeFreeValue(const void *key, const void *value, void *unused)
|
||||
{
|
||||
SDL_free((void *)value);
|
||||
}
|
||||
|
|
|
@ -29,30 +29,32 @@ typedef Uint32 (*SDL_HashTable_HashFn)(const void *key, void *data);
|
|||
typedef SDL_bool (*SDL_HashTable_KeyMatchFn)(const void *a, const void *b, void *data);
|
||||
typedef void (*SDL_HashTable_NukeFn)(const void *key, const void *value, void *data);
|
||||
|
||||
SDL_HashTable *SDL_CreateHashTable(void *data,
|
||||
extern SDL_HashTable *SDL_CreateHashTable(void *data,
|
||||
const Uint32 num_buckets,
|
||||
const SDL_HashTable_HashFn hashfn,
|
||||
const SDL_HashTable_KeyMatchFn keymatchfn,
|
||||
const SDL_HashTable_NukeFn nukefn,
|
||||
const SDL_bool stackable);
|
||||
|
||||
void SDL_EmptyHashTable(SDL_HashTable *table);
|
||||
void SDL_DestroyHashTable(SDL_HashTable *table);
|
||||
SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value);
|
||||
SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key);
|
||||
SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value);
|
||||
SDL_bool SDL_HashTableEmpty(SDL_HashTable *table);
|
||||
extern void SDL_EmptyHashTable(SDL_HashTable *table);
|
||||
extern void SDL_DestroyHashTable(SDL_HashTable *table);
|
||||
extern SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const void *value);
|
||||
extern SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key);
|
||||
extern SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void **_value);
|
||||
extern SDL_bool SDL_HashTableEmpty(SDL_HashTable *table);
|
||||
|
||||
// iterate all values for a specific key. This only makes sense if the hash is stackable. If not-stackable, just use SDL_FindInHashTable().
|
||||
SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter);
|
||||
extern SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, const void **_value, void **iter);
|
||||
|
||||
// iterate all key/value pairs in a hash (stackable hashes can have duplicate keys with multiple values).
|
||||
SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter);
|
||||
extern SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, const void **_value, void **iter);
|
||||
|
||||
Uint32 SDL_HashString(const void *key, void *unused);
|
||||
SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *unused);
|
||||
extern Uint32 SDL_HashString(const void *key, void *unused);
|
||||
extern SDL_bool SDL_KeyMatchString(const void *a, const void *b, void *unused);
|
||||
|
||||
Uint32 SDL_HashID(const void *key, void *unused);
|
||||
SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused);
|
||||
extern Uint32 SDL_HashID(const void *key, void *unused);
|
||||
extern SDL_bool SDL_KeyMatchID(const void *a, const void *b, void *unused);
|
||||
|
||||
extern void SDL_NukeFreeValue(const void *key, const void *value, void *unused);
|
||||
|
||||
#endif /* SDL_hashtable_h_ */
|
||||
|
|
|
@ -84,7 +84,7 @@ char *SDL_GetCameraThreadName(SDL_CameraDevice *device, char *buf, size_t buflen
|
|||
return buf;
|
||||
}
|
||||
|
||||
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormatEnum format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator)
|
||||
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator)
|
||||
{
|
||||
SDL_assert(data != NULL);
|
||||
if (data->allocated_specs <= data->num_specs) {
|
||||
|
@ -130,7 +130,7 @@ static size_t GetFrameBufLen(const SDL_CameraSpec *spec)
|
|||
const size_t w = (const size_t) spec->width;
|
||||
const size_t h = (const size_t) spec->height;
|
||||
const size_t wxh = w * h;
|
||||
const SDL_PixelFormatEnum fmt = spec->format;
|
||||
const SDL_PixelFormat fmt = spec->format;
|
||||
|
||||
switch (fmt) {
|
||||
// Some YUV formats have a larger Y plane than their U or V planes.
|
||||
|
@ -367,8 +367,8 @@ static int SDLCALL CameraSpecCmp(const void *vpa, const void *vpb)
|
|||
SDL_assert(b->width > 0);
|
||||
SDL_assert(b->height > 0);
|
||||
|
||||
const SDL_PixelFormatEnum afmt = a->format;
|
||||
const SDL_PixelFormatEnum bfmt = b->format;
|
||||
const SDL_PixelFormat afmt = a->format;
|
||||
const SDL_PixelFormat bfmt = b->format;
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(afmt) && !SDL_ISPIXELFORMAT_FOURCC(bfmt)) {
|
||||
return -1;
|
||||
} else if (!SDL_ISPIXELFORMAT_FOURCC(afmt) && SDL_ISPIXELFORMAT_FOURCC(bfmt)) {
|
||||
|
@ -879,8 +879,8 @@ SDL_bool SDL_CameraThreadIterate(SDL_CameraDevice *device)
|
|||
if (device->needs_conversion) {
|
||||
SDL_Surface *dstsurf = (device->needs_scaling == 1) ? device->conversion_surface : output_surface;
|
||||
SDL_ConvertPixels(srcsurf->w, srcsurf->h,
|
||||
srcsurf->format->format, srcsurf->pixels, srcsurf->pitch,
|
||||
dstsurf->format->format, dstsurf->pixels, dstsurf->pitch);
|
||||
srcsurf->format, srcsurf->pixels, srcsurf->pitch,
|
||||
dstsurf->format, dstsurf->pixels, dstsurf->pitch);
|
||||
srcsurf = dstsurf;
|
||||
}
|
||||
if (device->needs_scaling == 1) { // upscaling? Do it last. -1: downscale, 0: no scaling, 1: upscale
|
||||
|
@ -1005,8 +1005,8 @@ static void ChooseBestCameraSpec(SDL_CameraDevice *device, const SDL_CameraSpec
|
|||
SDL_assert(closest->height > 0);
|
||||
|
||||
// okay, we have what we think is the best resolution, now we just need the best format that supports it...
|
||||
const SDL_PixelFormatEnum wantfmt = spec->format;
|
||||
SDL_PixelFormatEnum best_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
const SDL_PixelFormat wantfmt = spec->format;
|
||||
SDL_PixelFormat best_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Colorspace best_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
for (int i = 0; i < num_specs; i++) {
|
||||
const SDL_CameraSpec *thisspec = &device->all_specs[i];
|
||||
|
@ -1124,7 +1124,7 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
|
|||
|
||||
device->needs_conversion = (closest.format != device->spec.format);
|
||||
|
||||
device->acquire_surface = SDL_CreateSurfaceFrom(NULL, closest.width, closest.height, 0, closest.format);
|
||||
device->acquire_surface = SDL_CreateSurfaceFrom(closest.width, closest.height, closest.format, NULL, 0);
|
||||
if (!device->acquire_surface) {
|
||||
ClosePhysicalCameraDevice(device);
|
||||
ReleaseCameraDevice(device);
|
||||
|
@ -1136,7 +1136,7 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
|
|||
if (device->needs_scaling && device->needs_conversion) {
|
||||
const SDL_bool downsampling_first = (device->needs_scaling < 0);
|
||||
const SDL_CameraSpec *s = downsampling_first ? &device->spec : &closest;
|
||||
const SDL_PixelFormatEnum fmt = downsampling_first ? closest.format : device->spec.format;
|
||||
const SDL_PixelFormat fmt = downsampling_first ? closest.format : device->spec.format;
|
||||
device->conversion_surface = SDL_CreateSurface(s->width, s->height, fmt);
|
||||
if (!device->conversion_surface) {
|
||||
ClosePhysicalCameraDevice(device);
|
||||
|
@ -1160,7 +1160,7 @@ SDL_Camera *SDL_OpenCameraDevice(SDL_CameraDeviceID instance_id, const SDL_Camer
|
|||
if (device->needs_scaling || device->needs_conversion) {
|
||||
surf = SDL_CreateSurface(device->spec.width, device->spec.height, device->spec.format);
|
||||
} else {
|
||||
surf = SDL_CreateSurfaceFrom(NULL, device->spec.width, device->spec.height, 0, device->spec.format);
|
||||
surf = SDL_CreateSurfaceFrom(device->spec.width, device->spec.height, device->spec.format, NULL, 0);
|
||||
}
|
||||
if (!surf) {
|
||||
ClosePhysicalCameraDevice(device);
|
||||
|
|
|
@ -64,7 +64,7 @@ typedef struct CameraFormatAddData
|
|||
int allocated_specs;
|
||||
} CameraFormatAddData;
|
||||
|
||||
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormatEnum format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator);
|
||||
int SDL_AddCameraFormat(CameraFormatAddData *data, SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h, int framerate_numerator, int framerate_denominator);
|
||||
|
||||
typedef struct SurfaceList
|
||||
{
|
||||
|
|
|
@ -252,7 +252,7 @@ static void DestroyCameraManager(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void format_android_to_sdl(Uint32 fmt, SDL_PixelFormatEnum *format, SDL_Colorspace *colorspace)
|
||||
static void format_android_to_sdl(Uint32 fmt, SDL_PixelFormat *format, SDL_Colorspace *colorspace)
|
||||
{
|
||||
switch (fmt) {
|
||||
#define CASE(x, y, z) case x: *format = y; *colorspace = z; return
|
||||
|
@ -274,7 +274,7 @@ static void format_android_to_sdl(Uint32 fmt, SDL_PixelFormatEnum *format, SDL_C
|
|||
*colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
}
|
||||
|
||||
static Uint32 format_sdl_to_android(SDL_PixelFormatEnum fmt)
|
||||
static Uint32 format_sdl_to_android(SDL_PixelFormat fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
#define CASE(x, y) case y: return x
|
||||
|
@ -632,7 +632,7 @@ static void GatherCameraSpecs(const char *devid, CameraFormatAddData *add_data,
|
|||
const int w = (int) i32ptr[1];
|
||||
const int h = (int) i32ptr[2];
|
||||
const int32_t type = i32ptr[3];
|
||||
SDL_PixelFormatEnum sdlfmt = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat sdlfmt = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Colorspace colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
|
||||
if (type == ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT) {
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* <key>com.apple.security.device.camera</key> <true/>
|
||||
*/
|
||||
|
||||
static void CoreMediaFormatToSDL(FourCharCode fmt, SDL_PixelFormatEnum *pixel_format, SDL_Colorspace *colorspace)
|
||||
static void CoreMediaFormatToSDL(FourCharCode fmt, SDL_PixelFormat *pixel_format, SDL_Colorspace *colorspace)
|
||||
{
|
||||
switch (fmt) {
|
||||
#define CASE(x, y, z) case x: *pixel_format = y; *colorspace = z; return
|
||||
|
@ -260,7 +260,7 @@ static int COREMEDIA_OpenDevice(SDL_CameraDevice *device, const SDL_CameraSpec *
|
|||
NSArray<AVCaptureDeviceFormat *> *formats = [avdevice formats];
|
||||
for (AVCaptureDeviceFormat *format in formats) {
|
||||
CMFormatDescriptionRef formatDescription = [format formatDescription];
|
||||
SDL_PixelFormatEnum device_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat device_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Colorspace device_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
CoreMediaFormatToSDL(CMFormatDescriptionGetMediaSubType(formatDescription), &device_format, &device_colorspace);
|
||||
if (device_format != spec->format || device_colorspace != spec->colorspace) {
|
||||
|
@ -384,7 +384,7 @@ static void GatherCameraSpecs(AVCaptureDevice *device, CameraFormatAddData *add_
|
|||
}
|
||||
|
||||
//NSLog(@"Available camera format: %@\n", fmt);
|
||||
SDL_PixelFormatEnum device_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat device_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Colorspace device_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
CoreMediaFormatToSDL(CMFormatDescriptionGetMediaSubType(fmt.formatDescription), &device_format, &device_colorspace);
|
||||
if (device_format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
|
|
|
@ -85,7 +85,7 @@ SDL_DEFINE_MEDIATYPE_GUID(MFVideoFormat_NV21, FCC('NV21'));
|
|||
static const struct
|
||||
{
|
||||
const GUID *guid;
|
||||
SDL_PixelFormatEnum format;
|
||||
SDL_PixelFormat format;
|
||||
SDL_Colorspace colorspace;
|
||||
} fmtmappings[] = {
|
||||
// This is not every possible format, just popular ones that SDL can reasonably handle.
|
||||
|
@ -281,7 +281,7 @@ static SDL_Colorspace GetMediaTypeColorspace(IMFMediaType *mediatype, SDL_Colors
|
|||
return colorspace;
|
||||
}
|
||||
|
||||
static void MediaTypeToSDLFmt(IMFMediaType *mediatype, SDL_PixelFormatEnum *format, SDL_Colorspace *colorspace)
|
||||
static void MediaTypeToSDLFmt(IMFMediaType *mediatype, SDL_PixelFormat *format, SDL_Colorspace *colorspace)
|
||||
{
|
||||
HRESULT ret;
|
||||
GUID type;
|
||||
|
@ -300,7 +300,7 @@ static void MediaTypeToSDLFmt(IMFMediaType *mediatype, SDL_PixelFormatEnum *form
|
|||
*colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
}
|
||||
|
||||
static const GUID *SDLFmtToMFVidFmtGuid(SDL_PixelFormatEnum format)
|
||||
static const GUID *SDLFmtToMFVidFmtGuid(SDL_PixelFormat format)
|
||||
{
|
||||
for (size_t i = 0; i < SDL_arraysize(fmtmappings); i++) {
|
||||
if (fmtmappings[i].format == format) {
|
||||
|
@ -930,7 +930,7 @@ static void GatherCameraSpecs(IMFMediaSource *source, CameraFormatAddData *add_d
|
|||
GUID type;
|
||||
ret = IMFMediaType_GetGUID(mediatype, &SDL_MF_MT_MAJOR_TYPE, &type);
|
||||
if (SUCCEEDED(ret) && WIN_IsEqualGUID(&type, &SDL_MFMediaType_Video)) {
|
||||
SDL_PixelFormatEnum sdlfmt = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat sdlfmt = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Colorspace colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
MediaTypeToSDLFmt(mediatype, &sdlfmt, &colorspace);
|
||||
if (sdlfmt != SDL_PIXELFORMAT_UNKNOWN) {
|
||||
|
|
|
@ -357,7 +357,7 @@ static void param_update(struct spa_list *param_list, struct spa_list *pending_l
|
|||
}
|
||||
|
||||
static struct sdl_video_format {
|
||||
SDL_PixelFormatEnum format;
|
||||
SDL_PixelFormat format;
|
||||
SDL_Colorspace colorspace;
|
||||
uint32_t id;
|
||||
} sdl_video_formats[] = {
|
||||
|
@ -389,7 +389,7 @@ static struct sdl_video_format {
|
|||
#endif
|
||||
};
|
||||
|
||||
static uint32_t sdl_format_to_id(SDL_PixelFormatEnum format)
|
||||
static uint32_t sdl_format_to_id(SDL_PixelFormat format)
|
||||
{
|
||||
struct sdl_video_format *f;
|
||||
SPA_FOR_EACH_ELEMENT(sdl_video_formats, f) {
|
||||
|
@ -399,7 +399,7 @@ static uint32_t sdl_format_to_id(SDL_PixelFormatEnum format)
|
|||
return SPA_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static void id_to_sdl_format(uint32_t id, SDL_PixelFormatEnum *format, SDL_Colorspace *colorspace)
|
||||
static void id_to_sdl_format(uint32_t id, SDL_PixelFormat *format, SDL_Colorspace *colorspace)
|
||||
{
|
||||
struct sdl_video_format *f;
|
||||
SPA_FOR_EACH_ELEMENT(sdl_video_formats, f) {
|
||||
|
@ -603,7 +603,7 @@ static void PIPEWIRECAMERA_ReleaseFrame(SDL_CameraDevice *device, SDL_Surface *f
|
|||
PIPEWIRE_pw_thread_loop_unlock(hotplug.loop);
|
||||
}
|
||||
|
||||
static void collect_rates(CameraFormatAddData *data, struct param *p, SDL_PixelFormatEnum sdlfmt, SDL_Colorspace colorspace, const struct spa_rectangle *size)
|
||||
static void collect_rates(CameraFormatAddData *data, struct param *p, SDL_PixelFormat sdlfmt, SDL_Colorspace colorspace, const struct spa_rectangle *size)
|
||||
{
|
||||
const struct spa_pod_prop *prop;
|
||||
struct spa_pod * values;
|
||||
|
@ -636,7 +636,7 @@ static void collect_rates(CameraFormatAddData *data, struct param *p, SDL_PixelF
|
|||
}
|
||||
}
|
||||
|
||||
static void collect_size(CameraFormatAddData *data, struct param *p, SDL_PixelFormatEnum sdlfmt, SDL_Colorspace colorspace)
|
||||
static void collect_size(CameraFormatAddData *data, struct param *p, SDL_PixelFormat sdlfmt, SDL_Colorspace colorspace)
|
||||
{
|
||||
const struct spa_pod_prop *prop;
|
||||
struct spa_pod * values;
|
||||
|
@ -670,7 +670,7 @@ static void collect_size(CameraFormatAddData *data, struct param *p, SDL_PixelFo
|
|||
static void collect_format(CameraFormatAddData *data, struct param *p)
|
||||
{
|
||||
const struct spa_pod_prop *prop;
|
||||
SDL_PixelFormatEnum sdlfmt;
|
||||
SDL_PixelFormat sdlfmt;
|
||||
SDL_Colorspace colorspace;
|
||||
struct spa_pod * values;
|
||||
uint32_t i, n_vals, choice, *ids;
|
||||
|
|
|
@ -391,7 +391,7 @@ static int AllocBufferUserPtr(SDL_CameraDevice *device, size_t buffer_size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void format_v4l2_to_sdl(Uint32 fmt, SDL_PixelFormatEnum *format, SDL_Colorspace *colorspace)
|
||||
static void format_v4l2_to_sdl(Uint32 fmt, SDL_PixelFormat *format, SDL_Colorspace *colorspace)
|
||||
{
|
||||
switch (fmt) {
|
||||
#define CASE(x, y, z) case x: *format = y; *colorspace = z; return
|
||||
|
@ -407,7 +407,7 @@ static void format_v4l2_to_sdl(Uint32 fmt, SDL_PixelFormatEnum *format, SDL_Colo
|
|||
*colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
}
|
||||
|
||||
static Uint32 format_sdl_to_v4l2(SDL_PixelFormatEnum fmt)
|
||||
static Uint32 format_sdl_to_v4l2(SDL_PixelFormat fmt)
|
||||
{
|
||||
switch (fmt) {
|
||||
#define CASE(y, x) case x: return y
|
||||
|
@ -645,7 +645,7 @@ static SDL_bool FindV4L2CameraDeviceByBusInfoCallback(SDL_CameraDevice *device,
|
|||
return (SDL_strcmp(handle->bus_info, (const char *) userdata) == 0);
|
||||
}
|
||||
|
||||
static int AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFormatEnum sdlfmt, SDL_Colorspace colorspace, Uint32 v4l2fmt, int w, int h)
|
||||
static int AddCameraFormat(const int fd, CameraFormatAddData *data, SDL_PixelFormat sdlfmt, SDL_Colorspace colorspace, Uint32 v4l2fmt, int w, int h)
|
||||
{
|
||||
struct v4l2_frmivalenum frmivalenum;
|
||||
SDL_zero(frmivalenum);
|
||||
|
@ -729,7 +729,7 @@ static void MaybeAddDevice(const char *path)
|
|||
SDL_zero(fmtdesc);
|
||||
fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
while (ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc) == 0) {
|
||||
SDL_PixelFormatEnum sdlfmt = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat sdlfmt = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Colorspace colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
format_v4l2_to_sdl(fmtdesc.pixelformat, &sdlfmt, &colorspace);
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ SDL3_0.0.0 {
|
|||
SDL_ConvertPixels;
|
||||
SDL_ConvertPixelsAndColorspace;
|
||||
SDL_ConvertSurface;
|
||||
SDL_ConvertSurfaceFormat;
|
||||
SDL_ConvertSurfaceFormatAndColorspace;
|
||||
SDL_ConvertSurfaceAndColorspace;
|
||||
SDL_CopyProperties;
|
||||
SDL_CreateAudioStream;
|
||||
SDL_CreateColorCursor;
|
||||
|
@ -330,7 +329,7 @@ SDL3_0.0.0 {
|
|||
SDL_GetKeyboards;
|
||||
SDL_GetLogOutputFunction;
|
||||
SDL_GetLogPriority;
|
||||
SDL_GetMasksForPixelFormatEnum;
|
||||
SDL_GetMasksForPixelFormat;
|
||||
SDL_GetMaxHapticEffects;
|
||||
SDL_GetMaxHapticEffectsPlaying;
|
||||
SDL_GetMemoryFunctions;
|
||||
|
@ -364,7 +363,8 @@ SDL3_0.0.0 {
|
|||
SDL_GetPens;
|
||||
SDL_GetPerformanceCounter;
|
||||
SDL_GetPerformanceFrequency;
|
||||
SDL_GetPixelFormatEnumForMasks;
|
||||
SDL_GetPixelFormatDetails;
|
||||
SDL_GetPixelFormatForMasks;
|
||||
SDL_GetPixelFormatName;
|
||||
SDL_GetPlatform;
|
||||
SDL_GetPowerInfo;
|
||||
|
@ -436,6 +436,7 @@ SDL3_0.0.0 {
|
|||
SDL_GetSurfaceColorKey;
|
||||
SDL_GetSurfaceColorMod;
|
||||
SDL_GetSurfaceColorspace;
|
||||
SDL_GetSurfacePalette;
|
||||
SDL_GetSurfaceProperties;
|
||||
SDL_GetSystemRAM;
|
||||
SDL_GetSystemTheme;
|
||||
|
@ -568,6 +569,8 @@ SDL3_0.0.0 {
|
|||
SDL_LogWarn;
|
||||
SDL_MapRGB;
|
||||
SDL_MapRGBA;
|
||||
SDL_MapSurfaceRGB;
|
||||
SDL_MapSurfaceRGBA;
|
||||
SDL_MaximizeWindow;
|
||||
SDL_MemoryBarrierAcquireFunction;
|
||||
SDL_MemoryBarrierReleaseFunction;
|
||||
|
@ -724,7 +727,6 @@ SDL3_0.0.0 {
|
|||
SDL_SetModState;
|
||||
SDL_SetNumberProperty;
|
||||
SDL_SetPaletteColors;
|
||||
SDL_SetPixelFormatPalette;
|
||||
SDL_SetPrimarySelectionText;
|
||||
SDL_SetProperty;
|
||||
SDL_SetPropertyWithCleanup;
|
||||
|
|
|
@ -83,8 +83,7 @@
|
|||
#define SDL_ConvertPixels SDL_ConvertPixels_REAL
|
||||
#define SDL_ConvertPixelsAndColorspace SDL_ConvertPixelsAndColorspace_REAL
|
||||
#define SDL_ConvertSurface SDL_ConvertSurface_REAL
|
||||
#define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_REAL
|
||||
#define SDL_ConvertSurfaceFormatAndColorspace SDL_ConvertSurfaceFormatAndColorspace_REAL
|
||||
#define SDL_ConvertSurfaceAndColorspace SDL_ConvertSurfaceAndColorspace_REAL
|
||||
#define SDL_CopyProperties SDL_CopyProperties_REAL
|
||||
#define SDL_CreateAudioStream SDL_CreateAudioStream_REAL
|
||||
#define SDL_CreateColorCursor SDL_CreateColorCursor_REAL
|
||||
|
@ -94,7 +93,6 @@
|
|||
#define SDL_CreateHapticEffect SDL_CreateHapticEffect_REAL
|
||||
#define SDL_CreateMutex SDL_CreateMutex_REAL
|
||||
#define SDL_CreatePalette SDL_CreatePalette_REAL
|
||||
#define SDL_CreatePixelFormat SDL_CreatePixelFormat_REAL
|
||||
#define SDL_CreatePopupWindow SDL_CreatePopupWindow_REAL
|
||||
#define SDL_CreateProperties SDL_CreateProperties_REAL
|
||||
#define SDL_CreateRWLock SDL_CreateRWLock_REAL
|
||||
|
@ -191,8 +189,8 @@
|
|||
#define SDL_GetAndroidSDKVersion SDL_GetAndroidSDKVersion_REAL
|
||||
#define SDL_GetAssertionHandler SDL_GetAssertionHandler_REAL
|
||||
#define SDL_GetAssertionReport SDL_GetAssertionReport_REAL
|
||||
#define SDL_GetAudioDeviceGain SDL_GetAudioDeviceGain_REAL
|
||||
#define SDL_GetAudioDeviceFormat SDL_GetAudioDeviceFormat_REAL
|
||||
#define SDL_GetAudioDeviceGain SDL_GetAudioDeviceGain_REAL
|
||||
#define SDL_GetAudioDeviceName SDL_GetAudioDeviceName_REAL
|
||||
#define SDL_GetAudioDriver SDL_GetAudioDriver_REAL
|
||||
#define SDL_GetAudioPlaybackDevices SDL_GetAudioPlaybackDevices_REAL
|
||||
|
@ -355,7 +353,7 @@
|
|||
#define SDL_GetKeyboards SDL_GetKeyboards_REAL
|
||||
#define SDL_GetLogOutputFunction SDL_GetLogOutputFunction_REAL
|
||||
#define SDL_GetLogPriority SDL_GetLogPriority_REAL
|
||||
#define SDL_GetMasksForPixelFormatEnum SDL_GetMasksForPixelFormatEnum_REAL
|
||||
#define SDL_GetMasksForPixelFormat SDL_GetMasksForPixelFormat_REAL
|
||||
#define SDL_GetMaxHapticEffects SDL_GetMaxHapticEffects_REAL
|
||||
#define SDL_GetMaxHapticEffectsPlaying SDL_GetMaxHapticEffectsPlaying_REAL
|
||||
#define SDL_GetMemoryFunctions SDL_GetMemoryFunctions_REAL
|
||||
|
@ -389,7 +387,8 @@
|
|||
#define SDL_GetPens SDL_GetPens_REAL
|
||||
#define SDL_GetPerformanceCounter SDL_GetPerformanceCounter_REAL
|
||||
#define SDL_GetPerformanceFrequency SDL_GetPerformanceFrequency_REAL
|
||||
#define SDL_GetPixelFormatEnumForMasks SDL_GetPixelFormatEnumForMasks_REAL
|
||||
#define SDL_GetPixelFormatDetails SDL_GetPixelFormatDetails_REAL
|
||||
#define SDL_GetPixelFormatForMasks SDL_GetPixelFormatForMasks_REAL
|
||||
#define SDL_GetPixelFormatName SDL_GetPixelFormatName_REAL
|
||||
#define SDL_GetPlatform SDL_GetPlatform_REAL
|
||||
#define SDL_GetPowerInfo SDL_GetPowerInfo_REAL
|
||||
|
@ -461,6 +460,7 @@
|
|||
#define SDL_GetSurfaceColorKey SDL_GetSurfaceColorKey_REAL
|
||||
#define SDL_GetSurfaceColorMod SDL_GetSurfaceColorMod_REAL
|
||||
#define SDL_GetSurfaceColorspace SDL_GetSurfaceColorspace_REAL
|
||||
#define SDL_GetSurfacePalette SDL_GetSurfacePalette_REAL
|
||||
#define SDL_GetSurfaceProperties SDL_GetSurfaceProperties_REAL
|
||||
#define SDL_GetSystemRAM SDL_GetSystemRAM_REAL
|
||||
#define SDL_GetSystemTheme SDL_GetSystemTheme_REAL
|
||||
|
@ -593,6 +593,8 @@
|
|||
#define SDL_LogWarn SDL_LogWarn_REAL
|
||||
#define SDL_MapRGB SDL_MapRGB_REAL
|
||||
#define SDL_MapRGBA SDL_MapRGBA_REAL
|
||||
#define SDL_MapSurfaceRGB SDL_MapSurfaceRGB_REAL
|
||||
#define SDL_MapSurfaceRGBA SDL_MapSurfaceRGBA_REAL
|
||||
#define SDL_MaximizeWindow SDL_MaximizeWindow_REAL
|
||||
#define SDL_MemoryBarrierAcquireFunction SDL_MemoryBarrierAcquireFunction_REAL
|
||||
#define SDL_MemoryBarrierReleaseFunction SDL_MemoryBarrierReleaseFunction_REAL
|
||||
|
@ -749,7 +751,6 @@
|
|||
#define SDL_SetModState SDL_SetModState_REAL
|
||||
#define SDL_SetNumberProperty SDL_SetNumberProperty_REAL
|
||||
#define SDL_SetPaletteColors SDL_SetPaletteColors_REAL
|
||||
#define SDL_SetPixelFormatPalette SDL_SetPixelFormatPalette_REAL
|
||||
#define SDL_SetPrimarySelectionText SDL_SetPrimarySelectionText_REAL
|
||||
#define SDL_SetProperty SDL_SetProperty_REAL
|
||||
#define SDL_SetPropertyWithCleanup SDL_SetPropertyWithCleanup_REAL
|
||||
|
|
|
@ -100,11 +100,10 @@ SDL_DYNAPI_PROC(int,SDL_CloseStorage,(SDL_Storage *a),(a),return)
|
|||
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ConvertAudioSamples,(const SDL_AudioSpec *a, const Uint8 *b, int c, const SDL_AudioSpec *d, Uint8 **e, int *f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ConvertEventToRenderCoordinates,(SDL_Renderer *a, SDL_Event *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, SDL_PixelFormatEnum c, const void *d, int e, SDL_PixelFormatEnum f, void *g, int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ConvertPixelsAndColorspace,(int a, int b, SDL_PixelFormatEnum c, SDL_Colorspace d, SDL_PropertiesID e, const void *f, int g, SDL_PixelFormatEnum h, SDL_Colorspace i, SDL_PropertiesID j, void *k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, SDL_PixelFormatEnum b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormatAndColorspace,(SDL_Surface *a, SDL_PixelFormatEnum b, SDL_Colorspace c, SDL_PropertiesID d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_ConvertPixelsAndColorspace,(int a, int b, SDL_PixelFormat c, SDL_Colorspace d, SDL_PropertiesID e, const void *f, int g, SDL_PixelFormat h, SDL_Colorspace i, SDL_PropertiesID j, void *k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, SDL_PixelFormat b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceAndColorspace,(SDL_Surface *a, SDL_PixelFormat b, const SDL_Palette *c, SDL_Colorspace d, SDL_PropertiesID e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_CopyProperties,(SDL_PropertiesID a, SDL_PropertiesID b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_CreateAudioStream,(const SDL_AudioSpec *a, const SDL_AudioSpec *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateColorCursor,(SDL_Surface *a, int b, int c),(a,b,c),return)
|
||||
|
@ -114,7 +113,6 @@ SDL_DYNAPI_PROC(int,SDL_CreateDirectory,(const char *a),(a),return)
|
|||
SDL_DYNAPI_PROC(int,SDL_CreateHapticEffect,(SDL_Haptic *a, const SDL_HapticEffect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Mutex*,SDL_CreateMutex,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(SDL_PixelFormatEnum a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Window*,SDL_CreatePopupWindow,(SDL_Window *a, int b, int c, int d, int e, SDL_WindowFlags f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_CreateProperties,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_RWLock*,SDL_CreateRWLock,(void),(),return)
|
||||
|
@ -123,11 +121,11 @@ SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRendererWithProperties,(SDL_PropertiesID
|
|||
SDL_DYNAPI_PROC(SDL_Semaphore*,SDL_CreateSemaphore,(Uint32 a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateSoftwareRenderer,(SDL_Surface *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_CreateStorageDirectory,(SDL_Storage *a, const char *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurface,(int a, int b, SDL_PixelFormatEnum c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurfaceFrom,(void *a, int b, int c, int d, SDL_PixelFormatEnum e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurface,(int a, int b, SDL_PixelFormat c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateSurfaceFrom,(int a, int b, SDL_PixelFormat c, void *d, int e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateSystemCursor,(SDL_SystemCursor a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_TLSID,SDL_CreateTLS,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTexture,(SDL_Renderer *a, SDL_PixelFormatEnum b, int c, int d, int e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTexture,(SDL_Renderer *a, SDL_PixelFormat b, int c, int d, int e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTextureFromSurface,(SDL_Renderer *a, SDL_Surface *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTextureWithProperties,(SDL_Renderer *a, SDL_PropertiesID b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThreadRuntime,(SDL_ThreadFunction a, const char *b, void *c, SDL_FunctionPointer d, SDL_FunctionPointer e),(a,b,c,d,e),return)
|
||||
|
@ -148,7 +146,6 @@ SDL_DYNAPI_PROC(void,SDL_DestroyCursor,(SDL_Cursor *a),(a),)
|
|||
SDL_DYNAPI_PROC(void,SDL_DestroyHapticEffect,(SDL_Haptic *a, int b),(a,b),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DestroyMutex,(SDL_Mutex *a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DestroyProperties,(SDL_PropertiesID a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DestroyRWLock,(SDL_RWLock *a),(a),)
|
||||
SDL_DYNAPI_PROC(void,SDL_DestroyRenderer,(SDL_Renderer *a),(a),)
|
||||
|
@ -375,7 +372,7 @@ SDL_DYNAPI_PROC(const Uint8*,SDL_GetKeyboardState,(int *a),(a),return)
|
|||
SDL_DYNAPI_PROC(SDL_KeyboardID*,SDL_GetKeyboards,(int *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetLogOutputFunction,(SDL_LogOutputFunction *a, void **b),(a,b),)
|
||||
SDL_DYNAPI_PROC(SDL_LogPriority,SDL_GetLogPriority,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetMasksForPixelFormatEnum,(SDL_PixelFormatEnum a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetMasksForPixelFormat,(SDL_PixelFormat a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetMaxHapticEffects,(SDL_Haptic *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetMaxHapticEffectsPlaying,(SDL_Haptic *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),)
|
||||
|
@ -409,8 +406,9 @@ SDL_DYNAPI_PROC(SDL_PenSubtype,SDL_GetPenType,(SDL_PenID a),(a),return)
|
|||
SDL_DYNAPI_PROC(SDL_PenID*,SDL_GetPens,(int *a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceCounter,(void),(),return)
|
||||
SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceFrequency,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_PixelFormatEnum,SDL_GetPixelFormatEnumForMasks,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetPixelFormatName,(SDL_PixelFormatEnum a),(a),return)
|
||||
SDL_DYNAPI_PROC(const SDL_PixelFormatDetails*,SDL_GetPixelFormatDetails,(SDL_PixelFormat a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_PixelFormat,SDL_GetPixelFormatForMasks,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetPixelFormatName,(SDL_PixelFormat a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetPlatform,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_PowerState,SDL_GetPowerInfo,(int *a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(char*,SDL_GetPrefPath,(const char *a, const char *b),(a,b),return)
|
||||
|
@ -419,8 +417,8 @@ SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)
|
|||
SDL_DYNAPI_PROC(char*,SDL_GetPrimarySelectionText,(void),(),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_GetProperty,(SDL_PropertiesID a, const char *b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertyType,SDL_GetPropertyType,(SDL_PropertiesID a, const char *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetRGBA,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e, Uint8 *f),(a,b,c,d,e,f),)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormatDetails *b, const SDL_Palette *c, Uint8 *d, Uint8 *e, Uint8 *f),(a,b,c,d,e,f),)
|
||||
SDL_DYNAPI_PROC(void,SDL_GetRGBA,(Uint32 a, const SDL_PixelFormatDetails *b, const SDL_Palette *c, Uint8 *d, Uint8 *e, Uint8 *f, Uint8 *g),(a,b,c,d,e,f,g),)
|
||||
SDL_DYNAPI_PROC(SDL_GamepadType,SDL_GetRealGamepadInstanceType,(SDL_JoystickID a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_GamepadType,SDL_GetRealGamepadType,(SDL_Gamepad *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRectAndLineIntersection,(const SDL_Rect *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return)
|
||||
|
@ -480,7 +478,8 @@ SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(
|
|||
SDL_DYNAPI_PROC(int,SDL_GetSurfaceClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetSurfaceColorKey,(SDL_Surface *a, Uint32 *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetSurfaceColorMod,(SDL_Surface *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetSurfaceColorspace,(SDL_Surface *a, SDL_Colorspace *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Colorspace,SDL_GetSurfaceColorspace,(SDL_Surface *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_Palette*,SDL_GetSurfacePalette,(SDL_Surface *a),(a),return)
|
||||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetSurfaceProperties,(SDL_Surface *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_GetSystemRAM,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_SystemTheme,SDL_GetSystemTheme,(void),(),return)
|
||||
|
@ -602,8 +601,10 @@ SDL_DYNAPI_PROC(int,SDL_LockSurface,(SDL_Surface *a),(a),return)
|
|||
SDL_DYNAPI_PROC(int,SDL_LockTexture,(SDL_Texture *a, const SDL_Rect *b, void **c, int *d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_LockTextureToSurface,(SDL_Texture *a, const SDL_Rect *b, SDL_Surface **c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_LogMessageV,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, va_list d),(a,b,c,d),)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormatDetails *a, const SDL_Palette *b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormatDetails *a, const SDL_Palette *b, Uint8 c, Uint8 d, Uint8 e, Uint8 f),(a,b,c,d,e,f),return)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_MapSurfaceRGB,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_MapSurfaceRGBA,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_MaximizeWindow,(SDL_Window *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquireFunction,(void),(),)
|
||||
SDL_DYNAPI_PROC(void,SDL_MemoryBarrierReleaseFunction,(void),(),)
|
||||
|
@ -643,7 +644,7 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_PenConnected,(SDL_PenID a),(a),return)
|
|||
SDL_DYNAPI_PROC(int,SDL_PlayHapticRumble,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_PollEvent,(SDL_Event *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_PostSemaphore,(SDL_Semaphore *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_PremultiplyAlpha,(int a, int b, SDL_PixelFormatEnum c, const void *d, int e, SDL_PixelFormatEnum f, void *g, int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_PremultiplyAlpha,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_DYNAPI_PROC(void,SDL_PumpEvents,(void),(),)
|
||||
SDL_DYNAPI_PROC(int,SDL_PushEvent,(SDL_Event *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_PutAudioStreamData,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return)
|
||||
|
@ -759,7 +760,6 @@ SDL_DYNAPI_PROC(int,SDL_SetMemoryFunctions,(SDL_malloc_func a, SDL_calloc_func b
|
|||
SDL_DYNAPI_PROC(void,SDL_SetModState,(SDL_Keymod a),(a),)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetNumberProperty,(SDL_PropertiesID a, const char *b, Sint64 c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPixelFormatPalette,(SDL_PixelFormat *a, SDL_Palette *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPrimarySelectionText,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetProperty,(SDL_PropertiesID a, const char *b, void *c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetPropertyWithCleanup,(SDL_PropertiesID a, const char *b, void *c, SDL_CleanupPropertyCallback d, void *e),(a,b,c,d,e),return)
|
||||
|
@ -783,7 +783,7 @@ SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorKey,(SDL_Surface *a, int b, Uint32 c),(a,
|
|||
SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorMod,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorspace,(SDL_Surface *a, SDL_Colorspace b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetSurfaceRLE,(SDL_Surface *a, int b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetSurfaceRLE,(SDL_Surface *a, SDL_bool b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetTLS,(SDL_TLSID a, const void *b, SDL_TLSDestructorCallback c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetTextInputArea,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return)
|
||||
SDL_DYNAPI_PROC(int,SDL_SetTextureAlphaMod,(SDL_Texture *a, Uint8 b),(a,b),return)
|
||||
|
|
|
@ -1493,8 +1493,8 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
|
||||
temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (surface->format != SDL_PIXELFORMAT_ARGB8888) {
|
||||
temp = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!temp) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -142,9 +142,9 @@ void SDL_QuitRender(void)
|
|||
}
|
||||
}
|
||||
|
||||
int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormatEnum format)
|
||||
int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
{
|
||||
SDL_PixelFormatEnum *texture_formats = (SDL_PixelFormatEnum *)SDL_realloc((void *)renderer->texture_formats, (renderer->num_texture_formats + 2) * sizeof(SDL_PixelFormatEnum));
|
||||
SDL_PixelFormat *texture_formats = (SDL_PixelFormat *)SDL_realloc((void *)renderer->texture_formats, (renderer->num_texture_formats + 2) * sizeof(SDL_PixelFormat));
|
||||
if (!texture_formats) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1244,7 +1244,7 @@ static SDL_bool IsSupportedBlendMode(SDL_Renderer *renderer, SDL_BlendMode blend
|
|||
}
|
||||
}
|
||||
|
||||
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormatEnum format)
|
||||
static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ static SDL_bool IsSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormatEnum fo
|
|||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormatEnum format)
|
||||
static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ static Uint32 GetClosestSupportedFormat(SDL_Renderer *renderer, SDL_PixelFormatE
|
|||
SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props)
|
||||
{
|
||||
SDL_Texture *texture;
|
||||
SDL_PixelFormatEnum format = (SDL_PixelFormatEnum)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_UNKNOWN);
|
||||
SDL_PixelFormat format = (SDL_PixelFormat)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_UNKNOWN);
|
||||
int access = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER, SDL_TEXTUREACCESS_STATIC);
|
||||
int w = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, 0);
|
||||
int h = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, 0);
|
||||
|
@ -1451,7 +1451,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
|
|||
return texture;
|
||||
}
|
||||
|
||||
SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormatEnum format, int access, int w, int h)
|
||||
SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, int access, int w, int h)
|
||||
{
|
||||
SDL_Texture *texture;
|
||||
SDL_PropertiesID props = SDL_CreateProperties();
|
||||
|
@ -1466,56 +1466,53 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormatEnum forma
|
|||
|
||||
SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
|
||||
{
|
||||
const SDL_PixelFormat *fmt;
|
||||
SDL_bool needAlpha;
|
||||
SDL_bool direct_update;
|
||||
int i;
|
||||
SDL_PixelFormatEnum format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_Palette *palette;
|
||||
SDL_Texture *texture;
|
||||
SDL_PropertiesID surface_props, props;
|
||||
SDL_PropertiesID props;
|
||||
SDL_Colorspace surface_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
SDL_Colorspace texture_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
|
||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
SDL_InvalidParamError("SDL_CreateTextureFromSurface(): surface");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* See what the best texture format is */
|
||||
fmt = surface->format;
|
||||
if (fmt->Amask || SDL_SurfaceHasColorKey(surface)) {
|
||||
if (SDL_ISPIXELFORMAT_ALPHA(surface->format) || SDL_SurfaceHasColorKey(surface)) {
|
||||
needAlpha = SDL_TRUE;
|
||||
} else {
|
||||
needAlpha = SDL_FALSE;
|
||||
}
|
||||
|
||||
/* If Palette contains alpha values, promotes to alpha format */
|
||||
if (fmt->palette) {
|
||||
palette = SDL_GetSurfacePalette(surface);
|
||||
if (palette) {
|
||||
SDL_bool is_opaque, has_alpha_channel;
|
||||
SDL_DetectPalette(fmt->palette, &is_opaque, &has_alpha_channel);
|
||||
SDL_DetectPalette(palette, &is_opaque, &has_alpha_channel);
|
||||
if (!is_opaque) {
|
||||
needAlpha = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_GetSurfaceColorspace(surface, &surface_colorspace) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
texture_colorspace = surface_colorspace;
|
||||
texture_colorspace = SDL_GetSurfaceColorspace(surface);
|
||||
|
||||
/* Try to have the best pixel format for the texture */
|
||||
/* No alpha, but a colorkey => promote to alpha */
|
||||
if (!fmt->Amask && SDL_SurfaceHasColorKey(surface)) {
|
||||
if (fmt->format == SDL_PIXELFORMAT_XRGB8888) {
|
||||
if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) && SDL_SurfaceHasColorKey(surface)) {
|
||||
if (surface->format == SDL_PIXELFORMAT_XRGB8888) {
|
||||
for (i = 0; i < renderer->num_texture_formats; ++i) {
|
||||
if (renderer->texture_formats[i] == SDL_PIXELFORMAT_ARGB8888) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (fmt->format == SDL_PIXELFORMAT_XBGR8888) {
|
||||
} else if (surface->format == SDL_PIXELFORMAT_XBGR8888) {
|
||||
for (i = 0; i < renderer->num_texture_formats; ++i) {
|
||||
if (renderer->texture_formats[i] == SDL_PIXELFORMAT_ABGR8888) {
|
||||
format = SDL_PIXELFORMAT_ABGR8888;
|
||||
|
@ -1526,15 +1523,15 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
|
|||
} else {
|
||||
/* Exact match would be fine */
|
||||
for (i = 0; i < renderer->num_texture_formats; ++i) {
|
||||
if (renderer->texture_formats[i] == fmt->format) {
|
||||
format = fmt->format;
|
||||
if (renderer->texture_formats[i] == surface->format) {
|
||||
format = surface->format;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for 10-bit pixel formats if needed */
|
||||
if (format == SDL_PIXELFORMAT_UNKNOWN && SDL_ISPIXELFORMAT_10BIT(fmt->format)) {
|
||||
if (format == SDL_PIXELFORMAT_UNKNOWN && SDL_ISPIXELFORMAT_10BIT(surface->format)) {
|
||||
for (i = 0; i < renderer->num_texture_formats; ++i) {
|
||||
if (SDL_ISPIXELFORMAT_10BIT(renderer->texture_formats[i])) {
|
||||
format = renderer->texture_formats[i];
|
||||
|
@ -1545,7 +1542,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
|
|||
|
||||
/* Look for floating point pixel formats if needed */
|
||||
if (format == SDL_PIXELFORMAT_UNKNOWN &&
|
||||
(SDL_ISPIXELFORMAT_10BIT(fmt->format) || SDL_ISPIXELFORMAT_FLOAT(fmt->format))) {
|
||||
(SDL_ISPIXELFORMAT_10BIT(surface->format) || SDL_ISPIXELFORMAT_FLOAT(surface->format))) {
|
||||
for (i = 0; i < renderer->num_texture_formats; ++i) {
|
||||
if (SDL_ISPIXELFORMAT_FLOAT(renderer->texture_formats[i])) {
|
||||
format = renderer->texture_formats[i];
|
||||
|
@ -1577,8 +1574,8 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
|
|||
}
|
||||
}
|
||||
|
||||
if (format == surface->format->format && texture_colorspace == surface_colorspace) {
|
||||
if (surface->format->Amask && SDL_SurfaceHasColorKey(surface)) {
|
||||
if (format == surface->format && texture_colorspace == surface_colorspace) {
|
||||
if (SDL_ISPIXELFORMAT_ALPHA(surface->format) && SDL_SurfaceHasColorKey(surface)) {
|
||||
/* Surface and Renderer formats are identical.
|
||||
* Intermediate conversion is needed to convert color key to alpha (SDL_ConvertColorkeyToAlpha()). */
|
||||
direct_update = SDL_FALSE;
|
||||
|
@ -1591,12 +1588,6 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
|
|||
direct_update = SDL_FALSE;
|
||||
}
|
||||
|
||||
if (surface->flags & SDL_SURFACE_USES_PROPERTIES) {
|
||||
surface_props = SDL_GetSurfaceProperties(surface);
|
||||
} else {
|
||||
surface_props = 0;
|
||||
}
|
||||
|
||||
props = SDL_CreateProperties();
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER, texture_colorspace);
|
||||
if (surface_colorspace == texture_colorspace) {
|
||||
|
@ -1627,7 +1618,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s
|
|||
SDL_Surface *temp = NULL;
|
||||
|
||||
/* Set up a destination surface for the texture update */
|
||||
temp = SDL_ConvertSurfaceFormatAndColorspace(surface, format, texture_colorspace, surface_props);
|
||||
temp = SDL_ConvertSurfaceAndColorspace(surface, format, NULL, texture_colorspace, surface->internal->props);
|
||||
if (temp) {
|
||||
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
|
||||
SDL_DestroySurface(temp);
|
||||
|
@ -2283,7 +2274,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Sur
|
|||
return ret;
|
||||
}
|
||||
|
||||
texture->locked_surface = SDL_CreateSurfaceFrom(pixels, real_rect.w, real_rect.h, pitch, texture->format);
|
||||
texture->locked_surface = SDL_CreateSurfaceFrom(real_rect.w, real_rect.h, texture->format, pixels, pitch);
|
||||
if (!texture->locked_surface) {
|
||||
SDL_UnlockTexture(texture);
|
||||
return -1;
|
||||
|
|
|
@ -65,7 +65,7 @@ struct SDL_Texture
|
|||
SDL_Colorspace colorspace; /**< The colorspace of the texture */
|
||||
float SDR_white_point; /**< The SDR white point for this content */
|
||||
float HDR_headroom; /**< The HDR headroom needed by this content */
|
||||
SDL_PixelFormatEnum format; /**< The pixel format of the texture */
|
||||
SDL_PixelFormat format; /**< The pixel format of the texture */
|
||||
int access; /**< SDL_TextureAccess */
|
||||
int w; /**< The width of the texture */
|
||||
int h; /**< The height of the texture */
|
||||
|
@ -217,7 +217,7 @@ struct SDL_Renderer
|
|||
|
||||
/* The current renderer info */
|
||||
const char *name;
|
||||
SDL_PixelFormatEnum *texture_formats;
|
||||
SDL_PixelFormat *texture_formats;
|
||||
int num_texture_formats;
|
||||
SDL_bool software;
|
||||
|
||||
|
@ -320,7 +320,7 @@ extern SDL_RenderDriver VITA_GXM_RenderDriver;
|
|||
extern void SDL_QuitRender(void);
|
||||
|
||||
/* Add a supported texture format to a renderer */
|
||||
extern int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormatEnum format);
|
||||
extern int SDL_AddSupportedTextureFormat(SDL_Renderer *renderer, SDL_PixelFormat format);
|
||||
|
||||
/* Setup colorspace conversion */
|
||||
extern void SDL_SetupRendererColorspace(SDL_Renderer *renderer, SDL_PropertiesID props);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "SDL_yuv_sw_c.h"
|
||||
#include "../video/SDL_yuv_c.h"
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormatEnum format, int w, int h)
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
||||
{
|
||||
SDL_SW_YUVTexture *swdata;
|
||||
|
||||
|
@ -336,7 +336,7 @@ void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata)
|
|||
}
|
||||
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
SDL_PixelFormatEnum target_format, int w, int h, void *pixels,
|
||||
SDL_PixelFormat target_format, int w, int h, void *pixels,
|
||||
int pitch)
|
||||
{
|
||||
int stretch;
|
||||
|
@ -365,7 +365,7 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
|||
swdata->display->pixels = pixels;
|
||||
swdata->display->pitch = pitch;
|
||||
} else {
|
||||
swdata->display = SDL_CreateSurfaceFrom(pixels, w, h, pitch, target_format);
|
||||
swdata->display = SDL_CreateSurfaceFrom(w, h, target_format, pixels, pitch);
|
||||
if (!swdata->display) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
struct SDL_SW_YUVTexture
|
||||
{
|
||||
SDL_PixelFormatEnum format;
|
||||
SDL_PixelFormatEnum target_format;
|
||||
SDL_PixelFormat format;
|
||||
SDL_PixelFormat target_format;
|
||||
int w, h;
|
||||
Uint8 *pixels;
|
||||
|
||||
|
@ -44,7 +44,7 @@ struct SDL_SW_YUVTexture
|
|||
|
||||
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormatEnum format, int w, int h);
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat 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,
|
||||
|
@ -60,7 +60,7 @@ int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
|||
void **pixels, int *pitch);
|
||||
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect,
|
||||
SDL_PixelFormatEnum target_format, int w, int h, void *pixels,
|
||||
SDL_PixelFormat target_format, int w, int h, void *pixels,
|
||||
int pitch);
|
||||
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ static D3DFORMAT PixelFormatToD3DFMT(Uint32 format)
|
|||
}
|
||||
}
|
||||
|
||||
static SDL_PixelFormatEnum D3DFMTToPixelFormat(D3DFORMAT format)
|
||||
static SDL_PixelFormat D3DFMTToPixelFormat(D3DFORMAT format)
|
||||
{
|
||||
switch (format) {
|
||||
case D3DFMT_R5G6B5:
|
||||
|
|
|
@ -244,7 +244,7 @@ static const GUID SDL_DXGI_DEBUG_ALL = { 0xe48ae283, 0xda80, 0x490b, { 0x87, 0xe
|
|||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
SDL_PixelFormatEnum D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
|
||||
SDL_PixelFormat D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
|
||||
{
|
||||
switch (dxgiFormat) {
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||
|
|
|
@ -361,7 +361,7 @@ static UINT D3D12_Align(UINT location, UINT alignment)
|
|||
return (location + (alignment - 1)) & ~(alignment - 1);
|
||||
}
|
||||
|
||||
static SDL_PixelFormatEnum D3D12_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
|
||||
static SDL_PixelFormat D3D12_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
|
||||
{
|
||||
switch (dxgiFormat) {
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
||||
|
|
|
@ -1450,7 +1450,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
static SDL_Surface *GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
{
|
||||
GL_RenderData *data = (GL_RenderData *)renderer->driverdata;
|
||||
SDL_PixelFormatEnum format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888;
|
||||
SDL_PixelFormat format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ARGB8888;
|
||||
GLint internalFormat;
|
||||
GLenum targetFormat, type;
|
||||
int w, h;
|
||||
|
|
|
@ -1966,7 +1966,7 @@ static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
static SDL_Surface *GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect)
|
||||
{
|
||||
GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata;
|
||||
SDL_PixelFormatEnum format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32;
|
||||
SDL_PixelFormat format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32;
|
||||
int w, h;
|
||||
SDL_Surface *surface;
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ static int SDL_BlendFillRect_ARGB8888(SDL_Surface *dst, const SDL_Rect *rect,
|
|||
static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->bytes_per_pixel) {
|
||||
|
@ -178,7 +178,7 @@ static int SDL_BlendFillRect_RGB(SDL_Surface *dst, const SDL_Rect *rect,
|
|||
static int SDL_BlendFillRect_RGBA(SDL_Surface *dst, const SDL_Rect *rect,
|
||||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->bytes_per_pixel) {
|
||||
|
@ -211,24 +211,24 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
|||
{
|
||||
SDL_Rect clipped;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRect(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
if (rect) {
|
||||
/* Perform clipping */
|
||||
if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
|
||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
||||
return 0;
|
||||
}
|
||||
rect = &clipped;
|
||||
} else {
|
||||
rect = &dst->clip_rect;
|
||||
rect = &dst->internal->clip_rect;
|
||||
}
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
@ -237,23 +237,23 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
|||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
switch (dst->format->bits_per_pixel) {
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x7C00:
|
||||
return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0xF800:
|
||||
return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
return SDL_BlendFillRect_XRGB8888(dst, rect, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
|
||||
|
@ -265,7 +265,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect,
|
|||
break;
|
||||
}
|
||||
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
|
||||
|
@ -281,12 +281,12 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendFillRects(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
|
||||
}
|
||||
|
||||
|
@ -297,23 +297,23 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
switch (dst->format->bits_per_pixel) {
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x7C00:
|
||||
func = SDL_BlendFillRect_RGB555;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0xF800:
|
||||
func = SDL_BlendFillRect_RGB565;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
func = SDL_BlendFillRect_XRGB8888;
|
||||
} else {
|
||||
func = SDL_BlendFillRect_ARGB8888;
|
||||
|
@ -326,7 +326,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
}
|
||||
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
func = SDL_BlendFillRect_RGB;
|
||||
} else {
|
||||
func = SDL_BlendFillRect_RGBA;
|
||||
|
@ -335,7 +335,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
|
||||
for (i = 0; i < count; ++i) {
|
||||
/* Perform clipping */
|
||||
if (!SDL_GetRectIntersection(&rects[i], &dst->clip_rect, &rect)) {
|
||||
if (!SDL_GetRectIntersection(&rects[i], &dst->internal->clip_rect, &rect)) {
|
||||
continue;
|
||||
}
|
||||
status = func(dst, &rect, blendMode, r, g, b, a);
|
||||
|
|
|
@ -30,7 +30,7 @@ static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
|||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
@ -343,7 +343,7 @@ static void SDL_BlendLine_RGB4(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
|||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
@ -448,7 +448,7 @@ static void SDL_BlendLine_RGBA4(SDL_Surface *dst, int x1, int y1, int x2, int y2
|
|||
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
|
||||
SDL_bool draw_end)
|
||||
{
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned r, g, b, a, inva;
|
||||
|
||||
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
|
||||
|
@ -763,7 +763,7 @@ typedef void (*BlendLineFunc)(SDL_Surface *dst,
|
|||
Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
SDL_bool draw_end);
|
||||
|
||||
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormat *fmt)
|
||||
static BlendLineFunc SDL_CalculateBlendLineFunc(const SDL_PixelFormatDetails *fmt)
|
||||
{
|
||||
switch (fmt->bytes_per_pixel) {
|
||||
case 2:
|
||||
|
@ -798,18 +798,18 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2,
|
|||
{
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendLine(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
func = SDL_CalculateBlendLineFunc(dst->internal->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -826,11 +826,11 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
SDL_bool draw_end;
|
||||
BlendLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
|
||||
}
|
||||
|
||||
func = SDL_CalculateBlendLineFunc(dst->format);
|
||||
func = SDL_CalculateBlendLineFunc(dst->internal->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_BlendLines(): Unsupported surface format");
|
||||
}
|
||||
|
@ -843,7 +843,7 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ static int SDL_BlendPoint_ARGB8888(SDL_Surface *dst, int x, int y, SDL_BlendMode
|
|||
static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->bytes_per_pixel) {
|
||||
|
@ -178,7 +178,7 @@ static int SDL_BlendPoint_RGB(SDL_Surface *dst, int x, int y, SDL_BlendMode blen
|
|||
static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
SDL_PixelFormat *fmt = dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
unsigned inva = 0xff - a;
|
||||
|
||||
switch (fmt->bytes_per_pixel) {
|
||||
|
@ -209,19 +209,19 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble
|
|||
int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r,
|
||||
Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoint(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
return SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -231,23 +231,23 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
|||
b = DRAW_MUL(b, a);
|
||||
}
|
||||
|
||||
switch (dst->format->bits_per_pixel) {
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x7C00:
|
||||
return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0xF800:
|
||||
return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
return SDL_BlendPoint_XRGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, a);
|
||||
|
@ -259,7 +259,7 @@ int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint
|
|||
break;
|
||||
}
|
||||
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
|
||||
} else {
|
||||
return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
|
||||
|
@ -277,12 +277,12 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
|
||||
int status = 0;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_BlendPoints(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_BlendPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
|
@ -293,25 +293,25 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
}
|
||||
|
||||
/* FIXME: Does this function pointer slow things down significantly? */
|
||||
switch (dst->format->bits_per_pixel) {
|
||||
switch (dst->internal->format->bits_per_pixel) {
|
||||
case 15:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x7C00:
|
||||
func = SDL_BlendPoint_RGB555;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0xF800:
|
||||
func = SDL_BlendPoint_RGB565;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
switch (dst->format->Rmask) {
|
||||
switch (dst->internal->format->Rmask) {
|
||||
case 0x00FF0000:
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
func = SDL_BlendPoint_XRGB8888;
|
||||
} else {
|
||||
func = SDL_BlendPoint_ARGB8888;
|
||||
|
@ -324,17 +324,17 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
}
|
||||
|
||||
if (!func) {
|
||||
if (!dst->format->Amask) {
|
||||
if (!dst->internal->format->Amask) {
|
||||
func = SDL_BlendPoint_RGB;
|
||||
} else {
|
||||
func = SDL_BlendPoint_RGBA;
|
||||
}
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||
miny = dst->clip_rect.y;
|
||||
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||
minx = dst->internal->clip_rect.x;
|
||||
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
|
||||
miny = dst->internal->clip_rect.y;
|
||||
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
|
|
|
@ -364,7 +364,7 @@
|
|||
#define HLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->bytes_per_pixel); \
|
||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
||||
type *pixel; \
|
||||
if (x1 <= x2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
|
@ -386,7 +386,7 @@
|
|||
#define VLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->bytes_per_pixel); \
|
||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
|
@ -408,7 +408,7 @@
|
|||
#define DLINE(type, op, draw_end) \
|
||||
{ \
|
||||
int length; \
|
||||
int pitch = (dst->pitch / dst->format->bytes_per_pixel); \
|
||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
||||
type *pixel; \
|
||||
if (y1 <= y2) { \
|
||||
pixel = (type *)dst->pixels + y1 * pitch + x1; \
|
||||
|
@ -628,7 +628,7 @@
|
|||
do { \
|
||||
int width = rect->w; \
|
||||
int height = rect->h; \
|
||||
int pitch = (dst->pitch / dst->format->bytes_per_pixel); \
|
||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel); \
|
||||
int skip = pitch - width; \
|
||||
type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
|
||||
while (height--) { \
|
||||
|
|
|
@ -31,7 +31,7 @@ static void SDL_DrawLine1(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
|
|||
{
|
||||
if (y1 == y2) {
|
||||
int length;
|
||||
int pitch = (dst->pitch / dst->format->bytes_per_pixel);
|
||||
int pitch = (dst->pitch / dst->internal->format->bytes_per_pixel);
|
||||
Uint8 *pixel;
|
||||
if (x1 <= x2) {
|
||||
pixel = (Uint8 *)dst->pixels + y1 * pitch + x1;
|
||||
|
@ -64,8 +64,8 @@ static void SDL_DrawLine2(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
|
|||
DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
SDL_GetRGBA(color, fmt, dst->internal->palette, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x7C00) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
|
||||
|
@ -93,8 +93,8 @@ static void SDL_DrawLine4(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint
|
|||
DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
|
||||
} else {
|
||||
Uint8 _r, _g, _b, _a;
|
||||
const SDL_PixelFormat *fmt = dst->format;
|
||||
SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
|
||||
const SDL_PixelFormatDetails *fmt = dst->internal->format;
|
||||
SDL_GetRGBA(color, fmt, dst->internal->palette, &_r, &_g, &_b, &_a);
|
||||
if (fmt->Rmask == 0x00FF0000) {
|
||||
if (!fmt->Amask) {
|
||||
AALINE(x1, y1, x2, y2,
|
||||
|
@ -117,7 +117,7 @@ typedef void (*DrawLineFunc)(SDL_Surface *dst,
|
|||
int x1, int y1, int x2, int y2,
|
||||
Uint32 color, SDL_bool draw_end);
|
||||
|
||||
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormat *fmt)
|
||||
static DrawLineFunc SDL_CalculateDrawLineFunc(const SDL_PixelFormatDetails *fmt)
|
||||
{
|
||||
switch (fmt->bytes_per_pixel) {
|
||||
case 1:
|
||||
|
@ -137,18 +137,18 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color)
|
|||
{
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_DrawLine(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
func = SDL_CalculateDrawLineFunc(dst->internal->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLine(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,11 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
SDL_bool draw_end;
|
||||
DrawLineFunc func;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_DrawLines(): dst");
|
||||
}
|
||||
|
||||
func = SDL_CalculateDrawLineFunc(dst->format);
|
||||
func = SDL_CalculateDrawLineFunc(dst->internal->format);
|
||||
if (!func) {
|
||||
return SDL_SetError("SDL_DrawLines(): Unsupported surface format");
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
|
||||
/* Perform clipping */
|
||||
/* FIXME: We don't actually want to clip, as it may change line slope */
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
if (!SDL_GetRectAndLineIntersection(&dst->internal->clip_rect, &x1, &y1, &x2, &y2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,23 +27,23 @@
|
|||
|
||||
int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoint(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoint(): Unsupported surface format");
|
||||
}
|
||||
|
||||
/* Perform clipping */
|
||||
if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
|
||||
x >= (dst->clip_rect.x + dst->clip_rect.w) ||
|
||||
y >= (dst->clip_rect.y + dst->clip_rect.h)) {
|
||||
if (x < dst->internal->clip_rect.x || y < dst->internal->clip_rect.y ||
|
||||
x >= (dst->internal->clip_rect.x + dst->internal->clip_rect.w) ||
|
||||
y >= (dst->internal->clip_rect.y + dst->internal->clip_rect.h)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (dst->format->bytes_per_pixel) {
|
||||
switch (dst->internal->format->bytes_per_pixel) {
|
||||
case 1:
|
||||
DRAW_FASTSETPIXELXY1(x, y);
|
||||
break;
|
||||
|
@ -67,19 +67,19 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
int i;
|
||||
int x, y;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_DrawPoints(): dst");
|
||||
}
|
||||
|
||||
/* This function doesn't work on surfaces < 8 bpp */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (dst->internal->format->bits_per_pixel < 8) {
|
||||
return SDL_SetError("SDL_DrawPoints(): Unsupported surface format");
|
||||
}
|
||||
|
||||
minx = dst->clip_rect.x;
|
||||
maxx = dst->clip_rect.x + dst->clip_rect.w - 1;
|
||||
miny = dst->clip_rect.y;
|
||||
maxy = dst->clip_rect.y + dst->clip_rect.h - 1;
|
||||
minx = dst->internal->clip_rect.x;
|
||||
maxx = dst->internal->clip_rect.x + dst->internal->clip_rect.w - 1;
|
||||
miny = dst->internal->clip_rect.y;
|
||||
maxy = dst->internal->clip_rect.y + dst->internal->clip_rect.h - 1;
|
||||
|
||||
for (i = 0; i < count; ++i) {
|
||||
x = points[i].x;
|
||||
|
@ -89,7 +89,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count,
|
|||
continue;
|
||||
}
|
||||
|
||||
switch (dst->format->bytes_per_pixel) {
|
||||
switch (dst->internal->format->bytes_per_pixel) {
|
||||
case 1:
|
||||
DRAW_FASTSETPIXELXY1(x, y);
|
||||
break;
|
||||
|
|
|
@ -104,7 +104,7 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
|||
SDL_Surface *surface = SDL_CreateSurface(texture->w, texture->h, texture->format);
|
||||
Uint8 r, g, b, a;
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return SDL_SetError("Cannot create surface");
|
||||
}
|
||||
texture->driverdata = surface;
|
||||
|
@ -119,7 +119,7 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
|
|||
/* Only RLE encode textures without an alpha channel since the RLE coder
|
||||
* discards the color values of pixels with an alpha value of zero.
|
||||
*/
|
||||
if (texture->access == SDL_TEXTUREACCESS_STATIC && !surface->format->Amask) {
|
||||
if (texture->access == SDL_TEXTUREACCESS_STATIC && !SDL_ISPIXELFORMAT_ALPHA(surface->format)) {
|
||||
SDL_SetSurfaceRLE(surface, 1);
|
||||
}
|
||||
|
||||
|
@ -140,8 +140,8 @@ static int SW_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||
src = (Uint8 *)pixels;
|
||||
dst = (Uint8 *)surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->bytes_per_pixel;
|
||||
length = (size_t)rect->w * surface->format->bytes_per_pixel;
|
||||
rect->x * surface->internal->format->bytes_per_pixel;
|
||||
length = (size_t)rect->w * surface->internal->format->bytes_per_pixel;
|
||||
for (row = 0; row < rect->h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
src += pitch;
|
||||
|
@ -160,7 +160,7 @@ static int SW_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||
|
||||
*pixels =
|
||||
(void *)((Uint8 *)surface->pixels + rect->y * surface->pitch +
|
||||
rect->x * surface->format->bytes_per_pixel);
|
||||
rect->x * surface->internal->format->bytes_per_pixel);
|
||||
*pitch = surface->pitch;
|
||||
return 0;
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
|||
int blitRequired = SDL_FALSE;
|
||||
int isOpaque = SDL_FALSE;
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
|||
/* Clone the source surface but use its pixel buffer directly.
|
||||
* The original source surface must be treated as read-only.
|
||||
*/
|
||||
src_clone = SDL_CreateSurfaceFrom(src->pixels, src->w, src->h, src->pitch, src->format->format);
|
||||
src_clone = SDL_CreateSurfaceFrom(src->w, src->h, src->format, src->pixels, src->pitch);
|
||||
if (!src_clone) {
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
|
@ -360,7 +360,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
|||
SDL_GetSurfaceColorMod(src, &rMod, &gMod, &bMod);
|
||||
|
||||
/* SDLgfx_rotateSurface only accepts 32-bit surfaces with a 8888 layout. Everything else has to be converted. */
|
||||
if (src->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format->format) != SDL_PACKEDLAYOUT_8888 || !src->format->Amask) {
|
||||
if (src->internal->format->bits_per_pixel != 32 || SDL_PIXELLAYOUT(src->format) != SDL_PACKEDLAYOUT_8888 || !SDL_ISPIXELFORMAT_ALPHA(src->format)) {
|
||||
blitRequired = SDL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
|||
}
|
||||
|
||||
/* Opaque surfaces are much easier to handle with the NONE blend mode. */
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !src->format->Amask && alphaMod == 255) {
|
||||
if (blendmode == SDL_BLENDMODE_NONE && !SDL_ISPIXELFORMAT_ALPHA(src->format) && alphaMod == 255) {
|
||||
isOpaque = SDL_TRUE;
|
||||
}
|
||||
|
||||
|
@ -482,15 +482,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
|
|||
* mode modulates the colors with the alpha channel, a surface without an alpha mask needs
|
||||
* to be created. This makes all source pixels opaque and the colors get copied correctly.
|
||||
*/
|
||||
SDL_Surface *src_rotated_rgb;
|
||||
SDL_PixelFormatEnum f = SDL_GetPixelFormatEnumForMasks(src_rotated->format->bits_per_pixel,
|
||||
src_rotated->format->Rmask,
|
||||
src_rotated->format->Gmask,
|
||||
src_rotated->format->Bmask,
|
||||
0);
|
||||
|
||||
src_rotated_rgb = SDL_CreateSurfaceFrom(src_rotated->pixels, src_rotated->w, src_rotated->h,
|
||||
src_rotated->pitch, f);
|
||||
SDL_Surface *src_rotated_rgb = SDL_CreateSurfaceFrom(src_rotated->w, src_rotated->h, src_rotated->format, src_rotated->pixels, src_rotated->pitch);
|
||||
if (!src_rotated_rgb) {
|
||||
retval = -1;
|
||||
} else {
|
||||
|
@ -680,7 +672,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
SW_DrawStateCache drawstate;
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -725,7 +717,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
const Uint8 a = (Uint8)SDL_roundf(SDL_clamp(cmd->data.color.color.a, 0.0f, 1.0f) * 255.0f);
|
||||
/* By definition the clear ignores the clip rect */
|
||||
SDL_SetSurfaceClipRect(surface, NULL);
|
||||
SDL_FillSurfaceRect(surface, NULL, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
SDL_FillSurfaceRect(surface, NULL, SDL_MapSurfaceRGBA(surface, r, g, b, a));
|
||||
drawstate.surface_cliprect_dirty = SDL_TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -751,7 +743,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawPoints(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
SDL_DrawPoints(surface, verts, count, SDL_MapSurfaceRGBA(surface, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendPoints(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
|
@ -779,7 +771,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_DrawLines(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
SDL_DrawLines(surface, verts, count, SDL_MapSurfaceRGBA(surface, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendLines(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
|
@ -807,7 +799,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_NONE) {
|
||||
SDL_FillSurfaceRects(surface, verts, count, SDL_MapRGBA(surface->format, r, g, b, a));
|
||||
SDL_FillSurfaceRects(surface, verts, count, SDL_MapSurfaceRGBA(surface, r, g, b, a));
|
||||
} else {
|
||||
SDL_BlendFillRects(surface, verts, count, blend, r, g, b, a);
|
||||
}
|
||||
|
@ -842,7 +834,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo
|
|||
|
||||
/* Prevent to do scaling + clipping on viewport boundaries as it may lose proportion */
|
||||
if (dstrect->x < 0 || dstrect->y < 0 || dstrect->x + dstrect->w > surface->w || dstrect->y + dstrect->h > surface->h) {
|
||||
SDL_Surface *tmp = SDL_CreateSurface(dstrect->w, dstrect->h, src->format->format);
|
||||
SDL_Surface *tmp = SDL_CreateSurface(dstrect->w, dstrect->h, src->format);
|
||||
/* Scale to an intermediate surface, then blit */
|
||||
if (tmp) {
|
||||
SDL_Rect r;
|
||||
|
@ -971,7 +963,7 @@ static SDL_Surface *SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
|||
SDL_Surface *surface = SW_ActivateRenderer(renderer);
|
||||
void *pixels;
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -987,9 +979,9 @@ static SDL_Surface *SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *
|
|||
|
||||
pixels = (void *)((Uint8 *)surface->pixels +
|
||||
rect->y * surface->pitch +
|
||||
rect->x * surface->format->bytes_per_pixel);
|
||||
rect->x * surface->internal->format->bytes_per_pixel);
|
||||
|
||||
return SDL_DuplicatePixels(rect->w, rect->h, surface->format->format, SDL_COLORSPACE_SRGB, pixels, surface->pitch);
|
||||
return SDL_DuplicatePixels(rect->w, rect->h, surface->format, SDL_COLORSPACE_SRGB, pixels, surface->pitch);
|
||||
}
|
||||
|
||||
static int SW_RenderPresent(SDL_Renderer *renderer)
|
||||
|
@ -1020,7 +1012,7 @@ static void SW_DestroyRenderer(SDL_Renderer *renderer)
|
|||
SDL_free(data);
|
||||
}
|
||||
|
||||
static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormatEnum format)
|
||||
static void SW_SelectBestFormats(SDL_Renderer *renderer, SDL_PixelFormat format)
|
||||
{
|
||||
/* Prefer the format used by the framebuffer by default. */
|
||||
SDL_AddSupportedTextureFormat(renderer, format);
|
||||
|
@ -1119,7 +1111,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
|||
{
|
||||
SW_RenderData *data;
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return SDL_InvalidParamError("surface");
|
||||
}
|
||||
|
||||
|
@ -1160,7 +1152,7 @@ int SW_CreateRendererForSurface(SDL_Renderer *renderer, SDL_Surface *surface, SD
|
|||
|
||||
renderer->name = SW_RenderDriver.name;
|
||||
|
||||
SW_SelectBestFormats(renderer, surface->format->format);
|
||||
SW_SelectBestFormats(renderer, surface->format);
|
||||
|
||||
SDL_SetupRendererColorspace(renderer, create_props);
|
||||
|
||||
|
@ -1193,7 +1185,7 @@ static int SW_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_Pro
|
|||
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "");
|
||||
}
|
||||
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,10 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
|
|||
#include "../../core/windows/SDL_windows.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL_rotate.h"
|
||||
|
||||
#include "../../video/SDL_blit.h"
|
||||
|
||||
/* ---- Internally used structures */
|
||||
|
||||
/**
|
||||
|
@ -491,14 +490,13 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
|||
{
|
||||
SDL_Surface *rz_dst;
|
||||
int is8bit, angle90;
|
||||
int i;
|
||||
SDL_BlendMode blendmode;
|
||||
Uint32 colorkey = 0;
|
||||
int colorKeyAvailable = SDL_FALSE;
|
||||
double sangleinv, cangleinv;
|
||||
|
||||
/* Sanity check */
|
||||
if (!src) {
|
||||
if (!SDL_SurfaceValid(src)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -508,8 +506,8 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
|||
}
|
||||
}
|
||||
/* This function requires a 32-bit surface or 8-bit surface with a colorkey */
|
||||
is8bit = src->format->bits_per_pixel == 8 && colorKeyAvailable;
|
||||
if (!(is8bit || (src->format->bits_per_pixel == 32 && src->format->Amask))) {
|
||||
is8bit = src->internal->format->bits_per_pixel == 8 && colorKeyAvailable;
|
||||
if (!(is8bit || (src->internal->format->bits_per_pixel == 32 && SDL_ISPIXELFORMAT_ALPHA(src->format)))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -521,18 +519,13 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
|||
rz_dst = NULL;
|
||||
if (is8bit) {
|
||||
/* Target surface is 8 bit */
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format);
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||
if (rz_dst) {
|
||||
if (src->format->palette) {
|
||||
for (i = 0; i < src->format->palette->ncolors; i++) {
|
||||
rz_dst->format->palette->colors[i] = src->format->palette->colors[i];
|
||||
}
|
||||
rz_dst->format->palette->ncolors = src->format->palette->ncolors;
|
||||
}
|
||||
SDL_SetSurfacePalette(rz_dst, src->internal->palette);
|
||||
}
|
||||
} else {
|
||||
/* Target surface is 32 bit with source RGBA ordering */
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format);
|
||||
rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format);
|
||||
}
|
||||
|
||||
/* Check target */
|
||||
|
@ -555,7 +548,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in
|
|||
/* Without a colorkey, the target texture has to be white for the MOD and MUL blend mode so
|
||||
* that the pixels outside the rotated area don't affect the destination surface.
|
||||
*/
|
||||
colorkey = SDL_MapRGBA(rz_dst->format, 255, 255, 255, 0);
|
||||
colorkey = SDL_MapSurfaceRGBA(rz_dst, 255, 255, 255, 0);
|
||||
SDL_FillSurfaceRect(rz_dst, NULL, colorkey);
|
||||
/* Setting a white colorkey for the destination surface makes the final blit discard
|
||||
* all pixels outside of the rotated area. This doesn't interfere with anything because
|
||||
|
|
|
@ -190,7 +190,7 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin
|
|||
Uint8 g = (Uint8)(((Sint64)w0 * c0.g + (Sint64)w1 * c1.g + (Sint64)w2 * c2.g) / area); \
|
||||
Uint8 b = (Uint8)(((Sint64)w0 * c0.b + (Sint64)w1 * c1.b + (Sint64)w2 * c2.b) / area); \
|
||||
Uint8 a = (Uint8)(((Sint64)w0 * c0.a + (Sint64)w1 * c1.a + (Sint64)w2 * c2.a) / area); \
|
||||
Uint32 color = SDL_MapRGBA(format, r, g, b, a);
|
||||
Uint32 color = SDL_MapRGBA(format, palette, r, g, b, a);
|
||||
|
||||
#define TRIANGLE_GET_COLOR \
|
||||
int r = (int)(((Sint64)w0 * c0.r + (Sint64)w1 * c1.r + (Sint64)w2 * c2.r) / area); \
|
||||
|
@ -235,7 +235,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
|||
|
||||
SDL_Surface *tmp = NULL;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -278,10 +278,10 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
|||
}
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE) {
|
||||
SDL_PixelFormatEnum format = dst->format->format;
|
||||
SDL_PixelFormat format = dst->format;
|
||||
|
||||
/* need an alpha format */
|
||||
if (!dst->format->Amask) {
|
||||
if (!SDL_ISPIXELFORMAT_ALPHA(format)) {
|
||||
format = SDL_PIXELFORMAT_ARGB8888;
|
||||
}
|
||||
|
||||
|
@ -293,19 +293,19 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
|||
}
|
||||
|
||||
if (blend == SDL_BLENDMODE_MOD) {
|
||||
Uint32 c = SDL_MapRGBA(tmp->format, 255, 255, 255, 255);
|
||||
Uint32 c = SDL_MapSurfaceRGBA(tmp, 255, 255, 255, 255);
|
||||
SDL_FillSurfaceRect(tmp, NULL, c);
|
||||
}
|
||||
|
||||
SDL_SetSurfaceBlendMode(tmp, blend);
|
||||
|
||||
dstbpp = tmp->format->bytes_per_pixel;
|
||||
dstbpp = tmp->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)tmp->pixels;
|
||||
dst_pitch = tmp->pitch;
|
||||
|
||||
} else {
|
||||
/* Write directly to destination surface */
|
||||
dstbpp = dst->format->bytes_per_pixel;
|
||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||
dst_pitch = dst->pitch;
|
||||
}
|
||||
|
@ -359,9 +359,9 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
|||
if (is_uniform) {
|
||||
Uint32 color;
|
||||
if (tmp) {
|
||||
color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a);
|
||||
color = SDL_MapSurfaceRGBA(tmp, c0.r, c0.g, c0.b, c0.a);
|
||||
} else {
|
||||
color = SDL_MapRGBA(dst->format, c0.r, c0.g, c0.b, c0.a);
|
||||
color = SDL_MapSurfaceRGBA(dst, c0.r, c0.g, c0.b, c0.a);
|
||||
}
|
||||
|
||||
if (dstbpp == 4) {
|
||||
|
@ -393,9 +393,14 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin
|
|||
TRIANGLE_END_LOOP
|
||||
}
|
||||
} else {
|
||||
SDL_PixelFormat *format = dst->format;
|
||||
const SDL_PixelFormatDetails *format;
|
||||
SDL_Palette *palette;
|
||||
if (tmp) {
|
||||
format = tmp->format;
|
||||
format = tmp->internal->format;
|
||||
palette = tmp->internal->palette;
|
||||
} else {
|
||||
format = dst->internal->format;
|
||||
palette = dst->internal->palette;
|
||||
}
|
||||
if (dstbpp == 4) {
|
||||
TRIANGLE_BEGIN_LOOP
|
||||
|
@ -481,10 +486,10 @@ int SDL_SW_BlitTriangle(
|
|||
|
||||
int has_modulation;
|
||||
|
||||
if (!src) {
|
||||
if (!SDL_SurfaceValid(src)) {
|
||||
return SDL_InvalidParamError("src");
|
||||
}
|
||||
if (!src) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("dst");
|
||||
}
|
||||
|
||||
|
@ -578,7 +583,7 @@ int SDL_SW_BlitTriangle(
|
|||
}
|
||||
|
||||
/* Set destination pointer */
|
||||
dstbpp = dst->format->bytes_per_pixel;
|
||||
dstbpp = dst->internal->format->bytes_per_pixel;
|
||||
dst_ptr = (Uint8 *)dst->pixels + dstrect.x * dstbpp + dstrect.y * dst->pitch;
|
||||
dst_pitch = dst->pitch;
|
||||
|
||||
|
@ -653,16 +658,16 @@ int SDL_SW_BlitTriangle(
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || !is_uniform) {
|
||||
if (blend != SDL_BLENDMODE_NONE || src->format != dst->format || has_modulation || !is_uniform) {
|
||||
/* Use SDL_BlitTriangle_Slow */
|
||||
|
||||
SDL_BlitInfo *info = &src->map->info;
|
||||
SDL_BlitInfo *info = &src->internal->map.info;
|
||||
SDL_BlitInfo tmp_info;
|
||||
|
||||
SDL_zero(tmp_info);
|
||||
|
||||
tmp_info.src_fmt = src->format;
|
||||
tmp_info.dst_fmt = dst->format;
|
||||
tmp_info.src_fmt = src->internal->format;
|
||||
tmp_info.dst_fmt = dst->internal->format;
|
||||
tmp_info.flags = info->flags;
|
||||
/*
|
||||
tmp_info.r = info->r;
|
||||
|
@ -766,7 +771,7 @@ end:
|
|||
#define FORMAT_2101010 1
|
||||
#define FORMAT_HAS_ALPHA(format) format == 0
|
||||
#define FORMAT_HAS_NO_ALPHA(format) format < 0
|
||||
static int detect_format(SDL_PixelFormat *pf)
|
||||
static int detect_format(const SDL_PixelFormatDetails *pf)
|
||||
{
|
||||
if (pf->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
return FORMAT_2101010;
|
||||
|
@ -792,8 +797,8 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info,
|
|||
Uint32 srcR, srcG, srcB, srcA;
|
||||
Uint32 dstpixel;
|
||||
Uint32 dstR, dstG, dstB, dstA;
|
||||
SDL_PixelFormat *src_fmt = info->src_fmt;
|
||||
SDL_PixelFormat *dst_fmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *src_fmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dst_fmt = info->dst_fmt;
|
||||
int srcbpp = src_fmt->bytes_per_pixel;
|
||||
int dstbpp = dst_fmt->bytes_per_pixel;
|
||||
int srcfmt_val;
|
||||
|
|
|
@ -367,7 +367,7 @@ typedef struct
|
|||
SDL_bool issueBatch;
|
||||
} VULKAN_RenderData;
|
||||
|
||||
static SDL_PixelFormatEnum VULKAN_VkFormatToSDLPixelFormat(VkFormat vkFormat)
|
||||
static SDL_PixelFormat VULKAN_VkFormatToSDLPixelFormat(VkFormat vkFormat)
|
||||
{
|
||||
switch (vkFormat) {
|
||||
case VK_FORMAT_B8G8R8A8_UNORM:
|
||||
|
|
|
@ -1038,14 +1038,14 @@ static void SDLTest_PrintRenderer(SDL_Renderer *renderer)
|
|||
int i;
|
||||
char text[1024];
|
||||
int max_texture_size;
|
||||
const SDL_PixelFormatEnum *texture_formats;
|
||||
const SDL_PixelFormat *texture_formats;
|
||||
|
||||
name = SDL_GetRendererName(renderer);
|
||||
|
||||
SDL_Log(" Renderer %s:\n", name);
|
||||
SDL_Log(" VSync: %d\n", (int)SDL_GetNumberProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_VSYNC_NUMBER, 0));
|
||||
|
||||
texture_formats = (const SDL_PixelFormatEnum *)SDL_GetProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
|
||||
texture_formats = (const SDL_PixelFormat *)SDL_GetProperty(SDL_GetRendererProperties(renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
|
||||
if (texture_formats) {
|
||||
(void)SDL_snprintf(text, sizeof(text), " Texture formats: ");
|
||||
for (i = 0; texture_formats[i]; ++i) {
|
||||
|
@ -1074,7 +1074,7 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (icon->format->palette) {
|
||||
if (icon->format == SDL_PIXELFORMAT_INDEX8) {
|
||||
/* Set the colorkey */
|
||||
SDL_SetSurfaceColorKey(icon, 1, *((Uint8 *)icon->pixels));
|
||||
}
|
||||
|
@ -1218,7 +1218,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
|||
SDL_Log("Usable bounds: %dx%d at %d,%d\n", usablebounds.w, usablebounds.h, usablebounds.x, usablebounds.y);
|
||||
|
||||
mode = SDL_GetDesktopDisplayMode(displayID);
|
||||
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask, &Gmask,
|
||||
SDL_GetMasksForPixelFormat(mode->format, &bpp, &Rmask, &Gmask,
|
||||
&Bmask, &Amask);
|
||||
SDL_Log(" Desktop mode: %dx%d@%gx %gHz, %d bits-per-pixel (%s)\n",
|
||||
mode->w, mode->h, mode->pixel_density, mode->refresh_rate, bpp,
|
||||
|
@ -1240,7 +1240,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
|
|||
SDL_Log(" Fullscreen video modes:\n");
|
||||
for (j = 0; j < m; ++j) {
|
||||
mode = modes[j];
|
||||
SDL_GetMasksForPixelFormatEnum(mode->format, &bpp, &Rmask,
|
||||
SDL_GetMasksForPixelFormat(mode->format, &bpp, &Rmask,
|
||||
&Gmask, &Bmask, &Amask);
|
||||
SDL_Log(" Mode %d: %dx%d@%gx %gHz, %d bits-per-pixel (%s)\n",
|
||||
j, mode->w, mode->h, mode->pixel_density, mode->refresh_rate, bpp,
|
||||
|
|
|
@ -33,17 +33,6 @@
|
|||
/* Counter for _CompareSurface calls; used for filename creation when comparisons fail */
|
||||
static int _CompareSurfaceCount = 0;
|
||||
|
||||
static void
|
||||
LogErrorFormat(const char *name, const SDL_PixelFormat *format)
|
||||
{
|
||||
SDLTest_LogError("%s: %08d %s, %u bits/%u bytes per pixel", name, format->format, SDL_GetPixelFormatName(format->format),
|
||||
format->bits_per_pixel, format->bytes_per_pixel);
|
||||
SDLTest_LogError("%s: R mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Rmask, format->Rloss, format->Rshift);
|
||||
SDLTest_LogError("%s: G mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Gmask, format->Gloss, format->Gshift);
|
||||
SDLTest_LogError("%s: B mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Bmask, format->Bloss, format->Bshift);
|
||||
SDLTest_LogError("%s: A mask %08" SDL_PRIx32 ", loss %u, shift %u", name, format->Amask, format->Aloss, format->Ashift);
|
||||
}
|
||||
|
||||
/* Compare surfaces */
|
||||
int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error)
|
||||
{
|
||||
|
@ -135,8 +124,8 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface,
|
|||
_CompareSurfaceCount++;
|
||||
if (ret != 0) {
|
||||
SDLTest_LogError("Comparison of pixels with allowable error of %i failed %i times.", allowable_error, ret);
|
||||
LogErrorFormat("Reference surface format", referenceSurface->format);
|
||||
LogErrorFormat("Actual surface format ", surface->format);
|
||||
SDLTest_LogError("Reference surface format: %s", SDL_GetPixelFormatName(referenceSurface->format));
|
||||
SDLTest_LogError("Actual surface format: %s", SDL_GetPixelFormatName(surface->format));
|
||||
SDLTest_LogError("First detected occurrence at position %i,%i with a squared RGB-difference of %i.", sampleErrorX, sampleErrorY, sampleDist);
|
||||
SDLTest_LogError("Reference pixel: R=%u G=%u B=%u A=%u", sampleReference.r, sampleReference.g, sampleReference.b, sampleReference.a);
|
||||
SDLTest_LogError("Actual pixel : R=%u G=%u B=%u A=%u", sampleActual.r, sampleActual.g, sampleActual.b, sampleActual.a);
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
*
|
||||
* Encoding of surfaces with per-pixel alpha:
|
||||
*
|
||||
* The sequence begins with a struct RLEDestFormat describing the target
|
||||
* The sequence begins with a struct SDL_PixelFormatDetails describing the target
|
||||
* pixel format, to provide reliable un-encoding.
|
||||
*
|
||||
* Each scan line is encoded twice: First all completely opaque pixels,
|
||||
|
@ -375,9 +375,9 @@
|
|||
*/
|
||||
#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
Pixel = ((r >> fmt->Rloss) << fmt->Rshift) | \
|
||||
((g >> fmt->Gloss) << fmt->Gshift) | \
|
||||
((b >> fmt->Bloss) << fmt->Bshift) | \
|
||||
Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \
|
||||
((g >> (8 - fmt->Gbits)) << fmt->Gshift) | \
|
||||
((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \
|
||||
(a << 24); \
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@
|
|||
static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
||||
Uint8 *dstbuf, const SDL_Rect *srcrect, unsigned alpha)
|
||||
{
|
||||
SDL_PixelFormat *fmt = surf_dst->format;
|
||||
const SDL_PixelFormatDetails *fmt = surf_dst->internal->format;
|
||||
|
||||
CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt);
|
||||
}
|
||||
|
@ -461,8 +461,8 @@ static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect,
|
|||
/* Set up the source and destination pointers */
|
||||
x = dstrect->x;
|
||||
y = dstrect->y;
|
||||
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * surf_src->format->bytes_per_pixel;
|
||||
srcbuf = (Uint8 *)surf_src->map->data;
|
||||
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * surf_src->internal->format->bytes_per_pixel;
|
||||
srcbuf = (Uint8 *)surf_src->internal->map.data + sizeof(SDL_PixelFormat);
|
||||
|
||||
{
|
||||
/* skip lines at the top if necessary */
|
||||
|
@ -488,7 +488,7 @@ static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect,
|
|||
} \
|
||||
}
|
||||
|
||||
switch (surf_src->format->bytes_per_pixel) {
|
||||
switch (surf_src->internal->format->bytes_per_pixel) {
|
||||
case 1:
|
||||
RLESKIP(1, Uint8);
|
||||
break;
|
||||
|
@ -507,12 +507,12 @@ static int SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect,
|
|||
}
|
||||
}
|
||||
|
||||
alpha = surf_src->map->info.a;
|
||||
alpha = surf_src->internal->map.info.a;
|
||||
/* if left or right edge clipping needed, call clip blit */
|
||||
if (srcrect->x || srcrect->w != surf_src->w) {
|
||||
RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha);
|
||||
} else {
|
||||
SDL_PixelFormat *fmt = surf_src->format;
|
||||
const SDL_PixelFormatDetails *fmt = surf_src->internal->format;
|
||||
|
||||
#define RLEBLIT(bpp, Type, do_blit) \
|
||||
do { \
|
||||
|
@ -604,31 +604,11 @@ done:
|
|||
dst = (Uint16)(d | d >> 16); \
|
||||
} while (0)
|
||||
|
||||
/* used to save the destination format in the encoding. Designed to be
|
||||
macro-compatible with SDL_PixelFormat but without the unneeded fields */
|
||||
typedef struct
|
||||
{
|
||||
Uint8 bytes_per_pixel;
|
||||
Uint8 padding[3];
|
||||
Uint32 Rmask;
|
||||
Uint32 Gmask;
|
||||
Uint32 Bmask;
|
||||
Uint32 Amask;
|
||||
Uint8 Rloss;
|
||||
Uint8 Gloss;
|
||||
Uint8 Bloss;
|
||||
Uint8 Aloss;
|
||||
Uint8 Rshift;
|
||||
Uint8 Gshift;
|
||||
Uint8 Bshift;
|
||||
Uint8 Ashift;
|
||||
} RLEDestFormat;
|
||||
|
||||
/* blit a pixel-alpha RLE surface clipped at the right and/or left edges */
|
||||
static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst,
|
||||
Uint8 *dstbuf, const SDL_Rect *srcrect)
|
||||
{
|
||||
SDL_PixelFormat *df = surf_dst->format;
|
||||
const SDL_PixelFormatDetails *df = surf_dst->internal->format;
|
||||
/*
|
||||
* clipped blitter: Ptype is the destination pixel type,
|
||||
* Ctype the translucent count type, and do_blend the macro
|
||||
|
@ -723,7 +703,7 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre
|
|||
int x, y;
|
||||
int w = surf_src->w;
|
||||
Uint8 *srcbuf, *dstbuf;
|
||||
SDL_PixelFormat *df = surf_dst->format;
|
||||
const SDL_PixelFormatDetails *df = surf_dst->internal->format;
|
||||
|
||||
/* Lock the destination if necessary */
|
||||
if (SDL_MUSTLOCK(surf_dst)) {
|
||||
|
@ -735,7 +715,7 @@ static int SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcre
|
|||
x = dstrect->x;
|
||||
y = dstrect->y;
|
||||
dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * df->bytes_per_pixel;
|
||||
srcbuf = (Uint8 *)surf_src->map->data + sizeof(RLEDestFormat);
|
||||
srcbuf = (Uint8 *)surf_src->internal->map.data + sizeof(SDL_PixelFormat);
|
||||
|
||||
{
|
||||
/* skip lines at the top if necessary */
|
||||
|
@ -884,7 +864,7 @@ done:
|
|||
|
||||
/* encode 32bpp rgb + a into 16bpp rgb, losing alpha */
|
||||
static int copy_opaque_16(void *dst, const Uint32 *src, int n,
|
||||
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
Uint16 *d = (Uint16 *)dst;
|
||||
|
@ -900,7 +880,7 @@ static int copy_opaque_16(void *dst, const Uint32 *src, int n,
|
|||
|
||||
/* decode opaque pixels from 16bpp to 32bpp rgb + a */
|
||||
static int uncopy_opaque_16(Uint32 *dst, const void *src, int n,
|
||||
RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
const Uint16 *s = (const Uint16 *)src;
|
||||
|
@ -917,7 +897,7 @@ static int uncopy_opaque_16(Uint32 *dst, const void *src, int n,
|
|||
|
||||
/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 */
|
||||
static int copy_transl_565(void *dst, const Uint32 *src, int n,
|
||||
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
Uint32 *d = (Uint32 *)dst;
|
||||
|
@ -935,7 +915,7 @@ static int copy_transl_565(void *dst, const Uint32 *src, int n,
|
|||
|
||||
/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 */
|
||||
static int copy_transl_555(void *dst, const Uint32 *src, int n,
|
||||
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
Uint32 *d = (Uint32 *)dst;
|
||||
|
@ -953,7 +933,7 @@ static int copy_transl_555(void *dst, const Uint32 *src, int n,
|
|||
|
||||
/* decode translucent pixels from 32bpp GORAB to 32bpp rgb + a */
|
||||
static int uncopy_transl_16(Uint32 *dst, const void *src, int n,
|
||||
RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
const Uint32 *s = (const Uint32 *)src;
|
||||
|
@ -971,7 +951,7 @@ static int uncopy_transl_16(Uint32 *dst, const void *src, int n,
|
|||
|
||||
/* encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */
|
||||
static int copy_32(void *dst, const Uint32 *src, int n,
|
||||
SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
Uint32 *d = (Uint32 *)dst;
|
||||
|
@ -987,7 +967,7 @@ static int copy_32(void *dst, const Uint32 *src, int n,
|
|||
|
||||
/* decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */
|
||||
static int uncopy_32(Uint32 *dst, const void *src, int n,
|
||||
RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
|
||||
const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt)
|
||||
{
|
||||
int i;
|
||||
const Uint32 *s = (const Uint32 *)src;
|
||||
|
@ -1011,23 +991,23 @@ static int uncopy_32(Uint32 *dst, const void *src, int n,
|
|||
static int RLEAlphaSurface(SDL_Surface *surface)
|
||||
{
|
||||
SDL_Surface *dest;
|
||||
SDL_PixelFormat *df;
|
||||
const SDL_PixelFormatDetails *df;
|
||||
int maxsize = 0;
|
||||
int max_opaque_run;
|
||||
int max_transl_run = 65535;
|
||||
unsigned masksum;
|
||||
Uint8 *rlebuf, *dst;
|
||||
int (*copy_opaque)(void *, const Uint32 *, int,
|
||||
SDL_PixelFormat *, SDL_PixelFormat *);
|
||||
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
||||
int (*copy_transl)(void *, const Uint32 *, int,
|
||||
SDL_PixelFormat *, SDL_PixelFormat *);
|
||||
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
||||
|
||||
dest = surface->map->dst;
|
||||
dest = surface->internal->map.dst;
|
||||
if (!dest) {
|
||||
return -1;
|
||||
}
|
||||
df = dest->format;
|
||||
if (surface->format->bits_per_pixel != 32) {
|
||||
df = dest->internal->format;
|
||||
if (surface->internal->format->bits_per_pixel != 32) {
|
||||
return -1; /* only 32bpp source supported */
|
||||
}
|
||||
|
||||
|
@ -1078,35 +1058,20 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
|||
return -1; /* anything else unsupported right now */
|
||||
}
|
||||
|
||||
maxsize += sizeof(RLEDestFormat);
|
||||
maxsize += sizeof(SDL_PixelFormat);
|
||||
rlebuf = (Uint8 *)SDL_malloc(maxsize);
|
||||
if (!rlebuf) {
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
/* save the destination format so we can undo the encoding later */
|
||||
RLEDestFormat *r = (RLEDestFormat *)rlebuf;
|
||||
r->bytes_per_pixel = df->bytes_per_pixel;
|
||||
r->Rmask = df->Rmask;
|
||||
r->Gmask = df->Gmask;
|
||||
r->Bmask = df->Bmask;
|
||||
r->Amask = df->Amask;
|
||||
r->Rloss = df->Rloss;
|
||||
r->Gloss = df->Gloss;
|
||||
r->Bloss = df->Bloss;
|
||||
r->Aloss = df->Aloss;
|
||||
r->Rshift = df->Rshift;
|
||||
r->Gshift = df->Gshift;
|
||||
r->Bshift = df->Bshift;
|
||||
r->Ashift = df->Ashift;
|
||||
}
|
||||
dst = rlebuf + sizeof(RLEDestFormat);
|
||||
*(SDL_PixelFormat *)rlebuf = df->format;
|
||||
dst = rlebuf + sizeof(SDL_PixelFormat);
|
||||
|
||||
/* Do the actual encoding */
|
||||
{
|
||||
int x, y;
|
||||
int h = surface->h, w = surface->w;
|
||||
SDL_PixelFormat *sf = surface->format;
|
||||
const SDL_PixelFormatDetails *sf = surface->internal->format;
|
||||
Uint32 *src = (Uint32 *)surface->pixels;
|
||||
Uint8 *lastline = dst; /* end of last non-blank line */
|
||||
|
||||
|
@ -1213,10 +1178,10 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
|||
#undef ADD_TRANSL_COUNTS
|
||||
|
||||
/* Now that we have it encoded, release the original pixels */
|
||||
if (!(surface->flags & SDL_PREALLOC)) {
|
||||
if (surface->flags & SDL_SIMD_ALIGNED) {
|
||||
if (!(surface->flags & SDL_SURFACE_PREALLOCATED)) {
|
||||
if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) {
|
||||
SDL_aligned_free(surface->pixels);
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
surface->flags &= ~SDL_SURFACE_SIMD_ALIGNED;
|
||||
} else {
|
||||
SDL_free(surface->pixels);
|
||||
}
|
||||
|
@ -1229,7 +1194,7 @@ static int RLEAlphaSurface(SDL_Surface *surface)
|
|||
if (!p) {
|
||||
p = rlebuf;
|
||||
}
|
||||
surface->map->data = p;
|
||||
surface->internal->map.data = p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1272,7 +1237,7 @@ static int RLEColorkeySurface(SDL_Surface *surface)
|
|||
int y;
|
||||
Uint8 *srcbuf, *lastline;
|
||||
int maxsize = 0;
|
||||
const int bpp = surface->format->bytes_per_pixel;
|
||||
const int bpp = surface->internal->format->bytes_per_pixel;
|
||||
getpix_func getpix;
|
||||
Uint32 ckey, rgbmask;
|
||||
int w, h;
|
||||
|
@ -1307,8 +1272,8 @@ static int RLEColorkeySurface(SDL_Surface *surface)
|
|||
srcbuf = (Uint8 *)surface->pixels;
|
||||
maxn = bpp == 4 ? 65535 : 255;
|
||||
dst = rlebuf;
|
||||
rgbmask = ~surface->format->Amask;
|
||||
ckey = surface->map->info.colorkey & rgbmask;
|
||||
rgbmask = ~surface->internal->format->Amask;
|
||||
ckey = surface->internal->map.info.colorkey & rgbmask;
|
||||
lastline = dst;
|
||||
getpix = getpixes[bpp - 1];
|
||||
w = surface->w;
|
||||
|
@ -1380,10 +1345,10 @@ static int RLEColorkeySurface(SDL_Surface *surface)
|
|||
#undef ADD_COUNTS
|
||||
|
||||
/* Now that we have it encoded, release the original pixels */
|
||||
if (!(surface->flags & SDL_PREALLOC)) {
|
||||
if (surface->flags & SDL_SIMD_ALIGNED) {
|
||||
if (!(surface->flags & SDL_SURFACE_PREALLOCATED)) {
|
||||
if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) {
|
||||
SDL_aligned_free(surface->pixels);
|
||||
surface->flags &= ~SDL_SIMD_ALIGNED;
|
||||
surface->flags &= ~SDL_SURFACE_SIMD_ALIGNED;
|
||||
} else {
|
||||
SDL_free(surface->pixels);
|
||||
}
|
||||
|
@ -1397,7 +1362,7 @@ static int RLEColorkeySurface(SDL_Surface *surface)
|
|||
if (!p) {
|
||||
p = rlebuf;
|
||||
}
|
||||
surface->map->data = p;
|
||||
surface->internal->map.data = p;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1408,12 +1373,12 @@ int SDL_RLESurface(SDL_Surface *surface)
|
|||
int flags;
|
||||
|
||||
/* Clear any previous RLE conversion */
|
||||
if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
|
||||
SDL_UnRLESurface(surface, 1);
|
||||
if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
SDL_UnRLESurface(surface, SDL_TRUE);
|
||||
}
|
||||
|
||||
/* We don't support RLE encoding of bitmaps */
|
||||
if (surface->format->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(surface->format) < 8) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1422,10 +1387,10 @@ int SDL_RLESurface(SDL_Surface *surface)
|
|||
return -1;
|
||||
}
|
||||
|
||||
flags = surface->map->info.flags;
|
||||
flags = surface->internal->map.info.flags;
|
||||
if (flags & SDL_COPY_COLORKEY) {
|
||||
/* ok */
|
||||
} else if ((flags & SDL_COPY_BLEND) && surface->format->Amask) {
|
||||
} else if ((flags & SDL_COPY_BLEND) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) {
|
||||
/* ok */
|
||||
} else {
|
||||
/* If we don't have colorkey or blending, nothing to do... */
|
||||
|
@ -1434,32 +1399,33 @@ int SDL_RLESurface(SDL_Surface *surface)
|
|||
|
||||
/* Pass on combinations not supported */
|
||||
if ((flags & SDL_COPY_MODULATE_COLOR) ||
|
||||
((flags & SDL_COPY_MODULATE_ALPHA) && surface->format->Amask) ||
|
||||
((flags & SDL_COPY_MODULATE_ALPHA) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) ||
|
||||
(flags & (SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) ||
|
||||
(flags & SDL_COPY_NEAREST)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Encode and set up the blit */
|
||||
if (!surface->format->Amask || !(flags & SDL_COPY_BLEND)) {
|
||||
if (!surface->map->identity) {
|
||||
if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) || !(flags & SDL_COPY_BLEND)) {
|
||||
if (!surface->internal->map.identity) {
|
||||
return -1;
|
||||
}
|
||||
if (RLEColorkeySurface(surface) < 0) {
|
||||
return -1;
|
||||
}
|
||||
surface->map->blit = SDL_RLEBlit;
|
||||
surface->map->info.flags |= SDL_COPY_RLE_COLORKEY;
|
||||
surface->internal->map.blit = SDL_RLEBlit;
|
||||
surface->internal->map.info.flags |= SDL_COPY_RLE_COLORKEY;
|
||||
} else {
|
||||
if (RLEAlphaSurface(surface) < 0) {
|
||||
return -1;
|
||||
}
|
||||
surface->map->blit = SDL_RLEAlphaBlit;
|
||||
surface->map->info.flags |= SDL_COPY_RLE_ALPHAKEY;
|
||||
surface->internal->map.blit = SDL_RLEAlphaBlit;
|
||||
surface->internal->map.info.flags |= SDL_COPY_RLE_ALPHAKEY;
|
||||
}
|
||||
|
||||
/* The surface is now accelerated */
|
||||
surface->flags |= SDL_RLEACCEL;
|
||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1474,12 +1440,12 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface)
|
|||
{
|
||||
Uint8 *srcbuf;
|
||||
Uint32 *dst;
|
||||
SDL_PixelFormat *sf = surface->format;
|
||||
RLEDestFormat *df = (RLEDestFormat *)surface->map->data;
|
||||
const SDL_PixelFormatDetails *sf = surface->internal->format;
|
||||
const SDL_PixelFormatDetails *df = SDL_GetPixelFormatDetails(*(SDL_PixelFormat *)surface->internal->map.data);
|
||||
int (*uncopy_opaque)(Uint32 *, const void *, int,
|
||||
RLEDestFormat *, SDL_PixelFormat *);
|
||||
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
||||
int (*uncopy_transl)(Uint32 *, const void *, int,
|
||||
RLEDestFormat *, SDL_PixelFormat *);
|
||||
const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *);
|
||||
int w = surface->w;
|
||||
int bpp = df->bytes_per_pixel;
|
||||
size_t size;
|
||||
|
@ -1499,12 +1465,12 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface)
|
|||
if (!surface->pixels) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
surface->flags |= SDL_SIMD_ALIGNED;
|
||||
surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
|
||||
/* fill background with transparent pixels */
|
||||
SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch);
|
||||
|
||||
dst = (Uint32 *)surface->pixels;
|
||||
srcbuf = (Uint8 *)(df + 1);
|
||||
srcbuf = (Uint8 *)surface->internal->map.data + sizeof(SDL_PixelFormat);
|
||||
for (;;) {
|
||||
/* copy opaque pixels */
|
||||
int ofs = 0;
|
||||
|
@ -1551,32 +1517,35 @@ end_function:
|
|||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
void SDL_UnRLESurface(SDL_Surface *surface, int recode)
|
||||
void SDL_UnRLESurface(SDL_Surface *surface, SDL_bool recode)
|
||||
{
|
||||
if (surface->flags & SDL_RLEACCEL) {
|
||||
surface->flags &= ~SDL_RLEACCEL;
|
||||
if (surface->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
surface->internal->flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
|
||||
if (recode && !(surface->flags & SDL_PREALLOC)) {
|
||||
if (surface->map->info.flags & SDL_COPY_RLE_COLORKEY) {
|
||||
if (recode && !(surface->flags & SDL_SURFACE_PREALLOCATED)) {
|
||||
if (surface->internal->map.info.flags & SDL_COPY_RLE_COLORKEY) {
|
||||
SDL_Rect full;
|
||||
size_t size;
|
||||
|
||||
/* re-create the original surface */
|
||||
if (SDL_size_mul_overflow(surface->h, surface->pitch, &size)) {
|
||||
/* Memory corruption? */
|
||||
surface->flags |= SDL_RLEACCEL;
|
||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
return;
|
||||
}
|
||||
surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size);
|
||||
if (!surface->pixels) {
|
||||
/* Oh crap... */
|
||||
surface->flags |= SDL_RLEACCEL;
|
||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
return;
|
||||
}
|
||||
surface->flags |= SDL_SIMD_ALIGNED;
|
||||
surface->flags |= SDL_SURFACE_SIMD_ALIGNED;
|
||||
|
||||
/* fill it with the background color */
|
||||
SDL_FillSurfaceRect(surface, NULL, surface->map->info.colorkey);
|
||||
SDL_FillSurfaceRect(surface, NULL, surface->internal->map.info.colorkey);
|
||||
|
||||
/* now render the encoded surface */
|
||||
full.x = full.y = 0;
|
||||
|
@ -1586,16 +1555,17 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode)
|
|||
} else {
|
||||
if (!UnRLEAlpha(surface)) {
|
||||
/* Oh crap... */
|
||||
surface->flags |= SDL_RLEACCEL;
|
||||
surface->internal->flags |= SDL_INTERNAL_SURFACE_RLEACCEL;
|
||||
SDL_UpdateSurfaceLockFlag(surface);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
surface->map->info.flags &=
|
||||
surface->internal->map.info.flags &=
|
||||
~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
|
||||
|
||||
SDL_free(surface->map->data);
|
||||
surface->map->data = NULL;
|
||||
SDL_free(surface->internal->map.data);
|
||||
surface->internal->map.data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
/* Set up source and destination buffer pointers, and BLIT! */
|
||||
if (okay && !SDL_RectEmpty(srcrect)) {
|
||||
SDL_BlitFunc RunBlit;
|
||||
SDL_BlitInfo *info = &src->map->info;
|
||||
SDL_BlitInfo *info = &src->internal->map.info;
|
||||
|
||||
/* Set up the blit information */
|
||||
info->src = (Uint8 *)src->pixels +
|
||||
|
@ -80,7 +80,7 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
info->dst_pitch = dst->pitch;
|
||||
info->dst_skip =
|
||||
info->dst_pitch - info->dst_w * info->dst_fmt->bytes_per_pixel;
|
||||
RunBlit = (SDL_BlitFunc)src->map->data;
|
||||
RunBlit = (SDL_BlitFunc)src->internal->map.data;
|
||||
|
||||
/* Run the actual software blit */
|
||||
RunBlit(info);
|
||||
|
@ -122,7 +122,7 @@ static SDL_bool SDL_UseAltivecPrefetch(void)
|
|||
}
|
||||
#endif /* SDL_PLATFORM_MACOS */
|
||||
|
||||
static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
|
||||
static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelFormat dst_format, int flags,
|
||||
SDL_BlitFuncEntry *entries)
|
||||
{
|
||||
int i, flagcheck = (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL | SDL_COPY_COLORKEY | SDL_COPY_NEAREST));
|
||||
|
@ -179,37 +179,39 @@ static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int
|
|||
int SDL_CalculateBlit(SDL_Surface *surface)
|
||||
{
|
||||
SDL_BlitFunc blit = NULL;
|
||||
SDL_BlitMap *map = surface->map;
|
||||
SDL_BlitMap *map = &surface->internal->map;
|
||||
SDL_Surface *dst = map->dst;
|
||||
SDL_Colorspace src_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
SDL_Colorspace dst_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
SDL_Colorspace src_colorspace = SDL_GetSurfaceColorspace(surface);
|
||||
SDL_Colorspace dst_colorspace = SDL_GetSurfaceColorspace(dst);
|
||||
|
||||
if (SDL_GetSurfaceColorspace(surface, &src_colorspace) < 0) {
|
||||
if (src_colorspace == SDL_COLORSPACE_UNKNOWN) {
|
||||
return -1;
|
||||
}
|
||||
if (SDL_GetSurfaceColorspace(dst, &dst_colorspace) < 0) {
|
||||
if (dst_colorspace == SDL_COLORSPACE_UNKNOWN) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* We don't currently support blitting to < 8 bpp surfaces */
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
SDL_InvalidateMap(map);
|
||||
return SDL_SetError("Blit combination not supported");
|
||||
}
|
||||
|
||||
#if SDL_HAVE_RLE
|
||||
/* Clean everything out to start */
|
||||
if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
|
||||
SDL_UnRLESurface(surface, 1);
|
||||
if (surface->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
SDL_UnRLESurface(surface, SDL_TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
map->blit = SDL_SoftBlit;
|
||||
map->info.src_surface = surface;
|
||||
map->info.src_fmt = surface->format;
|
||||
map->info.src_fmt = surface->internal->format;
|
||||
map->info.src_pal = surface->internal->palette;
|
||||
map->info.src_pitch = surface->pitch;
|
||||
map->info.dst_surface = dst;
|
||||
map->info.dst_fmt = dst->format;
|
||||
map->info.dst_fmt = dst->internal->format;
|
||||
map->info.dst_pal = dst->internal->palette;
|
||||
map->info.dst_pitch = dst->pitch;
|
||||
|
||||
#if SDL_HAVE_RLE
|
||||
|
@ -224,26 +226,27 @@ int SDL_CalculateBlit(SDL_Surface *surface)
|
|||
/* Choose a standard blit function */
|
||||
if (!blit) {
|
||||
if (src_colorspace != dst_colorspace ||
|
||||
surface->format->bytes_per_pixel > 4 ||
|
||||
dst->format->bytes_per_pixel > 4) {
|
||||
SDL_BYTESPERPIXEL(surface->format) > 4 ||
|
||||
SDL_BYTESPERPIXEL(dst->format) > 4) {
|
||||
blit = SDL_Blit_Slow_Float;
|
||||
}
|
||||
}
|
||||
if (!blit) {
|
||||
if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) {
|
||||
blit = SDL_BlitCopy;
|
||||
} else if (surface->format->Rloss > 8 || dst->format->Rloss > 8) {
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(surface->format) ||
|
||||
SDL_ISPIXELFORMAT_10BIT(dst->format)) {
|
||||
blit = SDL_Blit_Slow;
|
||||
}
|
||||
#if SDL_HAVE_BLIT_0
|
||||
else if (surface->format->bits_per_pixel < 8 &&
|
||||
SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
|
||||
else if (SDL_BITSPERPIXEL(surface->format) < 8 &&
|
||||
SDL_ISPIXELFORMAT_INDEXED(surface->format)) {
|
||||
blit = SDL_CalculateBlit0(surface);
|
||||
}
|
||||
#endif
|
||||
#if SDL_HAVE_BLIT_1
|
||||
else if (surface->format->bytes_per_pixel == 1 &&
|
||||
SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
|
||||
else if (SDL_BYTESPERPIXEL(surface->format) == 1 &&
|
||||
SDL_ISPIXELFORMAT_INDEXED(surface->format)) {
|
||||
blit = SDL_CalculateBlit1(surface);
|
||||
}
|
||||
#endif
|
||||
|
@ -260,8 +263,8 @@ int SDL_CalculateBlit(SDL_Surface *surface)
|
|||
}
|
||||
#if SDL_HAVE_BLIT_AUTO
|
||||
if (!blit) {
|
||||
Uint32 src_format = surface->format->format;
|
||||
Uint32 dst_format = dst->format->format;
|
||||
SDL_PixelFormat src_format = surface->format;
|
||||
SDL_PixelFormat dst_format = dst->format;
|
||||
|
||||
blit =
|
||||
SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
|
||||
|
@ -273,8 +276,8 @@ int SDL_CalculateBlit(SDL_Surface *surface)
|
|||
if (!blit)
|
||||
#endif
|
||||
{
|
||||
Uint32 src_format = surface->format->format;
|
||||
Uint32 dst_format = dst->format->format;
|
||||
SDL_PixelFormat src_format = surface->format;
|
||||
SDL_PixelFormat dst_format = dst->format;
|
||||
|
||||
if (!SDL_ISPIXELFORMAT_INDEXED(src_format) &&
|
||||
!SDL_ISPIXELFORMAT_FOURCC(src_format) &&
|
||||
|
|
|
@ -61,8 +61,10 @@ typedef struct
|
|||
int dst_w, dst_h;
|
||||
int dst_pitch;
|
||||
int dst_skip;
|
||||
SDL_PixelFormat *src_fmt;
|
||||
SDL_PixelFormat *dst_fmt;
|
||||
const SDL_PixelFormatDetails *src_fmt;
|
||||
const SDL_Palette *src_pal;
|
||||
const SDL_PixelFormatDetails *dst_fmt;
|
||||
const SDL_Palette *dst_pal;
|
||||
Uint8 *table;
|
||||
int flags;
|
||||
Uint32 colorkey;
|
||||
|
@ -73,8 +75,8 @@ typedef void (*SDL_BlitFunc)(SDL_BlitInfo *info);
|
|||
|
||||
typedef struct
|
||||
{
|
||||
Uint32 src_format;
|
||||
Uint32 dst_format;
|
||||
SDL_PixelFormat src_format;
|
||||
SDL_PixelFormat dst_format;
|
||||
int flags;
|
||||
unsigned int cpu;
|
||||
SDL_BlitFunc func;
|
||||
|
@ -83,8 +85,7 @@ typedef struct
|
|||
typedef int (SDLCALL *SDL_Blit) (struct SDL_Surface *src, const SDL_Rect *srcrect, struct SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
/* Blit mapping definition */
|
||||
/* typedef'ed in SDL_surface.h */
|
||||
struct SDL_BlitMap
|
||||
typedef struct SDL_BlitMap
|
||||
{
|
||||
SDL_Surface *dst;
|
||||
int identity;
|
||||
|
@ -96,7 +97,7 @@ struct SDL_BlitMap
|
|||
an invalid mapping */
|
||||
Uint32 dst_palette_version;
|
||||
Uint32 src_palette_version;
|
||||
};
|
||||
} SDL_BlitMap;
|
||||
|
||||
/* Functions found in SDL_blit.c */
|
||||
extern int SDL_CalculateBlit(SDL_Surface *surface);
|
||||
|
@ -122,9 +123,9 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
|||
/* Load pixel of the specified format from a buffer and get its R-G-B values */
|
||||
#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \
|
||||
{ \
|
||||
r = SDL_expand_byte[fmt->Rloss][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \
|
||||
g = SDL_expand_byte[fmt->Gloss][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \
|
||||
b = SDL_expand_byte[fmt->Bloss][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \
|
||||
r = SDL_expand_byte[fmt->Rbits][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \
|
||||
g = SDL_expand_byte[fmt->Gbits][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \
|
||||
b = SDL_expand_byte[fmt->Bbits][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \
|
||||
}
|
||||
#define RGB_FROM_RGB565(Pixel, r, g, b) \
|
||||
{ \
|
||||
|
@ -218,9 +219,9 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
|||
/* Assemble R-G-B values into a specified pixel format and store them */
|
||||
#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \
|
||||
{ \
|
||||
Pixel = ((r >> fmt->Rloss) << fmt->Rshift) | \
|
||||
((g >> fmt->Gloss) << fmt->Gshift) | \
|
||||
((b >> fmt->Bloss) << fmt->Bshift) | \
|
||||
Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \
|
||||
((g >> (8 - fmt->Gbits)) << fmt->Gshift) | \
|
||||
((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \
|
||||
fmt->Amask; \
|
||||
}
|
||||
#define RGB565_FROM_RGB(Pixel, r, g, b) \
|
||||
|
@ -334,10 +335,10 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
|||
/* FIXME: Should we rescale alpha into 0..255 here? */
|
||||
#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
r = SDL_expand_byte[fmt->Rloss][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \
|
||||
g = SDL_expand_byte[fmt->Gloss][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \
|
||||
b = SDL_expand_byte[fmt->Bloss][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \
|
||||
a = SDL_expand_byte[fmt->Aloss][((Pixel & fmt->Amask) >> fmt->Ashift)]; \
|
||||
r = SDL_expand_byte[fmt->Rbits][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \
|
||||
g = SDL_expand_byte[fmt->Gbits][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \
|
||||
b = SDL_expand_byte[fmt->Bbits][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \
|
||||
a = SDL_expand_byte[fmt->Abits][((Pixel & fmt->Amask) >> fmt->Ashift)]; \
|
||||
}
|
||||
#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
|
@ -446,10 +447,10 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
|||
/* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
|
||||
#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
Pixel = ((r >> fmt->Rloss) << fmt->Rshift) | \
|
||||
((g >> fmt->Gloss) << fmt->Gshift) | \
|
||||
((b >> fmt->Bloss) << fmt->Bshift) | \
|
||||
((a >> fmt->Aloss) << fmt->Ashift); \
|
||||
Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \
|
||||
((g >> (8 - fmt->Gbits)) << fmt->Gshift) | \
|
||||
((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \
|
||||
((a >> (8 - fmt->Abits)) << fmt->Ashift); \
|
||||
}
|
||||
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
|
||||
{ \
|
||||
|
@ -713,4 +714,6 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
|
|||
#pragma warning(disable : 4244) /* '=': conversion from 'X' to 'Y', possible loss of data */
|
||||
#endif
|
||||
|
||||
#include "SDL_surface_c.h"
|
||||
|
||||
#endif /* SDL_blit_h_ */
|
||||
|
|
|
@ -615,8 +615,8 @@ SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp)
|
|||
Uint8 *dst = info->dst;
|
||||
int srcskip = info->src_skip;
|
||||
int dstskip = info->dst_skip;
|
||||
const SDL_Color *srcpal = info->src_fmt->palette->colors;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = info->src_pal->colors;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp;
|
||||
int c;
|
||||
Uint32 pixel;
|
||||
|
@ -691,9 +691,8 @@ SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp)
|
|||
Uint8 *dst = info->dst;
|
||||
int srcskip = info->src_skip;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = srcfmt->palette->colors;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = info->src_pal->colors;
|
||||
int dstbpp;
|
||||
int c;
|
||||
Uint32 pixel;
|
||||
|
@ -920,14 +919,14 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
|||
{
|
||||
int which;
|
||||
|
||||
if (surface->map->dst->format->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(surface->internal->map.dst->format) < 8) {
|
||||
which = 0;
|
||||
} else {
|
||||
which = surface->map->dst->format->bytes_per_pixel;
|
||||
which = SDL_BYTESPERPIXEL(surface->internal->map.dst->format);
|
||||
}
|
||||
|
||||
if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX1) {
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX1) {
|
||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case 0:
|
||||
return bitmap_blit_1b[which];
|
||||
|
||||
|
@ -943,8 +942,8 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX2) {
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX2) {
|
||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case 0:
|
||||
return bitmap_blit_2b[which];
|
||||
|
||||
|
@ -960,8 +959,8 @@ SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX4) {
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX4) {
|
||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case 0:
|
||||
return bitmap_blit_4b[which];
|
||||
|
||||
|
|
|
@ -431,8 +431,8 @@ static void Blit1toNAlpha(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = info->src_fmt->palette->colors;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = info->src_pal->colors;
|
||||
int dstbpp;
|
||||
Uint32 pixel;
|
||||
unsigned sR, sG, sB, sA;
|
||||
|
@ -471,8 +471,8 @@ static void Blit1toNAlphaKey(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = info->src_fmt->palette->colors;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
const SDL_Color *srcpal = info->src_pal->colors;
|
||||
Uint32 ckey = info->colorkey;
|
||||
int dstbpp;
|
||||
Uint32 pixel;
|
||||
|
@ -517,15 +517,14 @@ static const SDL_BlitFunc one_blitkey[] = {
|
|||
SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
|
||||
{
|
||||
int which;
|
||||
SDL_PixelFormat *dstfmt;
|
||||
|
||||
dstfmt = surface->map->dst->format;
|
||||
if (dstfmt->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(surface->internal->map.dst->format) < 8) {
|
||||
which = 0;
|
||||
} else {
|
||||
which = dstfmt->bytes_per_pixel;
|
||||
which = SDL_BYTESPERPIXEL(surface->internal->map.dst->format);
|
||||
}
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
|
||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case 0:
|
||||
return one_blit[which];
|
||||
|
||||
|
@ -533,7 +532,7 @@ SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface)
|
|||
return one_blitkey[which];
|
||||
|
||||
case SDL_COPY_COLORKEY | SDL_COPY_BLEND: /* this is not super-robust but handles a specific case we found sdl12-compat. */
|
||||
return (surface->map->info.a == 255) ? one_blitkey[which] :
|
||||
return (surface->internal->map.info.a == 255) ? one_blitkey[which] :
|
||||
which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL;
|
||||
|
||||
case SDL_COPY_BLEND:
|
||||
|
|
|
@ -36,8 +36,8 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
|
|||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint8 *palmap = info->table;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_Color *dstpal = info->dst_pal->colors;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
Uint32 Pixel;
|
||||
unsigned sR, sG, sB;
|
||||
|
@ -49,9 +49,9 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
|
|||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
dR = dstfmt->palette->colors[*dst].r;
|
||||
dG = dstfmt->palette->colors[*dst].g;
|
||||
dB = dstfmt->palette->colors[*dst].b;
|
||||
dR = dstpal[*dst].r;
|
||||
dG = dstpal[*dst].g;
|
||||
dB = dstpal[*dst].b;
|
||||
ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB);
|
||||
dR &= 0xff;
|
||||
dG &= 0xff;
|
||||
|
@ -82,8 +82,8 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
|
|||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint8 *palmap = info->table;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_Color *dstpal = info->dst_pal->colors;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
Uint32 Pixel;
|
||||
unsigned sR, sG, sB, sA;
|
||||
|
@ -94,9 +94,9 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
|
|||
DUFFS_LOOP4(
|
||||
{
|
||||
DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
|
||||
dR = dstfmt->palette->colors[*dst].r;
|
||||
dG = dstfmt->palette->colors[*dst].g;
|
||||
dB = dstfmt->palette->colors[*dst].b;
|
||||
dR = dstpal[*dst].r;
|
||||
dG = dstpal[*dst].g;
|
||||
dB = dstpal[*dst].b;
|
||||
ALPHA_BLEND_RGB(sR, sG, sB, sA, dR, dG, dB);
|
||||
dR &= 0xff;
|
||||
dG &= 0xff;
|
||||
|
@ -127,8 +127,8 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
|
|||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint8 *palmap = info->table;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_Color *dstpal = info->dst_pal->colors;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
Uint32 ckey = info->colorkey;
|
||||
Uint32 Pixel;
|
||||
|
@ -142,9 +142,9 @@ static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
|
|||
{
|
||||
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
|
||||
if ( Pixel != ckey ) {
|
||||
dR = dstfmt->palette->colors[*dst].r;
|
||||
dG = dstfmt->palette->colors[*dst].g;
|
||||
dB = dstfmt->palette->colors[*dst].b;
|
||||
dR = dstpal[*dst].r;
|
||||
dG = dstpal[*dst].g;
|
||||
dB = dstpal[*dst].b;
|
||||
ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB);
|
||||
dR &= 0xff;
|
||||
dG &= 0xff;
|
||||
|
@ -864,8 +864,8 @@ static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
Uint32 Pixel;
|
||||
|
@ -902,8 +902,8 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
Uint32 ckey = info->colorkey;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
|
@ -942,7 +942,7 @@ static void Blit8888to8888PixelAlpha(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
|
||||
while (height--) {
|
||||
int i = 0;
|
||||
|
@ -970,8 +970,8 @@ static void Blit8888to8888PixelAlphaSwizzle(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
|
||||
while (height--) {
|
||||
int i = 0;
|
||||
|
@ -1000,8 +1000,8 @@ static void SDL_TARGETING("sse4.1") Blit8888to8888PixelAlphaSwizzleSSE41(SDL_Bli
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
|
||||
// The byte offsets for the start of each pixel
|
||||
const __m128i mask_offsets = _mm_set_epi8(
|
||||
|
@ -1092,8 +1092,8 @@ static void SDL_TARGETING("avx2") Blit8888to8888PixelAlphaSwizzleAVX2(SDL_BlitIn
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
|
||||
// The byte offsets for the start of each pixel
|
||||
const __m256i mask_offsets = _mm256_set_epi8(
|
||||
|
@ -1183,8 +1183,8 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int srcbpp;
|
||||
int dstbpp;
|
||||
Uint32 Pixel;
|
||||
|
@ -1216,15 +1216,15 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
|
|||
|
||||
SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
||||
{
|
||||
SDL_PixelFormat *sf = surface->format;
|
||||
SDL_PixelFormat *df = surface->map->dst->format;
|
||||
const SDL_PixelFormatDetails *sf = surface->internal->format;
|
||||
const SDL_PixelFormatDetails *df = surface->internal->map.dst->internal->format;
|
||||
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case SDL_COPY_BLEND:
|
||||
/* Per-pixel alpha blits */
|
||||
switch (df->bytes_per_pixel) {
|
||||
case 1:
|
||||
if (df->palette) {
|
||||
if (surface->internal->map.info.dst_pal) {
|
||||
return BlitNto1PixelAlpha;
|
||||
} else {
|
||||
/* RGB332 has no palette ! */
|
||||
|
@ -1273,7 +1273,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
|||
/* Per-surface alpha blits */
|
||||
switch (df->bytes_per_pixel) {
|
||||
case 1:
|
||||
if (df->palette) {
|
||||
if (surface->internal->map.info.dst_pal) {
|
||||
return BlitNto1SurfaceAlpha;
|
||||
} else {
|
||||
/* RGB332 has no palette ! */
|
||||
|
@ -1281,7 +1281,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
|||
}
|
||||
|
||||
case 2:
|
||||
if (surface->map->identity) {
|
||||
if (surface->internal->map.identity) {
|
||||
if (df->Gmask == 0x7e0) {
|
||||
#ifdef SDL_MMX_INTRINSICS
|
||||
if (SDL_HasMMX()) {
|
||||
|
@ -1328,7 +1328,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
|
|||
if (sf->Amask == 0) {
|
||||
if (df->bytes_per_pixel == 1) {
|
||||
|
||||
if (df->palette) {
|
||||
if (surface->internal->map.info.dst_pal) {
|
||||
return BlitNto1SurfaceAlphaKey;
|
||||
} else {
|
||||
/* RGB332 has no palette ! */
|
||||
|
|
|
@ -117,7 +117,7 @@ static size_t GetL3CacheSize(void)
|
|||
: vec_add(vec_lvsl(8, src), vec_splat_u8(8)))
|
||||
|
||||
/* Calculate the permute vector used for 32->32 swizzling */
|
||||
static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, const SDL_PixelFormat *dstfmt)
|
||||
static vector unsigned char calc_swizzle32(const SDL_PixelFormatDetails *srcfmt, const SDL_PixelFormatDetails *dstfmt)
|
||||
{
|
||||
/*
|
||||
* We have to assume that the bits that aren't used by other
|
||||
|
@ -125,8 +125,8 @@ static vector unsigned char calc_swizzle32(const SDL_PixelFormat *srcfmt, const
|
|||
* leave alpha with a zero mask, but we should still swizzle the bits.
|
||||
*/
|
||||
/* ARGB */
|
||||
static const struct SDL_PixelFormat default_pixel_format = {
|
||||
0, NULL, 0, 0, { 0, 0 }, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 0, 0, 0, 0, 16, 8, 0, 24, 0, NULL
|
||||
static const SDL_PixelFormatDetails default_pixel_format = {
|
||||
SDL_PIXELFORMAT_ARGB8888, 0, 0, { 0, 0 }, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 8, 8, 8, 8, 16, 8, 0, 24
|
||||
};
|
||||
const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x04, 0x04, 0x04,
|
||||
|
@ -201,7 +201,7 @@ static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = (Uint8 *)info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
vector unsigned char valpha = vec_splat_u8(0);
|
||||
vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL);
|
||||
vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06,
|
||||
|
@ -302,8 +302,8 @@ static void Blit_RGB565_32Altivec(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = (Uint8 *)info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
unsigned alpha;
|
||||
vector unsigned char valpha;
|
||||
vector unsigned char vpermute;
|
||||
|
@ -440,8 +440,8 @@ static void Blit_RGB555_32Altivec(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = (Uint8 *)info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
unsigned alpha;
|
||||
vector unsigned char valpha;
|
||||
vector unsigned char vpermute;
|
||||
|
@ -580,9 +580,9 @@ static void Blit32to32KeyAltivec(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip / 4;
|
||||
Uint32 *dstp = (Uint32 *)info->dst;
|
||||
int dstskip = info->dst_skip / 4;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
int copy_alpha = (srcfmt->Amask && dstfmt->Amask);
|
||||
unsigned alpha = dstfmt->Amask ? info->a : 0;
|
||||
|
@ -702,8 +702,8 @@ static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip / 4;
|
||||
Uint32 *dst = (Uint32 *)info->dst;
|
||||
int dstskip = info->dst_skip / 4;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
vector unsigned int vzero = vec_splat_u32(0);
|
||||
vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
|
||||
if (dstfmt->Amask && !srcfmt->Amask) {
|
||||
|
@ -788,8 +788,8 @@ static void ConvertAltivec32to32_prefetch(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip / 4;
|
||||
Uint32 *dst = (Uint32 *)info->dst;
|
||||
int dstskip = info->dst_skip / 4;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
vector unsigned int vzero = vec_splat_u32(0);
|
||||
vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
|
||||
if (dstfmt->Amask && !srcfmt->Amask) {
|
||||
|
@ -2064,9 +2064,9 @@ static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint16 *dst = (Uint16 *)info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
|
||||
Uint16 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
Uint16 mask = ((Uint32)info->a >> (8 - dstfmt->Abits)) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
@ -2096,7 +2096,7 @@ static void BlitNto1(SDL_BlitInfo *info)
|
|||
int srcbpp;
|
||||
Uint32 Pixel;
|
||||
int sR, sG, sB;
|
||||
SDL_PixelFormat *srcfmt;
|
||||
const SDL_PixelFormatDetails *srcfmt;
|
||||
|
||||
/* Set up some basic variables */
|
||||
width = info->dst_w;
|
||||
|
@ -2183,12 +2183,12 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint32 *dst = (Uint32 *)info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
|
||||
if (dstfmt->Amask) {
|
||||
/* RGB->RGBA, SET_ALPHA */
|
||||
Uint32 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift;
|
||||
Uint32 mask = ((Uint32)info->a >> (8 - dstfmt->Abits)) << dstfmt->Ashift;
|
||||
|
||||
while (height--) {
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
|
@ -2224,7 +2224,7 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
|
|||
}
|
||||
|
||||
/* permutation for mapping srcfmt to dstfmt, overloading or not the alpha channel */
|
||||
static void get_permutation(SDL_PixelFormat *srcfmt, SDL_PixelFormat *dstfmt,
|
||||
static void get_permutation(const SDL_PixelFormatDetails *srcfmt, const SDL_PixelFormatDetails *dstfmt,
|
||||
int *_p0, int *_p1, int *_p2, int *_p3, int *_alpha_channel)
|
||||
{
|
||||
int alpha_channel = 0, p0, p1, p2, p3;
|
||||
|
@ -2318,9 +2318,9 @@ static void BlitNtoN(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
unsigned alpha = dstfmt->Amask ? info->a : 0;
|
||||
|
||||
|
@ -2436,9 +2436,9 @@ static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
int c;
|
||||
|
||||
|
@ -2493,7 +2493,7 @@ static void BlitNto1Key(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const Uint8 *palmap = info->table;
|
||||
Uint32 ckey = info->colorkey;
|
||||
Uint32 rgbmask = ~srcfmt->Amask;
|
||||
|
@ -2592,8 +2592,8 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
|
|||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint32 ckey = info->colorkey;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
unsigned alpha = dstfmt->Amask ? info->a : 0;
|
||||
|
@ -2863,8 +2863,8 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
|
|||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
Uint32 ckey = info->colorkey;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
Uint32 rgbmask = ~srcfmt->Amask;
|
||||
|
||||
Uint8 srcbpp;
|
||||
|
@ -2965,7 +2965,7 @@ static void Blit2101010toN(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
Uint32 Pixel;
|
||||
unsigned sR, sG, sB, sA;
|
||||
|
@ -2996,7 +2996,7 @@ static void BlitNto2101010(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
Uint32 Pixel;
|
||||
unsigned sR, sG, sB, sA;
|
||||
|
@ -3027,9 +3027,9 @@ static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
|
||||
if (dstfmt->Amask) {
|
||||
|
@ -3100,9 +3100,9 @@ static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info)
|
|||
int srcskip = info->src_skip;
|
||||
Uint8 *dst = info->dst;
|
||||
int dstskip = info->dst_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *srcfmt = info->src_fmt;
|
||||
int srcbpp = srcfmt->bytes_per_pixel;
|
||||
SDL_PixelFormat *dstfmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *dstfmt = info->dst_fmt;
|
||||
int dstbpp = dstfmt->bytes_per_pixel;
|
||||
|
||||
if (dstfmt->Amask) {
|
||||
|
@ -3336,22 +3336,22 @@ static const struct blit_table *const normal_blit[] = {
|
|||
|
||||
SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
||||
{
|
||||
SDL_PixelFormat *srcfmt;
|
||||
SDL_PixelFormat *dstfmt;
|
||||
const SDL_PixelFormatDetails *srcfmt;
|
||||
const SDL_PixelFormatDetails *dstfmt;
|
||||
const struct blit_table *table;
|
||||
int which;
|
||||
SDL_BlitFunc blitfun;
|
||||
|
||||
/* Set up data for choosing the blit */
|
||||
srcfmt = surface->format;
|
||||
dstfmt = surface->map->dst->format;
|
||||
srcfmt = surface->internal->format;
|
||||
dstfmt = surface->internal->map.dst->internal->format;
|
||||
|
||||
/* We don't support destinations less than 8-bits */
|
||||
if (dstfmt->bits_per_pixel < 8) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
switch (surface->internal->map.info.flags & ~SDL_COPY_RLE_MASK) {
|
||||
case 0:
|
||||
blitfun = NULL;
|
||||
if (dstfmt->bits_per_pixel == 8) {
|
||||
|
@ -3427,7 +3427,7 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
|
|||
because RLE is the preferred fast way to deal with this.
|
||||
If a particular case turns out to be useful we'll add it. */
|
||||
|
||||
if (srcfmt->bytes_per_pixel == 2 && surface->map->identity != 0) {
|
||||
if (srcfmt->bytes_per_pixel == 2 && surface->internal->map.identity != 0) {
|
||||
return Blit2to2Key;
|
||||
} else if (dstfmt->bytes_per_pixel == 1) {
|
||||
return BlitNto1Key;
|
||||
|
|
|
@ -32,13 +32,13 @@ typedef enum
|
|||
SlowBlitPixelAccess_Large,
|
||||
} SlowBlitPixelAccess;
|
||||
|
||||
static SlowBlitPixelAccess GetPixelAccessMethod(SDL_PixelFormat *pf)
|
||||
static SlowBlitPixelAccess GetPixelAccessMethod(SDL_PixelFormat format)
|
||||
{
|
||||
if (pf->bytes_per_pixel > 4) {
|
||||
if (SDL_BYTESPERPIXEL(format) > 4) {
|
||||
return SlowBlitPixelAccess_Large;
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(pf->format)) {
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(format)) {
|
||||
return SlowBlitPixelAccess_10Bit;
|
||||
} else if (pf->Amask) {
|
||||
} else if (SDL_ISPIXELFORMAT_ALPHA(format)) {
|
||||
return SlowBlitPixelAccess_RGBA;
|
||||
} else {
|
||||
return SlowBlitPixelAccess_RGB;
|
||||
|
@ -62,8 +62,8 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
|
|||
Uint64 srcy, srcx;
|
||||
Uint64 posy, posx;
|
||||
Uint64 incy, incx;
|
||||
SDL_PixelFormat *src_fmt = info->src_fmt;
|
||||
SDL_PixelFormat *dst_fmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *src_fmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dst_fmt = info->dst_fmt;
|
||||
int srcbpp = src_fmt->bytes_per_pixel;
|
||||
int dstbpp = dst_fmt->bytes_per_pixel;
|
||||
SlowBlitPixelAccess src_access;
|
||||
|
@ -71,8 +71,8 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
|
|||
Uint32 rgbmask = ~src_fmt->Amask;
|
||||
Uint32 ckey = info->colorkey & rgbmask;
|
||||
|
||||
src_access = GetPixelAccessMethod(src_fmt);
|
||||
dst_access = GetPixelAccessMethod(dst_fmt);
|
||||
src_access = GetPixelAccessMethod(src_fmt->format);
|
||||
dst_access = GetPixelAccessMethod(dst_fmt->format);
|
||||
|
||||
incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
||||
incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
||||
|
@ -370,7 +370,7 @@ static Uint16 float_to_half(float a)
|
|||
return ir;
|
||||
}
|
||||
|
||||
static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, SDL_PixelFormat *fmt, SDL_Colorspace colorspace, float SDR_white_point,
|
||||
static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_PixelFormatDetails *fmt, SDL_Colorspace colorspace, float SDR_white_point,
|
||||
float *outR, float *outG, float *outB, float *outA)
|
||||
{
|
||||
Uint32 pixel;
|
||||
|
@ -525,7 +525,7 @@ static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, SDL_PixelF
|
|||
*outA = fA;
|
||||
}
|
||||
|
||||
static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, SDL_PixelFormat *fmt, SDL_Colorspace colorspace, float SDR_white_point,
|
||||
static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_PixelFormatDetails *fmt, SDL_Colorspace colorspace, float SDR_white_point,
|
||||
float fR, float fG, float fB, float fA)
|
||||
{
|
||||
Uint32 R, G, B, A;
|
||||
|
@ -755,8 +755,8 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
|
|||
Uint64 srcy, srcx;
|
||||
Uint64 posy, posx;
|
||||
Uint64 incy, incx;
|
||||
SDL_PixelFormat *src_fmt = info->src_fmt;
|
||||
SDL_PixelFormat *dst_fmt = info->dst_fmt;
|
||||
const SDL_PixelFormatDetails *src_fmt = info->src_fmt;
|
||||
const SDL_PixelFormatDetails *dst_fmt = info->dst_fmt;
|
||||
int srcbpp = src_fmt->bytes_per_pixel;
|
||||
int dstbpp = dst_fmt->bytes_per_pixel;
|
||||
SlowBlitPixelAccess src_access;
|
||||
|
@ -772,8 +772,10 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
|
|||
float src_headroom;
|
||||
SDL_TonemapContext tonemap;
|
||||
|
||||
if (SDL_GetSurfaceColorspace(info->src_surface, &src_colorspace) < 0 ||
|
||||
SDL_GetSurfaceColorspace(info->dst_surface, &dst_colorspace) < 0) {
|
||||
src_colorspace = SDL_GetSurfaceColorspace(info->src_surface);
|
||||
dst_colorspace = SDL_GetSurfaceColorspace(info->dst_surface);
|
||||
if (src_colorspace == SDL_COLORSPACE_UNKNOWN ||
|
||||
dst_colorspace == SDL_COLORSPACE_UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
src_primaries = SDL_COLORSPACEPRIMARIES(src_colorspace);
|
||||
|
@ -821,8 +823,8 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
|
|||
color_primaries_matrix = SDL_GetColorPrimariesConversionMatrix(src_primaries, dst_primaries);
|
||||
}
|
||||
|
||||
src_access = GetPixelAccessMethod(src_fmt);
|
||||
dst_access = GetPixelAccessMethod(dst_fmt);
|
||||
src_access = GetPixelAccessMethod(src_fmt->format);
|
||||
dst_access = GetPixelAccessMethod(dst_fmt->format);
|
||||
|
||||
incy = ((Uint64)info->src_h << 16) / info->dst_h;
|
||||
incx = ((Uint64)info->src_w << 16) / info->dst_w;
|
||||
|
|
|
@ -427,10 +427,10 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio)
|
|||
|
||||
/* Create a compatible surface, note that the colors are RGB ordered */
|
||||
{
|
||||
SDL_PixelFormatEnum format;
|
||||
SDL_PixelFormat format;
|
||||
|
||||
/* Get the pixel format */
|
||||
format = SDL_GetPixelFormatEnumForMasks(biBitCount, Rmask, Gmask, Bmask, Amask);
|
||||
format = SDL_GetPixelFormatForMasks(biBitCount, Rmask, Gmask, Bmask, Amask);
|
||||
surface = SDL_CreateSurface(biWidth, biHeight, format);
|
||||
|
||||
if (!surface) {
|
||||
|
@ -439,7 +439,7 @@ SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, SDL_bool closeio)
|
|||
}
|
||||
|
||||
/* Load the palette, if any */
|
||||
palette = (surface->format)->palette;
|
||||
palette = SDL_GetSurfacePalette(surface);
|
||||
if (palette) {
|
||||
if (SDL_SeekIO(src, fp_offset + 14 + biSize, SDL_IO_SEEK_SET) < 0) {
|
||||
SDL_SetError("Error seeking in datastream");
|
||||
|
@ -632,42 +632,42 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio)
|
|||
/* Make sure we have somewhere to save */
|
||||
intermediate_surface = NULL;
|
||||
if (dst) {
|
||||
if (!surface) {
|
||||
if (!SDL_SurfaceValid(surface)) {
|
||||
SDL_InvalidParamError("surface");
|
||||
goto done;
|
||||
}
|
||||
|
||||
#ifdef SAVE_32BIT_BMP
|
||||
/* We can save alpha information in a 32-bit BMP */
|
||||
if (surface->format->bits_per_pixel >= 8 &&
|
||||
(surface->format->Amask != 0 ||
|
||||
surface->map->info.flags & SDL_COPY_COLORKEY)) {
|
||||
if (SDL_BITSPERPIXEL(surface->format) >= 8 &&
|
||||
(SDL_ISPIXELFORMAT_ALPHA(surface->format) ||
|
||||
surface->internal->map.info.flags & SDL_COPY_COLORKEY)) {
|
||||
save32bit = SDL_TRUE;
|
||||
}
|
||||
#endif /* SAVE_32BIT_BMP */
|
||||
|
||||
if (surface->format->palette && !save32bit) {
|
||||
if (surface->format->bits_per_pixel == 8) {
|
||||
if (surface->internal->palette && !save32bit) {
|
||||
if (SDL_BITSPERPIXEL(surface->format) == 8) {
|
||||
intermediate_surface = surface;
|
||||
} else {
|
||||
SDL_SetError("%u bpp BMP files not supported",
|
||||
surface->format->bits_per_pixel);
|
||||
SDL_BITSPERPIXEL(surface->format));
|
||||
goto done;
|
||||
}
|
||||
} else if ((surface->format->bits_per_pixel == 24) && !save32bit &&
|
||||
} else if ((SDL_BITSPERPIXEL(surface->format) == 24) && !save32bit &&
|
||||
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
|
||||
(surface->format->Rmask == 0x00FF0000) &&
|
||||
(surface->format->Gmask == 0x0000FF00) &&
|
||||
(surface->format->Bmask == 0x000000FF)
|
||||
(surface->internal->format->Rmask == 0x00FF0000) &&
|
||||
(surface->internal->format->Gmask == 0x0000FF00) &&
|
||||
(surface->internal->format->Bmask == 0x000000FF)
|
||||
#else
|
||||
(surface->format->Rmask == 0x000000FF) &&
|
||||
(surface->format->Gmask == 0x0000FF00) &&
|
||||
(surface->format->Bmask == 0x00FF0000)
|
||||
(surface->internal->format->Rmask == 0x000000FF) &&
|
||||
(surface->internal->format->Gmask == 0x0000FF00) &&
|
||||
(surface->internal->format->Bmask == 0x00FF0000)
|
||||
#endif
|
||||
) {
|
||||
intermediate_surface = surface;
|
||||
} else {
|
||||
SDL_PixelFormatEnum pixel_format;
|
||||
SDL_PixelFormat pixel_format;
|
||||
|
||||
/* If the surface has a colorkey or alpha channel we'll save a
|
||||
32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */
|
||||
|
@ -676,7 +676,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio)
|
|||
} else {
|
||||
pixel_format = SDL_PIXELFORMAT_BGR24;
|
||||
}
|
||||
intermediate_surface = SDL_ConvertSurfaceFormat(surface, pixel_format);
|
||||
intermediate_surface = SDL_ConvertSurface(surface, pixel_format);
|
||||
if (!intermediate_surface) {
|
||||
SDL_SetError("Couldn't convert image to %d bpp",
|
||||
(int)SDL_BITSPERPIXEL(pixel_format));
|
||||
|
@ -694,7 +694,7 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio)
|
|||
}
|
||||
|
||||
if (SDL_LockSurface(intermediate_surface) == 0) {
|
||||
const size_t bw = intermediate_surface->w * intermediate_surface->format->bytes_per_pixel;
|
||||
const size_t bw = intermediate_surface->w * intermediate_surface->internal->format->bytes_per_pixel;
|
||||
|
||||
/* Set the BMP file header values */
|
||||
bfSize = 0; /* We'll write this when we're done */
|
||||
|
@ -720,13 +720,13 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio)
|
|||
biWidth = intermediate_surface->w;
|
||||
biHeight = intermediate_surface->h;
|
||||
biPlanes = 1;
|
||||
biBitCount = intermediate_surface->format->bits_per_pixel;
|
||||
biBitCount = intermediate_surface->internal->format->bits_per_pixel;
|
||||
biCompression = BI_RGB;
|
||||
biSizeImage = intermediate_surface->h * intermediate_surface->pitch;
|
||||
biXPelsPerMeter = 0;
|
||||
biYPelsPerMeter = 0;
|
||||
if (intermediate_surface->format->palette) {
|
||||
biClrUsed = intermediate_surface->format->palette->ncolors;
|
||||
if (intermediate_surface->internal->palette) {
|
||||
biClrUsed = intermediate_surface->internal->palette->ncolors;
|
||||
} else {
|
||||
biClrUsed = 0;
|
||||
}
|
||||
|
@ -784,12 +784,12 @@ int SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, SDL_bool closeio)
|
|||
}
|
||||
|
||||
/* Write the palette (in BGR color order) */
|
||||
if (intermediate_surface->format->palette) {
|
||||
if (intermediate_surface->internal->palette) {
|
||||
SDL_Color *colors;
|
||||
int ncolors;
|
||||
|
||||
colors = intermediate_surface->format->palette->colors;
|
||||
ncolors = intermediate_surface->format->palette->ncolors;
|
||||
colors = intermediate_surface->internal->palette->colors;
|
||||
ncolors = intermediate_surface->internal->palette->ncolors;
|
||||
for (i = 0; i < ncolors; ++i) {
|
||||
if (!SDL_WriteU8(dst, colors[i].b) ||
|
||||
!SDL_WriteU8(dst, colors[i].g) ||
|
||||
|
|
|
@ -231,13 +231,13 @@ static void SDL_FillSurfaceRect4(Uint8 *pixels, int pitch, Uint32 color, int w,
|
|||
*/
|
||||
int SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
|
||||
{
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_FillSurfaceRect(): dst");
|
||||
}
|
||||
|
||||
/* If 'rect' == NULL, then fill the whole surface */
|
||||
if (!rect) {
|
||||
rect = &dst->clip_rect;
|
||||
rect = &dst->internal->clip_rect;
|
||||
/* Don't attempt to fill if the surface's clip_rect is empty */
|
||||
if (SDL_RectEmpty(rect)) {
|
||||
return 0;
|
||||
|
@ -256,7 +256,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL;
|
||||
int i;
|
||||
|
||||
if (!dst) {
|
||||
if (!SDL_SurfaceValid(dst)) {
|
||||
return SDL_InvalidParamError("SDL_FillSurfaceRects(): dst");
|
||||
}
|
||||
|
||||
|
@ -277,11 +277,11 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
/* This function doesn't usually work on surfaces < 8 bpp
|
||||
* Except: support for 4bits, when filling full size.
|
||||
*/
|
||||
if (dst->format->bits_per_pixel < 8) {
|
||||
if (SDL_BITSPERPIXEL(dst->format) < 8) {
|
||||
if (count == 1) {
|
||||
const SDL_Rect *r = &rects[0];
|
||||
if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) {
|
||||
if (dst->format->bits_per_pixel == 4) {
|
||||
if (SDL_BITSPERPIXEL(dst->format) == 4) {
|
||||
Uint8 b = (((Uint8)color << 4) | (Uint8)color);
|
||||
SDL_memset(dst->pixels, b, (size_t)dst->h * dst->pitch);
|
||||
return 1;
|
||||
|
@ -292,7 +292,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
}
|
||||
|
||||
if (fill_function == NULL) {
|
||||
switch (dst->format->bytes_per_pixel) {
|
||||
switch (SDL_BYTESPERPIXEL(dst->format)) {
|
||||
case 1:
|
||||
{
|
||||
color |= (color << 8);
|
||||
|
@ -347,13 +347,13 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
|
|||
for (i = 0; i < count; ++i) {
|
||||
rect = &rects[i];
|
||||
/* Perform clipping */
|
||||
if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) {
|
||||
if (!SDL_GetRectIntersection(rect, &dst->internal->clip_rect, &clipped)) {
|
||||
continue;
|
||||
}
|
||||
rect = &clipped;
|
||||
|
||||
pixels = (Uint8 *)dst->pixels + rect->y * dst->pitch +
|
||||
rect->x * dst->format->bytes_per_pixel;
|
||||
rect->x * SDL_BYTESPERPIXEL(dst->format);
|
||||
|
||||
fill_function(pixels, dst->pitch, color, rect->w, rect->h);
|
||||
}
|
||||
|
|
|
@ -26,24 +26,25 @@
|
|||
#include "SDL_blit.h"
|
||||
#include "SDL_pixels_c.h"
|
||||
#include "SDL_RLEaccel_c.h"
|
||||
#include "../SDL_hashtable.h"
|
||||
#include "../SDL_list.h"
|
||||
|
||||
/* Lookup tables to expand partial bytes to the full 0..255 range */
|
||||
|
||||
static const Uint8 lookup_0[] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||
255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_1[] = {
|
||||
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255
|
||||
0, 255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_2[] = {
|
||||
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255
|
||||
0, 85, 170, 255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_3[] = {
|
||||
0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255
|
||||
0, 36, 72, 109, 145, 182, 218, 255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_4[] = {
|
||||
|
@ -51,19 +52,19 @@ static const Uint8 lookup_4[] = {
|
|||
};
|
||||
|
||||
static const Uint8 lookup_5[] = {
|
||||
0, 36, 72, 109, 145, 182, 218, 255
|
||||
0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_6[] = {
|
||||
0, 85, 170, 255
|
||||
0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_7[] = {
|
||||
0, 255
|
||||
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255
|
||||
};
|
||||
|
||||
static const Uint8 lookup_8[] = {
|
||||
255
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||
};
|
||||
|
||||
const Uint8 *SDL_expand_byte[9] = {
|
||||
|
@ -91,7 +92,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_expand_byte_10_size, SDL_arraysize(SDL_expand_byte_1
|
|||
#define CASE(X) \
|
||||
case X: \
|
||||
return #X;
|
||||
const char *SDL_GetPixelFormatName(SDL_PixelFormatEnum format)
|
||||
const char *SDL_GetPixelFormatName(SDL_PixelFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
|
||||
|
@ -165,8 +166,7 @@ const char *SDL_GetPixelFormatName(SDL_PixelFormatEnum format)
|
|||
}
|
||||
#undef CASE
|
||||
|
||||
SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int *bpp, Uint32 *Rmask,
|
||||
Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
|
||||
int SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
|
||||
{
|
||||
Uint32 masks[4];
|
||||
|
||||
|
@ -185,12 +185,11 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int *bpp, Ui
|
|||
default:
|
||||
*bpp = 0; // oh well.
|
||||
}
|
||||
return SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(format)) {
|
||||
SDL_SetError("SDL not built with YUV support");
|
||||
return SDL_FALSE;
|
||||
return SDL_SetError("SDL not built with YUV support");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -212,7 +211,7 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int *bpp, Ui
|
|||
*Gmask = 0x0000FF00;
|
||||
*Bmask = 0x00FF0000;
|
||||
#endif
|
||||
return SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (format == SDL_PIXELFORMAT_BGR24) {
|
||||
|
@ -225,14 +224,14 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int *bpp, Ui
|
|||
*Gmask = 0x0000FF00;
|
||||
*Bmask = 0x000000FF;
|
||||
#endif
|
||||
return SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 &&
|
||||
SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 &&
|
||||
SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) {
|
||||
/* Not a format that uses masks */
|
||||
return SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (SDL_PIXELLAYOUT(format)) {
|
||||
|
@ -285,8 +284,7 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int *bpp, Ui
|
|||
masks[3] = 0x00000003;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown pixel format");
|
||||
return SDL_FALSE;
|
||||
return SDL_SetError("Unknown pixel format");
|
||||
}
|
||||
|
||||
switch (SDL_PIXELORDER(format)) {
|
||||
|
@ -335,13 +333,12 @@ SDL_bool SDL_GetMasksForPixelFormatEnum(SDL_PixelFormatEnum format, int *bpp, Ui
|
|||
*Rmask = masks[3];
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown pixel format");
|
||||
return SDL_FALSE;
|
||||
return SDL_SetError("Unknown pixel format");
|
||||
}
|
||||
return SDL_TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_PixelFormatEnum SDL_GetPixelFormatEnumForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
|
||||
{
|
||||
switch (bpp) {
|
||||
case 1:
|
||||
|
@ -579,156 +576,133 @@ SDL_PixelFormatEnum SDL_GetPixelFormatEnumForMasks(int bpp, Uint32 Rmask, Uint32
|
|||
return SDL_PIXELFORMAT_UNKNOWN;
|
||||
}
|
||||
|
||||
static SDL_PixelFormat *formats;
|
||||
static SDL_SpinLock formats_lock = 0;
|
||||
static SDL_HashTable *SDL_format_details;
|
||||
static SDL_Mutex *SDL_format_details_lock;
|
||||
|
||||
SDL_PixelFormat *SDL_CreatePixelFormat(SDL_PixelFormatEnum pixel_format)
|
||||
{
|
||||
SDL_PixelFormat *format;
|
||||
|
||||
SDL_LockSpinlock(&formats_lock);
|
||||
|
||||
/* Look it up in our list of previously allocated formats */
|
||||
for (format = formats; format; format = format->next) {
|
||||
if (pixel_format == format->format) {
|
||||
++format->refcount;
|
||||
SDL_UnlockSpinlock(&formats_lock);
|
||||
return format;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate an empty pixel format structure, and initialize it */
|
||||
format = (SDL_PixelFormat *)SDL_malloc(sizeof(*format));
|
||||
if (!format) {
|
||||
SDL_UnlockSpinlock(&formats_lock);
|
||||
return NULL;
|
||||
}
|
||||
if (SDL_InitFormat(format, pixel_format) < 0) {
|
||||
SDL_UnlockSpinlock(&formats_lock);
|
||||
SDL_free(format);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!SDL_ISPIXELFORMAT_INDEXED(pixel_format)) {
|
||||
/* Cache the RGB formats */
|
||||
format->next = formats;
|
||||
formats = format;
|
||||
}
|
||||
|
||||
SDL_UnlockSpinlock(&formats_lock);
|
||||
|
||||
return format;
|
||||
}
|
||||
|
||||
int SDL_InitFormat(SDL_PixelFormat *format, SDL_PixelFormatEnum pixel_format)
|
||||
static int SDL_InitPixelFormatDetails(SDL_PixelFormatDetails *details, SDL_PixelFormat format)
|
||||
{
|
||||
int bpp;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
Uint32 mask;
|
||||
|
||||
if (!SDL_GetMasksForPixelFormatEnum(pixel_format, &bpp,
|
||||
&Rmask, &Gmask, &Bmask, &Amask)) {
|
||||
if (SDL_GetMasksForPixelFormat(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Set up the format */
|
||||
SDL_zerop(format);
|
||||
format->format = pixel_format;
|
||||
format->bits_per_pixel = (Uint8)bpp;
|
||||
format->bytes_per_pixel = (Uint8)((bpp + 7) / 8);
|
||||
SDL_zerop(details);
|
||||
details->format = format;
|
||||
details->bits_per_pixel = (Uint8)bpp;
|
||||
SDL_assert(SDL_BITSPERPIXEL(format) == details->bits_per_pixel);
|
||||
details->bytes_per_pixel = (Uint8)((bpp + 7) / 8);
|
||||
SDL_assert(SDL_BYTESPERPIXEL(format) == details->bytes_per_pixel);
|
||||
|
||||
format->Rmask = Rmask;
|
||||
format->Rshift = 0;
|
||||
format->Rloss = 8;
|
||||
details->Rmask = Rmask;
|
||||
details->Rshift = 0;
|
||||
details->Rbits = 0;
|
||||
if (Rmask) {
|
||||
for (mask = Rmask; !(mask & 0x01); mask >>= 1) {
|
||||
++format->Rshift;
|
||||
++details->Rshift;
|
||||
}
|
||||
for (; (mask & 0x01) && format->Rloss; mask >>= 1) {
|
||||
--format->Rloss;
|
||||
for (; (mask & 0x01); mask >>= 1) {
|
||||
++details->Rbits;
|
||||
}
|
||||
}
|
||||
|
||||
format->Gmask = Gmask;
|
||||
format->Gshift = 0;
|
||||
format->Gloss = 8;
|
||||
details->Gmask = Gmask;
|
||||
details->Gshift = 0;
|
||||
details->Gbits = 0;
|
||||
if (Gmask) {
|
||||
for (mask = Gmask; !(mask & 0x01); mask >>= 1) {
|
||||
++format->Gshift;
|
||||
++details->Gshift;
|
||||
}
|
||||
for (; (mask & 0x01) && format->Gloss; mask >>= 1) {
|
||||
--format->Gloss;
|
||||
for (; (mask & 0x01); mask >>= 1) {
|
||||
++details->Gbits;
|
||||
}
|
||||
}
|
||||
|
||||
format->Bmask = Bmask;
|
||||
format->Bshift = 0;
|
||||
format->Bloss = 8;
|
||||
details->Bmask = Bmask;
|
||||
details->Bshift = 0;
|
||||
details->Bbits = 0;
|
||||
if (Bmask) {
|
||||
for (mask = Bmask; !(mask & 0x01); mask >>= 1) {
|
||||
++format->Bshift;
|
||||
++details->Bshift;
|
||||
}
|
||||
for (; (mask & 0x01) && format->Bloss; mask >>= 1) {
|
||||
--format->Bloss;
|
||||
for (; (mask & 0x01); mask >>= 1) {
|
||||
++details->Bbits;
|
||||
}
|
||||
}
|
||||
|
||||
format->Amask = Amask;
|
||||
format->Ashift = 0;
|
||||
format->Aloss = 8;
|
||||
details->Amask = Amask;
|
||||
details->Ashift = 0;
|
||||
details->Abits = 0;
|
||||
if (Amask) {
|
||||
for (mask = Amask; !(mask & 0x01); mask >>= 1) {
|
||||
++format->Ashift;
|
||||
++details->Ashift;
|
||||
}
|
||||
for (; (mask & 0x01) && format->Aloss; mask >>= 1) {
|
||||
--format->Aloss;
|
||||
for (; (mask & 0x01); mask >>= 1) {
|
||||
++details->Abits;
|
||||
}
|
||||
}
|
||||
|
||||
format->palette = NULL;
|
||||
format->refcount = 1;
|
||||
format->next = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_DestroyPixelFormat(SDL_PixelFormat *format)
|
||||
const SDL_PixelFormatDetails *SDL_GetPixelFormatDetails(SDL_PixelFormat format)
|
||||
{
|
||||
SDL_PixelFormat *prev;
|
||||
SDL_PixelFormatDetails *details;
|
||||
|
||||
if (!format) {
|
||||
return;
|
||||
if (!SDL_format_details_lock) {
|
||||
SDL_format_details_lock = SDL_CreateMutex();
|
||||
}
|
||||
|
||||
SDL_LockSpinlock(&formats_lock);
|
||||
SDL_LockMutex(SDL_format_details_lock);
|
||||
|
||||
if (--format->refcount > 0) {
|
||||
SDL_UnlockSpinlock(&formats_lock);
|
||||
return;
|
||||
if (!SDL_format_details) {
|
||||
SDL_format_details = SDL_CreateHashTable(NULL, 8, SDL_HashID, SDL_KeyMatchID, SDL_NukeFreeValue, SDL_FALSE);
|
||||
}
|
||||
|
||||
/* Remove this format from our list */
|
||||
if (format == formats) {
|
||||
formats = format->next;
|
||||
} else if (formats) {
|
||||
for (prev = formats; prev->next; prev = prev->next) {
|
||||
if (prev->next == format) {
|
||||
prev->next = format->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (SDL_FindInHashTable(SDL_format_details, (const void *)(uintptr_t)format, (const void **)&details)) {
|
||||
return details;
|
||||
}
|
||||
|
||||
SDL_UnlockSpinlock(&formats_lock);
|
||||
|
||||
if (format->palette) {
|
||||
SDL_DestroyPalette(format->palette);
|
||||
/* Allocate an empty pixel format structure, and initialize it */
|
||||
details = (SDL_PixelFormatDetails *)SDL_malloc(sizeof(*details));
|
||||
if (!details) {
|
||||
goto done;
|
||||
}
|
||||
SDL_free(format);
|
||||
return;
|
||||
|
||||
if (SDL_InitPixelFormatDetails(details, format) < 0) {
|
||||
SDL_free(details);
|
||||
details = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!SDL_InsertIntoHashTable(SDL_format_details, (const void *)(uintptr_t)format, (void *)details)) {
|
||||
SDL_free(details);
|
||||
details = NULL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
SDL_UnlockMutex(SDL_format_details_lock);
|
||||
|
||||
return details;
|
||||
}
|
||||
|
||||
SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormatEnum format)
|
||||
void SDL_QuitPixelFormatDetails(void)
|
||||
{
|
||||
if (SDL_format_details) {
|
||||
SDL_DestroyHashTable(SDL_format_details);
|
||||
SDL_format_details = NULL;
|
||||
}
|
||||
if (SDL_format_details_lock) {
|
||||
SDL_DestroyMutex(SDL_format_details_lock);
|
||||
SDL_format_details_lock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormat format)
|
||||
{
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(format)) {
|
||||
if (format == SDL_PIXELFORMAT_P010) {
|
||||
|
@ -1065,33 +1039,6 @@ SDL_Palette *SDL_CreatePalette(int ncolors)
|
|||
return palette;
|
||||
}
|
||||
|
||||
int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
|
||||
{
|
||||
if (!format) {
|
||||
return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format");
|
||||
}
|
||||
|
||||
if (palette && palette->ncolors > (1 << format->bits_per_pixel)) {
|
||||
return SDL_SetError("SDL_SetPixelFormatPalette() passed a palette that doesn't match the format");
|
||||
}
|
||||
|
||||
if (format->palette == palette) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (format->palette) {
|
||||
SDL_DestroyPalette(format->palette);
|
||||
}
|
||||
|
||||
format->palette = palette;
|
||||
|
||||
if (format->palette) {
|
||||
++format->palette->refcount;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors,
|
||||
int firstcolor, int ncolors)
|
||||
{
|
||||
|
@ -1161,7 +1108,7 @@ void SDL_DitherColors(SDL_Color *colors, int bpp)
|
|||
/*
|
||||
* Match an RGB value to a particular palette index
|
||||
*/
|
||||
Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
/* Do colorspace distance matching */
|
||||
unsigned int smallest;
|
||||
|
@ -1189,7 +1136,7 @@ Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
|||
}
|
||||
|
||||
/* Tell whether palette is opaque, and if it has an alpha_channel */
|
||||
void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel)
|
||||
void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1235,56 +1182,94 @@ void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alph
|
|||
}
|
||||
|
||||
/* Find the opaque pixel value corresponding to an RGB triple */
|
||||
Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
|
||||
Uint32 SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
if (!format) {
|
||||
SDL_InvalidParamError("format");
|
||||
return 0;
|
||||
}
|
||||
if (format->palette) {
|
||||
return SDL_FindColor(format->palette, r, g, b, SDL_ALPHA_OPAQUE);
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(format->format)) {
|
||||
if (!palette) {
|
||||
SDL_InvalidParamError("palette");
|
||||
return 0;
|
||||
}
|
||||
return SDL_FindColor(palette, r, g, b, SDL_ALPHA_OPAQUE);
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
return (((Uint32)SDL_expand_byte_10[r]) << format->Rshift) |
|
||||
(((Uint32)SDL_expand_byte_10[g]) << format->Gshift) |
|
||||
(((Uint32)SDL_expand_byte_10[b]) << format->Bshift) |
|
||||
format->Amask;
|
||||
} else {
|
||||
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask;
|
||||
return ((Uint32)(r >> (8 - format->Rbits))) << format->Rshift |
|
||||
((Uint32)(g >> (8 - format->Gbits))) << format->Gshift |
|
||||
((Uint32)(b >> (8 - format->Bbits))) << format->Bshift |
|
||||
format->Amask;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find the pixel value corresponding to an RGBA quadruple */
|
||||
Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b,
|
||||
Uint8 a)
|
||||
Uint32 SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
|
||||
{
|
||||
if (!format) {
|
||||
SDL_InvalidParamError("format");
|
||||
return 0;
|
||||
}
|
||||
if (format->palette) {
|
||||
return SDL_FindColor(format->palette, r, g, b, a);
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(format->format)) {
|
||||
if (!palette) {
|
||||
SDL_InvalidParamError("palette");
|
||||
return 0;
|
||||
}
|
||||
return SDL_FindColor(palette, r, g, b, a);
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
return (((Uint32)SDL_expand_byte_10[r]) << format->Rshift) |
|
||||
(((Uint32)SDL_expand_byte_10[g]) << format->Gshift) |
|
||||
(((Uint32)SDL_expand_byte_10[b]) << format->Bshift) |
|
||||
((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask);
|
||||
((((Uint32)(a >> (8 - format->Abits))) << format->Ashift) & format->Amask);
|
||||
} else {
|
||||
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask);
|
||||
return ((Uint32)(r >> (8 - format->Rbits))) << format->Rshift |
|
||||
((Uint32)(g >> (8 - format->Gbits))) << format->Gshift |
|
||||
((Uint32)(b >> (8 - format->Bbits))) << format->Bshift |
|
||||
((((Uint32)(a >> (8 - format->Abits))) << format->Ashift) & format->Amask);
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g,
|
||||
Uint8 *b)
|
||||
void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b)
|
||||
{
|
||||
if (format->palette) {
|
||||
if (pixel < (unsigned)format->palette->ncolors) {
|
||||
*r = format->palette->colors[pixel].r;
|
||||
*g = format->palette->colors[pixel].g;
|
||||
*b = format->palette->colors[pixel].b;
|
||||
Uint8 unused;
|
||||
|
||||
if (!r) {
|
||||
r = &unused;
|
||||
}
|
||||
if (!g) {
|
||||
g = &unused;
|
||||
}
|
||||
if (!b) {
|
||||
b = &unused;
|
||||
}
|
||||
|
||||
if (!format) {
|
||||
*r = *g = *b = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(format->format)) {
|
||||
if (palette && pixel < (unsigned)palette->ncolors) {
|
||||
*r = palette->colors[pixel].r;
|
||||
*g = palette->colors[pixel].g;
|
||||
*b = palette->colors[pixel].b;
|
||||
} else {
|
||||
*r = *g = *b = 0;
|
||||
}
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
unsigned v;
|
||||
v = (pixel & format->Rmask) >> format->Rshift;
|
||||
*r = (Uint8)(v >> 2);
|
||||
|
@ -1295,27 +1280,49 @@ void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g,
|
|||
} else {
|
||||
unsigned v;
|
||||
v = (pixel & format->Rmask) >> format->Rshift;
|
||||
*r = SDL_expand_byte[format->Rloss][v];
|
||||
*r = SDL_expand_byte[format->Rbits][v];
|
||||
v = (pixel & format->Gmask) >> format->Gshift;
|
||||
*g = SDL_expand_byte[format->Gloss][v];
|
||||
*g = SDL_expand_byte[format->Gbits][v];
|
||||
v = (pixel & format->Bmask) >> format->Bshift;
|
||||
*b = SDL_expand_byte[format->Bloss][v];
|
||||
*b = SDL_expand_byte[format->Bbits][v];
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format,
|
||||
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
|
||||
void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
|
||||
{
|
||||
if (format->palette) {
|
||||
if (pixel < (unsigned)format->palette->ncolors) {
|
||||
*r = format->palette->colors[pixel].r;
|
||||
*g = format->palette->colors[pixel].g;
|
||||
*b = format->palette->colors[pixel].b;
|
||||
*a = format->palette->colors[pixel].a;
|
||||
Uint8 unused;
|
||||
|
||||
if (!r) {
|
||||
r = &unused;
|
||||
}
|
||||
if (!g) {
|
||||
g = &unused;
|
||||
}
|
||||
if (!b) {
|
||||
b = &unused;
|
||||
}
|
||||
if (!a) {
|
||||
a = &unused;
|
||||
}
|
||||
|
||||
if (!format) {
|
||||
*r = *g = *b = *a = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(format->format)) {
|
||||
if (palette && pixel < (unsigned)palette->ncolors) {
|
||||
*r = palette->colors[pixel].r;
|
||||
*g = palette->colors[pixel].g;
|
||||
*b = palette->colors[pixel].b;
|
||||
*a = palette->colors[pixel].a;
|
||||
} else {
|
||||
*r = *g = *b = *a = 0;
|
||||
}
|
||||
} else if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_10BIT(format->format)) {
|
||||
unsigned v;
|
||||
v = (pixel & format->Rmask) >> format->Rshift;
|
||||
*r = (Uint8)(v >> 2);
|
||||
|
@ -1324,22 +1331,22 @@ void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format,
|
|||
v = (pixel & format->Bmask) >> format->Bshift;
|
||||
*b = (Uint8)(v >> 2);
|
||||
v = (pixel & format->Amask) >> format->Ashift;
|
||||
*a = SDL_expand_byte[format->Aloss][v];
|
||||
*a = SDL_expand_byte[format->Abits][v];
|
||||
} else {
|
||||
unsigned v;
|
||||
v = (pixel & format->Rmask) >> format->Rshift;
|
||||
*r = SDL_expand_byte[format->Rloss][v];
|
||||
*r = SDL_expand_byte[format->Rbits][v];
|
||||
v = (pixel & format->Gmask) >> format->Gshift;
|
||||
*g = SDL_expand_byte[format->Gloss][v];
|
||||
*g = SDL_expand_byte[format->Gbits][v];
|
||||
v = (pixel & format->Bmask) >> format->Bshift;
|
||||
*b = SDL_expand_byte[format->Bloss][v];
|
||||
*b = SDL_expand_byte[format->Bbits][v];
|
||||
v = (pixel & format->Amask) >> format->Ashift;
|
||||
*a = SDL_expand_byte[format->Aloss][v];
|
||||
*a = SDL_expand_byte[format->Abits][v];
|
||||
}
|
||||
}
|
||||
|
||||
/* Map from Palette to Palette */
|
||||
static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
|
||||
static Uint8 *Map1to1(const SDL_Palette *src, const SDL_Palette *dst, int *identical)
|
||||
{
|
||||
Uint8 *map;
|
||||
int i;
|
||||
|
@ -1369,15 +1376,13 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
|
|||
}
|
||||
|
||||
/* Map from Palette to BitField */
|
||||
static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
|
||||
SDL_PixelFormat *dst)
|
||||
static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, const SDL_PixelFormatDetails *dst)
|
||||
{
|
||||
Uint8 *map;
|
||||
int i;
|
||||
int bpp;
|
||||
SDL_Palette *pal = src->palette;
|
||||
|
||||
bpp = ((dst->bytes_per_pixel == 3) ? 4 : dst->bytes_per_pixel);
|
||||
bpp = ((SDL_BYTESPERPIXEL(dst->format) == 3) ? 4 : SDL_BYTESPERPIXEL(dst->format));
|
||||
map = (Uint8 *)SDL_calloc(256, bpp);
|
||||
if (!map) {
|
||||
return NULL;
|
||||
|
@ -1389,19 +1394,18 @@ static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod,
|
|||
Uint8 G = (Uint8)((pal->colors[i].g * Gmod) / 255);
|
||||
Uint8 B = (Uint8)((pal->colors[i].b * Bmod) / 255);
|
||||
Uint8 A = (Uint8)((pal->colors[i].a * Amod) / 255);
|
||||
ASSEMBLE_RGBA(&map[i * bpp], dst->bytes_per_pixel, dst, (Uint32)R,
|
||||
ASSEMBLE_RGBA(&map[i * bpp], SDL_BYTESPERPIXEL(dst->format), dst, (Uint32)R,
|
||||
(Uint32)G, (Uint32)B, (Uint32)A);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/* Map from BitField to Dithered-Palette to Palette */
|
||||
static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
|
||||
static Uint8 *MapNto1(const SDL_PixelFormatDetails *src, const SDL_Palette *pal, int *identical)
|
||||
{
|
||||
/* Generate a 256 color dither palette */
|
||||
SDL_Palette dithered;
|
||||
SDL_Color colors[256];
|
||||
SDL_Palette *pal = dst->palette;
|
||||
|
||||
dithered.ncolors = 256;
|
||||
SDL_DitherColors(colors, 8);
|
||||
|
@ -1409,29 +1413,11 @@ static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical
|
|||
return Map1to1(&dithered, pal, identical);
|
||||
}
|
||||
|
||||
SDL_BlitMap *SDL_AllocBlitMap(void)
|
||||
{
|
||||
SDL_BlitMap *map;
|
||||
|
||||
/* Allocate the empty map */
|
||||
map = (SDL_BlitMap *)SDL_calloc(1, sizeof(*map));
|
||||
if (!map) {
|
||||
return NULL;
|
||||
}
|
||||
map->info.r = 0xFF;
|
||||
map->info.g = 0xFF;
|
||||
map->info.b = 0xFF;
|
||||
map->info.a = 0xFF;
|
||||
|
||||
/* It's ready to go */
|
||||
return map;
|
||||
}
|
||||
|
||||
void SDL_InvalidateAllBlitMap(SDL_Surface *surface)
|
||||
{
|
||||
SDL_ListNode *l = (SDL_ListNode *)surface->list_blitmap;
|
||||
SDL_ListNode *l = surface->internal->list_blitmap;
|
||||
|
||||
surface->list_blitmap = NULL;
|
||||
surface->internal->list_blitmap = NULL;
|
||||
|
||||
while (l) {
|
||||
SDL_ListNode *tmp = l;
|
||||
|
@ -1448,7 +1434,7 @@ void SDL_InvalidateMap(SDL_BlitMap *map)
|
|||
}
|
||||
if (map->dst) {
|
||||
/* Un-register from the destination surface */
|
||||
SDL_ListRemove((SDL_ListNode **)&(map->dst->list_blitmap), map);
|
||||
SDL_ListRemove(&map->dst->internal->list_blitmap, map);
|
||||
}
|
||||
map->dst = NULL;
|
||||
map->src_palette_version = 0;
|
||||
|
@ -1459,28 +1445,32 @@ void SDL_InvalidateMap(SDL_BlitMap *map)
|
|||
|
||||
int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
||||
{
|
||||
SDL_PixelFormat *srcfmt;
|
||||
SDL_PixelFormat *dstfmt;
|
||||
const SDL_PixelFormatDetails *srcfmt;
|
||||
const SDL_Palette *srcpal;
|
||||
const SDL_PixelFormatDetails *dstfmt;
|
||||
const SDL_Palette *dstpal;
|
||||
SDL_BlitMap *map;
|
||||
|
||||
/* Clear out any previous mapping */
|
||||
map = src->map;
|
||||
map = &src->internal->map;
|
||||
#if SDL_HAVE_RLE
|
||||
if ((src->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
|
||||
SDL_UnRLESurface(src, 1);
|
||||
if (src->internal->flags & SDL_INTERNAL_SURFACE_RLEACCEL) {
|
||||
SDL_UnRLESurface(src, SDL_TRUE);
|
||||
}
|
||||
#endif
|
||||
SDL_InvalidateMap(map);
|
||||
|
||||
/* Figure out what kind of mapping we're doing */
|
||||
map->identity = 0;
|
||||
srcfmt = src->format;
|
||||
dstfmt = dst->format;
|
||||
srcfmt = src->internal->format;
|
||||
srcpal = src->internal->palette;
|
||||
dstfmt = dst->internal->format;
|
||||
dstpal = dst->internal->palette;
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(srcfmt->format)) {
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) {
|
||||
/* Palette --> Palette */
|
||||
map->info.table =
|
||||
Map1to1(srcfmt->palette, dstfmt->palette, &map->identity);
|
||||
Map1to1(srcpal, dstpal, &map->identity);
|
||||
if (!map->identity) {
|
||||
if (!map->info.table) {
|
||||
return -1;
|
||||
|
@ -1492,8 +1482,8 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||
} else {
|
||||
/* Palette --> BitField */
|
||||
map->info.table =
|
||||
Map1toN(srcfmt, src->map->info.r, src->map->info.g,
|
||||
src->map->info.b, src->map->info.a, dstfmt);
|
||||
Map1toN(srcpal, src->internal->map.info.r, src->internal->map.info.g,
|
||||
src->internal->map.info.b, src->internal->map.info.a, dstfmt);
|
||||
if (!map->info.table) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1501,7 +1491,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||
} else {
|
||||
if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) {
|
||||
/* BitField --> Palette */
|
||||
map->info.table = MapNto1(srcfmt, dstfmt, &map->identity);
|
||||
map->info.table = MapNto1(srcfmt, dstpal, &map->identity);
|
||||
if (!map->identity) {
|
||||
if (!map->info.table) {
|
||||
return -1;
|
||||
|
@ -1520,17 +1510,17 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||
|
||||
if (map->dst) {
|
||||
/* Register BlitMap to the destination surface, to be invalidated when needed */
|
||||
SDL_ListAdd((SDL_ListNode **)&(map->dst->list_blitmap), map);
|
||||
SDL_ListAdd(&map->dst->internal->list_blitmap, map);
|
||||
}
|
||||
|
||||
if (dstfmt->palette) {
|
||||
map->dst_palette_version = dstfmt->palette->version;
|
||||
if (dstpal) {
|
||||
map->dst_palette_version = dstpal->version;
|
||||
} else {
|
||||
map->dst_palette_version = 0;
|
||||
}
|
||||
|
||||
if (srcfmt->palette) {
|
||||
map->src_palette_version = srcfmt->palette->version;
|
||||
if (srcpal) {
|
||||
map->src_palette_version = srcpal->version;
|
||||
} else {
|
||||
map->src_palette_version = 0;
|
||||
}
|
||||
|
@ -1539,11 +1529,3 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
|
|||
return SDL_CalculateBlit(src);
|
||||
}
|
||||
|
||||
void SDL_FreeBlitMap(SDL_BlitMap *map)
|
||||
{
|
||||
if (map) {
|
||||
SDL_InvalidateMap(map);
|
||||
SDL_free(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,20 +18,20 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_pixels_c_h_
|
||||
#define SDL_pixels_c_h_
|
||||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
/* Useful functions and variables from SDL_pixel.c */
|
||||
|
||||
#include "SDL_blit.h"
|
||||
|
||||
|
||||
/* Pixel format functions */
|
||||
extern int SDL_InitFormat(SDL_PixelFormat *format, SDL_PixelFormatEnum pixel_format);
|
||||
extern int SDL_CalculateSurfaceSize(SDL_PixelFormatEnum format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch);
|
||||
extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormatEnum pixel_format);
|
||||
extern int SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, SDL_bool minimalPitch);
|
||||
extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormat pixel_format);
|
||||
extern void SDL_QuitPixelFormatDetails(void);
|
||||
|
||||
/* Colorspace conversion functions */
|
||||
extern float SDL_sRGBtoLinear(float v);
|
||||
|
@ -43,23 +43,14 @@ extern const float *SDL_GetColorPrimariesConversionMatrix(SDL_ColorPrimaries src
|
|||
extern void SDL_ConvertColorPrimaries(float *fR, float *fG, float *fB, const float *matrix);
|
||||
|
||||
/* Blit mapping functions */
|
||||
extern SDL_BlitMap *SDL_AllocBlitMap(void);
|
||||
extern void SDL_InvalidateMap(SDL_BlitMap *map);
|
||||
extern int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst);
|
||||
extern void SDL_FreeBlitMap(SDL_BlitMap *map);
|
||||
|
||||
extern void SDL_InvalidateAllBlitMap(SDL_Surface *surface);
|
||||
|
||||
/* Surface functions */
|
||||
extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace);
|
||||
extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace);
|
||||
extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
|
||||
/* Miscellaneous functions */
|
||||
extern void SDL_DitherColors(SDL_Color *colors, int bpp);
|
||||
extern Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern void SDL_DetectPalette(SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel);
|
||||
extern SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormatEnum format, SDL_Colorspace colorspace, void *pixels, int pitch);
|
||||
extern Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
extern void SDL_DetectPalette(const SDL_Palette *pal, SDL_bool *is_opaque, SDL_bool *has_alpha_channel);
|
||||
extern SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, void *pixels, int pitch);
|
||||
|
||||
#endif /* SDL_pixels_c_h_ */
|
||||
|
|
|
@ -42,9 +42,9 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
return SDL_InvalidParamError("dst");
|
||||
}
|
||||
|
||||
if (src->format->format != dst->format->format) {
|
||||
if (src->format != dst->format) {
|
||||
// Slow!
|
||||
SDL_Surface *src_tmp = SDL_ConvertSurfaceFormat(src, dst->format->format);
|
||||
SDL_Surface *src_tmp = SDL_ConvertSurfaceAndColorspace(src, dst->format, dst->internal->palette, SDL_GetSurfaceColorspace(dst), dst->internal->props);
|
||||
if (!src_tmp) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(src->format->format)) {
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(src->format)) {
|
||||
// Slow!
|
||||
if (!dstrect) {
|
||||
full_dst.x = 0;
|
||||
|
@ -63,18 +63,17 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
dstrect = &full_dst;
|
||||
}
|
||||
|
||||
SDL_Surface *src_tmp = SDL_ConvertSurfaceFormat(src, SDL_PIXELFORMAT_XRGB8888);
|
||||
SDL_Surface *src_tmp = SDL_ConvertSurface(src, SDL_PIXELFORMAT_XRGB8888);
|
||||
SDL_Surface *dst_tmp = SDL_CreateSurface(dstrect->w, dstrect->h, SDL_PIXELFORMAT_XRGB8888);
|
||||
if (src_tmp && dst_tmp) {
|
||||
ret = SDL_SoftStretch(src_tmp, srcrect, dst_tmp, NULL, scaleMode);
|
||||
if (ret == 0) {
|
||||
SDL_Colorspace dst_colorspace = SDL_COLORSPACE_UNKNOWN;
|
||||
SDL_GetSurfaceColorspace(dst, &dst_colorspace);
|
||||
SDL_Colorspace dst_colorspace = SDL_GetSurfaceColorspace(dst);
|
||||
SDL_ConvertPixelsAndColorspace(dstrect->w, dstrect->h,
|
||||
dst_tmp->format->format, SDL_COLORSPACE_SRGB, 0,
|
||||
dst_tmp->format, SDL_COLORSPACE_SRGB, 0,
|
||||
dst_tmp->pixels, dst_tmp->pitch,
|
||||
dst->format->format, dst_colorspace, SDL_GetSurfaceProperties(dst),
|
||||
(Uint8 *)dst->pixels + dstrect->y * dst->pitch + dstrect->x * dst->format->bytes_per_pixel, dst->pitch);
|
||||
dst->format, dst_colorspace, SDL_GetSurfaceProperties(dst),
|
||||
(Uint8 *)dst->pixels + dstrect->y * dst->pitch + dstrect->x * SDL_BYTESPERPIXEL(dst->format), dst->pitch);
|
||||
}
|
||||
} else {
|
||||
ret = -1;
|
||||
|
@ -93,7 +92,7 @@ int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
|
|||
}
|
||||
|
||||
if (scaleMode == SDL_SCALEMODE_LINEAR) {
|
||||
if (src->format->bytes_per_pixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
if (SDL_BYTESPERPIXEL(src->format) != 4 || src->format == SDL_PIXELFORMAT_ARGB2101010) {
|
||||
return SDL_SetError("Wrong format");
|
||||
}
|
||||
}
|
||||
|
@ -972,8 +971,7 @@ int SDL_LowerSoftStretchNearest(SDL_Surface *s, const SDL_Rect *srcrect,
|
|||
int dst_h = dstrect->h;
|
||||
int src_pitch = s->pitch;
|
||||
int dst_pitch = d->pitch;
|
||||
|
||||
const int bpp = d->format->bytes_per_pixel;
|
||||
int bpp = SDL_BYTESPERPIXEL(d->format);
|
||||
|
||||
Uint32 *src = (Uint32 *)((Uint8 *)s->pixels + srcrect->x * bpp + srcrect->y * src_pitch);
|
||||
Uint32 *dst = (Uint32 *)((Uint8 *)d->pixels + dstrect->x * bpp + dstrect->y * dst_pitch);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_surface_c_h_
|
||||
#define SDL_surface_c_h_
|
||||
|
||||
/* Useful functions and variables from SDL_surface.c */
|
||||
|
||||
#include "../SDL_list.h"
|
||||
|
||||
/* Surface internal flags */
|
||||
typedef Uint32 SDL_SurfaceDataFlags;
|
||||
|
||||
#define SDL_INTERNAL_SURFACE_DONTFREE 0x00000001u /**< Surface is referenced internally */
|
||||
#define SDL_INTERNAL_SURFACE_STACK 0x00000002u /**< Surface is allocated on the stack */
|
||||
#define SDL_INTERNAL_SURFACE_RLEACCEL 0x00000004u /**< Surface is RLE encoded */
|
||||
|
||||
/* Surface internal data definition */
|
||||
struct SDL_SurfaceData
|
||||
{
|
||||
/** flags for this surface */
|
||||
SDL_SurfaceDataFlags flags;
|
||||
|
||||
/** properties for this surface */
|
||||
SDL_PropertiesID props;
|
||||
|
||||
/** detailed format for this surface */
|
||||
const SDL_PixelFormatDetails *format;
|
||||
|
||||
/** palette for indexed surfaces */
|
||||
SDL_Palette *palette;
|
||||
|
||||
/** information needed for surfaces requiring locks */
|
||||
int locked;
|
||||
|
||||
/** clipping information */
|
||||
SDL_Rect clip_rect;
|
||||
|
||||
/** info for fast blit mapping to other surfaces */
|
||||
SDL_BlitMap map;
|
||||
|
||||
/** list of BlitMap that hold a reference to this surface */
|
||||
SDL_ListNode *list_blitmap;
|
||||
};
|
||||
|
||||
typedef struct SDL_InternalSurface
|
||||
{
|
||||
SDL_Surface surface;
|
||||
SDL_SurfaceData internal;
|
||||
|
||||
} SDL_InternalSurface;
|
||||
|
||||
/* Surface functions */
|
||||
extern SDL_bool SDL_SurfaceValid(SDL_Surface *surface);
|
||||
extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface);
|
||||
extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace);
|
||||
extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace);
|
||||
extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||
|
||||
#endif /* SDL_surface_c_h_ */
|
|
@ -268,7 +268,7 @@ struct SDL_VideoDevice
|
|||
int (*SetWindowMouseGrab)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed);
|
||||
int (*SetWindowKeyboardGrab)(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool grabbed);
|
||||
void (*DestroyWindow)(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
int (*CreateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
int (*CreateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
int (*SetWindowFramebufferVSync)(SDL_VideoDevice *_this, SDL_Window *window, int vsync);
|
||||
int (*GetWindowFramebufferVSync)(SDL_VideoDevice *_this, SDL_Window *window, int *vsync);
|
||||
int (*UpdateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
|
|
|
@ -284,14 +284,14 @@ static void SDLCALL SDL_CleanupWindowTextureData(void *userdata, void *value)
|
|||
SDL_free(data);
|
||||
}
|
||||
|
||||
static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_PropertiesID props = SDL_GetWindowProperties(window);
|
||||
SDL_WindowTextureData *data = (SDL_WindowTextureData *)SDL_GetProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL);
|
||||
const SDL_bool transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE;
|
||||
int i;
|
||||
int w, h;
|
||||
const SDL_PixelFormatEnum *texture_formats;
|
||||
const SDL_PixelFormat *texture_formats;
|
||||
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
|
||||
|
@ -355,7 +355,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S
|
|||
data->renderer = renderer;
|
||||
}
|
||||
|
||||
texture_formats = (const SDL_PixelFormatEnum *)SDL_GetProperty(SDL_GetRendererProperties(data->renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
|
||||
texture_formats = (const SDL_PixelFormat *)SDL_GetProperty(SDL_GetRendererProperties(data->renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL);
|
||||
if (!texture_formats) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S
|
|||
*format = texture_formats[0];
|
||||
|
||||
for (i = 0; texture_formats[i] != SDL_PIXELFORMAT_UNKNOWN; ++i) {
|
||||
SDL_PixelFormatEnum texture_format = texture_formats[i];
|
||||
SDL_PixelFormat texture_format = texture_formats[i];
|
||||
if (!SDL_ISPIXELFORMAT_FOURCC(texture_format) &&
|
||||
!SDL_ISPIXELFORMAT_10BIT(texture_format) &&
|
||||
!SDL_ISPIXELFORMAT_FLOAT(texture_format) &&
|
||||
|
@ -2657,7 +2657,7 @@ int SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon)
|
|||
SDL_DestroySurface(window->icon);
|
||||
|
||||
/* Convert the icon into ARGB8888 */
|
||||
window->icon = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888);
|
||||
window->icon = SDL_ConvertSurface(icon, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!window->icon) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -3292,7 +3292,7 @@ static SDL_bool ShouldAttemptTextureFramebuffer(void)
|
|||
|
||||
static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
||||
{
|
||||
SDL_PixelFormatEnum format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
SDL_PixelFormat format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
void *pixels = NULL;
|
||||
int pitch = 0;
|
||||
SDL_bool created_framebuffer = SDL_FALSE;
|
||||
|
@ -3343,7 +3343,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
|
|||
return window->surface;
|
||||
}
|
||||
|
||||
return SDL_CreateSurfaceFrom(pixels, w, h, pitch, format);
|
||||
return SDL_CreateSurfaceFrom(w, h, format, pixels, pitch);
|
||||
}
|
||||
|
||||
SDL_bool SDL_WindowHasSurface(SDL_Window *window)
|
||||
|
@ -3359,7 +3359,7 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
|
|||
|
||||
if (!window->surface_valid) {
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
window->surface->internal->flags &= ~SDL_INTERNAL_SURFACE_DONTFREE;
|
||||
SDL_DestroySurface(window->surface);
|
||||
window->surface = NULL;
|
||||
}
|
||||
|
@ -3367,7 +3367,7 @@ SDL_Surface *SDL_GetWindowSurface(SDL_Window *window)
|
|||
window->surface = SDL_CreateWindowFramebuffer(window);
|
||||
if (window->surface) {
|
||||
window->surface_valid = SDL_TRUE;
|
||||
window->surface->flags |= SDL_DONTFREE;
|
||||
window->surface->internal->flags |= SDL_INTERNAL_SURFACE_DONTFREE;
|
||||
}
|
||||
}
|
||||
return window->surface;
|
||||
|
@ -3425,7 +3425,7 @@ int SDL_DestroyWindowSurface(SDL_Window *window)
|
|||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (window->surface) {
|
||||
window->surface->flags &= ~SDL_DONTFREE;
|
||||
window->surface->internal->flags &= ~SDL_INTERNAL_SURFACE_DONTFREE;
|
||||
SDL_DestroySurface(window->surface);
|
||||
window->surface = NULL;
|
||||
window->surface_valid = SDL_FALSE;
|
||||
|
@ -4949,7 +4949,7 @@ static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int fl
|
|||
mask[(y * ((icon->w + 7) / 8)) + (x / 8)] &= ~(0x01 << (7 - (x % 8)))
|
||||
|
||||
colorkey = icon->format->colorkey;
|
||||
switch (icon->format->bytes_per_pixel) {
|
||||
switch (SDL_BYTESPERPIXEL(icon->format)) {
|
||||
case 1:
|
||||
{
|
||||
Uint8 *pixels;
|
||||
|
@ -5370,7 +5370,7 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape)
|
|||
return -1;
|
||||
}
|
||||
|
||||
surface = SDL_ConvertSurfaceFormat(shape, SDL_PIXELFORMAT_ARGB32);
|
||||
surface = SDL_ConvertSurface(shape, SDL_PIXELFORMAT_ARGB32);
|
||||
if (!surface) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
|
||||
#if SDL_HAVE_YUV
|
||||
static SDL_bool IsPlanar2x2Format(SDL_PixelFormatEnum format);
|
||||
static SDL_bool IsPlanar2x2Format(SDL_PixelFormat format);
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -36,7 +36,7 @@ static SDL_bool IsPlanar2x2Format(SDL_PixelFormatEnum format);
|
|||
*
|
||||
* return 0 on success, -1 on error
|
||||
*/
|
||||
int SDL_CalculateYUVSize(SDL_PixelFormatEnum format, int w, int h, size_t *size, size_t *pitch)
|
||||
int SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, size_t *pitch)
|
||||
{
|
||||
#if SDL_HAVE_YUV
|
||||
int sz_plane = 0, sz_plane_chroma = 0, sz_plane_packed = 0;
|
||||
|
@ -187,7 +187,7 @@ static int GetYUVConversionType(SDL_Colorspace colorspace, YCbCrType *yuv_type)
|
|||
return SDL_SetError("Unsupported YUV colorspace");
|
||||
}
|
||||
|
||||
static SDL_bool IsPlanar2x2Format(SDL_PixelFormatEnum format)
|
||||
static SDL_bool IsPlanar2x2Format(SDL_PixelFormat format)
|
||||
{
|
||||
return format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV || format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21 || format == SDL_PIXELFORMAT_P010;
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ static SDL_bool IsPacked4Format(Uint32 format)
|
|||
return format == SDL_PIXELFORMAT_YUY2 || format == SDL_PIXELFORMAT_UYVY || format == SDL_PIXELFORMAT_YVYU;
|
||||
}
|
||||
|
||||
static int GetYUVPlanes(int width, int height, SDL_PixelFormatEnum format, const void *yuv, int yuv_pitch,
|
||||
static int GetYUVPlanes(int width, int height, SDL_PixelFormat format, const void *yuv, int yuv_pitch,
|
||||
const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride)
|
||||
{
|
||||
const Uint8 *planes[3] = { NULL, NULL, NULL };
|
||||
|
@ -304,7 +304,7 @@ static int GetYUVPlanes(int width, int height, SDL_PixelFormatEnum format, const
|
|||
|
||||
#ifdef SDL_SSE2_INTRINSICS
|
||||
static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse(
|
||||
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
|
||||
SDL_PixelFormat src_format, SDL_PixelFormat dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
|
||||
Uint8 *rgb, Uint32 rgb_stride,
|
||||
|
@ -411,7 +411,7 @@ static SDL_bool SDL_TARGETING("sse2") yuv_rgb_sse(
|
|||
}
|
||||
#else
|
||||
static SDL_bool yuv_rgb_sse(
|
||||
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
|
||||
SDL_PixelFormat src_format, SDL_PixelFormat dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
|
||||
Uint8 *rgb, Uint32 rgb_stride,
|
||||
|
@ -423,7 +423,7 @@ static SDL_bool yuv_rgb_sse(
|
|||
|
||||
#ifdef SDL_LSX_INTRINSICS
|
||||
static SDL_bool yuv_rgb_lsx(
|
||||
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
|
||||
SDL_PixelFormat src_format, SDL_PixelFormat dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
|
||||
Uint8 *rgb, Uint32 rgb_stride,
|
||||
|
@ -463,7 +463,7 @@ static SDL_bool yuv_rgb_lsx(
|
|||
}
|
||||
#else
|
||||
static SDL_bool yuv_rgb_lsx(
|
||||
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
|
||||
SDL_PixelFormat src_format, SDL_PixelFormat dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
|
||||
Uint8 *rgb, Uint32 rgb_stride,
|
||||
|
@ -474,7 +474,7 @@ static SDL_bool yuv_rgb_lsx(
|
|||
#endif
|
||||
|
||||
static SDL_bool yuv_rgb_std(
|
||||
SDL_PixelFormatEnum src_format, SDL_PixelFormatEnum dst_format,
|
||||
SDL_PixelFormat src_format, SDL_PixelFormat dst_format,
|
||||
Uint32 width, Uint32 height,
|
||||
const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
|
||||
Uint8 *rgb, Uint32 rgb_stride,
|
||||
|
@ -587,8 +587,8 @@ static SDL_bool yuv_rgb_std(
|
|||
}
|
||||
|
||||
int SDL_ConvertPixels_YUV_to_RGB(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
|
||||
{
|
||||
const Uint8 *y = NULL;
|
||||
const Uint8 *u = NULL;
|
||||
|
@ -709,7 +709,7 @@ static struct RGB2YUVFactors RGB2YUVFactorTables[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
|
||||
static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
|
||||
{
|
||||
const int src_pitch_x_2 = src_pitch * 2;
|
||||
const int height_half = height / 2;
|
||||
|
@ -1000,7 +1000,7 @@ static int SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
|
||||
static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, YCbCrType yuv_type)
|
||||
{
|
||||
const int src_pitch_x_2 = src_pitch * 2;
|
||||
const int height_half = height / 2;
|
||||
|
@ -1123,8 +1123,8 @@ static int SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const vo
|
|||
}
|
||||
|
||||
int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
|
||||
{
|
||||
YCbCrType yuv_type = YCBCR_601_LIMITED;
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
|
|||
}
|
||||
}
|
||||
|
||||
static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFormatEnum format,
|
||||
static int SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFormat format,
|
||||
const void *src, int src_pitch, void *dst, int dst_pitch)
|
||||
{
|
||||
int i;
|
||||
|
@ -1677,8 +1677,8 @@ static int SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int
|
|||
}
|
||||
|
||||
static int SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, void *dst, int dst_pitch)
|
||||
{
|
||||
if (src != dst) {
|
||||
/* Copy Y plane */
|
||||
|
@ -2235,8 +2235,8 @@ static int SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src
|
|||
}
|
||||
|
||||
static int SDL_ConvertPixels_Packed4_to_Packed4(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, void *dst, int dst_pitch)
|
||||
{
|
||||
switch (src_format) {
|
||||
case SDL_PIXELFORMAT_YUY2:
|
||||
|
@ -2277,8 +2277,8 @@ static int SDL_ConvertPixels_Packed4_to_Packed4(int width, int height,
|
|||
}
|
||||
|
||||
static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, void *dst, int dst_pitch)
|
||||
{
|
||||
int x, y;
|
||||
const Uint8 *srcY1, *srcY2, *srcU, *srcV;
|
||||
|
@ -2419,8 +2419,8 @@ static int SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height,
|
|||
}
|
||||
|
||||
static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, void *dst, int dst_pitch)
|
||||
{
|
||||
int x, y;
|
||||
const Uint8 *srcY1, *srcY2, *srcU1, *srcU2, *srcV1, *srcV2;
|
||||
|
@ -2552,8 +2552,8 @@ static int SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height,
|
|||
#endif /* SDL_HAVE_YUV */
|
||||
|
||||
int SDL_ConvertPixels_YUV_to_YUV(int width, int height,
|
||||
SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
|
||||
SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
|
||||
SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch,
|
||||
SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch)
|
||||
{
|
||||
#if SDL_HAVE_YUV
|
||||
if (src_colorspace != dst_colorspace) {
|
||||
|
|
|
@ -26,11 +26,11 @@
|
|||
|
||||
/* YUV conversion functions */
|
||||
|
||||
extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, SDL_PixelFormatEnum src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormatEnum dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch);
|
||||
|
||||
|
||||
extern int SDL_CalculateYUVSize(SDL_PixelFormatEnum format, int w, int h, size_t *size, size_t *pitch);
|
||||
extern int SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, size_t *pitch);
|
||||
|
||||
#endif /* SDL_yuv_c_h_ */
|
||||
|
|
|
@ -84,7 +84,7 @@ static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot
|
|||
int custom_cursor;
|
||||
SDL_Surface *converted;
|
||||
|
||||
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
|
||||
converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!converted) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -256,7 +256,7 @@ NSImage *Cocoa_CreateImage(SDL_Surface *surface)
|
|||
int i;
|
||||
NSImage *img;
|
||||
|
||||
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA32);
|
||||
converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_RGBA32);
|
||||
if (!converted) {
|
||||
return nil;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ NSImage *Cocoa_CreateImage(SDL_Surface *surface)
|
|||
isPlanar:NO
|
||||
colorSpaceName:NSDeviceRGBColorSpace
|
||||
bytesPerRow:converted->pitch
|
||||
bitsPerPixel:converted->format->bits_per_pixel];
|
||||
bitsPerPixel:SDL_BITSPERPIXEL(converted->format)];
|
||||
if (imgrep == nil) {
|
||||
SDL_DestroySurface(converted);
|
||||
return nil;
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#define DUMMY_SURFACE "SDL.internal.window.surface"
|
||||
|
||||
|
||||
int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XRGB8888;
|
||||
const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888;
|
||||
int w, h;
|
||||
|
||||
/* Create a new framebuffer */
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
#include <emscripten/threading.h>
|
||||
|
||||
int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XBGR8888;
|
||||
const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XBGR8888;
|
||||
int w, h;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef SDL_emscriptenframebuffer_h_
|
||||
#define SDL_emscriptenframebuffer_h_
|
||||
|
||||
extern int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void Emscripten_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int
|
|||
const char *cursor_url = NULL;
|
||||
SDL_Surface *conv_surf;
|
||||
|
||||
conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888);
|
||||
conv_surf = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ABGR8888);
|
||||
|
||||
if (!conv_surf) {
|
||||
return NULL;
|
||||
|
|
|
@ -44,7 +44,7 @@ static SDL_INLINE SDL_BLooper *_GetBeLooper() {
|
|||
}
|
||||
|
||||
int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window,
|
||||
SDL_PixelFormatEnum * format,
|
||||
SDL_PixelFormat * format,
|
||||
void ** pixels, int *pitch) {
|
||||
SDL_BWin *bwin = _ToBeWin(window);
|
||||
BScreen bscreen;
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
#include "../SDL_sysvideo.h"
|
||||
|
||||
extern int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
|
||||
SDL_PixelFormatEnum *format,
|
||||
SDL_PixelFormat *format,
|
||||
void **pixels, int *pitch);
|
||||
extern int HAIKU_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
|
||||
const SDL_Rect *rects, int numrects);
|
||||
|
|
|
@ -132,7 +132,7 @@ void _SpoutModeData(display_mode *bmode) {
|
|||
|
||||
|
||||
|
||||
SDL_PixelFormatEnum HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
|
||||
SDL_PixelFormat HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace)
|
||||
{
|
||||
switch (colorspace) {
|
||||
case B_CMAP8:
|
||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
extern SDL_PixelFormatEnum HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace);
|
||||
extern SDL_PixelFormat HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace);
|
||||
|
||||
extern int HAIKU_InitModes(SDL_VideoDevice *_this);
|
||||
extern int HAIKU_QuitModes(SDL_VideoDevice *_this);
|
||||
|
|
|
@ -179,7 +179,7 @@ static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot
|
|||
SDL_Cursor *cursor;
|
||||
SDL_Surface *converted;
|
||||
|
||||
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888);
|
||||
converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888);
|
||||
if (!converted) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_
|
|||
alpha-premultiplied, but the SDL surface we receive has
|
||||
straight-alpha pixels, so we always have to convert. */
|
||||
SDL_PremultiplyAlpha(surface->w, surface->h,
|
||||
surface->format->format, surface->pixels, surface->pitch,
|
||||
surface->format, surface->pixels, surface->pitch,
|
||||
SDL_PIXELFORMAT_ARGB8888, curdata->buffer, surface->w * 4);
|
||||
|
||||
cursor->driverdata = curdata;
|
||||
|
|
|
@ -42,7 +42,7 @@ static int GetSourceOffset(int x, int y, int source_width);
|
|||
static void FlushN3DSBuffer(const void *buffer, u32 bufsize, gfxScreen_t screen);
|
||||
|
||||
|
||||
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *framebuffer;
|
||||
const SDL_DisplayMode *mode;
|
||||
|
@ -82,10 +82,10 @@ int SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window,
|
|||
framebuffer = gfxGetFramebuffer(drv_data->screen, GFX_LEFT, &width, &height);
|
||||
bufsize = width * height * 4;
|
||||
|
||||
if (surface->format->bytes_per_pixel == 2)
|
||||
if (SDL_BYTESPERPIXEL(surface->format) == 2)
|
||||
CopyFramebuffertoN3DS_16(framebuffer, (Dimensions){ width, height },
|
||||
surface->pixels, (Dimensions){ surface->w, surface->h });
|
||||
else if (surface->format->bytes_per_pixel == 3)
|
||||
else if (SDL_BYTESPERPIXEL(surface->format) == 3)
|
||||
CopyFramebuffertoN3DS_24(framebuffer, (Dimensions){ width, height },
|
||||
surface->pixels, (Dimensions){ surface->w, surface->h });
|
||||
else
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
int SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
void SDL_N3DS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ struct SDL_DisplayModeData
|
|||
|
||||
static const struct
|
||||
{
|
||||
SDL_PixelFormatEnum pixfmt;
|
||||
SDL_PixelFormat pixfmt;
|
||||
GSPGPU_FramebufferFormat gspfmt;
|
||||
} format_map[] = {
|
||||
{ SDL_PIXELFORMAT_RGBA8888, GSP_RGBA8_OES },
|
||||
|
|
|
@ -44,11 +44,11 @@ void DrawBackground(SDL_VideoDevice *_this);
|
|||
void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 *screenBuffer);
|
||||
void RedrawWindowL(SDL_VideoDevice *_this);
|
||||
|
||||
int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_VideoData *phdata = _this->driverdata;
|
||||
SDL_Surface *surface;
|
||||
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XRGB4444;
|
||||
const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB4444;
|
||||
int w, h;
|
||||
|
||||
/* Free the old framebuffer surface */
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#define OFFSCREEN_SURFACE "SDL.internal.window.surface"
|
||||
|
||||
|
||||
int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_Surface *surface;
|
||||
const SDL_PixelFormatEnum surface_format = SDL_PIXELFORMAT_XRGB8888;
|
||||
const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888;
|
||||
int w, h;
|
||||
|
||||
/* Create a new framebuffer */
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void SDL_OFFSCREEN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
|
|
@ -152,7 +152,7 @@ fail:
|
|||
* @param[out] pitch Holds the number of bytes per line
|
||||
* @return 0 if successful, -1 on error
|
||||
*/
|
||||
static int createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormatEnum * format,
|
||||
static int createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormat * format,
|
||||
void ** pixels, int *pitch)
|
||||
{
|
||||
window_impl_t *impl = (window_impl_t *)window->driverdata;
|
||||
|
|
|
@ -61,7 +61,7 @@ static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
|||
VC_RECT_T dst_rect;
|
||||
Uint32 dummy;
|
||||
|
||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->pitch == surface->w * 4);
|
||||
|
||||
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <kernel.h>
|
||||
#include <swis.h>
|
||||
|
||||
int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *driverdata = window->driverdata;
|
||||
const char *sprite_name = "display";
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ enum
|
|||
|
||||
static const struct
|
||||
{
|
||||
SDL_PixelFormatEnum pixel_format;
|
||||
SDL_PixelFormat pixel_format;
|
||||
int modeflags, ncolour, log2bpp;
|
||||
} mode_to_pixelformat[] = {
|
||||
/* { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 }, */
|
||||
|
@ -70,7 +70,7 @@ static const struct
|
|||
{ SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 }
|
||||
};
|
||||
|
||||
static SDL_PixelFormatEnum RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp)
|
||||
static SDL_PixelFormat RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void vita_gpu_free(SceUID uid)
|
|||
sceKernelFreeMemBlock(uid);
|
||||
}
|
||||
|
||||
int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
SceDisplayFrameBuf framebuf;
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int VITA_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
|
|
@ -440,7 +440,7 @@ static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot
|
|||
|
||||
/* Wayland requires premultiplied alpha for its surfaces. */
|
||||
SDL_PremultiplyAlpha(surface->w, surface->h,
|
||||
surface->format->format, surface->pixels, surface->pitch,
|
||||
surface->format, surface->pixels, surface->pitch,
|
||||
SDL_PIXELFORMAT_ARGB8888, data->cursor_data.custom.shm_data, surface->w * 4);
|
||||
|
||||
data->surface = wl_compositor_create_surface(wd->compositor);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "SDL_windowsvideo.h"
|
||||
|
||||
int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch)
|
||||
int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch)
|
||||
{
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
SDL_bool isstack;
|
||||
|
@ -66,7 +66,7 @@ int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_
|
|||
|
||||
bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount;
|
||||
masks = (Uint32 *)((Uint8 *)info + info->bmiHeader.biSize);
|
||||
*format = SDL_GetPixelFormatEnumForMasks(bpp, masks[0], masks[1], masks[2], 0);
|
||||
*format = SDL_GetPixelFormatForMasks(bpp, masks[0], masks[1], masks[2], 0);
|
||||
}
|
||||
if (*format == SDL_PIXELFORMAT_UNKNOWN) {
|
||||
/* We'll use RGB format for now */
|
||||
|
|
|
@ -20,6 +20,6 @@
|
|||
*/
|
||||
#include "SDL_internal.h"
|
||||
|
||||
extern int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormatEnum *format, void **pixels, int *pitch);
|
||||
extern int WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch);
|
||||
extern int WIN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||
extern void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window);
|
||||
|
|
|
@ -49,7 +49,7 @@ static SDL_bool IsMonochromeSurface(SDL_Surface *surface)
|
|||
int x, y;
|
||||
Uint8 r, g, b, a;
|
||||
|
||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
|
||||
for (y = 0; y < surface->h; y++) {
|
||||
for (x = 0; x < surface->w; x++) {
|
||||
|
@ -76,7 +76,7 @@ static HBITMAP CreateColorBitmap(SDL_Surface *surface)
|
|||
BITMAPINFO bi;
|
||||
void *pixels;
|
||||
|
||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
|
||||
SDL_zero(bi);
|
||||
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
|
@ -114,7 +114,7 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface, SDL_bool is_monochrome)
|
|||
const int size = pitch * surface->h;
|
||||
static const unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 };
|
||||
|
||||
SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888);
|
||||
|
||||
pixels = SDL_small_alloc(Uint8, size * (is_monochrome ? 2 : 1), &isstack);
|
||||
if (!pixels) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue