Files
FreeRDP/rdtk/librdtk/test/TestRdTkNinePatch.c

63 lines
1.3 KiB
C
Raw Permalink Normal View History

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