forked from Green-Sky/tomato
Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
85
external/sdl/SDL/test/testoverlay.c
vendored
85
external/sdl/SDL/test/testoverlay.c
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
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
|
||||
@ -147,6 +147,7 @@ static Uint64 next_fps_check;
|
||||
static Uint32 frames;
|
||||
static const Uint32 fps_check_delay = 5000;
|
||||
|
||||
static Uint32 yuv_format = SDL_PIXELFORMAT_YV12;
|
||||
static SDL_Surface *MooseYUVSurfaces[MOOSEFRAMES_COUNT];
|
||||
static SDL_Texture *MooseTexture = NULL;
|
||||
static SDL_FRect displayrect;
|
||||
@ -187,31 +188,58 @@ static void MoveSprites(SDL_Renderer *renderer)
|
||||
static int i = 0;
|
||||
|
||||
if (streaming) {
|
||||
if (!paused) {
|
||||
i = (i + 1) % MOOSEFRAMES_COUNT;
|
||||
SDL_UpdateTexture(MooseTexture, NULL, MooseYUVSurfaces[i]->pixels, MooseYUVSurfaces[i]->pitch);
|
||||
}
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderTexture(renderer, MooseTexture, NULL, &displayrect);
|
||||
SDL_RenderPresent(renderer);
|
||||
if (!paused) {
|
||||
i = (i + 1) % MOOSEFRAMES_COUNT;
|
||||
/* Test both upload paths for NV12/NV21 formats */
|
||||
if ((yuv_format == SDL_PIXELFORMAT_NV12 || yuv_format == SDL_PIXELFORMAT_NV21) &&
|
||||
(i % 2) == 0) {
|
||||
#ifdef TEST_RECT_UPDATE
|
||||
SDL_Rect rect;
|
||||
|
||||
if (i == 0) {
|
||||
rect.x = 0;
|
||||
rect.y = 0;
|
||||
rect.w = MOOSEPIC_W;
|
||||
rect.h = MOOSEPIC_H;
|
||||
} else {
|
||||
rect.x = MOOSEPIC_W / 4;
|
||||
rect.y = MOOSEPIC_H / 4;
|
||||
rect.w = MOOSEPIC_W / 2;
|
||||
rect.h = MOOSEPIC_H / 2;
|
||||
}
|
||||
SDL_UpdateNVTexture(MooseTexture, &rect,
|
||||
(Uint8 *)MooseYUVSurfaces[i]->pixels + rect.y * MooseYUVSurfaces[i]->pitch + rect.x, MooseYUVSurfaces[i]->pitch,
|
||||
(Uint8 *)MooseYUVSurfaces[i]->pixels + MOOSEFRAME_SIZE + (rect.y + 1) / 2 * MooseYUVSurfaces[i]->pitch + (rect.x + 1) / 2, MooseYUVSurfaces[i]->pitch);
|
||||
#else
|
||||
SDL_UpdateNVTexture(MooseTexture, NULL,
|
||||
MooseYUVSurfaces[i]->pixels, MooseYUVSurfaces[i]->pitch,
|
||||
(Uint8 *)MooseYUVSurfaces[i]->pixels + MOOSEFRAME_SIZE, MooseYUVSurfaces[i]->pitch);
|
||||
#endif
|
||||
} else {
|
||||
SDL_UpdateTexture(MooseTexture, NULL, MooseYUVSurfaces[i]->pixels, MooseYUVSurfaces[i]->pitch);
|
||||
}
|
||||
}
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderTexture(renderer, MooseTexture, NULL, &displayrect);
|
||||
SDL_RenderPresent(renderer);
|
||||
} else {
|
||||
SDL_Texture *tmp;
|
||||
SDL_Texture *tmp;
|
||||
|
||||
/* Test SDL_CreateTextureFromSurface */
|
||||
if (!paused) {
|
||||
i = (i + 1) % MOOSEFRAMES_COUNT;
|
||||
}
|
||||
/* Test SDL_CreateTextureFromSurface */
|
||||
if (!paused) {
|
||||
i = (i + 1) % MOOSEFRAMES_COUNT;
|
||||
}
|
||||
|
||||
tmp = SDL_CreateTextureFromSurface(renderer, MooseYUVSurfaces[i]);
|
||||
if (tmp == NULL) {
|
||||
SDL_Log("Error %s", SDL_GetError());
|
||||
quit(7);
|
||||
}
|
||||
tmp = SDL_CreateTextureFromSurface(renderer, MooseYUVSurfaces[i]);
|
||||
if (!tmp) {
|
||||
SDL_Log("Error %s", SDL_GetError());
|
||||
quit(7);
|
||||
}
|
||||
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderTexture(renderer, tmp, NULL, &displayrect);
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_DestroyTexture(tmp);
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderTexture(renderer, tmp, NULL, &displayrect);
|
||||
SDL_RenderPresent(renderer);
|
||||
SDL_DestroyTexture(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -295,11 +323,10 @@ int main(int argc, char **argv)
|
||||
int nodelay = 0;
|
||||
int scale = 5;
|
||||
char *filename = NULL;
|
||||
int yuv_format = SDL_PIXELFORMAT_YV12;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -403,20 +430,20 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
RawMooseData = (Uint8 *)SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT);
|
||||
if (RawMooseData == NULL) {
|
||||
if (!RawMooseData) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n");
|
||||
quit(1);
|
||||
}
|
||||
|
||||
/* load the trojan moose images */
|
||||
filename = GetResourceFilename(NULL, "moose.dat");
|
||||
if (filename == NULL) {
|
||||
if (!filename) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
|
||||
quit(2);
|
||||
}
|
||||
handle = SDL_RWFromFile(filename, "rb");
|
||||
SDL_free(filename);
|
||||
if (handle == NULL) {
|
||||
if (!handle) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");
|
||||
quit(2);
|
||||
}
|
||||
@ -439,7 +466,7 @@ int main(int argc, char **argv)
|
||||
|
||||
if (streaming) {
|
||||
MooseTexture = SDL_CreateTexture(renderer, yuv_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
|
||||
if (MooseTexture == NULL) {
|
||||
if (!MooseTexture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
|
||||
quit(5);
|
||||
}
|
||||
@ -452,7 +479,7 @@ int main(int argc, char **argv)
|
||||
for (i = 0; i < MOOSEFRAMES_COUNT; i++) {
|
||||
/* Create RGB SDL_Surface */
|
||||
SDL_Surface *mooseRGBSurface = SDL_CreateSurface(MOOSEPIC_W, MOOSEPIC_H, SDL_PIXELFORMAT_RGB24);
|
||||
if (mooseRGBSurface == NULL) {
|
||||
if (!mooseRGBSurface) {
|
||||
quit(6);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user