diff --git a/.gitignore b/.gitignore index 3f82abce648be..05faf52e11e32 100644 --- a/.gitignore +++ b/.gitignore @@ -162,7 +162,6 @@ test/testshader test/testshape test/testsprite test/testspriteminimal -test/teststreaming test/testsurround test/testthread test/testtimer diff --git a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj index 5742f3338e84d..ba553de45eb71 100644 --- a/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj +++ b/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj @@ -19,7 +19,6 @@ F35E56E72983133F00A43A5F /* PBXTargetDependency */, DB0F490517CA5249008798C5 /* PBXTargetDependency */, DB0F490717CA5249008798C5 /* PBXTargetDependency */, - DB166E9816A1D7CF00A1396C /* PBXTargetDependency */, DB166E9616A1D7CD00A1396C /* PBXTargetDependency */, DB166E6C16A1D72000A1396C /* PBXTargetDependency */, DB166E5616A1D6B800A1396C /* PBXTargetDependency */, @@ -131,7 +130,6 @@ DB166E5416A1D6A300A1396C /* testscale.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC316A1C74100A1396C /* testscale.c */; }; DB166E6A16A1D70C00A1396C /* testshader.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC416A1C74100A1396C /* testshader.c */; }; DB166E9316A1D7BC00A1396C /* testspriteminimal.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC516A1C74100A1396C /* testspriteminimal.c */; }; - DB166E9416A1D7C700A1396C /* teststreaming.c in Sources */ = {isa = PBXBuildFile; fileRef = DB166CC616A1C74100A1396C /* teststreaming.c */; }; DB166E9A16A1D7F700A1396C /* moose.dat in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5E09D20839003FC8A1 /* moose.dat */; }; DB166E9C16A1D80900A1396C /* icon.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = 00794E5D09D20839003FC8A1 /* icon.bmp */; }; DB445EFB18184BB600B306B0 /* testdropfile.c in Sources */ = {isa = PBXBuildFile; fileRef = DB445EFA18184BB600B306B0 /* testdropfile.c */; }; @@ -183,7 +181,6 @@ F3C17C8228E4112900E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; }; F3C17C8328E4124400E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; }; F3C17C8428E4126400E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; }; - F3C17C8528E4127D00E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; }; F3C17CEB28E4177600E1A26D /* testgeometry.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17CD628E416AC00E1A26D /* testgeometry.c */; }; F3C17CEC28E417EB00E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; }; F3C17D3928E424B800E1A26D /* sample.wav in Resources */ = {isa = PBXBuildFile; fileRef = 00794E6209D20839003FC8A1 /* sample.wav */; }; @@ -268,8 +265,6 @@ F3CB56FB2A78983200766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F3CB56FD2A78983C00766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; }; F3CB56FE2A78983C00766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - F3CB57002A78984300766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; }; - F3CB57012A78984300766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F3CB57032A78984A00766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; }; F3CB57042A78984A00766177 /* SDL3.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F3CB57062A78985400766177 /* SDL3.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL3.framework */; }; @@ -570,13 +565,6 @@ remoteGlobalIDString = DB166E6D16A1D78400A1396C; remoteInfo = testspriteminimal; }; - DB166E9716A1D7CF00A1396C /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = DB166E8016A1D78C00A1396C; - remoteInfo = teststreaming; - }; F35E56E62983133F00A43A5F /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; @@ -681,16 +669,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - DB166E9916A1D7EE00A1396C /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 7; - files = ( - DB166E9A16A1D7F700A1396C /* moose.dat in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; DB166E9B16A1D7FC00A1396C /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1161,17 +1139,6 @@ name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; }; - F3CB57022A78984300766177 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - F3CB57012A78984300766177 /* SDL3.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; F3CB57052A78984A00766177 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -1272,7 +1239,6 @@ 003FA63A093FFD41000C53B3 /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../SDL/SDL.xcodeproj; sourceTree = SOURCE_ROOT; }; 00794E5D09D20839003FC8A1 /* icon.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = icon.bmp; sourceTree = ""; }; 00794E5E09D20839003FC8A1 /* moose.dat */ = {isa = PBXFileReference; lastKnownFileType = file; path = moose.dat; sourceTree = ""; }; - 00794E5F09D20839003FC8A1 /* picture.xbm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = picture.xbm; sourceTree = ""; }; 00794E6109D20839003FC8A1 /* sample.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = sample.bmp; sourceTree = ""; }; 00794E6209D20839003FC8A1 /* sample.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = sample.wav; sourceTree = ""; }; 00794E6309D20839003FC8A1 /* utf8.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = utf8.txt; sourceTree = ""; }; @@ -1319,7 +1285,6 @@ DB166CC316A1C74100A1396C /* testscale.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testscale.c; sourceTree = ""; }; DB166CC416A1C74100A1396C /* testshader.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testshader.c; sourceTree = ""; }; DB166CC516A1C74100A1396C /* testspriteminimal.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testspriteminimal.c; sourceTree = ""; }; - DB166CC616A1C74100A1396C /* teststreaming.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = teststreaming.c; sourceTree = ""; }; DB166D7F16A1D12400A1396C /* libSDL3_test.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libSDL3_test.a; sourceTree = BUILT_PRODUCTS_DIR; }; DB166D8416A1D1A500A1396C /* SDL_test_assert.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_assert.c; sourceTree = ""; }; DB166D8516A1D1A500A1396C /* SDL_test_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_common.c; sourceTree = ""; }; @@ -1338,7 +1303,6 @@ DB166E5216A1D69000A1396C /* testscale.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testscale.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB166E6816A1D6F300A1396C /* testshader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testshader.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB166E7E16A1D78400A1396C /* testspriteminimal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testspriteminimal.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E9116A1D78C00A1396C /* teststreaming.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = teststreaming.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB445EF818184B7000B306B0 /* testdropfile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testdropfile.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB445EFA18184BB600B306B0 /* testdropfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testdropfile.c; sourceTree = ""; }; DB89957E18A19ABA0092407C /* testhotplug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testhotplug.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1712,14 +1676,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - DB166E8316A1D78C00A1396C /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - F3CB57002A78984300766177 /* SDL3.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; DB445EE918184B7000B306B0 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1887,7 +1843,6 @@ 453774A4120915E3002F0F45 /* testshape.c */, 0017991910743F5300F5D044 /* testsprite.c */, DB166CC516A1C74100A1396C /* testspriteminimal.c */, - DB166CC616A1C74100A1396C /* teststreaming.c */, 092D6D58FFB311A97F000001 /* testthread.c */, 083E4880006D86A17F000001 /* testtimer.c */, F3C17C7328E40ADE00E1A26D /* testutils.c */, @@ -1942,7 +1897,6 @@ DB166E5216A1D69000A1396C /* testscale.app */, DB166E6816A1D6F300A1396C /* testshader.app */, DB166E7E16A1D78400A1396C /* testspriteminimal.app */, - DB166E9116A1D78C00A1396C /* teststreaming.app */, DB0F48EC17CA51E5008798C5 /* testdrawchessboard.app */, DB0F490117CA5212008798C5 /* testfilesystem.app */, DB89957E18A19ABA0092407C /* testhotplug.app */, @@ -2703,24 +2657,6 @@ productReference = DB166E7E16A1D78400A1396C /* testspriteminimal.app */; productType = "com.apple.product-type.application"; }; - DB166E8016A1D78C00A1396C /* teststreaming */ = { - isa = PBXNativeTarget; - buildConfigurationList = DB166E8E16A1D78C00A1396C /* Build configuration list for PBXNativeTarget "teststreaming" */; - buildPhases = ( - DB166E8116A1D78C00A1396C /* Sources */, - DB166E8316A1D78C00A1396C /* Frameworks */, - DB166E9916A1D7EE00A1396C /* CopyFiles */, - F3CB57022A78984300766177 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = teststreaming; - productName = teststreaming; - productReference = DB166E9116A1D78C00A1396C /* teststreaming.app */; - productType = "com.apple.product-type.application"; - }; DB445EE618184B7000B306B0 /* testdropfile */ = { isa = PBXNativeTarget; buildConfigurationList = DB445EF518184B7000B306B0 /* Build configuration list for PBXNativeTarget "testdropfile" */; @@ -2952,9 +2888,6 @@ DB166E6D16A1D78400A1396C = { ProvisioningStyle = Automatic; }; - DB166E8016A1D78C00A1396C = { - ProvisioningStyle = Automatic; - }; DB445EE618184B7000B306B0 = { ProvisioningStyle = Automatic; }; @@ -3035,7 +2968,6 @@ 4537749112091504002F0F45 /* testshape */, 001798FE10743F1000F5D044 /* testsprite */, DB166E6D16A1D78400A1396C /* testspriteminimal */, - DB166E8016A1D78C00A1396C /* teststreaming */, BEC567230761D90400A33029 /* testthread */, BEC5678D0761D90500A33029 /* testtimer */, BEC567A70761D90500A33029 /* testversion */, @@ -3439,15 +3371,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - DB166E8116A1D78C00A1396C /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - DB166E9416A1D7C700A1396C /* teststreaming.c in Sources */, - F3C17C8528E4127D00E1A26D /* testutils.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; DB445EE718184B7000B306B0 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3733,11 +3656,6 @@ target = DB166E6D16A1D78400A1396C /* testspriteminimal */; targetProxy = DB166E9516A1D7CD00A1396C /* PBXContainerItemProxy */; }; - DB166E9816A1D7CF00A1396C /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = DB166E8016A1D78C00A1396C /* teststreaming */; - targetProxy = DB166E9716A1D7CF00A1396C /* PBXContainerItemProxy */; - }; F35E56E72983133F00A43A5F /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = F35E56A2298312CB00A43A5F /* testautomation */; @@ -4658,26 +4576,6 @@ }; name = Release; }; - DB166E8F16A1D78C00A1396C /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = teststreaming; - PROVISIONING_PROFILE_SPECIFIER = ""; - }; - name = Debug; - }; - DB166E9016A1D78C00A1396C /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; - PRODUCT_NAME = teststreaming; - PROVISIONING_PROFILE_SPECIFIER = ""; - }; - name = Release; - }; DB445EF618184B7000B306B0 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -5192,15 +5090,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; - DB166E8E16A1D78C00A1396C /* Build configuration list for PBXNativeTarget "teststreaming" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - DB166E8F16A1D78C00A1396C /* Debug */, - DB166E9016A1D78C00A1396C /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Debug; - }; DB445EF518184B7000B306B0 /* Build configuration list for PBXNativeTarget "testdropfile" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d3071b9d3ec0f..8e210fdb153cf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -405,7 +405,6 @@ add_sdl_test_executable(testsprite MAIN_CALLBACKS NEEDS_RESOURCES TESTUTILS SOUR add_sdl_test_executable(testspriteminimal SOURCES testspriteminimal.c ${icon_png_header} DEPENDS generate-icon_png_header) add_sdl_test_executable(testspritesurface SOURCES testspritesurface.c ${icon_png_header} DEPENDS generate-icon_png_header) add_sdl_test_executable(testpalette SOURCES testpalette.c) -add_sdl_test_executable(teststreaming NEEDS_RESOURCES TESTUTILS SOURCES teststreaming.c) add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_ARGS --no-interactive NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c) add_sdl_test_executable(testurl SOURCES testurl.c) add_sdl_test_executable(testver NONINTERACTIVE NOTRACKMEM SOURCES testver.c) diff --git a/test/testoverlay.c b/test/testoverlay.c index ac568eee489f6..ad4cb445cd50f 100644 --- a/test/testoverlay.c +++ b/test/testoverlay.c @@ -31,10 +31,11 @@ #define MOOSEPIC_H 88 #define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) +#define MOOSEFRAME_PITCH MOOSEPIC_W #define MOOSEFRAMES_COUNT 10 /* *INDENT-OFF* */ /* clang-format off */ -static SDL_Color MooseColors[84] = { +static const SDL_Color MooseColors[84] = { {49, 49, 49, SDL_ALPHA_OPAQUE} , {66, 24, 0, SDL_ALPHA_OPAQUE} , {66, 33, 0, SDL_ALPHA_OPAQUE} @@ -147,9 +148,9 @@ 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_Surface *MooseSurfaces[MOOSEFRAMES_COUNT]; static SDL_Texture *MooseTexture = NULL; +static SDL_Palette *MoosePalette = NULL; static SDL_FRect displayrect; static int window_w; static int window_h; @@ -169,12 +170,14 @@ quit(int rc) * This allows testing of platforms where SDL_main is required and does meaningful cleanup. */ - SDL_free(RawMooseData); - for (i = 0; i < MOOSEFRAMES_COUNT; i++) { - SDL_DestroySurface(MooseYUVSurfaces[i]); + SDL_DestroySurface(MooseSurfaces[i]); } + SDL_DestroyPalette(MoosePalette); + + SDL_free(RawMooseData); + SDLTest_CommonQuit(state); /* Let 'main()' return normally */ @@ -190,34 +193,7 @@ static void MoveSprites(SDL_Renderer *renderer) if (streaming) { 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_UpdateTexture(MooseTexture, NULL, RawMooseData + i * MOOSEFRAME_SIZE, MOOSEFRAME_PITCH); } SDL_RenderClear(renderer); SDL_RenderTexture(renderer, MooseTexture, NULL, &displayrect); @@ -230,7 +206,7 @@ static void MoveSprites(SDL_Renderer *renderer) i = (i + 1) % MOOSEFRAMES_COUNT; } - tmp = SDL_CreateTextureFromSurface(renderer, MooseYUVSurfaces[i]); + tmp = SDL_CreateTextureFromSurface(renderer, MooseSurfaces[i]); if (!tmp) { SDL_Log("Error %s", SDL_GetError()); quit(7); @@ -322,7 +298,6 @@ int main(int argc, char **argv) { SDL_IOStream *handle; int i; - int j; int fps = 12; int nodelay = 0; int scale = 5; @@ -334,8 +309,6 @@ int main(int argc, char **argv) return 1; } - SDL_zeroa(MooseYUVSurfaces); - for (i = 1; i < argc;) { int consumed; @@ -380,33 +353,6 @@ int main(int argc, char **argv) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --fps option requires an argument [from 1 to 1000], default is 12."); quit(10); } - } else if (SDL_strcmp(argv[i], "--yuvformat") == 0) { - consumed = 2; - if (argv[i + 1]) { - char *fmt = argv[i + 1]; - - if (SDL_strcmp(fmt, "YV12") == 0) { - yuv_format = SDL_PIXELFORMAT_YV12; - } else if (SDL_strcmp(fmt, "IYUV") == 0) { - yuv_format = SDL_PIXELFORMAT_IYUV; - } else if (SDL_strcmp(fmt, "YUY2") == 0) { - yuv_format = SDL_PIXELFORMAT_YUY2; - } else if (SDL_strcmp(fmt, "UYVY") == 0) { - yuv_format = SDL_PIXELFORMAT_UYVY; - } else if (SDL_strcmp(fmt, "YVYU") == 0) { - yuv_format = SDL_PIXELFORMAT_YVYU; - } else if (SDL_strcmp(fmt, "NV12") == 0) { - yuv_format = SDL_PIXELFORMAT_NV12; - } else if (SDL_strcmp(fmt, "NV21") == 0) { - yuv_format = SDL_PIXELFORMAT_NV21; - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --yuvformat option requires one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)"); - quit(10); - } - } else { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "The --yuvformat option requires one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)"); - quit(10); - } } } @@ -414,7 +360,6 @@ int main(int argc, char **argv) static const char *options[] = { "[--fps ]", "[--nodelay]", - "[--yuvformat ] (one of the: YV12 (default), IYUV, YUY2, UYVY, YVYU, NV12, NV21)", "[--scale ] (initial scale of the overlay)", "[--nostreaming] path that use SDL_CreateTextureFromSurface() not STREAMING texture", NULL @@ -456,6 +401,13 @@ int main(int argc, char **argv) SDL_CloseIO(handle); + MoosePalette = SDL_CreatePalette(SDL_arraysize(MooseColors)); + if (!MoosePalette) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create palette: %s", SDL_GetError()); + quit(3); + } + SDL_SetPaletteColors(MoosePalette, MooseColors, 0, SDL_arraysize(MooseColors)); + /* Create the window and renderer */ window_w = MOOSEPIC_W * scale; window_h = MOOSEPIC_H * scale; @@ -469,48 +421,27 @@ int main(int argc, char **argv) SDL_Renderer *renderer = state->renderers[i]; if (streaming) { - MooseTexture = SDL_CreateTexture(renderer, yuv_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); + MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_INDEX8, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); if (!MooseTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s", SDL_GetError()); quit(5); } + SDL_SetTexturePalette(MooseTexture, MoosePalette); } } - /* Uncomment this to check vertex color with a YUV texture */ + /* Uncomment this to check vertex color with a paletted texture */ /* SDL_SetTextureColorMod(MooseTexture, 0xff, 0x80, 0x80); */ 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) { + MooseSurfaces[i] = SDL_CreateSurfaceFrom(MOOSEPIC_W, MOOSEPIC_H, SDL_PIXELFORMAT_INDEX8, + RawMooseData + i * MOOSEFRAME_SIZE, MOOSEFRAME_PITCH); + if (!MooseSurfaces[i]) { quit(6); } - - /* Load Moose into a RGB SDL_Surface */ - { - Uint8 *rgb = mooseRGBSurface->pixels; - Uint8 *frame = RawMooseData + i * MOOSEFRAME_SIZE; - for (j = 0; j < MOOSEFRAME_SIZE; ++j) { - rgb[0] = MooseColors[frame[j]].r; - rgb[1] = MooseColors[frame[j]].g; - rgb[2] = MooseColors[frame[j]].b; - rgb += 3; - } - } - - /* Convert to YUV SDL_Surface */ - MooseYUVSurfaces[i] = SDL_ConvertSurface(mooseRGBSurface, yuv_format); - if (MooseYUVSurfaces[i] == NULL) { - quit(7); - } - - SDL_DestroySurface(mooseRGBSurface); + SDL_SetSurfacePalette(MooseSurfaces[i], MoosePalette); } - SDL_free(RawMooseData); - RawMooseData = NULL; - /* set the start frame */ i = 0; if (nodelay) { diff --git a/test/teststreaming.c b/test/teststreaming.c deleted file mode 100644 index ea61b0e0b9bf7..0000000000000 --- a/test/teststreaming.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - Copyright (C) 1997-2025 Sam Lantinga - - 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. -*/ -/******************************************************************************** - * * - * Running moose :) Coded by Mike Gorchak. * - * * - ********************************************************************************/ - -#include -#include -#include -#include "testutils.h" - -#ifdef SDL_PLATFORM_EMSCRIPTEN -#include -#endif - -#include - -#define MOOSEPIC_W 64 -#define MOOSEPIC_H 88 - -#define MOOSEFRAME_SIZE (MOOSEPIC_W * MOOSEPIC_H) -#define MOOSEFRAMES_COUNT 10 - -/* *INDENT-OFF* */ /* clang-format off */ -static SDL_Color MooseColors[84] = { - {49, 49, 49, 255}, {66, 24, 0, 255}, {66, 33, 0, 255}, {66, 66, 66, 255}, - {66, 115, 49, 255}, {74, 33, 0, 255}, {74, 41, 16, 255}, {82, 33, 8, 255}, - {82, 41, 8, 255}, {82, 49, 16, 255}, {82, 82, 82, 255}, {90, 41, 8, 255}, - {90, 41, 16, 255}, {90, 57, 24, 255}, {99, 49, 16, 255}, {99, 66, 24, 255}, - {99, 66, 33, 255}, {99, 74, 33, 255}, {107, 57, 24, 255}, {107, 82, 41, 255}, - {115, 57, 33, 255}, {115, 66, 33, 255}, {115, 66, 41, 255}, {115, 74, 0, 255}, - {115, 90, 49, 255}, {115, 115, 115, 255}, {123, 82, 0, 255}, {123, 99, 57, 255}, - {132, 66, 41, 255}, {132, 74, 41, 255}, {132, 90, 8, 255}, {132, 99, 33, 255}, - {132, 99, 66, 255}, {132, 107, 66, 255}, {140, 74, 49, 255}, {140, 99, 16, 255}, - {140, 107, 74, 255}, {140, 115, 74, 255}, {148, 107, 24, 255}, {148, 115, 82, 255}, - {148, 123, 74, 255}, {148, 123, 90, 255}, {156, 115, 33, 255}, {156, 115, 90, 255}, - {156, 123, 82, 255}, {156, 132, 82, 255}, {156, 132, 99, 255}, {156, 156, 156, 255}, - {165, 123, 49, 255}, {165, 123, 90, 255}, {165, 132, 82, 255}, {165, 132, 90, 255}, - {165, 132, 99, 255}, {165, 140, 90, 255}, {173, 132, 57, 255}, {173, 132, 99, 255}, - {173, 140, 107, 255}, {173, 140, 115, 255}, {173, 148, 99, 255}, {173, 173, 173, 255}, - {181, 140, 74, 255}, {181, 148, 115, 255}, {181, 148, 123, 255}, {181, 156, 107, 255}, - {189, 148, 123, 255}, {189, 156, 82, 255}, {189, 156, 123, 255}, {189, 156, 132, 255}, - {189, 189, 189, 255}, {198, 156, 123, 255}, {198, 165, 132, 255}, {206, 165, 99, 255}, - {206, 165, 132, 255}, {206, 173, 140, 255}, {206, 206, 206, 255}, {214, 173, 115, 255}, - {214, 173, 140, 255}, {222, 181, 148, 255}, {222, 189, 132, 255}, {222, 189, 156, 255}, - {222, 222, 222, 255}, {231, 198, 165, 255}, {231, 231, 231, 255}, {239, 206, 173, 255} -}; -/* *INDENT-ON* */ /* clang-format on */ - -static Uint8 MooseFrames[MOOSEFRAMES_COUNT][MOOSEFRAME_SIZE]; - -static SDL_Renderer *renderer; -static int frame; -static SDL_Texture *MooseTexture; -static bool done = false; -static SDLTest_CommonState *state; - -static void quit(int rc) -{ - SDL_Quit(); - SDLTest_CommonDestroyState(state); - /* Let 'main()' return normally */ - if (rc != 0) { - exit(rc); - } -} - -static void UpdateTexture(SDL_Texture *texture) -{ - SDL_Color *color; - Uint8 *src; - Uint32 *dst; - int row, col; - void *pixels; - int pitch; - - if (!SDL_LockTexture(texture, NULL, &pixels, &pitch)) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s", SDL_GetError()); - quit(5); - } - src = MooseFrames[frame]; - for (row = 0; row < MOOSEPIC_H; ++row) { - dst = (Uint32 *)((Uint8 *)pixels + row * pitch); - for (col = 0; col < MOOSEPIC_W; ++col) { - color = &MooseColors[*src++]; - *dst++ = (0xFF000000 | (color->r << 16) | (color->g << 8) | color->b); - } - } - SDL_UnlockTexture(texture); -} - -static void loop(void) -{ - SDL_Event event; - - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_EVENT_KEY_DOWN: - if (event.key.key == SDLK_ESCAPE) { - done = true; - } - break; - case SDL_EVENT_QUIT: - done = true; - break; - default: - break; - } - } - - frame = (frame + 1) % MOOSEFRAMES_COUNT; - UpdateTexture(MooseTexture); - - SDL_RenderClear(renderer); - SDL_RenderTexture(renderer, MooseTexture, NULL, NULL); - SDL_RenderPresent(renderer); - -#ifdef SDL_PLATFORM_EMSCRIPTEN - if (done) { - emscripten_cancel_main_loop(); - } -#endif -} - -int main(int argc, char **argv) -{ - SDL_Window *window; - SDL_IOStream *handle; - char *filename = NULL; - - /* Initialize test framework */ - state = SDLTest_CommonCreateState(argv, 0); - if (!state) { - return 1; - } - - if (!SDLTest_CommonDefaultArgs(state, argc, argv)) { - SDL_Quit(); - SDLTest_CommonDestroyState(state); - return 1; - } - - if (!SDL_Init(SDL_INIT_VIDEO)) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s", SDL_GetError()); - return 1; - } - - /* load the moose images */ - filename = GetResourceFilename(NULL, "moose.dat"); - if (!filename) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory"); - return -1; - } - handle = SDL_IOFromFile(filename, "rb"); - SDL_free(filename); - if (!handle) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !"); - quit(2); - } - SDL_ReadIO(handle, MooseFrames, MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); - SDL_CloseIO(handle); - - /* Create the window and renderer */ - window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE); - if (!window) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s", SDL_GetError()); - quit(3); - } - - renderer = SDL_CreateRenderer(window, NULL); - if (!renderer) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s", SDL_GetError()); - quit(4); - } - - MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (!MooseTexture) { - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s", SDL_GetError()); - quit(5); - } - - /* Loop, waiting for QUIT or the escape key */ - frame = 0; - -#ifdef SDL_PLATFORM_EMSCRIPTEN - emscripten_set_main_loop(loop, 0, 1); -#else - while (!done) { - loop(); - } -#endif - - SDL_DestroyRenderer(renderer); - - quit(0); - return 0; -}