visualtest/include/SDL_visualtest_harness_argparser.h
author Ryan C. Gordon <icculus@icculus.org>
Fri, 10 Apr 2020 00:37:35 -0400
changeset 13724 aca267270368
parent 11382 2c50e79b19e0
permissions -rw-r--r--
metal: Added some support interfaces to Apple's Metal API (thanks, Caleb!).

Caleb Cornett's comments:

"A few weeks ago, Alex added a partial Metal API to SDL2:

https://hg.libsdl.org/SDL/rev/b87ba0fad17e

I noticed it was missing a few features that would help Metal become a
first-class citizen in SDL, so I went ahead and wrote them! Here are the new
APIs:

1. SDL_WINDOW_METAL flag for SDL_CreateWindow(). This allows the programmer
to specify that they intend to create a window for use with SDL_MetalView.
The flag is used to ensure correct usage of the API and to prevent
accidentally defaulting to OpenGL on iOS.

2. SDL_Metal_GetLayer(). This function takes a SDL_MetalView and returns a
pointer to the view's backing CAMetalLayer. This simplifies things
considerably, since in the current version of the SDL_Metal API the
programmer is required to bridge-cast a SDL_MetalView handle to an NSView or
UIView (depending on the platform) and then extract the layer from there.
SDL_Metal_GetLayer automatically handles all of that, making the operation
simple and cross-platform.

3. SDL_Metal_GetDrawableSize(). This function already exists in the current
SDL_Metal API (and is used behind-the-scenes for SDL_Vulkan_GetDrawableSize
on Apple platforms) but was not publicly exposed. My patch exposes this
function for public use. It works just like you'd expect.

Tested on macOS 10.14 and iOS 12.4."

Fixes Bugzilla #4796.
     1 /**
     2  *  \file SDL_visualtest_harness_argparser.h
     3  *
     4  *  Provides functionality to parse command line arguments to the test harness.
     5  */
     6 
     7 #include <SDL.h>
     8 #include "SDL_visualtest_sut_configparser.h"
     9 #include "SDL_visualtest_variator_common.h"
    10 #include "SDL_visualtest_action_configparser.h"
    11 
    12 #ifndef SDL_visualtest_harness_argparser_h_
    13 #define SDL_visualtest_harness_argparser_h_
    14 
    15 /** Maximum length of a path string */
    16 #define MAX_PATH_LEN 300
    17 /** Maximum length of a string of SUT arguments */
    18 #define MAX_SUT_ARGS_LEN 600
    19 
    20 /* Set up for C function definitions, even when using C++ */
    21 #ifdef __cplusplus
    22 extern "C" {
    23 #endif
    24 
    25 /**
    26  * Stores the state of the test harness.
    27  */
    28 typedef struct SDLVisualTest_HarnessState
    29 {
    30     /*! Path to the System Under Test (SUT) executable */
    31     char sutapp[MAX_PATH_LEN];
    32     /*! Command line arguments to be passed to the SUT */
    33     char sutargs[MAX_SUT_ARGS_LEN];
    34     /*! Time in milliseconds after which to kill the SUT */
    35     int timeout;
    36     /*! Configuration object for the SUT */
    37     SDLVisualTest_SUTConfig sut_config;
    38     /*! What type of variator to use to generate argument strings */
    39     SDLVisualTest_VariatorType variator_type;
    40     /*! The number of variations to generate */
    41     int num_variations;
    42     /*! If true, the test harness will just print the different variations
    43         without launching the SUT for each one */
    44     SDL_bool no_launch;
    45     /*! A queue with actions to be performed while the SUT is running */
    46     SDLVisualTest_ActionQueue action_queue;
    47     /*! Output directory to save the screenshots */
    48     char output_dir[MAX_PATH_LEN];
    49     /*! Path to directory with the verification images */
    50     char verify_dir[MAX_PATH_LEN];
    51 } SDLVisualTest_HarnessState;
    52 
    53 /**
    54  * Parse command line paramters to the test harness and populate a state object.
    55  *
    56  * \param argv  The array of command line parameters.
    57  * \param state Pointer to the state object to be populated.
    58  *
    59  * \return Non-zero on success, zero on failure.
    60  */
    61 int SDLVisualTest_ParseHarnessArgs(char** argv, SDLVisualTest_HarnessState* state);
    62 
    63 /**
    64  * Frees any resources associated with the state object pointed to by \c state.
    65  */
    66 void SDLVisualTest_FreeHarnessState(SDLVisualTest_HarnessState* state);
    67 
    68 /* Ends C function definitions when using C++ */
    69 #ifdef __cplusplus
    70 }
    71 #endif
    72 
    73 #endif /* SDL_visualtest_harness_argparser_h_ */
    74 
    75 /* vi: set ts=4 sw=4 expandtab: */