FreeRDP
TestRdTkNinePatch.c
1 
2 #include <stdio.h>
3 #include <stdint.h>
4 #include <rdtk/rdtk.h>
5 #include <winpr/error.h>
6 
7 int TestRdTkNinePatch(int argc, char* argv[])
8 {
9  rdtkEngine* engine = NULL;
10  rdtkSurface* surface = NULL;
11  uint32_t scanline = 0;
12  uint32_t width = 0;
13  uint32_t height = 0;
14  uint8_t* data = NULL;
15  int ret = -1;
16 
17  WINPR_UNUSED(argc);
18  WINPR_UNUSED(argv);
19 
20  if (!(engine = rdtk_engine_new()))
21  {
22  printf("%s: error creating rdtk engine (%" PRIu32 ")\n", __func__, GetLastError());
23  goto out;
24  }
25 
26  width = 1024;
27  height = 768;
28  scanline = width * 4;
29 
30  /* let rdtk allocate the surface buffer */
31  if (!(surface = rdtk_surface_new(engine, NULL, width, height, scanline)))
32  {
33  printf("%s: error creating auto-allocated surface (%" PRIu32 ")\n", __func__,
34  GetLastError());
35  goto out;
36  }
37  rdtk_surface_free(surface);
38  surface = NULL;
39 
40  /* test self-allocated buffer */
41  if (!(data = calloc(height, scanline)))
42  {
43  printf("%s: error allocating surface buffer (%" PRIu32 ")\n", __func__, GetLastError());
44  goto out;
45  }
46 
47  if (!(surface = rdtk_surface_new(engine, data, width, height, scanline)))
48  {
49  printf("%s: error creating self-allocated surface (%" PRIu32 ")\n", __func__,
50  GetLastError());
51  goto out;
52  }
53 
54  ret = 0;
55 
56 out:
57  rdtk_surface_free(surface);
58  rdtk_engine_free(engine);
59  free(data);
60 
61  return ret;
62 }