mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-17 02:08:27 +00:00
Fixed the colorspace for YUV textures using native RGB representations
Fixes https://github.com/libsdl-org/SDL/issues/10624
This commit is contained in:
parent
efc98062af
commit
16fb8e54cb
3 changed files with 7 additions and 4 deletions
|
@ -1453,7 +1453,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
|
|||
|
||||
if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
|
||||
#if SDL_HAVE_YUV
|
||||
texture->yuv = SDL_SW_CreateYUVTexture(format, w, h);
|
||||
texture->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->colorspace, w, h);
|
||||
#else
|
||||
SDL_SetError("SDL not built with YUV support");
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "../video/SDL_blit.h"
|
||||
#include "../video/SDL_yuv_c.h"
|
||||
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
||||
SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h)
|
||||
{
|
||||
SDL_SW_YUVTexture *swdata;
|
||||
|
||||
|
@ -52,6 +52,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h)
|
|||
}
|
||||
|
||||
swdata->format = format;
|
||||
swdata->colorspace = colorspace;
|
||||
swdata->target_format = SDL_PIXELFORMAT_UNKNOWN;
|
||||
swdata->w = w;
|
||||
swdata->h = h;
|
||||
|
@ -368,6 +369,7 @@ bool SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, SDL
|
|||
if (!swdata->display) {
|
||||
return false;
|
||||
}
|
||||
swdata->target_format = target_format;
|
||||
}
|
||||
if (!swdata->stretch) {
|
||||
swdata->stretch = SDL_CreateSurface(swdata->w, swdata->h, target_format);
|
||||
|
@ -378,7 +380,7 @@ bool SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, SDL
|
|||
pixels = swdata->stretch->pixels;
|
||||
pitch = swdata->stretch->pitch;
|
||||
}
|
||||
if (!SDL_ConvertPixels(swdata->w, swdata->h, swdata->format, swdata->planes[0], swdata->pitches[0], target_format, pixels, pitch)) {
|
||||
if (!SDL_ConvertPixelsAndColorspace(swdata->w, swdata->h, swdata->format, swdata->colorspace, 0, swdata->planes[0], swdata->pitches[0], target_format, SDL_COLORSPACE_SRGB, 0, pixels, pitch)) {
|
||||
return false;
|
||||
}
|
||||
if (stretch) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
struct SDL_SW_YUVTexture
|
||||
{
|
||||
SDL_PixelFormat format;
|
||||
SDL_Colorspace colorspace;
|
||||
SDL_PixelFormat target_format;
|
||||
int w, h;
|
||||
Uint8 *pixels;
|
||||
|
@ -44,7 +45,7 @@ struct SDL_SW_YUVTexture
|
|||
|
||||
typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
|
||||
|
||||
extern SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, int w, int h);
|
||||
extern SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h);
|
||||
extern bool SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, int *pitch);
|
||||
extern bool SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch);
|
||||
extern bool SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue