2014-10-01 03:40:16 +04:00
|
|
|
|
2021-06-18 11:01:52 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
2014-10-01 03:40:16 +04:00
|
|
|
#include <rdtk/rdtk.h>
|
2021-06-18 11:01:52 +03:00
|
|
|
#include <winpr/error.h>
|
2014-10-01 03:40:16 +04:00
|
|
|
|
|
|
|
int TestRdTkNinePatch(int argc, char* argv[])
|
|
|
|
{
|
2016-06-01 17:26:26 +03:00
|
|
|
rdtkEngine* engine = NULL;
|
|
|
|
rdtkSurface* surface = NULL;
|
2021-06-18 11:01:52 +03:00
|
|
|
uint32_t scanline;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint8_t* data = NULL;
|
2016-06-01 17:26:26 +03:00
|
|
|
int ret = -1;
|
2014-10-01 03:40:16 +04:00
|
|
|
|
2021-06-18 11:01:52 +03:00
|
|
|
WINPR_UNUSED(argc);
|
|
|
|
WINPR_UNUSED(argv);
|
|
|
|
|
2016-06-01 17:26:26 +03:00
|
|
|
if (!(engine = rdtk_engine_new()))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("%s: error creating rdtk engine (%" PRIu32 ")\n", __FUNCTION__, GetLastError());
|
2016-06-01 17:26:26 +03:00
|
|
|
goto out;
|
|
|
|
}
|
2014-10-01 03:40:16 +04:00
|
|
|
|
2016-06-01 17:26:26 +03:00
|
|
|
width = 1024;
|
|
|
|
height = 768;
|
|
|
|
scanline = width * 4;
|
|
|
|
|
|
|
|
/* let rdtk allocate the surface buffer */
|
|
|
|
if (!(surface = rdtk_surface_new(engine, NULL, width, height, scanline)))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("%s: error creating auto-allocated surface (%" PRIu32 ")\n", __FUNCTION__,
|
|
|
|
GetLastError());
|
2016-06-01 17:26:26 +03:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
rdtk_surface_free(surface);
|
|
|
|
surface = NULL;
|
|
|
|
|
|
|
|
/* test self-allocated buffer */
|
|
|
|
if (!(data = calloc(height, scanline)))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("%s: error allocating surface buffer (%" PRIu32 ")\n", __FUNCTION__, GetLastError());
|
2016-06-01 17:26:26 +03:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(surface = rdtk_surface_new(engine, data, width, height, scanline)))
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("%s: error creating self-allocated surface (%" PRIu32 ")\n", __FUNCTION__,
|
|
|
|
GetLastError());
|
2016-06-01 17:26:26 +03:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
rdtk_surface_free(surface);
|
2014-10-01 03:40:16 +04:00
|
|
|
rdtk_engine_free(engine);
|
2016-06-01 17:26:26 +03:00
|
|
|
free(data);
|
2014-10-01 03:40:16 +04:00
|
|
|
|
2016-06-01 17:26:26 +03:00
|
|
|
return ret;
|
2014-10-01 03:40:16 +04:00
|
|
|
}
|